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
4 changes: 1 addition & 3 deletions process/core/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
from process.data_structure.primary_pumping_variables import (
init_primary_pumping_variables,
)
from process.data_structure.pulse_variables import init_pulse_variables
from process.data_structure.rebco_variables import init_rebco_variables
from process.data_structure.scan_variables import init_scan_variables
from process.data_structure.stellarator_variables import init_stellarator_variables
Expand Down Expand Up @@ -282,7 +281,6 @@ def init_all_module_vars():
init_pf_power_variables()
init_build_variables()
init_constraint_variables()
init_pulse_variables()
init_rebco_variables()
init_dcll_module()
init_power_variables()
Expand Down Expand Up @@ -821,7 +819,7 @@ def check_process(inputs, data): # noqa: ARG001
)

# Pulsed power plant model
if data_structure.pulse_variables.i_pulsed_plant == 1:
if data.pulse.i_pulsed_plant == 1:
data_structure.global_variables.icase = "Pulsed tokamak model"
else:
data_structure.buildings_variables.esbldgm3 = 0.0
Expand Down
10 changes: 5 additions & 5 deletions process/core/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ def __post_init__(self):
data_structure.heat_transport_variables, float, range=(1000000.0, 10000000000.0)
),
"bcritsc": InputVariable(data_structure.tfcoil_variables, float, range=(10.0, 50.0)),
"bctmp": InputVariable(data_structure.pulse_variables, float, range=(1.0, 800.0)),
"bctmp": InputVariable("pulse", float, range=(1.0, 800.0)),
"e_beam_kev": InputVariable(
data_structure.current_drive_variables, float, range=(1.0, 1000000.0)
),
Expand Down Expand Up @@ -528,7 +528,7 @@ def __post_init__(self):
"drtop": InputVariable(data_structure.tfcoil_variables, float, range=(-1.5, 1.5)),
"drveff": InputVariable(data_structure.ife_variables, float, range=(0.01, 1.0)),
"dtlife": InputVariable("costs", float, range=(0.0, 15.0)),
"dtstor": InputVariable(data_structure.pulse_variables, float, range=(50.0, 500.0)),
"dtstor": InputVariable("pulse", float, range=(50.0, 500.0)),
"dx_fw_module": InputVariable("fwbs", float, range=(0.0005, 0.1)),
"dz_tf_cryostat": InputVariable(
data_structure.buildings_variables, float, range=(0.0, 20.0)
Expand Down Expand Up @@ -1657,7 +1657,7 @@ def __post_init__(self):
"i_plasma_wall_gap": InputVariable(
data_structure.physics_variables, int, choices=[0, 1]
),
"i_pulsed_plant": InputVariable(data_structure.pulse_variables, int, choices=[0, 1]),
"i_pulsed_plant": InputVariable("pulse", int, choices=[0, 1]),
"i_q95_fixed": InputVariable(
data_structure.constraint_variables, int, choices=[0, 1]
),
Expand Down Expand Up @@ -1747,7 +1747,7 @@ def __post_init__(self):
),
"istell": InputVariable(data_structure.stellarator_variables, int, range=(0, 6)),
"isthtr": InputVariable(data_structure.stellarator_variables, int, range=(1, 3)),
"istore": InputVariable(data_structure.pulse_variables, int, range=(1, 3)),
"istore": InputVariable("pulse", int, range=(1, 3)),
"i_cs_superconductor": InputVariable(
data_structure.pfcoil_variables, int, range=(1, 9)
),
Expand All @@ -1756,7 +1756,7 @@ def __post_init__(self):
),
"itart": InputVariable(data_structure.physics_variables, int, choices=[0, 1]),
"itartpf": InputVariable(data_structure.physics_variables, int, choices=[0, 1]),
"itcycl": InputVariable(data_structure.pulse_variables, int, range=(1, 3)),
"itcycl": InputVariable("pulse", int, range=(1, 3)),
"i_pflux_fw_neutron": InputVariable(
data_structure.physics_variables, int, range=(1, 2)
),
Expand Down
2 changes: 2 additions & 0 deletions process/core/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from process.data_structure.cs_fatigue_variables import CSFatigueData
from process.data_structure.first_wall_variables import FirstWallData
from process.data_structure.fwbs_variables import FWBSData
from process.data_structure.pulse_variables import PulseData
from process.data_structure.reinke_variables import ReinkeData
from process.data_structure.structure_variables import StructureData
from process.data_structure.times_variables import TimesData
Expand All @@ -31,6 +32,7 @@ class DataStructure:
times: TimesData = initialise_later
reinke: ReinkeData = initialise_later
ccfe_hcpb: CCFEHCPBData = initialise_later
pulse: PulseData = initialise_later

def __post_init__(self):
for f in fields(self):
Expand Down
69 changes: 33 additions & 36 deletions process/data_structure/pulse_variables.py
Original file line number Diff line number Diff line change
@@ -1,36 +1,33 @@
bctmp: float = None
"""first wall bulk coolant temperature (C)"""

dtstor: float = None
"""maximum allowable temperature change in stainless steel thermal storage block (K) (`istore=3`)"""

istore: int = None
"""Switch for thermal storage method:
- =1 option 1 of Electrowatt report, AEA FUS 205
- =2 option 2 of Electrowatt report, AEA FUS 205
- =3 stainless steel block
"""

itcycl: int = None
"""Switch for first wall axial stress model:
- =1 total axial constraint, no bending
- =2 no axial constraint, no bending
- =3 no axial constraint, bending
"""

i_pulsed_plant: int = None
"""Switch for reactor model:
- =0 continuous operation
- =1 pulsed operation
"""


def init_pulse_variables():
"""Initialise the pulse variables"""
global bctmp, dtstor, istore, itcycl, i_pulsed_plant

bctmp = 320.0
dtstor = 300.0
istore = 1
itcycl = 1
i_pulsed_plant = 0
from dataclasses import dataclass


@dataclass
class PulseData:
bctmp: float = 320.0
"""first wall bulk coolant temperature (C)"""

dtstor: float = 300.0
"""maximum allowable temperature change in stainless steel thermal storage block (K) (`istore=3`)"""

istore: int = 1
"""Switch for thermal storage method:
- =1 option 1 of Electrowatt report, AEA FUS 205
- =2 option 2 of Electrowatt report, AEA FUS 205
- =3 stainless steel block
"""

itcycl: int = 1
"""Switch for first wall axial stress model:
- =1 total axial constraint, no bending
- =2 no axial constraint, no bending
- =3 no axial constraint, bending
"""

i_pulsed_plant: int = 0
"""Switch for reactor model:
- =0 continuous operation
- =1 pulsed operation
"""


CREATE_DICTS_FROM_DATACLASS = PulseData
17 changes: 8 additions & 9 deletions process/models/costs/costs.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
pf_power_variables,
pfcoil_variables,
physics_variables,
pulse_variables,
tfcoil_variables,
)
from process.models.tfcoil.base import TFConductorModel
Expand Down Expand Up @@ -2600,8 +2599,8 @@ def acc2253(self):
# Thermal storage options for a pulsed reactor
# See F/MPE/MOD/CAG/PROCESS/PULSE/0008 and 0014

if pulse_variables.i_pulsed_plant == 1:
if pulse_variables.istore == 1:
if self.data.pulse.i_pulsed_plant == 1:
if self.data.pulse.istore == 1:
# Option 1 from ELECTROWATT report
# Pulsed Fusion Reactor Study : AEA FUS 205

Expand All @@ -2623,7 +2622,7 @@ def acc2253(self):
# Externally fired superheater
self.data.costs.c2253 += 29.0e0

elif pulse_variables.istore == 2:
elif self.data.pulse.istore == 2:
# Option 2 from ELECTROWATT report
# Pulsed Fusion Reactor Study : AEA FUS 205

Expand Down Expand Up @@ -2652,29 +2651,29 @@ def acc2253(self):
# Increased cooling water system capacity
self.data.costs.c2253 += 18.0e0

elif pulse_variables.istore == 3:
elif self.data.pulse.istore == 3:
# Simplistic approach that assumes that a large stainless steel
# block acts as the thermal storage medium. No account is taken
# of the cost of the piping within the block, etc.
#
# shcss is the specific heat capacity of stainless steel (J/kg/K)
# pulse_variables.dtstor is the maximum allowable temperature change in the
# self.data.pulse.dtstor is the maximum allowable temperature change in the
# stainless steel block (input)

shcss = 520.0e0
self.data.costs.c2253 = (
self.data.costs.ucblss
* (heat_transport_variables.p_plant_primary_heat_mw * 1.0e6)
* self.data.times.t_plant_pulse_no_burn
/ (shcss * pulse_variables.dtstor)
/ (shcss * self.data.pulse.dtstor)
)

else:
raise ProcessValueError(
"Illegal value for istore", istore=pulse_variables.istore
"Illegal value for istore", istore=self.data.pulse.istore
)

if pulse_variables.istore < 3:
if self.data.pulse.istore < 3:
# Scale self.data.costs.c2253 with net electric power

self.data.costs.c2253 = (
Expand Down
3 changes: 1 addition & 2 deletions process/models/physics/physics.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
impurity_radiation_module,
numerics,
physics_variables,
pulse_variables,
stellarator_variables,
)
from process.models.physics import impurity_radiation
Expand Down Expand Up @@ -430,7 +429,7 @@ def run(self):
# =======================================================

# Set PF coil ramp times
if pulse_variables.i_pulsed_plant != 1:
if self.data.pulse.i_pulsed_plant != 1:
if self.data.times.i_t_current_ramp_up == 0:
self.data.times.t_plant_pulse_plasma_current_ramp_up = (
physics_variables.plasma_current / 5.0e5
Expand Down
5 changes: 2 additions & 3 deletions process/models/pulse.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
pf_power_variables,
pfcoil_variables,
physics_variables,
pulse_variables,
)

logger = logging.getLogger(__name__)
Expand All @@ -38,7 +37,7 @@ def run(self, output: bool = False):
output :
indicate whether output should be written to the output file, or not
"""
if pulse_variables.i_pulsed_plant == 1:
if self.data.pulse.i_pulsed_plant == 1:
self.tohswg(output=output)

# Burn time calculation
Expand All @@ -62,7 +61,7 @@ def tohswg(self, output: bool):
output :
indicate whether output should be written to the output file, or not
"""
if pulse_variables.i_pulsed_plant != 1:
if self.data.pulse.i_pulsed_plant != 1:
return

# Current/turn in Central Solenoid at beginning of pulse (A/turn)
Expand Down
13 changes: 6 additions & 7 deletions tests/unit/models/test_costs_1990.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
pf_power_variables,
pfcoil_variables,
physics_variables,
pulse_variables,
tfcoil_variables,
)

Expand Down Expand Up @@ -3784,11 +3783,11 @@ def test_acc2253(acc2253param, monkeypatch, costs):
acc2253param.p_plant_electric_net_mw,
)

monkeypatch.setattr(pulse_variables, "i_pulsed_plant", acc2253param.i_pulsed_plant)
monkeypatch.setattr(costs.data.pulse, "i_pulsed_plant", acc2253param.i_pulsed_plant)

monkeypatch.setattr(pulse_variables, "dtstor", acc2253param.dtstor)
monkeypatch.setattr(costs.data.pulse, "dtstor", acc2253param.dtstor)

monkeypatch.setattr(pulse_variables, "istore", acc2253param.istore)
monkeypatch.setattr(costs.data.pulse, "istore", acc2253param.istore)

monkeypatch.setattr(
costs.data.times, "t_plant_pulse_no_burn", acc2253param.t_plant_pulse_no_burn
Expand Down Expand Up @@ -5518,11 +5517,11 @@ def test_acc2253_urt(acc2253param, monkeypatch, costs):
acc2253param.p_plant_electric_net_mw,
)

monkeypatch.setattr(pulse_variables, "i_pulsed_plant", acc2253param.i_pulsed_plant)
monkeypatch.setattr(costs.data.pulse, "i_pulsed_plant", acc2253param.i_pulsed_plant)

monkeypatch.setattr(pulse_variables, "dtstor", acc2253param.dtstor)
monkeypatch.setattr(costs.data.pulse, "dtstor", acc2253param.dtstor)

monkeypatch.setattr(pulse_variables, "istore", acc2253param.istore)
monkeypatch.setattr(costs.data.pulse, "istore", acc2253param.istore)

monkeypatch.setattr(
costs.data.times, "t_plant_pulse_no_burn", acc2253param.t_plant_pulse_no_burn
Expand Down
10 changes: 4 additions & 6 deletions tests/unit/models/test_pulse.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,17 @@
pf_power_variables,
pfcoil_variables,
physics_variables,
pulse_variables,
)
from process.models.pulse import Pulse


@pytest.fixture
def pulse():
def pulse(process_models):
"""Provides Pulse object for testing.

:returns: initialised Pulse object
:rtype: process.pulse.Pulse
"""
return Pulse()
return process_models.pulse


class TohswgParam(NamedTuple):
Expand Down Expand Up @@ -1238,7 +1236,7 @@ def test_tohswg(tohswgparam, monkeypatch, pulse):

monkeypatch.setattr(numerics, "active_constraints", tohswgparam.active_constraints)

monkeypatch.setattr(pulse_variables, "i_pulsed_plant", tohswgparam.i_pulsed_plant)
monkeypatch.setattr(pulse.data.pulse, "i_pulsed_plant", tohswgparam.i_pulsed_plant)

pulse.tohswg(output=False)

Expand All @@ -1265,8 +1263,8 @@ def test_calculate_burn_time_valid(
v_plasma_loop_burn,
t_plant_pulse_fusion_ramp,
expected,
pulse,
):
pulse = Pulse()
result = pulse.calculate_burn_time(
vs_cs_pf_total_burn=vs_cs_pf_total_burn,
v_plasma_loop_burn=v_plasma_loop_burn,
Expand Down
Loading