From 927e8c8fc1e7dc74869c8b4407f1f785f1def98f Mon Sep 17 00:00:00 2001 From: Tom Body <116750897+tbody-cfs@users.noreply.github.com> Date: Wed, 11 Sep 2024 12:08:36 -0400 Subject: [PATCH] Remove duplicated formula and add separatrix_electron_temp as Algorithm (#91) * Remove duplicated formula and add separatrix_electron_temp as Algorithm * Rename parallel_heat_flux_density to q_parallel --- .../formulas/scrape_off_layer/__init__.py | 2 ++ .../separatrix_electron_temp.py | 18 +++++----- .../scrape_off_layer/two_point_model/model.py | 8 ++--- .../target_electron_density.py | 6 ++-- .../two_point_model/target_electron_flux.py | 6 ++-- .../two_point_model/target_electron_temp.py | 6 ++-- .../two_point_model/target_first_model.py | 8 ++--- .../two_point_model_algorithms.py | 6 ++-- .../upstream_electron_temp.py | 33 ------------------- cfspopcon/variables.yaml | 12 +++++++ docs/doc_sources/physics_glossary.rst | 3 ++ 11 files changed, 46 insertions(+), 62 deletions(-) delete mode 100644 cfspopcon/formulas/scrape_off_layer/upstream_electron_temp.py diff --git a/cfspopcon/formulas/scrape_off_layer/__init__.py b/cfspopcon/formulas/scrape_off_layer/__init__.py index d94272da..1419d677 100644 --- a/cfspopcon/formulas/scrape_off_layer/__init__.py +++ b/cfspopcon/formulas/scrape_off_layer/__init__.py @@ -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, @@ -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", diff --git a/cfspopcon/formulas/scrape_off_layer/separatrix_electron_temp.py b/cfspopcon/formulas/scrape_off_layer/separatrix_electron_temp.py index ade11251..9a4ab7d9 100644 --- a/cfspopcon/formulas/scrape_off_layer/separatrix_electron_temp.py +++ b/cfspopcon/formulas/scrape_off_layer/separatrix_electron_temp.py @@ -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, @@ -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` + q_parallel: [GW/m^2] :term:`glossary link` + parallel_connection_length: [m] :term:`glossary link` + kappa_e0: [W / (eV**3.5 m)] :term:`glossary link` + SOL_conduction_fraction: [eV] :term:`glossary link` 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) diff --git a/cfspopcon/formulas/scrape_off_layer/two_point_model/model.py b/cfspopcon/formulas/scrape_off_layer/two_point_model/model.py index 1a046f98..4e3949bb 100644 --- a/cfspopcon/formulas/scrape_off_layer/two_point_model/model.py +++ b/cfspopcon/formulas/scrape_off_layer/two_point_model/model.py @@ -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, @@ -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: [~] @@ -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, @@ -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, ) diff --git a/cfspopcon/formulas/scrape_off_layer/two_point_model/target_electron_density.py b/cfspopcon/formulas/scrape_off_layer/two_point_model/target_electron_density.py index c7ec9239..e20cec2e 100644 --- a/cfspopcon/formulas/scrape_off_layer/two_point_model/target_electron_density.py +++ b/cfspopcon/formulas/scrape_off_layer/two_point_model/target_electron_density.py @@ -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]: @@ -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( diff --git a/cfspopcon/formulas/scrape_off_layer/two_point_model/target_electron_flux.py b/cfspopcon/formulas/scrape_off_layer/two_point_model/target_electron_flux.py index 29915b9d..951b649d 100644 --- a/cfspopcon/formulas/scrape_off_layer/two_point_model/target_electron_flux.py +++ b/cfspopcon/formulas/scrape_off_layer/two_point_model/target_electron_flux.py @@ -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]: @@ -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( diff --git a/cfspopcon/formulas/scrape_off_layer/two_point_model/target_electron_temp.py b/cfspopcon/formulas/scrape_off_layer/two_point_model/target_electron_temp.py index 0092b384..852956db 100644 --- a/cfspopcon/formulas/scrape_off_layer/two_point_model/target_electron_temp.py +++ b/cfspopcon/formulas/scrape_off_layer/two_point_model/target_electron_temp.py @@ -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]: @@ -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( diff --git a/cfspopcon/formulas/scrape_off_layer/two_point_model/target_first_model.py b/cfspopcon/formulas/scrape_off_layer/two_point_model/target_first_model.py index b603ad8b..cca8cea8 100644 --- a/cfspopcon/formulas/scrape_off_layer/two_point_model/target_first_model.py +++ b/cfspopcon/formulas/scrape_off_layer/two_point_model/target_first_model.py @@ -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, @@ -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: [~] @@ -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, @@ -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, ) diff --git a/cfspopcon/formulas/scrape_off_layer/two_point_model/two_point_model_algorithms.py b/cfspopcon/formulas/scrape_off_layer/two_point_model/two_point_model_algorithms.py index a663128c..24e8581f 100644 --- a/cfspopcon/formulas/scrape_off_layer/two_point_model/two_point_model_algorithms.py +++ b/cfspopcon/formulas/scrape_off_layer/two_point_model/two_point_model_algorithms.py @@ -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, @@ -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, @@ -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, diff --git a/cfspopcon/formulas/scrape_off_layer/upstream_electron_temp.py b/cfspopcon/formulas/scrape_off_layer/upstream_electron_temp.py deleted file mode 100644 index ade11251..00000000 --- a/cfspopcon/formulas/scrape_off_layer/upstream_electron_temp.py +++ /dev/null @@ -1,33 +0,0 @@ -"""Routines to calculate the upstream electron temperature.""" - -from typing import Union - -import xarray as xr - -from ...unit_handling import Quantity - - -def calc_separatrix_electron_temp( - target_electron_temp: Union[Quantity, xr.DataArray], - parallel_heat_flux_density: 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, -) -> Union[Quantity, xr.DataArray]: - """Calculate the upstream electron temperature assuming Spitzer-Harm heat conductivity. - - 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] - - 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) diff --git a/cfspopcon/variables.yaml b/cfspopcon/variables.yaml index d29ee4df..dc0b30a5 100644 --- a/cfspopcon/variables.yaml +++ b/cfspopcon/variables.yaml @@ -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 @@ -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 @@ -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 @@ -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 @@ -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: @@ -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 diff --git a/docs/doc_sources/physics_glossary.rst b/docs/doc_sources/physics_glossary.rst index 98e9bb7d..43ea2386 100644 --- a/docs/doc_sources/physics_glossary.rst +++ b/docs/doc_sources/physics_glossary.rst @@ -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.