Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions process/core/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)"
)
Expand Down
15 changes: 12 additions & 3 deletions process/models/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
)
Expand Down Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions process/models/divertor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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:
Expand Down
3 changes: 2 additions & 1 deletion process/models/geometry/plasma.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import numpy as np

from process.models.build import DivertorNumberModels
from process.models.physics.plasma_geometry import PlasmaShapeModelType


Expand Down Expand Up @@ -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
)
Expand Down
3 changes: 2 additions & 1 deletion process/models/tfcoil/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
Loading