From 60981e93e51ea765d3ce0ed7bdde344c9892010a Mon Sep 17 00:00:00 2001 From: mn3981 Date: Wed, 29 Apr 2026 11:02:22 +0100 Subject: [PATCH 1/5] Add BlktModelTypes enum for blanket model types Co-authored-by: Copilot --- process/models/blankets/blanket_library.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/process/models/blankets/blanket_library.py b/process/models/blankets/blanket_library.py index 98c5c4109..92fbf3e4c 100644 --- a/process/models/blankets/blanket_library.py +++ b/process/models/blankets/blanket_library.py @@ -26,6 +26,7 @@ darcy_friction_haaland, ) from process.models.power import PumpingPowerModelTypes +from enum import IntEnum logger = logging.getLogger(__name__) @@ -44,6 +45,14 @@ # FCI Flow Channel Insert +class BlktModelTypes(IntEnum): + """Enum for blanket model types. `i_blanket_type`""" + + CCFE_HCPB = 1 + DCLL = 5 + + + class FWBlktCoolantLoopTypes(IntEnum): """Enumeration for first wall and blanket coolant loop types. `i_fw_blkt_shared_coolant`.""" From 185c822fbc3c8de38c44eaccb3ace53b3fcec763 Mon Sep 17 00:00:00 2001 From: mn3981 Date: Wed, 29 Apr 2026 11:08:39 +0100 Subject: [PATCH 2/5] Refactor blanket type checks to use BlktModelTypes enum for improved readability and maintainability Co-authored-by: Copilot --- process/core/caller.py | 5 +++-- process/core/init.py | 3 ++- process/core/output.py | 5 +++-- process/models/blankets/blanket_library.py | 5 ++--- process/models/power.py | 7 ++++--- 5 files changed, 14 insertions(+), 11 deletions(-) diff --git a/process/core/caller.py b/process/core/caller.py index df8716424..807d83848 100644 --- a/process/core/caller.py +++ b/process/core/caller.py @@ -15,6 +15,7 @@ from process.core.solver import constraints from process.core.solver.iteration_variables import set_scaled_iteration_variable from process.core.solver.objectives import objective_function +from process.models.blankets.blanket_library import BlktModelTypes from process.models.tfcoil.base import TFConductorModel from process.models.tfcoil.superconducting import SuperconductingTFTurnType @@ -344,11 +345,11 @@ def _call_models_once(self, xc: np.ndarray, data: DataStructure): 4 | KIT HCLL model 5 | DCLL model """ - if self.data.fwbs.i_blanket_type == 1: + if self.data.fwbs.i_blanket_type == BlktModelTypes.CCFE_HCPB: # CCFE HCPB model self.models.ccfe_hcpb.run() - elif self.data.fwbs.i_blanket_type == 5: + elif self.data.fwbs.i_blanket_type == BlktModelTypes.DCLL: # DCLL model self.models.dcll.run() diff --git a/process/core/init.py b/process/core/init.py index d5ed1f892..24e7619b1 100644 --- a/process/core/init.py +++ b/process/core/init.py @@ -29,6 +29,7 @@ init_superconducting_tf_coil_variables, ) from process.data_structure.tfcoil_variables import init_tfcoil_variables +from process.models.blankets.blanket_library import BlktModelTypes from process.models.stellarator.initialization import st_init from process.models.superconductors import ( SuperconductorMaterial, @@ -1116,7 +1117,7 @@ def check_process(inputs, data): # noqa: ARG001 # Ensure that blanket material fractions allow non-zero space for steel # CCFE HCPB Model - if data.stellarator.istell == 0 and (data.fwbs.i_blanket_type == 1): + if data.stellarator.istell == 0 and (data.fwbs.i_blanket_type == BlktModelTypes.CCFE_HCPB): fsum = data.fwbs.breeder_multiplier + data.fwbs.vfcblkt + data.fwbs.vfpblkt if fsum >= 1.0: raise ProcessValidationError( diff --git a/process/core/output.py b/process/core/output.py index 83435cca6..3774ca7f0 100644 --- a/process/core/output.py +++ b/process/core/output.py @@ -1,5 +1,6 @@ from process import data_structure from process.core.log import logging_model_handler +from process.models.blankets.blanket_library import BlktModelTypes from process.models.tfcoil.base import TFConductorModel from process.models.tfcoil.superconducting import ( SuperconductingTFTurnType, @@ -122,11 +123,11 @@ def write(models, data, _outfile): # First wall geometry models.fw.output() - if data.fwbs.i_blanket_type == 1: + if data.fwbs.i_blanket_type == BlktModelTypes.CCFE_HCPB: # CCFE HCPB model models.ccfe_hcpb.output() - elif data.fwbs.i_blanket_type == 5: + elif data.fwbs.i_blanket_type == BlktModelTypes.DCLL: # DCLL model models.dcll.output() diff --git a/process/models/blankets/blanket_library.py b/process/models/blankets/blanket_library.py index 92fbf3e4c..2ba5a5524 100644 --- a/process/models/blankets/blanket_library.py +++ b/process/models/blankets/blanket_library.py @@ -47,12 +47,11 @@ class BlktModelTypes(IntEnum): """Enum for blanket model types. `i_blanket_type`""" - + CCFE_HCPB = 1 DCLL = 5 - class FWBlktCoolantLoopTypes(IntEnum): """Enumeration for first wall and blanket coolant loop types. `i_fw_blkt_shared_coolant`.""" @@ -897,7 +896,7 @@ def set_blanket_module_geometry(self): Error If the poloidal segment length is less than three times the minimum liquid breeder pipe width. """ - if self.data.fwbs.i_blanket_type == 5: + if self.data.fwbs.i_blanket_type == BlktModelTypes.DCLL: # Unless DCLL then we will use BZ self.data.blanket.len_blkt_inboard_coolant_channel_radial = ( self.data.build.blbuith diff --git a/process/models/power.py b/process/models/power.py index a81f0c06f..43d036fab 100644 --- a/process/models/power.py +++ b/process/models/power.py @@ -17,6 +17,7 @@ tfcoil_variables, ) from process.data_structure.pfcoil_variables import NGC2 +from process.models.blankets.blanket_library import BlktModelTypes class PumpingPowerModelTypes(IntEnum): @@ -1934,7 +1935,7 @@ def plant_thermal_efficiency(self, eta_turbine: float) -> float: ) if i_thermal_electric_conversion == ElectricConversionModelTypes.CCFE_HCPB_VALUE: # CCFE HCPB Model - if self.data.fwbs.i_blanket_type == 1: + if self.data.fwbs.i_blanket_type == BlktModelTypes.CCFE_HCPB: # HCPB, efficiency taken from M. Kovari 2016 # "PROCESS": A systems code for fusion power plants - # Part 2: Engineering @@ -1950,7 +1951,7 @@ def plant_thermal_efficiency(self, eta_turbine: float) -> float: == ElectricConversionModelTypes.CCFE_HCPB_VALUE_WITH_DIVERTOR ): # CCFE HCPB Model - if self.data.fwbs.i_blanket_type == 1: + if self.data.fwbs.i_blanket_type == BlktModelTypes.CCFE_HCPB: # HCPB, efficiency taken from M. Kovari 2016 # "PROCESS": A systems code for fusion power plants - # Part 2: Engineering @@ -1971,7 +1972,7 @@ def plant_thermal_efficiency(self, eta_turbine: float) -> float: == ElectricConversionModelTypes.STEAM_RANKINE_CYCLE ): # CCFE HCPB Model - if self.data.fwbs.i_blanket_type == 1: + if self.data.fwbs.i_blanket_type == BlktModelTypes.CCFE_HCPB: # If coolant is helium, the steam cycle is assumed to be superheated # and a different correlation is used. The turbine inlet temperature # is assumed to be 20 degrees below the primary coolant outlet From 7c31fb85406f26fe150d5ffc340b627641fb92da Mon Sep 17 00:00:00 2001 From: mn3981 Date: Wed, 29 Apr 2026 15:15:34 +0100 Subject: [PATCH 3/5] Refactor blanket type checks to use BlktModelTypes enum for consistency in power calculations Co-authored-by: Copilot --- process/models/blankets/blanket_library.py | 4 ++-- process/models/power.py | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/process/models/blankets/blanket_library.py b/process/models/blankets/blanket_library.py index 2ba5a5524..43fa68eca 100644 --- a/process/models/blankets/blanket_library.py +++ b/process/models/blankets/blanket_library.py @@ -26,7 +26,6 @@ darcy_friction_haaland, ) from process.models.power import PumpingPowerModelTypes -from enum import IntEnum logger = logging.getLogger(__name__) @@ -896,7 +895,8 @@ def set_blanket_module_geometry(self): Error If the poloidal segment length is less than three times the minimum liquid breeder pipe width. """ - if self.data.fwbs.i_blanket_type == BlktModelTypes.DCLL: + i_blanket_type = BlktModelTypes(self.data.fwbs.i_blanket_type) + if i_blanket_type == BlktModelTypes.DCLL: # Unless DCLL then we will use BZ self.data.blanket.len_blkt_inboard_coolant_channel_radial = ( self.data.build.blbuith diff --git a/process/models/power.py b/process/models/power.py index 43d036fab..af8076fd5 100644 --- a/process/models/power.py +++ b/process/models/power.py @@ -1933,6 +1933,7 @@ def plant_thermal_efficiency(self, eta_turbine: float) -> float: i_thermal_electric_conversion = ElectricConversionModelTypes( self.data.fwbs.i_thermal_electric_conversion ) + i_blanket_type = BlktModelTypes(fwbs_variables.i_blanket_type) if i_thermal_electric_conversion == ElectricConversionModelTypes.CCFE_HCPB_VALUE: # CCFE HCPB Model if self.data.fwbs.i_blanket_type == BlktModelTypes.CCFE_HCPB: From 37a24cee8fc85aedc9d3f82e3e2863c14bed900a Mon Sep 17 00:00:00 2001 From: mn3981 Date: Tue, 12 May 2026 10:13:08 +0100 Subject: [PATCH 4/5] Refactor imports to use BlktModelTypes from blanket_variables for consistency --- process/core/caller.py | 2 +- process/core/init.py | 2 +- process/core/output.py | 2 +- process/data_structure/blanket_variables.py | 8 ++++++++ process/models/blankets/blanket_library.py | 8 +------- process/models/power.py | 6 +++--- 6 files changed, 15 insertions(+), 13 deletions(-) diff --git a/process/core/caller.py b/process/core/caller.py index 807d83848..9b6c0f4f6 100644 --- a/process/core/caller.py +++ b/process/core/caller.py @@ -15,7 +15,7 @@ from process.core.solver import constraints from process.core.solver.iteration_variables import set_scaled_iteration_variable from process.core.solver.objectives import objective_function -from process.models.blankets.blanket_library import BlktModelTypes +from process.data_structure.blanket_variables import BlktModelTypes from process.models.tfcoil.base import TFConductorModel from process.models.tfcoil.superconducting import SuperconductingTFTurnType diff --git a/process/core/init.py b/process/core/init.py index 24e7619b1..d6afcfaf5 100644 --- a/process/core/init.py +++ b/process/core/init.py @@ -16,6 +16,7 @@ from process.core.log import logging_model_handler from process.core.solver import iteration_variables from process.core.solver.constraints import ConstraintManager +from process.data_structure.blanket_variables import BlktModelTypes from process.data_structure.impurity_radiation_module import ( init_impurity_radiation_module, ) @@ -29,7 +30,6 @@ init_superconducting_tf_coil_variables, ) from process.data_structure.tfcoil_variables import init_tfcoil_variables -from process.models.blankets.blanket_library import BlktModelTypes from process.models.stellarator.initialization import st_init from process.models.superconductors import ( SuperconductorMaterial, diff --git a/process/core/output.py b/process/core/output.py index 3774ca7f0..caded8abe 100644 --- a/process/core/output.py +++ b/process/core/output.py @@ -1,6 +1,6 @@ from process import data_structure from process.core.log import logging_model_handler -from process.models.blankets.blanket_library import BlktModelTypes +from process.data_structure.blanket_variables import BlktModelTypes from process.models.tfcoil.base import TFConductorModel from process.models.tfcoil.superconducting import ( SuperconductingTFTurnType, diff --git a/process/data_structure/blanket_variables.py b/process/data_structure/blanket_variables.py index 51d37e4b3..4f663a592 100644 --- a/process/data_structure/blanket_variables.py +++ b/process/data_structure/blanket_variables.py @@ -26,6 +26,14 @@ """ from dataclasses import dataclass +from enum import IntEnum + + +class BlktModelTypes(IntEnum): + """Enum for blanket model types. `i_blanket_type`""" + + CCFE_HCPB = 1 + DCLL = 5 @dataclass diff --git a/process/models/blankets/blanket_library.py b/process/models/blankets/blanket_library.py index 43fa68eca..58c628c23 100644 --- a/process/models/blankets/blanket_library.py +++ b/process/models/blankets/blanket_library.py @@ -13,6 +13,7 @@ from process.data_structure import ( physics_variables, ) +from process.data_structure.blanket_variables import BlktModelTypes from process.models.build import FwBlktVVShape from process.models.engineering.ivc_functions import ( calculate_pipe_bend_radius, @@ -44,13 +45,6 @@ # FCI Flow Channel Insert -class BlktModelTypes(IntEnum): - """Enum for blanket model types. `i_blanket_type`""" - - CCFE_HCPB = 1 - DCLL = 5 - - class FWBlktCoolantLoopTypes(IntEnum): """Enumeration for first wall and blanket coolant loop types. `i_fw_blkt_shared_coolant`.""" diff --git a/process/models/power.py b/process/models/power.py index af8076fd5..8f84067fa 100644 --- a/process/models/power.py +++ b/process/models/power.py @@ -17,7 +17,7 @@ tfcoil_variables, ) from process.data_structure.pfcoil_variables import NGC2 -from process.models.blankets.blanket_library import BlktModelTypes +from process.data_structure.blanket_variables import BlktModelTypes class PumpingPowerModelTypes(IntEnum): @@ -1933,10 +1933,10 @@ def plant_thermal_efficiency(self, eta_turbine: float) -> float: i_thermal_electric_conversion = ElectricConversionModelTypes( self.data.fwbs.i_thermal_electric_conversion ) - i_blanket_type = BlktModelTypes(fwbs_variables.i_blanket_type) + i_blanket_type = BlktModelTypes(self.data.fwbs.i_blanket_type) if i_thermal_electric_conversion == ElectricConversionModelTypes.CCFE_HCPB_VALUE: # CCFE HCPB Model - if self.data.fwbs.i_blanket_type == BlktModelTypes.CCFE_HCPB: + if i_blanket_type == BlktModelTypes.CCFE_HCPB: # HCPB, efficiency taken from M. Kovari 2016 # "PROCESS": A systems code for fusion power plants - # Part 2: Engineering From fbd877eba33f4b4538317ec9ca4caf06a2f3da33 Mon Sep 17 00:00:00 2001 From: mn3981 Date: Wed, 20 May 2026 15:14:53 +0100 Subject: [PATCH 5/5] Post rebase fixes --- process/core/init.py | 4 +++- process/models/power.py | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/process/core/init.py b/process/core/init.py index d6afcfaf5..c65dce19e 100644 --- a/process/core/init.py +++ b/process/core/init.py @@ -1117,7 +1117,9 @@ def check_process(inputs, data): # noqa: ARG001 # Ensure that blanket material fractions allow non-zero space for steel # CCFE HCPB Model - if data.stellarator.istell == 0 and (data.fwbs.i_blanket_type == BlktModelTypes.CCFE_HCPB): + if data.stellarator.istell == 0 and ( + data.fwbs.i_blanket_type == BlktModelTypes.CCFE_HCPB + ): fsum = data.fwbs.breeder_multiplier + data.fwbs.vfcblkt + data.fwbs.vfpblkt if fsum >= 1.0: raise ProcessValidationError( diff --git a/process/models/power.py b/process/models/power.py index 8f84067fa..716441950 100644 --- a/process/models/power.py +++ b/process/models/power.py @@ -16,8 +16,8 @@ physics_variables, tfcoil_variables, ) -from process.data_structure.pfcoil_variables import NGC2 from process.data_structure.blanket_variables import BlktModelTypes +from process.data_structure.pfcoil_variables import NGC2 class PumpingPowerModelTypes(IntEnum):