Skip to content

Commit

Permalink
Backwards compatibility: add reg 9 to named options
Browse files Browse the repository at this point in the history
  • Loading branch information
tbody-cfs committed Oct 15, 2024
1 parent ce73323 commit c4e1721
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 14 deletions.
12 changes: 11 additions & 1 deletion cfspopcon/formulas/scrape_off_layer/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
"""Routines to calculate the scrape-off-layer conditions and check divertor survivability."""

from .heat_flux_density import calc_B_pol_omp, calc_B_tor_omp, calc_fieldline_pitch_at_omp, calc_parallel_heat_flux_density, calc_q_perp
from .lambda_q import calc_lambda_q
from .lambda_q import (
calc_lambda_q,
calc_lambda_q_with_brunner,
calc_lambda_q_with_eich_regression_9,
calc_lambda_q_with_eich_regression_14,
calc_lambda_q_with_eich_regression_15,
)
from .reattachment_models import (
calc_ionization_volume_from_AUG,
calc_neutral_flux_density_factor,
Expand All @@ -25,6 +31,10 @@
"two_point_model_fixed_qpart",
"two_point_model_fixed_tet",
"calc_lambda_q",
"calc_lambda_q_with_brunner",
"calc_lambda_q_with_eich_regression_14",
"calc_lambda_q_with_eich_regression_15",
"calc_lambda_q_with_eich_regression_9",
"calc_separatrix_electron_density",
"calc_separatrix_electron_temp",
"calc_B_pol_omp",
Expand Down
33 changes: 20 additions & 13 deletions cfspopcon/formulas/scrape_off_layer/lambda_q.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
major_radius=ureg.meter,
B_pol_out_mid=ureg.tesla,
inverse_aspect_ratio=ureg.dimensionless,
magnetic_field_on_axis=ureg.T,
q_star=ureg.dimensionless,
lambda_q_factor=ureg.dimensionless,
),
)
Expand All @@ -25,43 +27,47 @@ def calc_lambda_q(
major_radius: float,
B_pol_out_mid: float,
inverse_aspect_ratio: float,
magnetic_field_on_axis: float,
q_star: float,
lambda_q_factor: float = 1.0,
) -> float:
"""Calculate SOL heat flux decay length (lambda_q) from a scaling.
TODO: Remove in next major release, in favour of using algorithms directly.
Args:
lambda_q_scaling: :term:`glossary link<lambda_q_scaling>`
average_total_pressure: [atm] :term:`glossary link <average_total_pressure>`
power_crossing_separatrix: [MW] :term:`glossary link<power_crossing_separatrix>`
major_radius: [m] :term:`glossary link<major_radius>`
B_pol_out_mid: [T] :term:`glossary link<B_pol_out_mid>`
inverse_aspect_ratio: [~] :term:`glossary link<inverse_aspect_ratio>`
magnetic_field_on_axis: [T] :term:`glossary link<magnetic_field_on_axis>`
q_star: [~] :term:`glossary link<q_star>`
lambda_q_factor: [~] :term:`glossary link<lambda_q_factor>`
Returns:
:term:`lambda_q` [mm]
"""
if lambda_q_scaling == LambdaQScaling.Brunner:
return float(
calc_lambda_q_with_brunner.unitless_func(average_total_pressure=average_total_pressure, lambda_q_factor=lambda_q_factor)
lambda_q = calc_lambda_q_with_brunner.unitless_func(average_total_pressure=average_total_pressure, lambda_q_factor=lambda_q_factor)
elif lambda_q_scaling == LambdaQScaling.EichRegression9:
lambda_q = calc_lambda_q_with_eich_regression_9(
magnetic_field_on_axis=magnetic_field_on_axis, q_star=q_star, power_crossing_separatrix=power_crossing_separatrix
)
elif lambda_q_scaling == LambdaQScaling.EichRegression14:
return float(calc_lambda_q_with_eich_regression_14.unitless_func(B_pol_out_mid=B_pol_out_mid, lambda_q_factor=lambda_q_factor))
lambda_q = calc_lambda_q_with_eich_regression_14.unitless_func(B_pol_out_mid=B_pol_out_mid, lambda_q_factor=lambda_q_factor)
elif lambda_q_scaling == LambdaQScaling.EichRegression15:
return float(
calc_lambda_q_with_eich_regression_15.unitless_func(
power_crossing_separatrix=power_crossing_separatrix,
major_radius=major_radius,
B_pol_out_mid=B_pol_out_mid,
inverse_aspect_ratio=inverse_aspect_ratio,
lambda_q_factor=lambda_q_factor,
)
lambda_q = calc_lambda_q_with_eich_regression_15.unitless_func(
power_crossing_separatrix=power_crossing_separatrix,
major_radius=major_radius,
B_pol_out_mid=B_pol_out_mid,
inverse_aspect_ratio=inverse_aspect_ratio,
lambda_q_factor=lambda_q_factor,
)
else:
raise NotImplementedError(f"No implementation for lambda_q scaling {lambda_q_scaling}")

return float(lambda_q)


@Algorithm.register_algorithm(return_keys=["lambda_q"])
@wraps_ufunc(
Expand Down Expand Up @@ -96,6 +102,7 @@ def calc_lambda_q_with_eich_regression_9(
return float(lambda_q_factor * 0.7 * magnetic_field_on_axis**-0.77 * q_star**1.05 * power_crossing_separatrix**0.09)


@Algorithm.register_algorithm(return_keys=["lambda_q"])
@wraps_ufunc(return_units=dict(lambda_q=ureg.millimeter), input_units=dict(B_pol_out_mid=ureg.tesla, lambda_q_factor=ureg.dimensionless))
def calc_lambda_q_with_eich_regression_14(B_pol_out_mid: float, lambda_q_factor: float = 1.0) -> float:
"""Return lambda_q according to Eich regression 14.
Expand Down
1 change: 1 addition & 0 deletions cfspopcon/named_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class LambdaQScaling(Enum):
"""Options for heat flux decay length scaling."""

Brunner = auto()
EichRegression9 = auto()
EichRegression14 = auto()
EichRegression15 = auto()

Expand Down
5 changes: 5 additions & 0 deletions cfspopcon/variables.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ B_pol_out_mid:
used_by:
- calc_fieldline_pitch_at_omp
- calc_lambda_q
- calc_lambda_q_with_eich_regression_14
- calc_lambda_q_with_eich_regression_15
- calc_power_crossing_separatrix_in_electron_channel
B_t_out_mid:
Expand Down Expand Up @@ -843,6 +844,7 @@ lambda_q:
- calc_lambda_q
- calc_lambda_q_with_brunner
- calc_lambda_q_with_eich_regression_9
- calc_lambda_q_with_eich_regression_14
- calc_lambda_q_with_eich_regression_15
used_by:
- calc_parallel_heat_flux_density
Expand All @@ -858,6 +860,7 @@ lambda_q_factor:
- calc_lambda_q
- calc_lambda_q_with_brunner
- calc_lambda_q_with_eich_regression_9
- calc_lambda_q_with_eich_regression_14
- calc_lambda_q_with_eich_regression_15
lambda_q_scaling:
default_units: null
Expand Down Expand Up @@ -906,6 +909,7 @@ magnetic_field_on_axis:
- calc_beta_normalized
- calc_troyon_limit
- calc_B_tor_omp
- calc_lambda_q
- calc_lambda_q_with_eich_regression_9
- calc_SepOS_L_mode_density_limit
- calc_SepOS_LH_transition
Expand Down Expand Up @@ -1469,6 +1473,7 @@ q_star:
- calc_PBpRnSq
- calc_bootstrap_fraction
- calc_plasma_current_from_qstar
- calc_lambda_q
- calc_lambda_q_with_eich_regression_9
radas_dir:
default_units: null
Expand Down

0 comments on commit c4e1721

Please sign in to comment.