From ebdc15d7de2b17ab5a3b911db406cc590c3f7ba7 Mon Sep 17 00:00:00 2001 From: mn3981 Date: Tue, 13 Oct 2026 13:07:53 +0100 Subject: [PATCH 1/5] Add CSUseModel enumeration for Central Solenoid usage models --- process/data_structure/pfcoil_variables.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/process/data_structure/pfcoil_variables.py b/process/data_structure/pfcoil_variables.py index efad8f5193..38bfbad862 100644 --- a/process/data_structure/pfcoil_variables.py +++ b/process/data_structure/pfcoil_variables.py @@ -15,6 +15,15 @@ class PFConductorModel(IntEnum): SUPERCONDUCTING = 0 RESISTIVE = 1 + +@unique +class CSUseModel(IntEnum): + """Enumeration for Central Solenoid usage models.""" + + NO_CENTRAL_SOLENOID = 0 + """No central solenoid is present""" + FULL_PULSE = 1 + """Central solenoid is used to drive the plasma current for the full pulse""" N_PF_GROUPS_MAX = 10 From 14d123d2410683a46d5236a47c759bb4128d3726 Mon Sep 17 00:00:00 2001 From: mn3981 Date: Tue, 13 Oct 2026 13:25:00 +0100 Subject: [PATCH 2/5] Refactor Central Solenoid usage handling with CSUseModel enumeration --- process/data_structure/pfcoil_variables.py | 3 +- process/models/costs/costs.py | 6 +- process/models/pfcoil.py | 79 +++++++++++--------- process/models/power.py | 4 +- process/models/stellarator/initialization.py | 4 +- tests/unit/models/test_costs_1990.py | 8 +- tests/unit/models/test_pfcoil.py | 7 +- tests/unit/models/test_power.py | 5 +- 8 files changed, 65 insertions(+), 51 deletions(-) diff --git a/process/data_structure/pfcoil_variables.py b/process/data_structure/pfcoil_variables.py index 38bfbad862..265bcd5cec 100644 --- a/process/data_structure/pfcoil_variables.py +++ b/process/data_structure/pfcoil_variables.py @@ -15,7 +15,8 @@ class PFConductorModel(IntEnum): SUPERCONDUCTING = 0 RESISTIVE = 1 - + + @unique class CSUseModel(IntEnum): """Enumeration for Central Solenoid usage models.""" diff --git a/process/models/costs/costs.py b/process/models/costs/costs.py index 208f98cbe0..a28a5ada6c 100644 --- a/process/models/costs/costs.py +++ b/process/models/costs/costs.py @@ -8,7 +8,7 @@ from process.core import process_output as po from process.core.exceptions import ProcessValueError from process.core.model import Model -from process.data_structure.pfcoil_variables import PFConductorModel +from process.data_structure.pfcoil_variables import CSUseModel, PFConductorModel from process.models.tfcoil.base import TFConductorModel from process.models.vacuum import VacuumPumpType @@ -1627,7 +1627,7 @@ def acc2222(self): # Non-Central Solenoid coils - if self.data.build.iohcl == 1: + if CSUseModel(self.data.build.iohcl) != CSUseModel.NO_CENTRAL_SOLENOID: npf = self.data.pf_coil.n_cs_pf_coils - 1 else: npf = self.data.pf_coil.n_cs_pf_coils @@ -1715,7 +1715,7 @@ def acc2222(self): # Central Solenoid - if self.data.build.iohcl == 1: + if CSUseModel(self.data.build.iohcl) == CSUseModel.FULL_PULSE: # Superconductor ($/m) if self.data.costs.supercond_cost_model == 0: # Issue #328 Use CS conductor cross-sectional area (m2) diff --git a/process/models/pfcoil.py b/process/models/pfcoil.py index c8bf6b0a4d..f4563b85f5 100644 --- a/process/models/pfcoil.py +++ b/process/models/pfcoil.py @@ -23,6 +23,7 @@ NFIXMX, NGC2, NPTSMX, + CSUseModel, PFConductorModel, ) from process.models import superconductors @@ -152,7 +153,7 @@ def pfcoil(self): self.data.pf_coil.n_cs_pf_coils += self.data.pf_coil.n_pf_coils_in_group[i] # Add one if an Central Solenoid is present, and make an extra group - if self.data.build.iohcl != 0: + if CSUseModel(self.data.build.iohcl) != CSUseModel.NO_CENTRAL_SOLENOID: self.data.pf_coil.n_cs_pf_coils += 1 self.data.pf_coil.n_pf_coils_in_group[self.data.pf_coil.n_pf_coil_groups] = 1 @@ -199,7 +200,7 @@ def pfcoil(self): # nfxf is the total no of filaments into which the Central Solenoid is split, # if present - if self.data.build.iohcl == 0: + if CSUseModel(self.data.build.iohcl) == CSUseModel.NO_CENTRAL_SOLENOID: self.data.pf_coil.nfxf = 0 c_cs_flat_top_end = 0.0e0 else: @@ -459,7 +460,10 @@ def pfcoil(self): match self.data.pf_coil.i_pf_location[i]: case PFLocationTypes.ABOVE_CS: # Do not allow if no central solenoid - if self.data.build.iohcl == 0: + if ( + CSUseModel(self.data.build.iohcl) + == CSUseModel.NO_CENTRAL_SOLENOID + ): raise ProcessValueError( "i_pf_location(i) should not be 1 if iohcl=0" ) @@ -633,7 +637,7 @@ def pfcoil(self): # Flux swing required from CS coil csflux = -(self.data.physics.vs_plasma_ramp_required) - pfflux - if self.data.build.iohcl == 1: + if CSUseModel(self.data.build.iohcl) == CSUseModel.FULL_PULSE: # Required current change in CS coil # Proposed new calculation... @@ -1054,7 +1058,7 @@ def pfcoil(self): ) # Find Central Solenoid information - if self.data.build.iohcl != 0: + if CSUseModel(self.data.build.iohcl) != CSUseModel.NO_CENTRAL_SOLENOID: self.cs_coil.ohcalc() # Summation of weights and current @@ -1627,10 +1631,10 @@ def vsec(self): This routine calculates the volt-second capability of the PF coil system. """ - if self.data.build.iohcl == 0: + if CSUseModel(self.data.build.iohcl) == CSUseModel.NO_CENTRAL_SOLENOID: # No Central Solenoid self.data.pf_coil.nef = self.data.pf_coil.n_pf_cs_plasma_circuits - 1 - else: + else: # Full pulse self.data.pf_coil.nef = self.data.pf_coil.n_pf_cs_plasma_circuits - 2 self.data.pf_coil.vs_pf_coils_total_ramp = 0.0e0 @@ -1653,7 +1657,7 @@ def vsec(self): ) # Central Solenoid startup volt-seconds - if self.data.build.iohcl != 0: + if CSUseModel(self.data.build.iohcl) != CSUseModel.NO_CENTRAL_SOLENOID: self.data.pf_coil.vsdum[self.data.pf_coil.n_cs_pf_coils - 1, 0] = ( self.data.pf_coil.ind_pf_cs_plasma_mutual[ self.data.pf_coil.n_pf_cs_plasma_circuits - 1, @@ -1683,7 +1687,7 @@ def vsec(self): ) # Burn volt-seconds - if self.data.build.iohcl != 0: + if CSUseModel(self.data.build.iohcl) != CSUseModel.NO_CENTRAL_SOLENOID: self.data.pf_coil.vsdum[self.data.pf_coil.n_cs_pf_coils - 1, 2] = ( self.data.pf_coil.ind_pf_cs_plasma_mutual[ self.data.pf_coil.n_pf_cs_plasma_circuits - 1, @@ -1788,7 +1792,7 @@ def induct(self, output): roh = np.zeros(noh) zoh = np.zeros(noh) - if self.data.build.iohcl != 0: + if CSUseModel(self.data.build.iohcl) != CSUseModel.NO_CENTRAL_SOLENOID: roh[:] = pf_d.r_cs_middle delzoh = ( @@ -1817,7 +1821,7 @@ def induct(self, output): rc[i] = rplasma[i] zc[i] = zplasma[i] - if self.data.build.iohcl != 0: + if CSUseModel(self.data.build.iohcl) != CSUseModel.NO_CENTRAL_SOLENOID: xohpl = 0.0 if self.data.build.dr_cs >= delzoh: deltar = math.sqrt((self.data.build.dr_cs**2 - delzoh**2) / 12.0e0) @@ -1898,7 +1902,7 @@ def induct(self, output): ncoilj - 1, pf_d.n_pf_cs_plasma_circuits - 1 ] - if self.data.build.iohcl != 0: + if CSUseModel(self.data.build.iohcl) != CSUseModel.NO_CENTRAL_SOLENOID: # Central Solenoid self inductance a = pf_d.r_cs_middle # mean radius of coil b = 2.0e0 * pf_d.z_pf_coil_upper[pf_d.n_cs_pf_coils - 1] # length of coil @@ -1949,7 +1953,7 @@ def induct(self, output): ) # PF coil - PF coil inductances - if self.data.build.iohcl == 0: + if CSUseModel(self.data.build.iohcl) == CSUseModel.NO_CENTRAL_SOLENOID: pf_d.nef = pf_d.n_cs_pf_coils else: pf_d.nef = pf_d.n_cs_pf_coils - 1 @@ -2005,7 +2009,7 @@ def induct(self, output): f"{ig + 1}\t{pf_d.ind_pf_cs_plasma_mutual[:n_pf_cs, ig]}", ) - if self.data.build.iohcl != 0: + if CSUseModel(self.data.build.iohcl) != CSUseModel.NO_CENTRAL_SOLENOID: op.write( self.outfile, f"CS\t{pf_d.ind_pf_cs_plasma_mutual[:n_pf_cs, n_pf_cs - 2]}", @@ -2042,7 +2046,7 @@ def outpf(self): "(iohcl)", self.data.build.iohcl, ) - if self.data.build.iohcl == 0: + if CSUseModel(self.data.build.iohcl) == CSUseModel.NO_CENTRAL_SOLENOID: op.ocmmnt(self.outfile, "No central solenoid included") op.oblnkl(self.outfile) elif pf_d.i_pf_conductor == PFConductorModel.SUPERCONDUCTING: @@ -2392,7 +2396,7 @@ def outpf(self): pf_d.p_pf_coil_resistive_total_flat_top, "OP ", ) - if self.data.build.iohcl != 0: + if CSUseModel(self.data.build.iohcl) != CSUseModel.NO_CENTRAL_SOLENOID: op.ovarre( self.outfile, "Central solenoid resistive power (W)", @@ -2403,7 +2407,7 @@ def outpf(self): # pf_d.nef is the number of coils excluding the Central Solenoid pf_d.nef = pf_d.n_cs_pf_coils - if self.data.build.iohcl != 0: + if CSUseModel(self.data.build.iohcl) != CSUseModel.NO_CENTRAL_SOLENOID: pf_d.nef -= 1 op.osubhd(self.outfile, "Geometry of PF coils, central solenoid and plasma:") @@ -2421,7 +2425,7 @@ def outpf(self): for k in range(pf_d.nef) ] - if self.data.build.iohcl != 0: + if CSUseModel(self.data.build.iohcl) != CSUseModel.NO_CENTRAL_SOLENOID: cs_index = pf_d.n_cs_pf_coils - 1 pf_centre = abs( pf_d.z_pf_coil_upper[cs_index] - pf_d.z_pf_coil_lower[cs_index] @@ -2513,7 +2517,7 @@ def outpf(self): ) self.tf_pf_collision_detector() - if self.data.build.iohcl != 0: + if CSUseModel(self.data.build.iohcl) != CSUseModel.NO_CENTRAL_SOLENOID: op.ovarre( self.mfile, "Central solenoid radius (m)", @@ -2598,7 +2602,7 @@ def outpf(self): ]) # Central Solenoid, if present - if self.data.build.iohcl != 0: + if CSUseModel(self.data.build.iohcl) != CSUseModel.NO_CENTRAL_SOLENOID: cs_index = pf_d.n_cs_pf_coils - 1 cs_peak_j = max( abs(pf_d.j_cs_pulse_start), @@ -2799,9 +2803,9 @@ def outvolt(self): inv_st_pulse = 1.0e0 / pf_d.f_j_cs_start_pulse_end_flat_top for k in range(self.data.pf_coil.n_pf_cs_plasma_circuits - 1): - if (self.data.build.iohcl != 0) and ( - k == self.data.pf_coil.n_pf_cs_plasma_circuits - 2 - ): + if ( + CSUseModel(self.data.build.iohcl) != CSUseModel.NO_CENTRAL_SOLENOID + ) and (k == self.data.pf_coil.n_pf_cs_plasma_circuits - 2): line = ["CS"] else: line = [f"PF {k + 1}"] @@ -2830,9 +2834,9 @@ def outvolt(self): op.ocmmnt(self.outfile, "This consists of: CS coil field balancing:") rows = [] for k in range(pf_d.n_pf_cs_plasma_circuits - 1): - if (self.data.build.iohcl != 0) and ( - k == self.data.pf_coil.n_pf_cs_plasma_circuits - 2 - ): + if ( + CSUseModel(self.data.build.iohcl) != CSUseModel.NO_CENTRAL_SOLENOID + ) and (k == self.data.pf_coil.n_pf_cs_plasma_circuits - 2): rows.append([ "CS", f"{cpft[k, 0] * pf_d.n_pf_coil_turns[k]:.3e}", @@ -2868,9 +2872,9 @@ def outvolt(self): op.ocmmnt(self.outfile, "And: equilibrium field:") rows = [] for k in range(pf_d.n_pf_cs_plasma_circuits - 1): - if (self.data.build.iohcl != 0) and ( - k == self.data.pf_coil.n_pf_cs_plasma_circuits - 2 - ): + if ( + CSUseModel(self.data.build.iohcl) != CSUseModel.NO_CENTRAL_SOLENOID + ) and (k == self.data.pf_coil.n_pf_cs_plasma_circuits - 2): rows.append([ "CS", f"{0.0:.3e}", @@ -2930,9 +2934,9 @@ def outvolt(self): if k == self.data.pf_coil.n_pf_cs_plasma_circuits - 1: circuit_name = f"Plasma Time point {jjj} (A)" circuit_var_name = f"(plasmat{jjj})" - elif (self.data.build.iohcl != 0) and ( - k == self.data.pf_coil.n_pf_cs_plasma_circuits - 2 - ): + elif ( + CSUseModel(self.data.build.iohcl) != CSUseModel.NO_CENTRAL_SOLENOID + ) and (k == self.data.pf_coil.n_pf_cs_plasma_circuits - 2): circuit_name = f"CS Circuit Time point {jjj} (A)" circuit_var_name = f"(cs t{jjj})" else: @@ -4545,7 +4549,10 @@ def peak_b_field_at_pf_coil( outer edges of a given PF coil. The calculation includes the effects from all the coils and the plasma. """ - if data.build.iohcl != 0 and n_coil == data.pf_coil.n_cs_pf_coils: + if ( + CSUseModel(data.build.iohcl) != CSUseModel.NO_CENTRAL_SOLENOID + and n_coil == data.pf_coil.n_cs_pf_coils + ): # Peak field is to be calculated at the Central Solenoid itself, # so exclude its own contribution; its self field is # dealt with externally using routine calculate_cs_self_peak_magnetic_field() @@ -4584,7 +4591,7 @@ def peak_b_field_at_pf_coil( t_b_field_peak=t_b_field_peak, ) - if data.build.iohcl == 0: + if CSUseModel(data.build.iohcl) == CSUseModel.NO_CENTRAL_SOLENOID: # No Central Solenoid kk = 0 else: @@ -4714,7 +4721,9 @@ def peak_b_field_at_pf_coil( ) # b_pf_coil_peak and bpf2 for the Central Solenoid are calculated in OHCALC - if (data.build.iohcl != 0) and (n_coil == data.pf_coil.n_cs_pf_coils): + if (CSUseModel(data.build.iohcl) != CSUseModel.NO_CENTRAL_SOLENOID) and ( + n_coil == data.pf_coil.n_cs_pf_coils + ): return ( b_pf_inner_radial, b_pf_outer_radial, diff --git a/process/models/power.py b/process/models/power.py index 2c8bfeec08..5d458dd8b8 100644 --- a/process/models/power.py +++ b/process/models/power.py @@ -12,7 +12,7 @@ from process.core.exceptions import ProcessValueError from process.core.model import Model from process.data_structure.blanket_variables import BlktModelTypes -from process.data_structure.pfcoil_variables import NGC2, PFConductorModel +from process.data_structure.pfcoil_variables import NGC2, CSUseModel, PFConductorModel from process.models.pulse import PulseTimings @@ -345,7 +345,7 @@ def pfpwr(self, output: bool, pulse_timings: PulseTimings): # Bussing losses assume aluminium bussing with 100 A/cm**2 ic = -1 n_pf_coil_groups = self.data.pf_coil.n_pf_coil_groups - if self.data.build.iohcl != 0: + if CSUseModel(self.data.build.iohcl) != CSUseModel.NO_CENTRAL_SOLENOID: n_pf_coil_groups += 1 # Map PF group to representative circuit index (used for busbar I^2R per circuit) diff --git a/process/models/stellarator/initialization.py b/process/models/stellarator/initialization.py index f151b99772..056033c00f 100644 --- a/process/models/stellarator/initialization.py +++ b/process/models/stellarator/initialization.py @@ -4,6 +4,8 @@ from typing import TYPE_CHECKING +from process.data_structure.pfcoil_variables import CSUseModel + if TYPE_CHECKING: from process.core.data_structure.base import DataStructure @@ -23,7 +25,7 @@ def st_init(data: DataStructure): # Build quantities data.build.dr_cs = 0.0 - data.build.iohcl = 0 + data.build.iohcl = CSUseModel.NO_CENTRAL_SOLENOID data.pf_coil.f_z_cs_tf_internal = 0.0 data.build.dr_cs_tf_gap = 0.0 data.build.f_dr_tf_outboard_inboard = 1.0 diff --git a/tests/unit/models/test_costs_1990.py b/tests/unit/models/test_costs_1990.py index 6d442bc2c6..9bdbf204a0 100644 --- a/tests/unit/models/test_costs_1990.py +++ b/tests/unit/models/test_costs_1990.py @@ -5,7 +5,7 @@ import numpy as np import pytest -from process.data_structure.pfcoil_variables import PFConductorModel +from process.data_structure.pfcoil_variables import CSUseModel, PFConductorModel from process.data_structure.vacuum_variables import VacuumPumpType from process.models.engineering.pumping import CoolantType from process.models.superconductors import ( @@ -1927,7 +1927,7 @@ class Acc2222Param(NamedTuple): "acc2222param", [ Acc2222Param( - iohcl=1, + iohcl=CSUseModel.FULL_PULSE, uccase=50, uccu=75, cconshpf=70, @@ -2118,7 +2118,7 @@ class Acc2222Param(NamedTuple): expected_c22224=9.1894413521392071, ), Acc2222Param( - iohcl=1, + iohcl=CSUseModel.FULL_PULSE, uccase=50, uccu=75, cconshpf=70, @@ -2309,7 +2309,7 @@ class Acc2222Param(NamedTuple): expected_c22224=9.1894413521392071, ), Acc2222Param( - iohcl=1, + iohcl=CSUseModel.FULL_PULSE, uccase=50, uccu=75, cconshpf=70, diff --git a/tests/unit/models/test_pfcoil.py b/tests/unit/models/test_pfcoil.py index 80144eea60..62758d9bbe 100644 --- a/tests/unit/models/test_pfcoil.py +++ b/tests/unit/models/test_pfcoil.py @@ -16,6 +16,7 @@ from process.core import constants from process.data_structure.pfcoil_variables import ( N_PF_COILS_IN_GROUP_MAX, + CSUseModel, PFConductorModel, ) from process.models.pfcoil import ( @@ -2489,7 +2490,7 @@ class PFCoilParam(NamedTuple): "pfcoilparam", [ PFCoilParam( - iohcl=1, + iohcl=CSUseModel.FULL_PULSE, dz_tf_upper_lower_midplane=0.0, z_tf_top=4.0, z_tf_inside_half=8.8, @@ -3592,7 +3593,7 @@ def test_peakb(monkeypatch, pfcoil): monkeypatch.setattr(pfcoil.data.pf_coil, "xind", np.zeros(64)) monkeypatch.setattr(pfcoil.data.pf_coil, "bpf2", np.zeros(22)) - monkeypatch.setattr(pfcoil.data.build, "iohcl", 1) + monkeypatch.setattr(pfcoil.data.build, "iohcl", CSUseModel.FULL_PULSE) monkeypatch.setattr(pfcoil.data.pf_coil, "a_cs_poloidal", 9.0218815014803365874412) monkeypatch.setattr(pfcoil.data.build, "z_tf_inside_half", 9.0730900215620327) monkeypatch.setattr(pfcoil.data.build, "dr_cs", 0.55242000000000002) @@ -3882,7 +3883,7 @@ def test_induct(pfcoil, monkeypatch): :param monkeypatch: mocking fixture :type monkeypatch: _pytest.monkeypatch.MonkeyPatch """ - monkeypatch.setattr(pfcoil.data.build, "iohcl", 1) + monkeypatch.setattr(pfcoil.data.build, "iohcl", CSUseModel.FULL_PULSE) monkeypatch.setattr(pfcoil.data.build, "dr_cs", 0.55242000000000002) monkeypatch.setattr(pfcoil.data.pf_coil, "n_cs_pf_coils", 7) monkeypatch.setattr( diff --git a/tests/unit/models/test_power.py b/tests/unit/models/test_power.py index fa28f1ea51..b2a5900cd1 100644 --- a/tests/unit/models/test_power.py +++ b/tests/unit/models/test_power.py @@ -3,6 +3,7 @@ import numpy as np import pytest +from process.data_structure.pfcoil_variables import CSUseModel from process.models.pulse import PulseTimings @@ -197,7 +198,7 @@ class PfpwrParam(NamedTuple): "pfpwrparam", [ PfpwrParam( - iohcl=1, + iohcl=CSUseModel.FULL_PULSE, poloidalpower=np.zeros(5), n_pf_coil_groups=4, c_pf_coil_turn=np.array( @@ -812,7 +813,7 @@ class PfpwrParam(NamedTuple): expected_srcktpm=1071.1112934857531, ), PfpwrParam( - iohcl=1, + iohcl=CSUseModel.FULL_PULSE, poloidalpower=np.array( np.array( (59332953.082890816, 43806300.444207191, 0, 0, -211211992.31967318), From c58491baaaf1efabac075ba41190390293878287 Mon Sep 17 00:00:00 2001 From: mn3981 Date: Tue, 13 Oct 2026 13:26:50 +0100 Subject: [PATCH 3/5] Rename 'iohcl' to 'i_cs_use' for central solenoid control across multiple files --- .../source/eng-models/central-solenoid.md | 4 +- process/core/input.py | 2 +- process/data_structure/build_variables.py | 2 +- process/models/costs/costs.py | 4 +- process/models/pfcoil.py | 59 ++++++++++--------- process/models/power.py | 2 +- process/models/stellarator/initialization.py | 2 +- .../input_files/low_aspect_ratio_DEMO.IN.DAT | 2 +- .../input_files/spherical_tokamak_eval.IN.DAT | 2 +- .../input_files/st_regression.IN.DAT | 2 +- tests/unit/models/test_costs_1990.py | 10 ++-- tests/unit/models/test_pfcoil.py | 12 ++-- tests/unit/models/test_power.py | 8 +-- 13 files changed, 56 insertions(+), 55 deletions(-) diff --git a/documentation/source/eng-models/central-solenoid.md b/documentation/source/eng-models/central-solenoid.md index a89de20998..d489224950 100644 --- a/documentation/source/eng-models/central-solenoid.md +++ b/documentation/source/eng-models/central-solenoid.md @@ -6,8 +6,8 @@ the central solenoid causes a change in the flux linked to the plasma region, in it. `PROCESS` calculates the amount of flux required to produce the plasma current, and also the amount actually available. The code measures the magnetic flux in units of Volt.seconds (= Webers). -Switch `iohcl` controls whether a central solenoid is present. A value of 1 denotes that this coil -is present, and should be assigned a non-zero thickness `dr_cs`. A value of `iohcl` = 0 denotes +Switch `i_cs_use` controls whether a central solenoid is present. A value of 1 denotes that this coil +is present, and should be assigned a non-zero thickness `dr_cs`. A value of `i_cs_use` = 0 denotes that no central solenoid is present, in which case the thickness `dr_cs` should be zero. No PF coils should be located at positions defined by `i_pf_location(j)` = 1 if no central solenoid is present. diff --git a/process/core/input.py b/process/core/input.py index 31b6c6f6cd..c54b53d1bb 100644 --- a/process/core/input.py +++ b/process/core/input.py @@ -1044,7 +1044,7 @@ def bounds(self) -> tuple[NumberType | None, NumberType | None]: "i_plasma_ignited": InputVariable("physics", int, choices=[0, 1]), "i_blkt_module_segmentation": InputVariable("fwbs", int, choices=[0, 1]), "inuclear": InputVariable("fwbs", int, choices=[0, 1]), - "iohcl": InputVariable("build", int, choices=[0, 1]), + "i_cs_use": InputVariable("build", int, choices=[0, 1]), "i_plasma_pedestal": InputVariable("physics", int, choices=[0, 1]), "i_pf_conductor": InputVariable("pf_coil", int, choices=[0, 1]), "ipnet": InputVariable("costs", int, choices=[0, 1]), diff --git a/process/data_structure/build_variables.py b/process/data_structure/build_variables.py index 7888944d8f..25c35a57ab 100644 --- a/process/data_structure/build_variables.py +++ b/process/data_structure/build_variables.py @@ -174,7 +174,7 @@ class BuildData: hr1: float = 0.0 """half-height of TF coil inboard leg straight section (m)""" - iohcl: int = 1 + i_cs_use: int = 1 """Switch for existence of central solenoid: - =0 central solenoid not present - =1 central solenoid exists diff --git a/process/models/costs/costs.py b/process/models/costs/costs.py index a28a5ada6c..e1d3e7628f 100644 --- a/process/models/costs/costs.py +++ b/process/models/costs/costs.py @@ -1627,7 +1627,7 @@ def acc2222(self): # Non-Central Solenoid coils - if CSUseModel(self.data.build.iohcl) != CSUseModel.NO_CENTRAL_SOLENOID: + if CSUseModel(self.data.build.i_cs_use) != CSUseModel.NO_CENTRAL_SOLENOID: npf = self.data.pf_coil.n_cs_pf_coils - 1 else: npf = self.data.pf_coil.n_cs_pf_coils @@ -1715,7 +1715,7 @@ def acc2222(self): # Central Solenoid - if CSUseModel(self.data.build.iohcl) == CSUseModel.FULL_PULSE: + if CSUseModel(self.data.build.i_cs_use) == CSUseModel.FULL_PULSE: # Superconductor ($/m) if self.data.costs.supercond_cost_model == 0: # Issue #328 Use CS conductor cross-sectional area (m2) diff --git a/process/models/pfcoil.py b/process/models/pfcoil.py index f4563b85f5..cb54e83c20 100644 --- a/process/models/pfcoil.py +++ b/process/models/pfcoil.py @@ -153,7 +153,7 @@ def pfcoil(self): self.data.pf_coil.n_cs_pf_coils += self.data.pf_coil.n_pf_coils_in_group[i] # Add one if an Central Solenoid is present, and make an extra group - if CSUseModel(self.data.build.iohcl) != CSUseModel.NO_CENTRAL_SOLENOID: + if CSUseModel(self.data.build.i_cs_use) != CSUseModel.NO_CENTRAL_SOLENOID: self.data.pf_coil.n_cs_pf_coils += 1 self.data.pf_coil.n_pf_coils_in_group[self.data.pf_coil.n_pf_coil_groups] = 1 @@ -200,7 +200,7 @@ def pfcoil(self): # nfxf is the total no of filaments into which the Central Solenoid is split, # if present - if CSUseModel(self.data.build.iohcl) == CSUseModel.NO_CENTRAL_SOLENOID: + if CSUseModel(self.data.build.i_cs_use) == CSUseModel.NO_CENTRAL_SOLENOID: self.data.pf_coil.nfxf = 0 c_cs_flat_top_end = 0.0e0 else: @@ -461,11 +461,11 @@ def pfcoil(self): case PFLocationTypes.ABOVE_CS: # Do not allow if no central solenoid if ( - CSUseModel(self.data.build.iohcl) + CSUseModel(self.data.build.i_cs_use) == CSUseModel.NO_CENTRAL_SOLENOID ): raise ProcessValueError( - "i_pf_location(i) should not be 1 if iohcl=0" + "i_pf_location(i) should not be 1 if i_cs_use=0" ) # PF coil is stacked on top of the Central Solenoid # This coil is to balance Central Solenoid flux and should @@ -637,7 +637,7 @@ def pfcoil(self): # Flux swing required from CS coil csflux = -(self.data.physics.vs_plasma_ramp_required) - pfflux - if CSUseModel(self.data.build.iohcl) == CSUseModel.FULL_PULSE: + if CSUseModel(self.data.build.i_cs_use) == CSUseModel.FULL_PULSE: # Required current change in CS coil # Proposed new calculation... @@ -1058,7 +1058,7 @@ def pfcoil(self): ) # Find Central Solenoid information - if CSUseModel(self.data.build.iohcl) != CSUseModel.NO_CENTRAL_SOLENOID: + if CSUseModel(self.data.build.i_cs_use) != CSUseModel.NO_CENTRAL_SOLENOID: self.cs_coil.ohcalc() # Summation of weights and current @@ -1631,7 +1631,7 @@ def vsec(self): This routine calculates the volt-second capability of the PF coil system. """ - if CSUseModel(self.data.build.iohcl) == CSUseModel.NO_CENTRAL_SOLENOID: + if CSUseModel(self.data.build.i_cs_use) == CSUseModel.NO_CENTRAL_SOLENOID: # No Central Solenoid self.data.pf_coil.nef = self.data.pf_coil.n_pf_cs_plasma_circuits - 1 else: # Full pulse @@ -1657,7 +1657,7 @@ def vsec(self): ) # Central Solenoid startup volt-seconds - if CSUseModel(self.data.build.iohcl) != CSUseModel.NO_CENTRAL_SOLENOID: + if CSUseModel(self.data.build.i_cs_use) != CSUseModel.NO_CENTRAL_SOLENOID: self.data.pf_coil.vsdum[self.data.pf_coil.n_cs_pf_coils - 1, 0] = ( self.data.pf_coil.ind_pf_cs_plasma_mutual[ self.data.pf_coil.n_pf_cs_plasma_circuits - 1, @@ -1687,7 +1687,7 @@ def vsec(self): ) # Burn volt-seconds - if CSUseModel(self.data.build.iohcl) != CSUseModel.NO_CENTRAL_SOLENOID: + if CSUseModel(self.data.build.i_cs_use) != CSUseModel.NO_CENTRAL_SOLENOID: self.data.pf_coil.vsdum[self.data.pf_coil.n_cs_pf_coils - 1, 2] = ( self.data.pf_coil.ind_pf_cs_plasma_mutual[ self.data.pf_coil.n_pf_cs_plasma_circuits - 1, @@ -1792,7 +1792,7 @@ def induct(self, output): roh = np.zeros(noh) zoh = np.zeros(noh) - if CSUseModel(self.data.build.iohcl) != CSUseModel.NO_CENTRAL_SOLENOID: + if CSUseModel(self.data.build.i_cs_use) != CSUseModel.NO_CENTRAL_SOLENOID: roh[:] = pf_d.r_cs_middle delzoh = ( @@ -1821,7 +1821,7 @@ def induct(self, output): rc[i] = rplasma[i] zc[i] = zplasma[i] - if CSUseModel(self.data.build.iohcl) != CSUseModel.NO_CENTRAL_SOLENOID: + if CSUseModel(self.data.build.i_cs_use) != CSUseModel.NO_CENTRAL_SOLENOID: xohpl = 0.0 if self.data.build.dr_cs >= delzoh: deltar = math.sqrt((self.data.build.dr_cs**2 - delzoh**2) / 12.0e0) @@ -1902,7 +1902,7 @@ def induct(self, output): ncoilj - 1, pf_d.n_pf_cs_plasma_circuits - 1 ] - if CSUseModel(self.data.build.iohcl) != CSUseModel.NO_CENTRAL_SOLENOID: + if CSUseModel(self.data.build.i_cs_use) != CSUseModel.NO_CENTRAL_SOLENOID: # Central Solenoid self inductance a = pf_d.r_cs_middle # mean radius of coil b = 2.0e0 * pf_d.z_pf_coil_upper[pf_d.n_cs_pf_coils - 1] # length of coil @@ -1953,7 +1953,7 @@ def induct(self, output): ) # PF coil - PF coil inductances - if CSUseModel(self.data.build.iohcl) == CSUseModel.NO_CENTRAL_SOLENOID: + if CSUseModel(self.data.build.i_cs_use) == CSUseModel.NO_CENTRAL_SOLENOID: pf_d.nef = pf_d.n_cs_pf_coils else: pf_d.nef = pf_d.n_cs_pf_coils - 1 @@ -2009,7 +2009,7 @@ def induct(self, output): f"{ig + 1}\t{pf_d.ind_pf_cs_plasma_mutual[:n_pf_cs, ig]}", ) - if CSUseModel(self.data.build.iohcl) != CSUseModel.NO_CENTRAL_SOLENOID: + if CSUseModel(self.data.build.i_cs_use) != CSUseModel.NO_CENTRAL_SOLENOID: op.write( self.outfile, f"CS\t{pf_d.ind_pf_cs_plasma_mutual[:n_pf_cs, n_pf_cs - 2]}", @@ -2043,10 +2043,10 @@ def outpf(self): op.ovarre( self.mfile, "Existence_of_central_solenoid", - "(iohcl)", - self.data.build.iohcl, + "(i_cs_use)", + self.data.build.i_cs_use, ) - if CSUseModel(self.data.build.iohcl) == CSUseModel.NO_CENTRAL_SOLENOID: + if CSUseModel(self.data.build.i_cs_use) == CSUseModel.NO_CENTRAL_SOLENOID: op.ocmmnt(self.outfile, "No central solenoid included") op.oblnkl(self.outfile) elif pf_d.i_pf_conductor == PFConductorModel.SUPERCONDUCTING: @@ -2396,7 +2396,7 @@ def outpf(self): pf_d.p_pf_coil_resistive_total_flat_top, "OP ", ) - if CSUseModel(self.data.build.iohcl) != CSUseModel.NO_CENTRAL_SOLENOID: + if CSUseModel(self.data.build.i_cs_use) != CSUseModel.NO_CENTRAL_SOLENOID: op.ovarre( self.outfile, "Central solenoid resistive power (W)", @@ -2407,7 +2407,7 @@ def outpf(self): # pf_d.nef is the number of coils excluding the Central Solenoid pf_d.nef = pf_d.n_cs_pf_coils - if CSUseModel(self.data.build.iohcl) != CSUseModel.NO_CENTRAL_SOLENOID: + if CSUseModel(self.data.build.i_cs_use) != CSUseModel.NO_CENTRAL_SOLENOID: pf_d.nef -= 1 op.osubhd(self.outfile, "Geometry of PF coils, central solenoid and plasma:") @@ -2425,7 +2425,7 @@ def outpf(self): for k in range(pf_d.nef) ] - if CSUseModel(self.data.build.iohcl) != CSUseModel.NO_CENTRAL_SOLENOID: + if CSUseModel(self.data.build.i_cs_use) != CSUseModel.NO_CENTRAL_SOLENOID: cs_index = pf_d.n_cs_pf_coils - 1 pf_centre = abs( pf_d.z_pf_coil_upper[cs_index] - pf_d.z_pf_coil_lower[cs_index] @@ -2517,7 +2517,7 @@ def outpf(self): ) self.tf_pf_collision_detector() - if CSUseModel(self.data.build.iohcl) != CSUseModel.NO_CENTRAL_SOLENOID: + if CSUseModel(self.data.build.i_cs_use) != CSUseModel.NO_CENTRAL_SOLENOID: op.ovarre( self.mfile, "Central solenoid radius (m)", @@ -2602,7 +2602,7 @@ def outpf(self): ]) # Central Solenoid, if present - if CSUseModel(self.data.build.iohcl) != CSUseModel.NO_CENTRAL_SOLENOID: + if CSUseModel(self.data.build.i_cs_use) != CSUseModel.NO_CENTRAL_SOLENOID: cs_index = pf_d.n_cs_pf_coils - 1 cs_peak_j = max( abs(pf_d.j_cs_pulse_start), @@ -2804,7 +2804,7 @@ def outvolt(self): for k in range(self.data.pf_coil.n_pf_cs_plasma_circuits - 1): if ( - CSUseModel(self.data.build.iohcl) != CSUseModel.NO_CENTRAL_SOLENOID + CSUseModel(self.data.build.i_cs_use) != CSUseModel.NO_CENTRAL_SOLENOID ) and (k == self.data.pf_coil.n_pf_cs_plasma_circuits - 2): line = ["CS"] else: @@ -2835,7 +2835,7 @@ def outvolt(self): rows = [] for k in range(pf_d.n_pf_cs_plasma_circuits - 1): if ( - CSUseModel(self.data.build.iohcl) != CSUseModel.NO_CENTRAL_SOLENOID + CSUseModel(self.data.build.i_cs_use) != CSUseModel.NO_CENTRAL_SOLENOID ) and (k == self.data.pf_coil.n_pf_cs_plasma_circuits - 2): rows.append([ "CS", @@ -2873,7 +2873,7 @@ def outvolt(self): rows = [] for k in range(pf_d.n_pf_cs_plasma_circuits - 1): if ( - CSUseModel(self.data.build.iohcl) != CSUseModel.NO_CENTRAL_SOLENOID + CSUseModel(self.data.build.i_cs_use) != CSUseModel.NO_CENTRAL_SOLENOID ) and (k == self.data.pf_coil.n_pf_cs_plasma_circuits - 2): rows.append([ "CS", @@ -2935,7 +2935,8 @@ def outvolt(self): circuit_name = f"Plasma Time point {jjj} (A)" circuit_var_name = f"(plasmat{jjj})" elif ( - CSUseModel(self.data.build.iohcl) != CSUseModel.NO_CENTRAL_SOLENOID + CSUseModel(self.data.build.i_cs_use) + != CSUseModel.NO_CENTRAL_SOLENOID ) and (k == self.data.pf_coil.n_pf_cs_plasma_circuits - 2): circuit_name = f"CS Circuit Time point {jjj} (A)" circuit_var_name = f"(cs t{jjj})" @@ -4550,7 +4551,7 @@ def peak_b_field_at_pf_coil( The calculation includes the effects from all the coils and the plasma. """ if ( - CSUseModel(data.build.iohcl) != CSUseModel.NO_CENTRAL_SOLENOID + CSUseModel(data.build.i_cs_use) != CSUseModel.NO_CENTRAL_SOLENOID and n_coil == data.pf_coil.n_cs_pf_coils ): # Peak field is to be calculated at the Central Solenoid itself, @@ -4591,7 +4592,7 @@ def peak_b_field_at_pf_coil( t_b_field_peak=t_b_field_peak, ) - if CSUseModel(data.build.iohcl) == CSUseModel.NO_CENTRAL_SOLENOID: + if CSUseModel(data.build.i_cs_use) == CSUseModel.NO_CENTRAL_SOLENOID: # No Central Solenoid kk = 0 else: @@ -4721,7 +4722,7 @@ def peak_b_field_at_pf_coil( ) # b_pf_coil_peak and bpf2 for the Central Solenoid are calculated in OHCALC - if (CSUseModel(data.build.iohcl) != CSUseModel.NO_CENTRAL_SOLENOID) and ( + if (CSUseModel(data.build.i_cs_use) != CSUseModel.NO_CENTRAL_SOLENOID) and ( n_coil == data.pf_coil.n_cs_pf_coils ): return ( diff --git a/process/models/power.py b/process/models/power.py index 5d458dd8b8..9b00886722 100644 --- a/process/models/power.py +++ b/process/models/power.py @@ -345,7 +345,7 @@ def pfpwr(self, output: bool, pulse_timings: PulseTimings): # Bussing losses assume aluminium bussing with 100 A/cm**2 ic = -1 n_pf_coil_groups = self.data.pf_coil.n_pf_coil_groups - if CSUseModel(self.data.build.iohcl) != CSUseModel.NO_CENTRAL_SOLENOID: + if CSUseModel(self.data.build.i_cs_use) != CSUseModel.NO_CENTRAL_SOLENOID: n_pf_coil_groups += 1 # Map PF group to representative circuit index (used for busbar I^2R per circuit) diff --git a/process/models/stellarator/initialization.py b/process/models/stellarator/initialization.py index 056033c00f..5c37d22555 100644 --- a/process/models/stellarator/initialization.py +++ b/process/models/stellarator/initialization.py @@ -25,7 +25,7 @@ def st_init(data: DataStructure): # Build quantities data.build.dr_cs = 0.0 - data.build.iohcl = CSUseModel.NO_CENTRAL_SOLENOID + data.build.i_cs_use = CSUseModel.NO_CENTRAL_SOLENOID data.pf_coil.f_z_cs_tf_internal = 0.0 data.build.dr_cs_tf_gap = 0.0 data.build.f_dr_tf_outboard_inboard = 1.0 diff --git a/tests/regression/input_files/low_aspect_ratio_DEMO.IN.DAT b/tests/regression/input_files/low_aspect_ratio_DEMO.IN.DAT index fc7557a2ca..cd4445f1af 100644 --- a/tests/regression/input_files/low_aspect_ratio_DEMO.IN.DAT +++ b/tests/regression/input_files/low_aspect_ratio_DEMO.IN.DAT @@ -791,7 +791,7 @@ f_nd_impurity_electrons(14) = 5e-05 *Tungsten *iteration variables - j_cs_flat_top_end, f_j_cs_start_pulse_end_flat_top and f_a_cs_steel -iohcl = 1 * Switch for existence of central solenoid; +i_cs_use = 1 * Switch for existence of central solenoid; * DESCRIPTION: Switch for existence of central solenoid * JUSTIFICATION: Inductive machine - use CS for startup diff --git a/tests/regression/input_files/spherical_tokamak_eval.IN.DAT b/tests/regression/input_files/spherical_tokamak_eval.IN.DAT index f79f323f4e..949478d2e9 100644 --- a/tests/regression/input_files/spherical_tokamak_eval.IN.DAT +++ b/tests/regression/input_files/spherical_tokamak_eval.IN.DAT @@ -66,7 +66,7 @@ dz_vv_lower = 0.3 * vacuum vessel underside thickness (TF coil / shield) (m) dr_shld_vv_gap_inboard = 0.01 * gap between inboard vacuum vessel and thermal shield (m) (`iteration variable 61`) dr_cs_tf_gap = 0.0 * gap between central solenoid and TF coil (m) (`iteration variable 42`) gapomin = 0.0 * minimum gap between outboard vacuum vessel and TF coil (m) (`iteration variable 31`) -iohcl = 0 * Switch for existence of central solenoid; +i_cs_use = 0 * Switch for existence of central solenoid; i_cs_precomp = 0 * Switch for existence of central solenoid pre-compression structure; i_tf_inside_cs = 0 * Switch for placing the TF coil inside the CS i_tf_turn_type = 2 * CroCo Turn geometry for HTS Tapes diff --git a/tests/regression/input_files/st_regression.IN.DAT b/tests/regression/input_files/st_regression.IN.DAT index 5b2f404a4c..5997a4c163 100644 --- a/tests/regression/input_files/st_regression.IN.DAT +++ b/tests/regression/input_files/st_regression.IN.DAT @@ -1482,7 +1482,7 @@ tftmp = 20.0 *-------------------------------- CS & PF Coils --------------------------------------------------------------------------------------------------------------------------------------------------------------------* *‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾* -iohcl = 0 +i_cs_use = 0 * DESCRIPTION: Switch for (0: no CS inductive current on start up * 1: Yes there is a CS inductive current on start up) * JUSTIFICATION: Want no inductive current at flat-top when steady state running. diff --git a/tests/unit/models/test_costs_1990.py b/tests/unit/models/test_costs_1990.py index 9bdbf204a0..6516137dc9 100644 --- a/tests/unit/models/test_costs_1990.py +++ b/tests/unit/models/test_costs_1990.py @@ -1852,7 +1852,7 @@ def test_acc2221(acc2221param, monkeypatch, costs): class Acc2222Param(NamedTuple): - iohcl: Any = None + i_cs_use: Any = None uccase: Any = None @@ -1927,7 +1927,7 @@ class Acc2222Param(NamedTuple): "acc2222param", [ Acc2222Param( - iohcl=CSUseModel.FULL_PULSE, + i_cs_use=CSUseModel.FULL_PULSE, uccase=50, uccu=75, cconshpf=70, @@ -2118,7 +2118,7 @@ class Acc2222Param(NamedTuple): expected_c22224=9.1894413521392071, ), Acc2222Param( - iohcl=CSUseModel.FULL_PULSE, + i_cs_use=CSUseModel.FULL_PULSE, uccase=50, uccu=75, cconshpf=70, @@ -2309,7 +2309,7 @@ class Acc2222Param(NamedTuple): expected_c22224=9.1894413521392071, ), Acc2222Param( - iohcl=CSUseModel.FULL_PULSE, + i_cs_use=CSUseModel.FULL_PULSE, uccase=50, uccu=75, cconshpf=70, @@ -2515,7 +2515,7 @@ def test_acc2222(acc2222param, monkeypatch, costs): :type monkeypatch: _pytest.monkeypatch.monkeypatch """ - monkeypatch.setattr(costs.data.build, "iohcl", acc2222param.iohcl) + monkeypatch.setattr(costs.data.build, "i_cs_use", acc2222param.i_cs_use) monkeypatch.setattr(costs.data.costs, "uccase", acc2222param.uccase) diff --git a/tests/unit/models/test_pfcoil.py b/tests/unit/models/test_pfcoil.py index 62758d9bbe..b135513886 100644 --- a/tests/unit/models/test_pfcoil.py +++ b/tests/unit/models/test_pfcoil.py @@ -1231,7 +1231,7 @@ def test_vsec(pfcoil, monkeypatch): :param monkeypatch: mocking fixture :type monkeypatch: _pytest.monkeypatch.MonkeyPatch """ - monkeypatch.setattr(pfcoil.data.build, "iohcl", 1) + monkeypatch.setattr(pfcoil.data.build, "i_cs_use", 1) monkeypatch.setattr(pfcoil.data.pf_coil, "vs_pf_coils_total_ramp", 0.0) monkeypatch.setattr(pfcoil.data.pf_coil, "vs_cs_pf_total_burn", 0.0) monkeypatch.setattr(pfcoil.data.pf_coil, "n_cs_pf_coils", 7) @@ -2417,7 +2417,7 @@ def test_calculate_cs_self_peak_midplane_axial_stress_invalid(cs_coil): class PFCoilParam(NamedTuple): - iohcl: Any = None + i_cs_use: Any = None dz_tf_upper_lower_midplane: Any = None z_tf_top: Any = None z_tf_inside_half: Any = None @@ -2490,7 +2490,7 @@ class PFCoilParam(NamedTuple): "pfcoilparam", [ PFCoilParam( - iohcl=CSUseModel.FULL_PULSE, + i_cs_use=CSUseModel.FULL_PULSE, dz_tf_upper_lower_midplane=0.0, z_tf_top=4.0, z_tf_inside_half=8.8, @@ -2577,7 +2577,7 @@ def test_pfcoil(monkeypatch, pfcoil, pfcoilparam): :type pfcoilparam: pfcoilparam """ for field in [ - "iohcl", + "i_cs_use", "dz_tf_upper_lower_midplane", "z_tf_top", "z_tf_inside_half", @@ -3593,7 +3593,7 @@ def test_peakb(monkeypatch, pfcoil): monkeypatch.setattr(pfcoil.data.pf_coil, "xind", np.zeros(64)) monkeypatch.setattr(pfcoil.data.pf_coil, "bpf2", np.zeros(22)) - monkeypatch.setattr(pfcoil.data.build, "iohcl", CSUseModel.FULL_PULSE) + monkeypatch.setattr(pfcoil.data.build, "i_cs_use", CSUseModel.FULL_PULSE) monkeypatch.setattr(pfcoil.data.pf_coil, "a_cs_poloidal", 9.0218815014803365874412) monkeypatch.setattr(pfcoil.data.build, "z_tf_inside_half", 9.0730900215620327) monkeypatch.setattr(pfcoil.data.build, "dr_cs", 0.55242000000000002) @@ -3883,7 +3883,7 @@ def test_induct(pfcoil, monkeypatch): :param monkeypatch: mocking fixture :type monkeypatch: _pytest.monkeypatch.MonkeyPatch """ - monkeypatch.setattr(pfcoil.data.build, "iohcl", CSUseModel.FULL_PULSE) + monkeypatch.setattr(pfcoil.data.build, "i_cs_use", CSUseModel.FULL_PULSE) monkeypatch.setattr(pfcoil.data.build, "dr_cs", 0.55242000000000002) monkeypatch.setattr(pfcoil.data.pf_coil, "n_cs_pf_coils", 7) monkeypatch.setattr( diff --git a/tests/unit/models/test_power.py b/tests/unit/models/test_power.py index b2a5900cd1..11a7ae26dc 100644 --- a/tests/unit/models/test_power.py +++ b/tests/unit/models/test_power.py @@ -129,7 +129,7 @@ def test_cryo(cryoparam, monkeypatch, power): class PfpwrParam(NamedTuple): - iohcl: Any = None + i_cs_use: Any = None poloidalpower: Any = None @@ -198,7 +198,7 @@ class PfpwrParam(NamedTuple): "pfpwrparam", [ PfpwrParam( - iohcl=CSUseModel.FULL_PULSE, + i_cs_use=CSUseModel.FULL_PULSE, poloidalpower=np.zeros(5), n_pf_coil_groups=4, c_pf_coil_turn=np.array( @@ -813,7 +813,7 @@ class PfpwrParam(NamedTuple): expected_srcktpm=1071.1112934857531, ), PfpwrParam( - iohcl=CSUseModel.FULL_PULSE, + i_cs_use=CSUseModel.FULL_PULSE, poloidalpower=np.array( np.array( (59332953.082890816, 43806300.444207191, 0, 0, -211211992.31967318), @@ -1454,7 +1454,7 @@ def test_pfpwr(pfpwrparam, monkeypatch, power): :type monkeypatch: _pytest.monkeypatch.monkeypatch """ - monkeypatch.setattr(power.data.build, "iohcl", pfpwrparam.iohcl) + monkeypatch.setattr(power.data.build, "i_cs_use", pfpwrparam.i_cs_use) monkeypatch.setattr(power.data.pf_power, "poloidalpower", pfpwrparam.poloidalpower) From 0faa8f6c854c14c8b1b00252bafa59570b6088ed Mon Sep 17 00:00:00 2001 From: mn3981 Date: Tue, 13 Oct 2026 13:35:43 +0100 Subject: [PATCH 4/5] Update obsolete_vars.py to rename 'iohcl' to 'i_cs_use' for consistency in variable naming --- process/core/data_structure/obsolete_vars.py | 1 + 1 file changed, 1 insertion(+) diff --git a/process/core/data_structure/obsolete_vars.py b/process/core/data_structure/obsolete_vars.py index 284642cb90..9cdaba0e17 100644 --- a/process/core/data_structure/obsolete_vars.py +++ b/process/core/data_structure/obsolete_vars.py @@ -481,6 +481,7 @@ "f_p_div_lower": "f_p_div_lower_separatrix", "temp_plasma_pedestal_kev": "temp_plasma_pedestal_electron_kev", "temp_plasma_separatrix_kev": "temp_plasma_separatrix_electron_kev", + "iohcl": "i_cs_use", } OBS_VARS_HELP = { From a5cd18a93bc3b0d670d802343639a655564a121e Mon Sep 17 00:00:00 2001 From: mn3981 Date: Wed, 14 Oct 2026 16:18:02 +0100 Subject: [PATCH 5/5] Refactor iohcl handling to use CSUseModel enumeration for consistency in Central Solenoid logic --- process/core/io/plot/summary/magnets/cs.py | 4 ++-- process/core/io/plot/summary/magnets/pf.py | 17 +++++++++++++---- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/process/core/io/plot/summary/magnets/cs.py b/process/core/io/plot/summary/magnets/cs.py index e62e45d2fb..a3e79a851b 100644 --- a/process/core/io/plot/summary/magnets/cs.py +++ b/process/core/io/plot/summary/magnets/cs.py @@ -11,7 +11,7 @@ from process.core.io.plot.summary.common import box_style, setup_axis, text_layout from process.core.io.plot.summary.constants import SOLENOID_COLOUR from process.core.io.plot.summary.reporting.text import plot_info -from process.data_structure.pfcoil_variables import NFIXMX +from process.data_structure.pfcoil_variables import NFIXMX, CSUseModel from process.models.superconductors import SuperconductorModel if TYPE_CHECKING: @@ -513,7 +513,7 @@ def plot_pf_cs_plasma_mutual_inductance( axis.set_yticks(range(n_pf_cs_plasma_circuits)) labels = list(range(1, n_pf_cs_plasma_circuits + 1)) - if iohcl == 1: + if CSUseModel(iohcl) == CSUseModel.FULL_PULSE: labels[-2] = "CS" labels[-1] = "Plasma" axis.set_xticklabels(labels) diff --git a/process/core/io/plot/summary/magnets/pf.py b/process/core/io/plot/summary/magnets/pf.py index fa9de88bb9..3626f01c9d 100644 --- a/process/core/io/plot/summary/magnets/pf.py +++ b/process/core/io/plot/summary/magnets/pf.py @@ -9,6 +9,7 @@ from process.core.io.plot.summary.constants import CSCOMPRESSION_COLOUR, SOLENOID_COLOUR from process.core.io.plot.summary.radial_build import cumulative_radial_build2 +from process.data_structure.pfcoil_variables import CSUseModel from process.models.geometry.pfcoil import pfcoil_geometry if TYPE_CHECKING: @@ -59,11 +60,17 @@ def plot_pf_coils( number_of_coils += 1 # Check for Central Solenoid - iohcl = mfile.get("iohcl", scan=scan) if "iohcl" in mfile.data else 1 + iohcl = ( + mfile.get("iohcl", scan=scan) if "iohcl" in mfile.data else CSUseModel.FULL_PULSE + ) # If Central Solenoid present, ignore last entry in for loop # The last entry will be the OH coil in this case - noc = number_of_coils - 1 if iohcl == 1 else number_of_coils + noc = ( + number_of_coils - 1 + if CSUseModel(iohcl) == CSUseModel.FULL_PULSE + else number_of_coils + ) for coil in range(noc): coils_r.append(mfile.get(f"r_pf_coil_middle[{coil + 1:01}]", scan=scan)) @@ -145,8 +152,10 @@ def plot_pf_dimensions( z_pf_coil_middle = [] radial_thicknesses = [] vertical_thicknesses = [] - iohcl = mfile.get("iohcl", scan=scan) if "iohcl" in mfile.data else 1 - x = 1 if iohcl == 0 else 2 + iohcl = ( + mfile.get("iohcl", scan=scan) if "iohcl" in mfile.data else CSUseModel.FULL_PULSE + ) + x = 1 if CSUseModel(iohcl) == CSUseModel.NO_CENTRAL_SOLENOID else 2 for coil in range(int(mfile.get("n_pf_cs_plasma_circuits", scan=scan) - x)): r_pf_coil_middle.append(mfile.get(f"r_pf_coil_middle[{coil + 1}]", scan=scan)) z_pf_coil_middle.append(mfile.get(f"z_pf_coil_middle[{coil + 1}]", scan=scan))