diff --git a/process/core/init.py b/process/core/init.py index 0fa2e9ecb..0b0305673 100644 --- a/process/core/init.py +++ b/process/core/init.py @@ -58,6 +58,7 @@ ) from process.data_structure.tfcoil_variables import init_tfcoil_variables from process.data_structure.times_variables import init_times_variables +from process.models.build import DivertorNumberModels from process.models.stellarator.initialization import st_init from process.models.superconductors import ( SuperconductorMaterial, @@ -618,8 +619,8 @@ def check_process(inputs, data): # noqa: ARG001 "REINKE IMPURITY MODEL: The Martin LH threshold scale is not being used and is recommended for the Reinke model", stacklevel=2, ) - - if data_structure.physics_variables.i_single_null == 0: + i_single_null = DivertorNumberModels(data_structure.physics_variables.i_single_null) + if i_single_null == DivertorNumberModels.DOUBLE_NULL: data_structure.divertor_variables.n_divertors = 2 data_structure.build_variables.dz_fw_plasma_gap = ( data_structure.build_variables.dz_xpoint_divertor @@ -631,7 +632,7 @@ def check_process(inputs, data): # noqa: ARG001 data_structure.build_variables.dz_vv_lower ) warn("Double-null: Upper vertical build forced to match lower", stacklevel=2) - else: # i_single_null == 1 + else: # i_single_null == DivertorNumberModels.SINGLE_NULL data_structure.divertor_variables.n_divertors = 1 # Tight aspect ratio options (ST) @@ -736,7 +737,7 @@ def check_process(inputs, data): # noqa: ARG001 ) # Check if a single null divertor is used in double null machine - if data_structure.physics_variables.i_single_null == 0 and ( + if i_single_null == DivertorNumberModels.DOUBLE_NULL and ( data_structure.physics_variables.f_p_div_lower in {1.0, 0.0} ): warn("Operating with a single null in a double null machine", stacklevel=2) @@ -818,7 +819,7 @@ def check_process(inputs, data): # noqa: ARG001 raise ProcessValidationError( "More than 2 divertor coils (i_pf_location = 2) is not a valid configuration" ) - if data_structure.physics_variables.i_single_null == 1 and j < 2: + if i_single_null == DivertorNumberModels.SINGLE_NULL and j < 2: raise ProcessValidationError( "If i_single_null=1, use 2 individual divertor coils (i_pf_location = 2, 2; n_pf_coils_in_group = 1, 1)" ) diff --git a/process/models/build.py b/process/models/build.py index 36cd13769..54310cbb4 100644 --- a/process/models/build.py +++ b/process/models/build.py @@ -28,6 +28,13 @@ logger = logging.getLogger(__name__) +class DivertorNumberModels(IntEnum): + """Enum for divertor number models. `i_single_null` is the index for this enum.""" + + DOUBLE_NULL = 0 + SINGLE_NULL = 1 + + class FwBlktVVShape(IntEnum): """Enum for first wall, blanket, and vacuum vessel shape options.""" @@ -178,7 +185,8 @@ def calculate_vertical_build(self, output: bool): physics_variables.i_single_null, ) - if physics_variables.i_single_null == 0: + i_single_null = DivertorNumberModels(physics_variables.i_single_null) + if i_single_null == DivertorNumberModels.DOUBLE_NULL: po.ocmmnt(self.outfile, "Double null case") # Start at the top and work down. @@ -810,7 +818,7 @@ def calculate_vertical_build(self, output: bool): ) # Vertical locations of divertor coils - if physics_variables.i_single_null == 0: + if i_single_null == DivertorNumberModels.DOUBLE_NULL: build_variables.z_tf_top = ( build_variables.z_tf_inside_half + build_variables.dr_tf_inboard ) @@ -1691,7 +1699,8 @@ def calculate_radial_build(self, output: bool): build_variables.dr_blkt_inboard + build_variables.dr_blkt_outboard ) - if physics_variables.i_single_null == 1: + i_single_null = DivertorNumberModels(physics_variables.i_single_null) + if i_single_null == DivertorNumberModels.SINGLE_NULL: # Check if build_variables.dz_fw_plasma_gap has been set too small build_variables.dz_fw_plasma_gap = max( 0.5e0 diff --git a/process/models/divertor.py b/process/models/divertor.py index f89a42b1e..9567368ee 100644 --- a/process/models/divertor.py +++ b/process/models/divertor.py @@ -11,6 +11,7 @@ from process.data_structure import fwbs_variables as fwbs from process.data_structure import physics_variables as pv from process.data_structure import tfcoil_variables as tfv +from process.models.build import DivertorNumberModels class Divertor(Model): @@ -181,10 +182,10 @@ def divtart( # Total divertor area # Single null case - if i_single_null == 1: + if i_single_null == DivertorNumberModels.SINGLE_NULL: areadv = a1 + a2 + a3 # Double null case - elif i_single_null == 0: + elif i_single_null == DivertorNumberModels.DOUBLE_NULL: areadv = 2.0 * (a1 + a2 + a3) if dv.i_div_heat_load == 1: diff --git a/process/models/geometry/plasma.py b/process/models/geometry/plasma.py index 5131897d1..999211db8 100644 --- a/process/models/geometry/plasma.py +++ b/process/models/geometry/plasma.py @@ -7,6 +7,7 @@ import numpy as np +from process.models.build import DivertorNumberModels from process.models.physics.plasma_geometry import PlasmaShapeModelType @@ -77,7 +78,7 @@ def plasma_geometry( theta2 = np.arcsin((kappa * rminor) / r2) inang = 1.0 / r1 outang = 1.5 / r2 - if i_single_null == 0: + if i_single_null == DivertorNumberModels.DOUBLE_NULL: angs1 = np.linspace( -(inang + theta1) + np.pi, (inang + theta1) + np.pi, 500, endpoint=True ) diff --git a/process/models/tfcoil/base.py b/process/models/tfcoil/base.py index 8e481b078..5d168a698 100644 --- a/process/models/tfcoil/base.py +++ b/process/models/tfcoil/base.py @@ -26,6 +26,7 @@ tfcoil_variables, ) from process.data_structure import build_variables as bv +from process.models.build import DivertorNumberModels from process.models.superconductors import SuperconductorModel if TYPE_CHECKING: @@ -498,7 +499,7 @@ def tf_coil_shape_inner( r_tf_arc[3] = r_tf_arc[1] r_tf_arc[4] = r_tf_arc[0] - if i_single_null == 0: + if i_single_null == DivertorNumberModels.DOUBLE_NULL: z_tf_arc[0] = FSTRAIGHT * z_tf_inside_half z_tf_arc[1] = z_tf_inside_half z_tf_arc[2] = 0