From 7b4588f04350775114238bb77471854fcb8fc2d6 Mon Sep 17 00:00:00 2001 From: Timothy Nunn Date: Thu, 21 May 2026 11:29:57 +0100 Subject: [PATCH 1/5] Enforce use of slots on all data structures --- process/data_structure/blanket_variables.py | 2 +- process/data_structure/build_variables.py | 2 +- process/data_structure/buildings_variables.py | 2 +- process/data_structure/ccfe_hcpb_variables.py | 2 +- .../data_structure/constraint_variables.py | 2 +- process/data_structure/cost_2015_variables.py | 2 +- process/data_structure/cost_variables.py | 2 +- .../data_structure/cs_fatigue_variables.py | 2 +- .../data_structure/current_drive_variables.py | 2 +- process/data_structure/dcll_variables.py | 2 +- process/data_structure/divertor_variables.py | 2 +- .../data_structure/first_wall_variables.py | 2 +- process/data_structure/fwbs_variables.py | 2 +- .../heat_transport_variables.py | 2 +- process/data_structure/ife_variables.py | 2 +- .../data_structure/neoclassics_variables.py | 2 +- process/data_structure/pf_power_variables.py | 2 +- process/data_structure/pfcoil_variables.py | 2 +- process/data_structure/power_variables.py | 2 +- .../primary_pumping_variables.py | 2 +- process/data_structure/pulse_variables.py | 2 +- process/data_structure/reinke_variables.py | 2 +- .../stellarator_configuration.py | 2 +- .../data_structure/stellarator_variables.py | 2 +- process/data_structure/structure_variables.py | 2 +- process/data_structure/times_variables.py | 2 +- process/data_structure/vacuum_variables.py | 2 +- .../data_structure/water_usage_variables.py | 2 +- tests/unit/core/test_data_structure.py | 21 +++++++++++++++++++ 29 files changed, 49 insertions(+), 28 deletions(-) create mode 100644 tests/unit/core/test_data_structure.py diff --git a/process/data_structure/blanket_variables.py b/process/data_structure/blanket_variables.py index 51d37e4b33..e3e9584fed 100644 --- a/process/data_structure/blanket_variables.py +++ b/process/data_structure/blanket_variables.py @@ -28,7 +28,7 @@ from dataclasses import dataclass -@dataclass +@dataclass(slots=True) class BlanketData: vol_shld_inboard: float = 0.0 """Volume of inboard shield (m3)""" diff --git a/process/data_structure/build_variables.py b/process/data_structure/build_variables.py index 75c9c2dece..89297e4344 100644 --- a/process/data_structure/build_variables.py +++ b/process/data_structure/build_variables.py @@ -1,7 +1,7 @@ from dataclasses import dataclass -@dataclass +@dataclass(slots=True) class BuildData: aplasmin: float = 0.25 """minimum minor radius (m)""" diff --git a/process/data_structure/buildings_variables.py b/process/data_structure/buildings_variables.py index 4b24b19c53..6226c92f32 100644 --- a/process/data_structure/buildings_variables.py +++ b/process/data_structure/buildings_variables.py @@ -1,7 +1,7 @@ from dataclasses import dataclass -@dataclass +@dataclass(slots=True) class BuildingsData: admv: float = 1.0e5 """administration building volume (m3)""" diff --git a/process/data_structure/ccfe_hcpb_variables.py b/process/data_structure/ccfe_hcpb_variables.py index d985b0e10d..5b0e86958d 100644 --- a/process/data_structure/ccfe_hcpb_variables.py +++ b/process/data_structure/ccfe_hcpb_variables.py @@ -9,7 +9,7 @@ from dataclasses import dataclass -@dataclass +@dataclass(slots=True) class CCFEHCPBData: armour_density: float = 0.0 """FW armour density [kg/m3]""" diff --git a/process/data_structure/constraint_variables.py b/process/data_structure/constraint_variables.py index 42b77d30f3..b55a45b772 100644 --- a/process/data_structure/constraint_variables.py +++ b/process/data_structure/constraint_variables.py @@ -1,7 +1,7 @@ from dataclasses import dataclass -@dataclass +@dataclass(slots=True) class ConstraintData: p_hcd_injected_min_mw: float = 0.1 """minimum auxiliary power (MW) (`constraint equation 40`)""" diff --git a/process/data_structure/cost_2015_variables.py b/process/data_structure/cost_2015_variables.py index eedb2c1304..55ca6c12df 100644 --- a/process/data_structure/cost_2015_variables.py +++ b/process/data_structure/cost_2015_variables.py @@ -3,7 +3,7 @@ import numpy as np -@dataclass +@dataclass(slots=True) class Cost2015Data: mean_electric_output: float = 0.0 diff --git a/process/data_structure/cost_variables.py b/process/data_structure/cost_variables.py index 5c2070e566..3efd8bd58c 100644 --- a/process/data_structure/cost_variables.py +++ b/process/data_structure/cost_variables.py @@ -1,7 +1,7 @@ from dataclasses import dataclass, field -@dataclass +@dataclass(slots=True) class CostData: c228: float = 0.0 """c228 account cost""" diff --git a/process/data_structure/cs_fatigue_variables.py b/process/data_structure/cs_fatigue_variables.py index b7f726003b..b903bd7d71 100644 --- a/process/data_structure/cs_fatigue_variables.py +++ b/process/data_structure/cs_fatigue_variables.py @@ -1,7 +1,7 @@ from dataclasses import dataclass -@dataclass +@dataclass(slots=True) class CSFatigueData: residual_sig_hoop: float = 2.4e8 """residual hoop stress in strucutal material (Pa)""" diff --git a/process/data_structure/current_drive_variables.py b/process/data_structure/current_drive_variables.py index 984216febd..329318e8aa 100644 --- a/process/data_structure/current_drive_variables.py +++ b/process/data_structure/current_drive_variables.py @@ -5,7 +5,7 @@ from dataclasses import dataclass -@dataclass +@dataclass(slots=True) class CurrentDriveData: dx_beam_duct: float = 0.58 """width of neutral beam duct where it passes between the TF coils (m) diff --git a/process/data_structure/dcll_variables.py b/process/data_structure/dcll_variables.py index 80668b8f5b..90bb67cbe1 100644 --- a/process/data_structure/dcll_variables.py +++ b/process/data_structure/dcll_variables.py @@ -72,7 +72,7 @@ from dataclasses import dataclass -@dataclass +@dataclass(slots=True) class DCLLData: r_fci: float = 0.0 """Radial thickness of FCIs [m]""" diff --git a/process/data_structure/divertor_variables.py b/process/data_structure/divertor_variables.py index cca7a800ad..4608b78f41 100644 --- a/process/data_structure/divertor_variables.py +++ b/process/data_structure/divertor_variables.py @@ -1,7 +1,7 @@ from dataclasses import dataclass -@dataclass +@dataclass(slots=True) class DivertorData: """Divertor model dataclass""" diff --git a/process/data_structure/first_wall_variables.py b/process/data_structure/first_wall_variables.py index 2aa327df15..7df351ffba 100644 --- a/process/data_structure/first_wall_variables.py +++ b/process/data_structure/first_wall_variables.py @@ -1,7 +1,7 @@ from dataclasses import dataclass -@dataclass +@dataclass(slots=True) class FirstWallData: a_fw_total_full_coverage: float = 0.0 """First wall total surface area with no holes or ports [m^2]""" diff --git a/process/data_structure/fwbs_variables.py b/process/data_structure/fwbs_variables.py index 4ac163e17d..3f1041e677 100644 --- a/process/data_structure/fwbs_variables.py +++ b/process/data_structure/fwbs_variables.py @@ -8,7 +8,7 @@ from dataclasses import dataclass, field -@dataclass +@dataclass(slots=True) class FWBSData: life_blkt_fpy: float = 0.0 """Full power blanket lifetime (years)""" diff --git a/process/data_structure/heat_transport_variables.py b/process/data_structure/heat_transport_variables.py index 5512f6b792..855626fcf8 100644 --- a/process/data_structure/heat_transport_variables.py +++ b/process/data_structure/heat_transport_variables.py @@ -8,7 +8,7 @@ from dataclasses import dataclass -@dataclass +@dataclass(slots=True) class HeatTransportData: p_plant_electric_base: float = 5.0e6 """base plant electric load (W)""" diff --git a/process/data_structure/ife_variables.py b/process/data_structure/ife_variables.py index 9fc7ece237..1731867a17 100644 --- a/process/data_structure/ife_variables.py +++ b/process/data_structure/ife_variables.py @@ -29,7 +29,7 @@ """ -@dataclass +@dataclass(slots=True) class IFEData: bldr: float = 1.0 """radial thickness of IFE blanket (m; calculated `if ifetyp=4`)""" diff --git a/process/data_structure/neoclassics_variables.py b/process/data_structure/neoclassics_variables.py index 74380c5370..e623f114f2 100644 --- a/process/data_structure/neoclassics_variables.py +++ b/process/data_structure/neoclassics_variables.py @@ -12,7 +12,7 @@ """Number of Gauss laguerre roots""" -@dataclass +@dataclass(slots=True) class NeoclassicsData: densities: list[float] = field(default_factory=lambda: np.zeros(4)) """Densities of the species that are considered [/m3]""" diff --git a/process/data_structure/pf_power_variables.py b/process/data_structure/pf_power_variables.py index fff22c0416..4ed641a8eb 100644 --- a/process/data_structure/pf_power_variables.py +++ b/process/data_structure/pf_power_variables.py @@ -7,7 +7,7 @@ import numpy as np -@dataclass +@dataclass(slots=True) class PFPowerData: acptmax: float = 0.0 """average of currents in PF circuits (kA)""" diff --git a/process/data_structure/pfcoil_variables.py b/process/data_structure/pfcoil_variables.py index 720e813ae5..7e1120504c 100644 --- a/process/data_structure/pfcoil_variables.py +++ b/process/data_structure/pfcoil_variables.py @@ -23,7 +23,7 @@ """new variable to include 2 additional circuits: plasma and central solenoid""" -@dataclass +@dataclass(slots=True) class PFCoilData: # PF coil module variables nef: int = 0 diff --git a/process/data_structure/power_variables.py b/process/data_structure/power_variables.py index 377bab4adf..4949aae659 100644 --- a/process/data_structure/power_variables.py +++ b/process/data_structure/power_variables.py @@ -1,7 +1,7 @@ from dataclasses import dataclass, field -@dataclass +@dataclass(slots=True) class PowerData: qmisc: float = 0.0 diff --git a/process/data_structure/primary_pumping_variables.py b/process/data_structure/primary_pumping_variables.py index ba2f42911f..38f6a13ecf 100644 --- a/process/data_structure/primary_pumping_variables.py +++ b/process/data_structure/primary_pumping_variables.py @@ -1,7 +1,7 @@ from dataclasses import dataclass -@dataclass +@dataclass(slots=True) class PrimaryPumpingData: gamma_he: float = 1.667 """ratio of specific heats for helium (`i_p_coolant_pumping=3`)""" diff --git a/process/data_structure/pulse_variables.py b/process/data_structure/pulse_variables.py index 96215ece95..b5b760b158 100644 --- a/process/data_structure/pulse_variables.py +++ b/process/data_structure/pulse_variables.py @@ -1,7 +1,7 @@ from dataclasses import dataclass -@dataclass +@dataclass(slots=True) class PulseData: bctmp: float = 320.0 """first wall bulk coolant temperature (C)""" diff --git a/process/data_structure/reinke_variables.py b/process/data_structure/reinke_variables.py index 7fb27b4c35..445ee85d43 100644 --- a/process/data_structure/reinke_variables.py +++ b/process/data_structure/reinke_variables.py @@ -1,7 +1,7 @@ from dataclasses import dataclass -@dataclass +@dataclass(slots=True) class ReinkeData: impvardiv: int = 9 """Index of impurity to be iterated for Reinke divertor detachment criterion""" diff --git a/process/data_structure/stellarator_configuration.py b/process/data_structure/stellarator_configuration.py index 70a0857a41..313801a543 100644 --- a/process/data_structure/stellarator_configuration.py +++ b/process/data_structure/stellarator_configuration.py @@ -1,7 +1,7 @@ from dataclasses import dataclass -@dataclass +@dataclass(slots=True) class StellaratorConfigData: stella_config_name: str = "" """Name of the configuration""" diff --git a/process/data_structure/stellarator_variables.py b/process/data_structure/stellarator_variables.py index d74b18adb9..c761c1849f 100644 --- a/process/data_structure/stellarator_variables.py +++ b/process/data_structure/stellarator_variables.py @@ -1,7 +1,7 @@ from dataclasses import dataclass -@dataclass +@dataclass(slots=True) class StellaratorData: f_st_n_coils: float = 0.0 """Actual number of coils to reference value from stella_config file""" diff --git a/process/data_structure/structure_variables.py b/process/data_structure/structure_variables.py index e3155886c5..082461bb18 100644 --- a/process/data_structure/structure_variables.py +++ b/process/data_structure/structure_variables.py @@ -1,7 +1,7 @@ from dataclasses import dataclass -@dataclass +@dataclass(slots=True) class StructureData: """Data describing the structure.""" diff --git a/process/data_structure/times_variables.py b/process/data_structure/times_variables.py index ba5cbdc3d2..7cd54a1067 100644 --- a/process/data_structure/times_variables.py +++ b/process/data_structure/times_variables.py @@ -3,7 +3,7 @@ import numpy as np -@dataclass +@dataclass(slots=True) class TimesData: pulsetimings: int = 1 """Switch for pulse timings (if i_pulsed_plant=1): diff --git a/process/data_structure/vacuum_variables.py b/process/data_structure/vacuum_variables.py index adf982428c..25204f6856 100644 --- a/process/data_structure/vacuum_variables.py +++ b/process/data_structure/vacuum_variables.py @@ -1,7 +1,7 @@ from dataclasses import dataclass -@dataclass +@dataclass(slots=True) class VacuumData: i_vacuum_pumping: str = "old" """switch for vacuum pumping model: diff --git a/process/data_structure/water_usage_variables.py b/process/data_structure/water_usage_variables.py index a555412776..aa27f11e18 100644 --- a/process/data_structure/water_usage_variables.py +++ b/process/data_structure/water_usage_variables.py @@ -9,7 +9,7 @@ from dataclasses import dataclass -@dataclass +@dataclass(slots=True) class WaterUseData: airtemp: float = 15.0 """ambient air temperature (degrees Celsius)""" diff --git a/tests/unit/core/test_data_structure.py b/tests/unit/core/test_data_structure.py new file mode 100644 index 0000000000..62702bd26c --- /dev/null +++ b/tests/unit/core/test_data_structure.py @@ -0,0 +1,21 @@ +from dataclasses import fields + +import pytest + +from process.core.model import DataStructure + +DATA_STRUCTURES = {f.name: f.type() for f in fields(DataStructure)} + + +@pytest.mark.parametrize( + "data_structure_class", + DATA_STRUCTURES.values(), + ids=DATA_STRUCTURES.keys(), +) +def test_arbitrary_assigns_disallowed(data_structure_class): + """A test that checks arbitrary data cannot be assigned to a data structure. + + I.e. that the data class uses slots. + """ + with pytest.raises(AttributeError): + data_structure_class.my_property_that_doesnt_exist = 42 From 62531e505e71de1123fd89556e2b02803dcc587e Mon Sep 17 00:00:00 2001 From: Timothy Nunn Date: Thu, 21 May 2026 14:03:21 +0100 Subject: [PATCH 2/5] Fix non-existent variables being set on Water data structure --- process/models/water_use.py | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/process/models/water_use.py b/process/models/water_use.py index cd20df58af..bc603609a9 100644 --- a/process/models/water_use.py +++ b/process/models/water_use.py @@ -201,7 +201,7 @@ def cooling_water_body(self, wastetherm: float, output: bool): # self.data.water_use.watertemp < 25 degC # convert self.data.water_use.windspeed to mph - self.data.water_use.windspeedmph = self.data.water_use.windspeed * 2.237e0 + windspeedmph = self.data.water_use.windspeed * 2.237e0 # convert heat loading into cal/(cm2.sec) heatloadimp = heatload * 1000000.0e0 * 0.239e0 / 40469000.0e0 @@ -210,17 +210,15 @@ def cooling_water_body(self, wastetherm: float, output: bool): heatratio = ( d + (e * self.data.water_use.watertemp) - + (f * self.data.water_use.windspeedmph) + + (f * windspeedmph) + (g * heatload) + (h * self.data.water_use.watertemp**2) - + (i * self.data.water_use.windspeedmph**2) + + (i * windspeedmph**2) + (j * heatload**2) ) # estimate resultant heated water temperature - self.data.water_use.watertempheated = self.data.water_use.watertemp + ( - heatloadimp * heatratio - ) + watertempheated = self.data.water_use.watertemp + (heatloadimp * heatratio) # find wind function, m/(day.kPa), applicable to this water body: windfunction = ( @@ -232,10 +230,7 @@ def cooling_water_body(self, wastetherm: float, output: bool): # difference in saturation vapour pressure (Clausius-Clapeyron approximation) satvapdelta = ( 0.611e0 - * np.exp( - (17.27e0 * self.data.water_use.watertempheated) - / (237.3e0 + self.data.water_use.watertempheated) - ) + * np.exp((17.27e0 * watertempheated) / (237.3e0 + watertempheated)) ) - ( 0.611e0 * np.exp( From e654f4aea8f0bb8dc60146d7caf4c47f587f49e1 Mon Sep 17 00:00:00 2001 From: Timothy Nunn Date: Thu, 21 May 2026 14:13:14 +0100 Subject: [PATCH 3/5] Fix non-existent variables being set on PF data structure --- process/data_structure/pfcoil_variables.py | 3 ++ process/models/pfcoil.py | 46 +++++++++------------- 2 files changed, 21 insertions(+), 28 deletions(-) diff --git a/process/data_structure/pfcoil_variables.py b/process/data_structure/pfcoil_variables.py index 7e1120504c..8c51127123 100644 --- a/process/data_structure/pfcoil_variables.py +++ b/process/data_structure/pfcoil_variables.py @@ -504,5 +504,8 @@ class PFCoilData: radius_cs_turn_cable_space: float = 0.0 """Length of CS of CS coil turn conduit length""" + r_pf_outside_tf_midplane: float = 0.0 + """ Radial position of PF coil at the midplane.""" + CREATE_DICTS_FROM_DATACLASS = PFCoilData diff --git a/process/models/pfcoil.py b/process/models/pfcoil.py index 71f73afe9c..868263034f 100644 --- a/process/models/pfcoil.py +++ b/process/models/pfcoil.py @@ -73,7 +73,7 @@ def pfcoil(self): pcls0 = np.zeros(N_PF_GROUPS_MAX, dtype=int) ncls0 = np.zeros(N_PF_GROUPS_MAX + 2, dtype=int) - self.data.pf_coil.rcls0, self.data.pf_coil.zcls0 = np.zeros( + rcls0, zcls0 = np.zeros( ( 2, N_PF_GROUPS_MAX, @@ -81,7 +81,7 @@ def pfcoil(self): ), order="F", ) - self.data.pf_coil.ccls0 = np.zeros(int(N_PF_GROUPS_MAX / 2)) + ccls0 = np.zeros(int(N_PF_GROUPS_MAX / 2)) brin, bzin, rpts, zpts = np.zeros((4, NPTSMX)) bfix, bvec = np.zeros((2, lrow1)) gmat, _, _ = np.zeros((3, lrow1, lcol1), order="F") @@ -504,26 +504,18 @@ def pfcoil(self): for ccount in range(ngrp0): ncls0[ccount] = 2 - self.data.pf_coil.rcls0[ccount, 0] = ( - self.data.pf_coil.r_pf_coil_middle_group_array[ - pcls0[ccount] - 1, 0 - ] - ) - self.data.pf_coil.rcls0[ccount, 1] = ( - self.data.pf_coil.r_pf_coil_middle_group_array[ - pcls0[ccount] - 1, 1 - ] - ) - self.data.pf_coil.zcls0[ccount, 0] = ( - self.data.pf_coil.z_pf_coil_middle_group_array[ - pcls0[ccount] - 1, 0 - ] - ) - self.data.pf_coil.zcls0[ccount, 1] = ( - self.data.pf_coil.z_pf_coil_middle_group_array[ - pcls0[ccount] - 1, 1 - ] - ) + rcls0[ccount, 0] = self.data.pf_coil.r_pf_coil_middle_group_array[ + pcls0[ccount] - 1, 0 + ] + rcls0[ccount, 1] = self.data.pf_coil.r_pf_coil_middle_group_array[ + pcls0[ccount] - 1, 1 + ] + zcls0[ccount, 0] = self.data.pf_coil.z_pf_coil_middle_group_array[ + pcls0[ccount] - 1, 0 + ] + zcls0[ccount, 1] = self.data.pf_coil.z_pf_coil_middle_group_array[ + pcls0[ccount] - 1, 1 + ] npts0 = 1 rpts[0] = pv.rmajor @@ -546,7 +538,7 @@ def pfcoil(self): pv.b_plasma_vertical_required = bzin[0] - _ssqef, self.data.pf_coil.ccls0 = self.efc( + _ssqef, ccls0 = self.efc( npts0, rpts, zpts, @@ -558,8 +550,8 @@ def pfcoil(self): self.data.pf_coil.c_pf_cs_current_filaments, ngrp0, ncls0, - self.data.pf_coil.rcls0, - self.data.pf_coil.zcls0, + rcls0, + zcls0, self.data.pf_coil.alfapf, bfix, gmat, @@ -567,9 +559,7 @@ def pfcoil(self): ) for ccount in range(ngrp0): - self.data.pf_coil.ccls[pcls0[ccount] - 1] = self.data.pf_coil.ccls0[ - ccount - ] + self.data.pf_coil.ccls[pcls0[ccount] - 1] = ccls0[ccount] # Flux swing from vertical field From 69465389ed144ac1ef71549fa35e1879030dbb80 Mon Sep 17 00:00:00 2001 From: Timothy Nunn Date: Thu, 21 May 2026 14:13:26 +0100 Subject: [PATCH 4/5] Fix non-existent variables being set on Power data structure --- process/data_structure/power_variables.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/process/data_structure/power_variables.py b/process/data_structure/power_variables.py index 4949aae659..9cb71b8fd0 100644 --- a/process/data_structure/power_variables.py +++ b/process/data_structure/power_variables.py @@ -72,7 +72,7 @@ class PowerData: p_cryo_plant_electric_profile_mw: list[float] = field(default_factory=list) """Profile of total cryo plant electric power (MW) over pulse""" - p_plant_electric_base_total__profile_mw: list[float] = field(default_factory=list) + p_plant_electric_base_total_profile_mw: list[float] = field(default_factory=list) """Profile of total plant electric base power (MW) over pulse""" p_plant_electric_gross_profile_mw: list[float] = field(default_factory=list) From 1f3e2e7c3e862eadb98cedc1c93a40a27e8aea30 Mon Sep 17 00:00:00 2001 From: Timothy Nunn Date: Thu, 21 May 2026 15:23:35 +0100 Subject: [PATCH 5/5] Correct non-existent variables set in Stellarator --- process/models/stellarator/heating.py | 4 ++-- process/models/stellarator/preset_config.py | 13 ++++++++----- process/models/stellarator/stellarator.py | 6 +++--- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/process/models/stellarator/heating.py b/process/models/stellarator/heating.py index 9bbf3d8780..46313b35bd 100644 --- a/process/models/stellarator/heating.py +++ b/process/models/stellarator/heating.py @@ -37,7 +37,7 @@ def st_heat(stellarator, f_output: bool, data: DataStructure): data.current_drive.eta_hcd_primary_injector_wall_plug = ( data.current_drive.eta_ecrh_injector_wall_plug ) - data.current_drive.p_hcd_electric_total_mw = ( + data.heat_transport.p_hcd_electric_total_mw = ( data.current_drive.p_hcd_injected_ions_mw + data.current_drive.p_hcd_injected_electrons_mw ) / data.current_drive.eta_hcd_primary_injector_wall_plug @@ -82,7 +82,7 @@ def st_heat(stellarator, f_output: bool, data: DataStructure): data.current_drive.eta_hcd_primary_injector_wall_plug = ( data.current_drive.eta_beam_injector_wall_plug ) - data.current_drive.p_hcd_electric_total_mw = ( + data.heat_transport.p_hcd_electric_total_mw = ( data.current_drive.p_hcd_injected_ions_mw + data.current_drive.p_hcd_injected_electrons_mw ) / data.current_drive.eta_hcd_primary_injector_wall_plug diff --git a/process/models/stellarator/preset_config.py b/process/models/stellarator/preset_config.py index 88ee842965..24a8c94413 100644 --- a/process/models/stellarator/preset_config.py +++ b/process/models/stellarator/preset_config.py @@ -248,8 +248,11 @@ def load_stellarator_config(istell: int, config_file: Path | None, data: DataStr raise ProcessValueError(f"{istell=} is not an integer in the range [1, 6]") for variable_name, variable_value in machine_config.items(): - setattr( - data.stellarator_config, - f"stella_config_{variable_name.lower()}", - variable_value, - ) + name_on_data_structure = f"stella_config_{variable_name.lower()}" + + if hasattr(data.stellarator_config, name_on_data_structure): + setattr( + data.stellarator_config, + name_on_data_structure, + variable_value, + ) diff --git a/process/models/stellarator/stellarator.py b/process/models/stellarator/stellarator.py index d2dd447170..3ff3c75380 100644 --- a/process/models/stellarator/stellarator.py +++ b/process/models/stellarator/stellarator.py @@ -200,7 +200,7 @@ def st_new_config(self): To clarify the coils scaling factor: Coil aspect ratio factor can be described with the reversed equation (so if we would know r_coil_minor) - self.data.stellarator.f_coil_aspect = ( + f_coil_aspect = ( (physics_variables.rmajor / self.data.stellarator.r_coil_minor) / (self.data.stellarator_config.stella_config_rmajor_ref / self.data.stellarator_config.stella_config_coil_rminor) @@ -252,7 +252,7 @@ def st_new_config(self): ) # B-field scaling factor # Coil aspect ratio factor to the reference calculation (we use it to scale the coil minor radius) - self.data.stellarator.f_coil_aspect = self.data.stellarator.f_st_coil_aspect + f_coil_aspect = self.data.stellarator.f_st_coil_aspect # Coil major radius, scaled with respect to the reference calculation self.data.stellarator.r_coil_major = ( @@ -263,7 +263,7 @@ def st_new_config(self): self.data.stellarator.r_coil_minor = ( self.data.stellarator_config.stella_config_coil_rminor * self.data.stellarator.f_st_rmajor - / self.data.stellarator.f_coil_aspect + / f_coil_aspect ) self.data.stellarator.f_coil_shape = (