Skip to content

Commit

Permalink
Remove duplicated formula and add separatrix_electron_temp as Algorit…
Browse files Browse the repository at this point in the history
…hm (#91)

* Remove duplicated formula and add separatrix_electron_temp as Algorithm

* Rename parallel_heat_flux_density to q_parallel
  • Loading branch information
tbody-cfs authored Sep 11, 2024
1 parent 3e56891 commit 927e8c8
Show file tree
Hide file tree
Showing 11 changed files with 46 additions and 62 deletions.
2 changes: 2 additions & 0 deletions cfspopcon/formulas/scrape_off_layer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
calc_reattachment_time_henderson,
)
from .separatrix_density import calc_separatrix_electron_density
from .separatrix_electron_temp import calc_separatrix_electron_temp
from .two_point_model import (
solve_target_first_two_point_model,
solve_two_point_model,
Expand All @@ -25,6 +26,7 @@
"two_point_model_fixed_tet",
"calc_lambda_q",
"calc_separatrix_electron_density",
"calc_separatrix_electron_temp",
"calc_B_pol_omp",
"calc_B_tor_omp",
"calc_fieldline_pitch_at_omp",
Expand Down
18 changes: 9 additions & 9 deletions cfspopcon/formulas/scrape_off_layer/separatrix_electron_temp.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@

import xarray as xr

from ...algorithm_class import Algorithm
from ...unit_handling import Quantity


@Algorithm.register_algorithm(return_keys=["separatrix_electron_temp"])
def calc_separatrix_electron_temp(
target_electron_temp: Union[Quantity, xr.DataArray],
parallel_heat_flux_density: Union[Quantity, xr.DataArray],
q_parallel: Union[Quantity, xr.DataArray],
parallel_connection_length: Union[Quantity, xr.DataArray],
kappa_e0: Union[Quantity, xr.DataArray],
SOL_conduction_fraction: Union[float, xr.DataArray] = 1.0,
Expand All @@ -19,15 +21,13 @@ def calc_separatrix_electron_temp(
Equation 38 from :cite:`stangeby_2018`, keeping the dependence on target_electron_temp.
Args:
target_electron_temp: [eV]
parallel_heat_flux_density: [GW/m^2]
parallel_connection_length: [m]
kappa_e0: [W / (eV**3.5 m)]
SOL_conduction_fraction: [eV]
target_electron_temp: [eV] :term:`glossary link<target_electron_temp>`
q_parallel: [GW/m^2] :term:`glossary link<q_parallel>`
parallel_connection_length: [m] :term:`glossary link<parallel_connection_length>`
kappa_e0: [W / (eV**3.5 m)] :term:`glossary link<kappa_e0>`
SOL_conduction_fraction: [eV] :term:`glossary link<SOL_conduction_fraction>`
Returns:
separatrix_electron_temp [eV]
"""
return (
target_electron_temp**3.5 + 3.5 * (SOL_conduction_fraction * parallel_heat_flux_density * parallel_connection_length / kappa_e0)
) ** (2.0 / 7.0)
return (target_electron_temp**3.5 + 3.5 * (SOL_conduction_fraction * q_parallel * parallel_connection_length / kappa_e0)) ** (2.0 / 7.0)
8 changes: 4 additions & 4 deletions cfspopcon/formulas/scrape_off_layer/two_point_model/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

def solve_two_point_model(
SOL_power_loss_fraction: Unitfull,
parallel_heat_flux_density: Unitfull,
q_parallel: Unitfull,
parallel_connection_length: Unitfull,
separatrix_electron_density: Unitfull,
toroidal_flux_expansion: Unitfull,
Expand Down Expand Up @@ -65,7 +65,7 @@ def solve_two_point_model(
Args:
SOL_power_loss_fraction: [~]
parallel_heat_flux_density: [GW/m^2]
q_parallel: [GW/m^2]
parallel_connection_length: [m]
separatrix_electron_density: [m^-3]
toroidal_flux_expansion: [~]
Expand Down Expand Up @@ -111,7 +111,7 @@ def solve_two_point_model(

new_separatrix_electron_temp = calc_separatrix_electron_temp(
target_electron_temp=target_electron_temp,
parallel_heat_flux_density=parallel_heat_flux_density,
q_parallel=q_parallel,
parallel_connection_length=parallel_connection_length,
SOL_conduction_fraction=SOL_conduction_fraction,
kappa_e0=kappa_e0,
Expand All @@ -132,7 +132,7 @@ def solve_two_point_model(

f_basic_kwargs = dict(
average_ion_mass=average_ion_mass,
parallel_heat_flux_density=parallel_heat_flux_density,
q_parallel=q_parallel,
upstream_total_pressure=upstream_total_pressure,
sheath_heat_transmission_factor=sheath_heat_transmission_factor,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def calc_target_electron_density(

def calc_target_electron_density_basic(
average_ion_mass: Union[Quantity, xr.DataArray],
parallel_heat_flux_density: Union[Quantity, xr.DataArray],
q_parallel: Union[Quantity, xr.DataArray],
upstream_total_pressure: Union[Quantity, xr.DataArray],
sheath_heat_transmission_factor: Union[float, xr.DataArray],
) -> Union[Quantity, xr.DataArray]:
Expand All @@ -31,14 +31,14 @@ def calc_target_electron_density_basic(
Args:
average_ion_mass: [amu]
parallel_heat_flux_density: [GW/m^2]
q_parallel: [GW/m^2]
upstream_total_pressure: [atm]
sheath_heat_transmission_factor: [~]
Returns:
target_electron_density_basic [m^-3]
"""
return sheath_heat_transmission_factor**2 / (32.0 * average_ion_mass) * upstream_total_pressure**3 / parallel_heat_flux_density**2
return sheath_heat_transmission_factor**2 / (32.0 * average_ion_mass) * upstream_total_pressure**3 / q_parallel**2


def calc_f_vol_loss_target_electron_density(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def calc_target_electron_flux(

def calc_target_electron_flux_basic(
average_ion_mass: Union[Quantity, xr.DataArray],
parallel_heat_flux_density: Union[Quantity, xr.DataArray],
q_parallel: Union[Quantity, xr.DataArray],
upstream_total_pressure: Union[Quantity, xr.DataArray],
sheath_heat_transmission_factor: Union[float, xr.DataArray],
) -> Union[Quantity, xr.DataArray]:
Expand All @@ -31,14 +31,14 @@ def calc_target_electron_flux_basic(
Args:
average_ion_mass: [amu]
parallel_heat_flux_density: [GW/m^2]
q_parallel: [GW/m^2]
upstream_total_pressure: [atm]
sheath_heat_transmission_factor: [~]
Returns:
target_electron_flux_basic [m^-2 s^-1]
"""
return sheath_heat_transmission_factor / (8.0 * average_ion_mass) * upstream_total_pressure**2 / parallel_heat_flux_density
return sheath_heat_transmission_factor / (8.0 * average_ion_mass) * upstream_total_pressure**2 / q_parallel


def calc_f_vol_loss_target_electron_flux(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def calc_target_electron_temp(

def calc_target_electron_temp_basic(
average_ion_mass: Union[Quantity, xr.DataArray],
parallel_heat_flux_density: Union[Quantity, xr.DataArray],
q_parallel: Union[Quantity, xr.DataArray],
upstream_total_pressure: Union[Quantity, xr.DataArray],
sheath_heat_transmission_factor: Union[float, xr.DataArray],
) -> Union[Quantity, xr.DataArray]:
Expand All @@ -31,14 +31,14 @@ def calc_target_electron_temp_basic(
Args:
average_ion_mass: [amu]
parallel_heat_flux_density: [GW/m^2]
q_parallel: [GW/m^2]
upstream_total_pressure: [atm]
sheath_heat_transmission_factor: [~]
Returns:
target_electron_temp_basic [eV]
"""
return (8.0 * average_ion_mass / sheath_heat_transmission_factor**2) * (parallel_heat_flux_density**2 / upstream_total_pressure**2)
return (8.0 * average_ion_mass / sheath_heat_transmission_factor**2) * (q_parallel**2 / upstream_total_pressure**2)


def calc_f_vol_loss_target_electron_temp(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

def solve_target_first_two_point_model(
target_electron_temp: Unitfull,
parallel_heat_flux_density: Unitfull,
q_parallel: Unitfull,
parallel_connection_length: Unitfull,
separatrix_electron_density: Unitfull,
toroidal_flux_expansion: Unitfull,
Expand All @@ -47,7 +47,7 @@ def solve_target_first_two_point_model(
Args:
target_electron_temp: [eV]
parallel_heat_flux_density: [GW/m^2]
q_parallel: [GW/m^2]
parallel_connection_length: [m]
separatrix_electron_density: [m^-3]
toroidal_flux_expansion: [~]
Expand All @@ -70,7 +70,7 @@ def solve_target_first_two_point_model(

separatrix_electron_temp = calc_separatrix_electron_temp(
target_electron_temp=target_electron_temp,
parallel_heat_flux_density=parallel_heat_flux_density,
q_parallel=q_parallel,
parallel_connection_length=parallel_connection_length,
SOL_conduction_fraction=SOL_conduction_fraction,
kappa_e0=kappa_e0,
Expand All @@ -86,7 +86,7 @@ def solve_target_first_two_point_model(

f_basic_kwargs = dict(
average_ion_mass=average_ion_mass,
parallel_heat_flux_density=parallel_heat_flux_density,
q_parallel=q_parallel,
upstream_total_pressure=upstream_total_pressure,
sheath_heat_transmission_factor=sheath_heat_transmission_factor,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def two_point_model_fixed_fpow(
target_electron_flux,
) = solve_two_point_model(
SOL_power_loss_fraction=SOL_power_loss_fraction,
parallel_heat_flux_density=q_parallel,
q_parallel=q_parallel,
parallel_connection_length=parallel_connection_length,
separatrix_electron_density=nesep_over_nebar * average_electron_density,
toroidal_flux_expansion=toroidal_flux_expansion,
Expand Down Expand Up @@ -124,7 +124,7 @@ def two_point_model_fixed_qpart(
target_electron_flux,
) = solve_two_point_model(
SOL_power_loss_fraction=SOL_power_loss_fraction,
parallel_heat_flux_density=q_parallel,
q_parallel=q_parallel,
parallel_connection_length=parallel_connection_length,
separatrix_electron_density=nesep_over_nebar * average_electron_density,
toroidal_flux_expansion=toroidal_flux_expansion,
Expand Down Expand Up @@ -182,7 +182,7 @@ def two_point_model_fixed_tet(
target_electron_flux,
) = solve_target_first_two_point_model(
target_electron_temp=target_electron_temp,
parallel_heat_flux_density=q_parallel,
q_parallel=q_parallel,
parallel_connection_length=parallel_connection_length,
separatrix_electron_density=separatrix_electron_density,
toroidal_flux_expansion=toroidal_flux_expansion,
Expand Down
33 changes: 0 additions & 33 deletions cfspopcon/formulas/scrape_off_layer/upstream_electron_temp.py

This file was deleted.

12 changes: 12 additions & 0 deletions cfspopcon/variables.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -820,6 +820,7 @@ kappa_e0:
set_by: []
used_by:
- calc_edge_impurity_concentration
- calc_separatrix_electron_temp
- two_point_model_fixed_fpow
- two_point_model_fixed_qpart
- two_point_model_fixed_tet
Expand Down Expand Up @@ -1240,6 +1241,7 @@ parallel_connection_length:
'upstream' position (usually the outboard midplane) to the divertor target.
set_by: []
used_by:
- calc_separatrix_electron_temp
- two_point_model_fixed_fpow
- two_point_model_fixed_qpart
- two_point_model_fixed_tet
Expand Down Expand Up @@ -1428,6 +1430,7 @@ q_parallel:
- calc_parallel_heat_flux_density
used_by:
- calc_edge_impurity_concentration
- calc_separatrix_electron_temp
- two_point_model_fixed_fpow
- two_point_model_fixed_qpart
- two_point_model_fixed_tet
Expand Down Expand Up @@ -1611,6 +1614,7 @@ separatrix_electron_temp:
- The electron temperature at the 'upstream' end of a scrape-off-layer flux-tube
(usually at the outboard midplane).
set_by:
- calc_separatrix_electron_temp
- two_point_model_fixed_fpow
- two_point_model_fixed_qpart
- two_point_model_fixed_tet
Expand Down Expand Up @@ -1697,6 +1701,13 @@ SOC_LOC_ratio:
set_by:
- switch_to_linearised_ohmic_confinement_below_threshold
used_by: []
SOL_conduction_fraction:
default_units: dimensionless
description:
- Fraction of power carried by heat conduction in the scrape-off-layer.
set_by: []
used_by:
- calc_separatrix_electron_temp
SOL_momentum_loss_function:
default_units: null
description:
Expand Down Expand Up @@ -1813,6 +1824,7 @@ target_electron_temp:
- two_point_model_fixed_qpart
used_by:
- calc_edge_impurity_concentration
- calc_separatrix_electron_temp
- two_point_model_fixed_tet
- calc_neutral_pressure_kallenbach
- calc_power_crossing_separatrix_in_electron_channel
Expand Down
3 changes: 3 additions & 0 deletions docs/doc_sources/physics_glossary.rst
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,9 @@ Physics Glossary
SOC_LOC_ratio
Ratio of the energy confinement time from the chosen saturated ohmic confinement (SOC) scaling and the chosen linear ohmic confinement (LOC) scaling.

SOL_conduction_fraction
Fraction of power carried by heat conduction in the scrape-off-layer.

SOL_momentum_loss_function
Fraction of momentum entering a scrape-off-layer flux tube which is lost before reaching the divertor target.

Expand Down

0 comments on commit 927e8c8

Please sign in to comment.