Skip to content
Merged
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 @@ -22,6 +22,7 @@
from process.data_structure.neoclassics_variables import init_neoclassics_variables
from process.data_structure.pf_power_variables import init_pf_power_variables
from process.data_structure.physics_variables import (
DivertorNumberModels,
init_physics_module,
init_physics_variables,
)
Expand Down Expand Up @@ -569,14 +570,14 @@ 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)
Comment thread
timothy-nunn marked this conversation as resolved.
if i_single_null == DivertorNumberModels.DOUBLE_NULL:
data.divertor.n_divertors = 2
data.build.dz_fw_plasma_gap = data.build.dz_xpoint_divertor
data.build.dz_shld_upper = data.build.dz_shld_lower
data.build.dz_vv_upper = data.build.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.divertor.n_divertors = 1

# Tight aspect ratio options (ST)
Expand Down Expand Up @@ -681,7 +682,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 @@ -763,7 +764,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
10 changes: 10 additions & 0 deletions process/data_structure/physics_variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,18 @@
Module containing global variables relating to the plasma physics
"""

from enum import IntEnum

import numpy as np


class DivertorNumberModels(IntEnum):
"""Enum for divertor number models. `i_single_null` is the index for this enum."""

DOUBLE_NULL = 0
SINGLE_NULL = 1


# From physics.f90:
iscz: int = None

Expand Down
10 changes: 7 additions & 3 deletions process/models/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
superconducting_tf_coil_variables,
tfcoil_variables,
)
from process.data_structure.physics_variables import DivertorNumberModels
from process.models.physics.current_drive import (
CurrentDriveMethodType,
CurrentDriveModel,
Expand Down Expand Up @@ -172,7 +173,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 @@ -804,7 +806,8 @@ def calculate_vertical_build(self, output: bool):
)

# Vertical locations of divertor coils
if physics_variables.i_single_null == 0:
i_single_null = DivertorNumberModels(physics_variables.i_single_null)
if i_single_null == DivertorNumberModels.DOUBLE_NULL:
self.data.build.z_tf_top = (
self.data.build.z_tf_inside_half + self.data.build.dr_tf_inboard
)
Expand Down Expand Up @@ -1645,7 +1648,8 @@ def calculate_radial_build(self, output: bool):
self.data.build.dr_blkt_inboard + self.data.build.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 self.data.build.dz_fw_plasma_gap has been set too small
self.data.build.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 @@ -8,6 +8,7 @@
from process.core.model import Model
from process.data_structure import physics_variables as pv
from process.data_structure import tfcoil_variables as tfv
from process.data_structure.physics_variables import DivertorNumberModels


class Divertor(Model):
Expand Down Expand Up @@ -178,10 +179,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 self.data.divertor.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.data_structure.physics_variables import DivertorNumberModels
from process.models.physics.plasma_geometry import PlasmaShapeModelType


Comment thread
timothy-nunn marked this conversation as resolved.
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 @@ -25,6 +25,7 @@
superconducting_tf_coil_variables,
tfcoil_variables,
)
from process.data_structure.physics_variables import DivertorNumberModels
from process.models.superconductors import SuperconductorModel

if TYPE_CHECKING:
Expand Down Expand Up @@ -508,7 +509,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