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
9 changes: 5 additions & 4 deletions process/core/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
from process.data_structure.vacuum_variables import init_vacuum_variables
from process.data_structure.water_usage_variables import init_watuse_variables
from process.models.stellarator.initialization import st_init
from process.models.tfcoil.base import TFCoilShapeModel


def init_process():
Expand Down Expand Up @@ -733,8 +734,8 @@ def check_process(inputs): # noqa: ARG001
warn("Operating with a single null in a double null machine", stacklevel=2)

# Set the TF coil shape to picture frame (if default value)
if data_structure.tfcoil_variables.i_tf_shape == 0:
data_structure.tfcoil_variables.i_tf_shape = 2
if data_structure.tfcoil_variables.i_tf_shape == TFCoilShapeModel.DEFAULT:
data_structure.tfcoil_variables.i_tf_shape = TFCoilShapeModel.PICTURE_FRAME

# Warning stating that the CP fast neutron fluence calculation
# is not addapted for cryoaluminium calculations yet
Expand Down Expand Up @@ -781,8 +782,8 @@ def check_process(inputs): # noqa: ARG001
)

# Set the TF coil shape to PROCESS D-shape (if default value)
if data_structure.tfcoil_variables.i_tf_shape == 0:
data_structure.tfcoil_variables.i_tf_shape = 1
if data_structure.tfcoil_variables.i_tf_shape == TFCoilShapeModel.DEFAULT:
data_structure.tfcoil_variables.i_tf_shape = TFCoilShapeModel.D_SHAPE

# Check PF coil configurations
j = 0
Expand Down
3 changes: 2 additions & 1 deletion process/core/io/plot_proc.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
from process.models.physics.impurity_radiation import read_impurity_file
from process.models.physics.l_h_transition import PlasmaConfinementTransitionModel
from process.models.physics.plasma_current import PlasmaCurrent, PlasmaCurrentModel
from process.models.tfcoil.base import TFCoilShapeModel
from process.models.tfcoil.superconducting import SUPERCONDUCTING_TF_TYPES

mpl.rcParams["figure.max_open_warning"] = 40
Expand Down Expand Up @@ -5659,7 +5660,7 @@ def plot_tf_coils(
else:
i_tf_shape = 1

if i_tf_shape == 2:
if i_tf_shape == TFCoilShapeModel.PICTURE_FRAME:
rects = tfcoil_geometry_rectangular_shape(
x1=x1,
x2=x2,
Expand Down
3 changes: 2 additions & 1 deletion process/models/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
superconducting_tf_coil_variables,
tfcoil_variables,
)
from process.models.tfcoil.base import TFCoilShapeModel

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -1620,7 +1621,7 @@ def plasma_outboard_edge_toroidal_ripple(
dx_tf_wp_conductor_max = 2.0e0 * r_wp_max * np.tan(np.pi / n_tf_coils)

flag = 0
if i_tf_shape == 2:
if i_tf_shape == TFCoilShapeModel.PICTURE_FRAME:
# Ken McClements ST picture frame coil analytical ripple calc
# Calculated ripple for coil at r_tf_outboard_mid (%)
ripple = 100.0e0 * ((rmajor + rminor) / r_tf_outboard_mid) ** (n_tf_coils)
Expand Down
6 changes: 5 additions & 1 deletion process/models/pfcoil.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from process.data_structure import rebco_variables as rcv
from process.data_structure import tfcoil_variables as tfv
from process.data_structure import times_variables as tv
from process.models.tfcoil.base import TFCoilShapeModel

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -1268,7 +1269,10 @@ def place_pf_outside_tf(
rminor * zref[n_pf_group] * sign
)
# Coil radius is constant / stacked for picture frame TF or if placement switch is set
if i_tf_shape == 2 or i_r_pf_outside_tf_placement == 1:
if (
i_tf_shape == TFCoilShapeModel.PICTURE_FRAME
or i_r_pf_outside_tf_placement == 1
):
r_pf_coil_middle_group_array[n_pf_group, coil] = r_pf_outside_tf_midplane
else:
# Coil radius follows TF coil curve for TF (D-shape)
Expand Down
33 changes: 26 additions & 7 deletions process/models/tfcoil/base.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
from __future__ import annotations

import copy
import json
import logging
from enum import IntEnum
from typing import TYPE_CHECKING

import numba
import numpy as np
Expand All @@ -19,11 +23,26 @@
tfcoil_variables,
)
from process.data_structure import build_variables as bv
from process.models.build import Build

if TYPE_CHECKING:
from process.models.build import Build

logger = logging.getLogger(__name__)


class TFCoilShapeModel(IntEnum):
Comment thread
chris-ashe marked this conversation as resolved.
"""Enumeration for TF coil shape models.
0: Auto-select
1: D-shape
2: Picture frame coil

"""

DEFAULT = 0
D_SHAPE = 1
PICTURE_FRAME = 2


class TFCoil:
"""Calculates the parameters of a resistive TF coil system for a fusion power plant"""

Expand Down Expand Up @@ -383,7 +402,7 @@ def tf_coil_shape_inner(
tfa = np.zeros(4)
tfb = np.zeros(4)

if i_tf_shape == 1 and itart == 0:
if i_tf_shape == TFCoilShapeModel.D_SHAPE and itart == 0:
# PROCESS D-shape parameterisation
r_tf_arc[0] = r_tf_inboard_out
r_tf_arc[1] = rmajor - 0.2e0 * rminor
Expand Down Expand Up @@ -413,7 +432,7 @@ def tf_coil_shape_inner(
bb = tfb[ii] + 0.5e0 * dr_tf_inboard
len_tf_coil += 0.25e0 * self.circumference(aa, bb)

elif i_tf_shape == 1 and itart == 1:
elif i_tf_shape == TFCoilShapeModel.D_SHAPE and itart == 1:
# Centrepost with D-shaped
r_tf_arc[0] = r_cp_top
r_tf_arc[1] = rmajor - 0.2e0 * rminor
Expand All @@ -436,7 +455,7 @@ def tf_coil_shape_inner(
bb = tfb[ii] + 0.5e0 * dr_tf_outboard
len_tf_coil += 0.25e0 * self.circumference(aa, bb)

elif i_tf_shape == 2:
elif i_tf_shape == TFCoilShapeModel.PICTURE_FRAME:
# Picture frame coil
if itart == 0:
r_tf_arc[0] = r_tf_inboard_out
Expand Down Expand Up @@ -801,15 +820,15 @@ def outtf(self):
"(i_tf_shape)",
tfcoil_variables.i_tf_shape,
)
if tfcoil_variables.i_tf_shape == 1:
if tfcoil_variables.i_tf_shape == TFCoilShapeModel.D_SHAPE:
po.oblnkl(self.outfile)
po.ocmmnt(self.outfile, "D-shape coil, inner surface shape approximated by")
po.ocmmnt(
self.outfile,
"by a straight segment and elliptical arcs between the following points:",
)
po.oblnkl(self.outfile)
elif tfcoil_variables.i_tf_shape == 2:
elif tfcoil_variables.i_tf_shape == TFCoilShapeModel.PICTURE_FRAME:
po.oblnkl(self.outfile)
po.ocmmnt(self.outfile, "Picture frame coil, inner surface approximated by")
po.ocmmnt(
Expand Down Expand Up @@ -1761,7 +1780,7 @@ def outtf(self):

# Ripple calculations
po.osubhd(self.outfile, "Ripple information:")
if tfcoil_variables.i_tf_shape == 1:
if tfcoil_variables.i_tf_shape == TFCoilShapeModel.D_SHAPE:
po.ovarre(
self.outfile,
"Max allowed tfcoil_variables.ripple amplitude at plasma outboard midplane (%)",
Expand Down
Loading