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
33 changes: 26 additions & 7 deletions process/core/solver/constraints.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
from process.data_structure.build_variables import TFCSRadialConfiguration
from process.models.physics.density_limit import DensityLimitModel
from process.models.physics.exhaust import PlasmaExhaust
from process.models.physics.physics import BetaComponentLimits, PlasmaBeta
from process.models.physics.physics import (
BetaComponentLimits,
PlasmaBeta,
PlasmaIgnitionModel,
)
from process.models.tfcoil.base import TFConductorModel

ConstraintSymbolType = Literal["=", ">=", "<="]
Expand Down Expand Up @@ -270,7 +274,10 @@ def constraint_equation_2(constraint_registration, data):
pnumerator = pscaling

# if plasma not ignited include injected power
if data.physics.i_plasma_ignited == 0:
if (
PlasmaIgnitionModel(data.physics.i_plasma_ignited)
== PlasmaIgnitionModel.NON_IGNITED
):
pdenom = (
data.physics.f_p_alpha_plasma_deposited * data.physics.pden_alpha_total_mw
+ data.physics.pden_non_alpha_charged_mw
Expand Down Expand Up @@ -303,7 +310,10 @@ def constraint_equation_3(constraint_registration, data):
vol_plasma: plasma volume (m3)
"""
# No assume plasma ignition:
if data.physics.i_plasma_ignited == 0:
if (
PlasmaIgnitionModel(data.physics.i_plasma_ignited)
== PlasmaIgnitionModel.NON_IGNITED
):
return eq(
(
data.physics.pden_ion_transport_loss_mw
Expand Down Expand Up @@ -363,7 +373,10 @@ def constraint_equation_4(constraint_registration, data):
pnumerator = pscaling

# if plasma not ignited include injected power
if data.physics.i_plasma_ignited == 0:
if (
PlasmaIgnitionModel(data.physics.i_plasma_ignited)
== PlasmaIgnitionModel.NON_IGNITED
):
pdenom = (
data.physics.f_p_alpha_plasma_deposited
* data.physics.f_pden_alpha_electron_mw
Expand Down Expand Up @@ -453,7 +466,7 @@ def constraint_equation_7(constraint_registration, data):
nd_beam_ions_out: hot beam ion density from calculation (/m³)
nd_beam_ions: hot beam ion density, variable (/m³)
"""
if data.physics.i_plasma_ignited == 1:
if PlasmaIgnitionModel(data.physics.i_plasma_ignited) == PlasmaIgnitionModel.IGNITED:
raise ProcessValueError("Do not use constraint equation 7 if i_plasma_ignited=1")

return eq(
Expand Down Expand Up @@ -808,7 +821,10 @@ def constraint_equation_28(constraint_registration, data):
during plasma start-up, and is excluded from all steady-state
power balance calculations.
"""
if data.physics.i_plasma_ignited != 0:
if (
PlasmaIgnitionModel(data.physics.i_plasma_ignited)
!= PlasmaIgnitionModel.NON_IGNITED
):
raise ProcessValueError("Do not use constraint 28 if i_plasma_ignited=1")

return geq(
Expand Down Expand Up @@ -1739,7 +1755,10 @@ def constraint_equation_91(constraint_registration, data):
te0_ecrh_achievable: Max. achievable electron temperature at ignition point
"""
# Achievable ECRH te needs to be larger than needed te for igntion
if data.physics.i_plasma_ignited == 0:
if (
PlasmaIgnitionModel(data.physics.i_plasma_ignited)
== PlasmaIgnitionModel.NON_IGNITED
):
value = (
data.stellarator.powerht_constraint
+ data.current_drive.p_hcd_primary_extra_heat_mw
Expand Down
7 changes: 7 additions & 0 deletions process/data_structure/physics_variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@
import numpy as np


class PlasmaIgnitionModel(IntEnum):
"""Enum for plasma ignition models."""

NON_IGNITED = 0
IGNITED = 1


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

Expand Down
13 changes: 10 additions & 3 deletions process/models/physics/confinement_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
ConfinementMode,
ConfinementRadiationLossModel,
ConfinementTimeModel,
PlasmaIgnitionModel,
)
from process.models.physics.plasma_geometry import PlasmaGeom

Expand Down Expand Up @@ -143,7 +144,7 @@ def calculate_confinement_time(
)

# If the device is not ignited, add the injected auxiliary power
if i_plasma_ignited == 0:
if PlasmaIgnitionModel(i_plasma_ignited) == PlasmaIgnitionModel.NON_IGNITED:
p_plasma_loss_mw += p_hcd_injected_total_mw

# Include the radiation as a loss term based on radiation model
Expand Down Expand Up @@ -1101,7 +1102,10 @@ def fhz(hfact: float) -> float:

# Take into account whether injected power is included in tau_e calculation
# (i.e. whether device is ignited)
if self.data.physics.i_plasma_ignited == 0:
if (
PlasmaIgnitionModel(self.data.physics.i_plasma_ignited)
== PlasmaIgnitionModel.NON_IGNITED
):
fhz_value -= (
self.data.current_drive.p_hcd_injected_total_mw
/ self.data.physics.vol_plasma
Expand All @@ -1128,7 +1132,10 @@ def output_confinement_time_info(self):
"""
po.oheadr(self.outfile, "Plasma Energy Confinement")

if self.data.physics.i_plasma_ignited == 1:
if (
PlasmaIgnitionModel(self.data.physics.i_plasma_ignited)
== PlasmaIgnitionModel.IGNITED
):
po.ocmmnt(
self.outfile,
"Device is assumed to be ignited for the calculation of confinement "
Expand Down
11 changes: 9 additions & 2 deletions process/models/physics/current_drive.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
)
from process.core.exceptions import ProcessError, ProcessValueError
from process.core.model import Model
from process.data_structure.physics_variables import PlasmaIgnitionModel
from process.models.physics.plasma_profiles import PlasmaProfile

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -2290,7 +2291,10 @@ def current_drive(self):
)

# Reset injected power to zero for ignited plasma (fudge)
if self.data.physics.i_plasma_ignited == 1:
if (
PlasmaIgnitionModel(self.data.physics.i_plasma_ignited)
== PlasmaIgnitionModel.IGNITED
):
self.data.heat_transport.p_hcd_electric_total_mw = 0.0e0

# Ratio of fusion to input (injection+ohmic) power
Expand Down Expand Up @@ -2394,7 +2398,10 @@ def output(self):
"(i_plasma_ignited)",
self.data.physics.i_plasma_ignited,
)
if self.data.physics.i_plasma_ignited == 1:
if (
PlasmaIgnitionModel(self.data.physics.i_plasma_ignited)
== PlasmaIgnitionModel.IGNITED
):
po.ocmmnt(
self.outfile,
"Ignited plasma; injected power only used for start-up phase",
Expand Down
17 changes: 13 additions & 4 deletions process/models/physics/physics.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from process.core.exceptions import ProcessValueError
from process.core.model import Model
from process.data_structure.impurity_radiation_variables import N_IMPURITIES
from process.data_structure.physics_variables import PlasmaIgnitionModel
from process.models.physics import impurity_radiation
from process.models.physics.profiles import (
DensityProfilePedestalType,
Expand Down Expand Up @@ -601,7 +602,8 @@ def run(self):
# Calculate neutral beam slowing down effects
# If ignited, then ignore beam fusion effects
if (self.data.current_drive.c_beam_total != 0.0e0) and ( # noqa: RUF069
self.data.physics.i_plasma_ignited == 0
PlasmaIgnitionModel(self.data.physics.i_plasma_ignited)
== PlasmaIgnitionModel.NON_IGNITED
):
(
self.data.physics.beta_beam,
Expand Down Expand Up @@ -773,7 +775,8 @@ def run(self):
# which is assumed to be absorbed by the first wall
pinj = (
self.data.current_drive.p_hcd_injected_total_mw
if self.data.physics.i_plasma_ignited == 0
if PlasmaIgnitionModel(self.data.physics.i_plasma_ignited)
== PlasmaIgnitionModel.NON_IGNITED
else 0.0
)

Expand Down Expand Up @@ -1176,7 +1179,10 @@ def plasma_composition(self):

# Beam hot ion component
# If ignited, prevent beam fusion effects
if self.data.physics.i_plasma_ignited == 0:
if (
PlasmaIgnitionModel(self.data.physics.i_plasma_ignited)
== PlasmaIgnitionModel.NON_IGNITED
):
self.data.physics.nd_beam_ions = (
self.data.physics.nd_plasma_electrons_vol_avg
* self.data.physics.f_nd_beam_electron
Expand Down Expand Up @@ -2295,7 +2301,10 @@ def outplas(self):
self.data.current_drive.p_hcd_injected_electrons_mw,
"OP ",
)
if self.data.physics.i_plasma_ignited == 1:
if (
PlasmaIgnitionModel(self.data.physics.i_plasma_ignited)
== PlasmaIgnitionModel.IGNITED
):
po.ocmmnt(self.outfile, " (Injected power only used for start-up phase)")

self.exhaust.output()
Expand Down
3 changes: 2 additions & 1 deletion process/models/stellarator/heating.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from process.core import process_output as po
from process.core.exceptions import ProcessValueError
from process.core.model import DataStructure
from process.data_structure.physics_variables import PlasmaIgnitionModel

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -142,7 +143,7 @@ def output(stellarator, data: DataStructure, f_p_beam_injected_ions=None):
elif data.stellarator.isthtr == 3:
po.ocmmnt(stellarator.outfile, "Neutral Beam Injection Heating")

if data.physics.i_plasma_ignited == 1:
if PlasmaIgnitionModel(data.physics.i_plasma_ignited) == PlasmaIgnitionModel.IGNITED:
po.ocmmnt(
stellarator.outfile,
"Ignited plasma; injected power only used for start-up phase",
Expand Down
9 changes: 7 additions & 2 deletions process/models/stellarator/stellarator.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from process.core.coolprop_interface import FluidProperties
from process.core.exceptions import ProcessValueError
from process.core.model import Model
from process.data_structure.physics_variables import PlasmaIgnitionModel
from process.models.engineering.pumping import CoolantType
from process.models.physics.physics import Physics, rether
from process.models.power import PumpingPowerModelTypes
Expand Down Expand Up @@ -1975,7 +1976,8 @@ def st_phys(self, output):
# If ignited, then ignore beam fusion effects

if (self.data.current_drive.p_hcd_beam_injected_total_mw != 0.0e0) and ( # noqa: RUF069
self.data.physics.i_plasma_ignited == 0
PlasmaIgnitionModel(self.data.physics.i_plasma_ignited)
== PlasmaIgnitionModel.NON_IGNITED
):
(
self.data.physics.beta_beam,
Expand Down Expand Up @@ -2152,7 +2154,10 @@ def st_phys(self, output):
0.00001e0, powht
) # To avoid negative heating power. This line is VERY important

if self.data.physics.i_plasma_ignited == 0:
if (
PlasmaIgnitionModel(self.data.physics.i_plasma_ignited)
== PlasmaIgnitionModel.NON_IGNITED
):
# if not ignited add the auxiliary power
powht += self.data.current_drive.p_hcd_injected_total_mw

Expand Down
Loading
Loading