diff --git a/process/core/init.py b/process/core/init.py index 3cd0c357d..1844350a1 100644 --- a/process/core/init.py +++ b/process/core/init.py @@ -58,7 +58,6 @@ ) from process.data_structure.tfcoil_variables import init_tfcoil_variables from process.data_structure.times_variables import init_times_variables -from process.data_structure.vacuum_variables import init_vacuum_variables from process.models.stellarator.initialization import st_init from process.models.superconductors import ( SuperconductorMaterial, @@ -71,7 +70,7 @@ from process.core.model import DataStructure -def init_process(data_structure: DataStructure): +def init_process(data: DataStructure): """Routine that calls the initialisation routines This routine calls the main initialisation routines that set @@ -85,7 +84,7 @@ def init_process(data_structure: DataStructure): process_output.OutputFileManager.open_files() # Input any desired new initial values - inputs = parse_input_file(data_structure) + inputs = parse_input_file(data) # Set active constraints set_active_constraints() @@ -97,7 +96,7 @@ def init_process(data_structure: DataStructure): st_init() # Check input data for errors/ambiguities - check_process(inputs) + check_process(inputs, data) run_summary() @@ -291,7 +290,6 @@ def init_all_module_vars(): init_primary_pumping_variables() init_pfcoil_variables() init_structure_variables() - init_vacuum_variables() init_pf_power_variables() init_build_variables() init_constraint_variables() @@ -304,7 +302,7 @@ def init_all_module_vars(): init_neoclassics_variables() -def check_process(inputs): # noqa: ARG001 +def check_process(inputs, data): # noqa: ARG001 """Routine to reset specific variables if certain options are being used @@ -380,7 +378,7 @@ def check_process(inputs): # noqa: ARG001 : data_structure.numerics.neqns + data_structure.numerics.nineqns ] == 63 - ).any() and data_structure.vacuum_variables.i_vacuum_pumping != "simple": + ).any() and data.vacuum.i_vacuum_pumping != "simple": raise ProcessValidationError( "Constraint 63 is requested without the correct vacuum model (simple)" ) diff --git a/process/core/input.py b/process/core/input.py index 797be7c0b..848458da5 100644 --- a/process/core/input.py +++ b/process/core/input.py @@ -958,7 +958,7 @@ def __post_init__(self): data_structure.physics_variables, float, range=(0.0, 10.0) ), "pres_vv_chamber_dwell_start": InputVariable( - data_structure.vacuum_variables, float, range=(1e-06, 10000.0) + "vacuum", float, range=(1e-06, 10000.0) ), "temp_blkt_coolant_in": InputVariable( data_structure.fwbs_variables, float, range=(200.0, 600.0) @@ -1090,12 +1090,8 @@ def __post_init__(self): "f_z_cs_tf_internal": InputVariable( data_structure.pfcoil_variables, float, range=(0.0, 2.0) ), - "outgasfactor": InputVariable( - data_structure.vacuum_variables, float, range=(1e-06, 1000.0) - ), - "outgasindex": InputVariable( - data_structure.vacuum_variables, float, range=(1e-06, 1000.0) - ), + "outgasfactor": InputVariable("vacuum", float, range=(1e-06, 1000.0)), + "outgasindex": InputVariable("vacuum", float, range=(1e-06, 1000.0)), "temp_blkt_coolant_out": InputVariable( data_structure.fwbs_variables, float, range=(450.0, 900.0) ), @@ -1107,9 +1103,7 @@ def __post_init__(self): ), "paris_coefficient": InputVariable("cs_fatigue", float, range=(1e-20, 10.0)), "paris_power_law": InputVariable("cs_fatigue", float, range=(1.0, 10.0)), - "pres_vv_chamber_base": InputVariable( - data_structure.vacuum_variables, float, range=(1e-08, 0.001) - ), + "pres_vv_chamber_base": InputVariable("vacuum", float, range=(1e-08, 0.001)), "p_plasma_separatrix_min_mw": InputVariable( data_structure.constraint_variables, float, range=(0.1, 1000.0) ), @@ -1167,9 +1161,7 @@ def __post_init__(self): "p_fusion_total_max_mw": InputVariable( data_structure.constraint_variables, float, range=(1.0, 10000.0) ), - "pres_div_chamber_burn": InputVariable( - data_structure.vacuum_variables, float, range=(0.0, 10.0) - ), + "pres_div_chamber_burn": InputVariable("vacuum", float, range=(0.0, 10.0)), "pres_fw_coolant": InputVariable( data_structure.fwbs_variables, float, range=(100000.0, 100000000.0) ), @@ -1191,17 +1183,11 @@ def __post_init__(self): data_structure.times_variables, float, range=(0.0, 1.0) ), "f_a_vac_pump_port_plasma_surface": InputVariable( - data_structure.vacuum_variables, float, range=(1e-06, 1.0) - ), - "f_volflow_vac_pumps_impedance": InputVariable( - data_structure.vacuum_variables, float, range=(1e-06, 1.0) - ), - "volflow_vac_pumps_max": InputVariable( - data_structure.vacuum_variables, float, range=(1e-06, 1000.0) - ), - "molflow_vac_pumps": InputVariable( - data_structure.vacuum_variables, float, range=(0.0, 1e30) + "vacuum", float, range=(1e-06, 1.0) ), + "f_volflow_vac_pumps_impedance": InputVariable("vacuum", float, range=(1e-06, 1.0)), + "volflow_vac_pumps_max": InputVariable("vacuum", float, range=(1e-06, 1000.0)), + "molflow_vac_pumps": InputVariable("vacuum", float, range=(0.0, 1e30)), "pflux_plant_floor_electric": InputVariable( data_structure.heat_transport_variables, float, range=(0.0, 1000.0) ), @@ -1223,9 +1209,7 @@ def __post_init__(self): "radius_fw_channel": InputVariable( data_structure.fwbs_variables, float, range=(0.001, 0.5) ), - "outgrat_fw": InputVariable( - data_structure.vacuum_variables, float, range=(1e-10, 1e-06) - ), + "outgrat_fw": InputVariable("vacuum", float, range=(1e-10, 1e-06)), "rbrt": InputVariable(data_structure.buildings_variables, float, range=(0.0, 10.0)), "rbvfac": InputVariable(data_structure.buildings_variables, float, range=(0.9, 3.0)), "rbwt": InputVariable(data_structure.buildings_variables, float, range=(0.0, 10.0)), @@ -1552,9 +1536,7 @@ def __post_init__(self): "temp_tf_cryo": InputVariable( data_structure.tfcoil_variables, float, range=(0.01, 293.0) ), - "temp_vv_chamber_gas_burn_end": InputVariable( - data_structure.vacuum_variables, float, range=(1.0, 1000.0) - ), + "temp_vv_chamber_gas_burn_end": InputVariable("vacuum", float, range=(1.0, 1000.0)), "i_t_current_ramp_up": InputVariable( data_structure.times_variables, int, choices=[0, 1] ), @@ -1786,9 +1768,7 @@ def __post_init__(self): data_structure.rebco_variables, float, range=(1.0e6, 1.0e10) ), "cost_model": InputVariable(data_structure.cost_variables, int, choices=[0, 1, 2]), - "i_vac_pump_dwell": InputVariable( - data_structure.vacuum_variables, int, choices=[0, 1, 2] - ), + "i_vac_pump_dwell": InputVariable("vacuum", int, choices=[0, 1, 2]), "i_fw_blkt_vv_shape": InputVariable( data_structure.fwbs_variables, int, range=(1, 2) ), @@ -1993,9 +1973,7 @@ def __post_init__(self): "npdiv": InputVariable(data_structure.fwbs_variables, int, range=(0, 4)), "nphcdin": InputVariable(data_structure.fwbs_variables, int, range=(0, 4)), "nphcdout": InputVariable(data_structure.fwbs_variables, int, range=(0, 4)), - "i_vacuum_pump_type": InputVariable( - data_structure.vacuum_variables, int, choices=[0, 1] - ), + "i_vacuum_pump_type": InputVariable("vacuum", int, choices=[0, 1]), "num_rh_systems": InputVariable(data_structure.cost_variables, int, range=(1, 10)), "output_costs": InputVariable(data_structure.cost_variables, int, choices=[0, 1]), "i_p_coolant_pumping": InputVariable( @@ -2027,9 +2005,7 @@ def __post_init__(self): "i_fw_coolant_type": InputVariable( data_structure.fwbs_variables, str, choices=["helium", "water"] ), - "i_vacuum_pumping": InputVariable( - data_structure.vacuum_variables, str, choices=["old", "simple"] - ), + "i_vacuum_pumping": InputVariable("vacuum", str, choices=["old", "simple"]), "dcond": InputVariable(data_structure.tfcoil_variables, float, array=True), "c_pf_coil_turn_peak_input": InputVariable( data_structure.pfcoil_variables, float, array=True diff --git a/process/core/model.py b/process/core/model.py index d586f80ac..bad11bc26 100644 --- a/process/core/model.py +++ b/process/core/model.py @@ -3,6 +3,7 @@ from process.data_structure.cost_2015_variables import Cost2015Data from process.data_structure.cs_fatigue_variables import CSFatigueData +from process.data_structure.vacuum_variables import VacuumData from process.data_structure.water_usage_variables import WaterUseData initialise_later = object() @@ -13,6 +14,7 @@ class DataStructure: water_use: WaterUseData = initialise_later costs_2015: Cost2015Data = initialise_later cs_fatigue: CSFatigueData = initialise_later + vacuum: VacuumData = initialise_later def __post_init__(self): for f in fields(self): @@ -27,7 +29,7 @@ class Model(abc.ABC): def run(self) -> None: """Run the model. - The run method is resposible for 'running' the model, ensuring it updates the data + The run method is responsible for 'running' the model, ensuring it updates the data structure with variables that subsequent models will require. """ diff --git a/process/core/solver/constraints.py b/process/core/solver/constraints.py index a814e8dad..d383fd4ee 100644 --- a/process/core/solver/constraints.py +++ b/process/core/solver/constraints.py @@ -1345,14 +1345,14 @@ def constraint_equation_62(constraint_registration, _data): @ConstraintManager.register_constraint(63, "", "<=") -def constraint_equation_63(constraint_registration, _data): +def constraint_equation_63(constraint_registration, data): """Upper limit on n_iter_vacuum_pumps (i_vacuum_pumping = simple) tfno: number of TF coils (default = 50 for stellarators) n_iter_vacuum_pumps: number of high vacuum pumps (real number), each with the throughput """ return leq( - data_structure.vacuum_variables.n_iter_vacuum_pumps, + data.vacuum.n_iter_vacuum_pumps, data_structure.tfcoil_variables.n_tf_coils, constraint_registration, ) diff --git a/process/data_structure/vacuum_variables.py b/process/data_structure/vacuum_variables.py index c938b7b56..adf982428 100644 --- a/process/data_structure/vacuum_variables.py +++ b/process/data_structure/vacuum_variables.py @@ -1,127 +1,89 @@ -i_vacuum_pumping: str = None -"""switch for vacuum pumping model: +from dataclasses import dataclass - - ='old' for old detailed ETR model - - ='simple' for simple steady-state model with comparison to ITER cryopumps - !#TODO: old and simple not suitable names. -""" - -n_iter_vacuum_pumps: float = None -"""number of high vacuum pumps (real number), each with the throughput of one -ITER cryopump (50 Pa m3 s-1), all operating at the same time (`i_vacuum_pumping='simple'`) -""" - -i_vacuum_pump_type: int = None -"""switch for vacuum pump type: - - - =0 - for turbomolecular pump (magnetic bearing) with speed of 2.0 m3/s - (1.95 for N2, 1.8 for He, 1.8 for DT) - - =1 - for compound cryopump with nominal speed of 10.0 m3/s - (9.0 for N2, 5.0 for He and 25.0 for DT) -""" - -n_vv_vacuum_ducts: int = None -"""number of ducts (torus to pumps)""" - -dlscal: float = None -"""vacuum system duct length scaling""" - -pres_vv_chamber_base: float = None -"""base pressure during dwell before gas pre-fill(Pa)""" - -pres_div_chamber_burn: float = None -"""divertor chamber pressure during burn (Pa)""" - -molflow_vac_pumps: float = None -"""Pump throughput (molecules/s) (default is ITER value)""" - -outgrat_fw: float = None -"""plasma chamber wall outgassing rate (Pa-m/s)""" - -temp_vv_chamber_gas_burn_end: float = None -"""neutral gas temperature in chamber (K)""" - -m_vv_vacuum_duct_shield: float = None -"""mass of vacuum duct shield (kg)""" - -dia_vv_vacuum_ducts: float = None -"""diameter of duct passage (m)""" - -n_vac_pumps_high: int = None -"""number of high vacuum pumps""" - -i_vac_pump_dwell: int = None -"""switch for dwell pumping options: - - - =0 pumping only during t_plant_pulse_dwell - - =1 pumping only during t_plant_pulse_coil_precharge - - =2 pumping during t_plant_pulse_dwell + t_plant_pulse_coil_precharge - - The following are used in the Battes, Day and Rohde pump-down model - See "Basic considerations on the pump-down time in the dwell phase of a pulsed fusion DEMO" - http://dx.doi.org/10.1016/j.fusengdes.2015.07.011)(i_vacuum_pumping=simple') -""" - -f_a_vac_pump_port_plasma_surface: float = None -"""area of one pumping port as a fraction of plasma surface area""" - -volflow_vac_pumps_max: float = None -"""maximum pumping speed per unit area for deuterium & tritium, molecular flow""" - -f_volflow_vac_pumps_impedance: float = None -"""effective pumping speed reduction factor due to duct impedance""" - -pres_vv_chamber_dwell_start: float = None -"""initial neutral pressure at the beginning of the dwell phase (Pa)""" - -outgasindex: float = None -"""outgassing decay index""" - -outgasfactor: float = None -"""outgassing prefactor kw: outgassing rate at 1 s per unit area (Pa m s-1)""" - - -def init_vacuum_variables(): - """Initialise Vacuum variables""" - global \ - i_vacuum_pumping, \ - n_iter_vacuum_pumps, \ - i_vacuum_pump_type, \ - n_vv_vacuum_ducts, \ - dlscal, \ - pres_vv_chamber_base, \ - pres_div_chamber_burn, \ - molflow_vac_pumps, \ - outgrat_fw, \ - temp_vv_chamber_gas_burn_end, \ - m_vv_vacuum_duct_shield, \ - dia_vv_vacuum_ducts, \ - n_vac_pumps_high, \ - i_vac_pump_dwell, \ - f_a_vac_pump_port_plasma_surface, \ - volflow_vac_pumps_max, \ - f_volflow_vac_pumps_impedance, \ - pres_vv_chamber_dwell_start, \ - outgasindex, \ - outgasfactor - - i_vacuum_pumping = "old" - n_iter_vacuum_pumps = 0.0 - i_vacuum_pump_type = 1 - n_vv_vacuum_ducts = 0 - dlscal = 0.0 - pres_vv_chamber_base = 5.0e-4 - pres_div_chamber_burn = 0.36 - molflow_vac_pumps = 1.2155e22 - outgrat_fw = 1.3e-8 - temp_vv_chamber_gas_burn_end = 300.0 - m_vv_vacuum_duct_shield = 0.0 - dia_vv_vacuum_ducts = 0.0 - n_vac_pumps_high = 0 - i_vac_pump_dwell = 0 - f_a_vac_pump_port_plasma_surface = 0.0203 - volflow_vac_pumps_max = 27.3 - f_volflow_vac_pumps_impedance = 0.167 - pres_vv_chamber_dwell_start = 1.0 - outgasindex = 1.0 - outgasfactor = 0.0235 + +@dataclass +class VacuumData: + i_vacuum_pumping: str = "old" + """switch for vacuum pumping model: + + - ='old' for old detailed ETR model + - ='simple' for simple steady-state model with comparison to ITER cryopumps + !#TODO: old and simple not suitable names. + """ + + n_iter_vacuum_pumps: float = 0.0 + """number of high vacuum pumps (real number), each with the throughput of one + ITER cryopump (50 Pa m3 s-1), all operating at the same time (`i_vacuum_pumping='simple'`) + """ + + i_vacuum_pump_type: int = 1 + """switch for vacuum pump type: + + - =0 - for turbomolecular pump (magnetic bearing) with speed of 2.0 m3/s + (1.95 for N2, 1.8 for He, 1.8 for DT) + - =1 - for compound cryopump with nominal speed of 10.0 m3/s + (9.0 for N2, 5.0 for He and 25.0 for DT) + """ + + n_vv_vacuum_ducts: int = 0 + """number of ducts (torus to pumps)""" + + dlscal: float = 0.0 + """vacuum system duct length scaling""" + + pres_vv_chamber_base: float = 5.0e-4 + """base pressure during dwell before gas pre-fill(Pa)""" + + pres_div_chamber_burn: float = 0.36 + """divertor chamber pressure during burn (Pa)""" + + molflow_vac_pumps: float = 1.2155e22 + """Pump throughput (molecules/s) (default is ITER value)""" + + outgrat_fw: float = 1.3e-8 + """plasma chamber wall outgassing rate (Pa-m/s)""" + + temp_vv_chamber_gas_burn_end: float = 300.0 + """neutral gas temperature in chamber (K)""" + + m_vv_vacuum_duct_shield: float = 0.0 + """mass of vacuum duct shield (kg)""" + + dia_vv_vacuum_ducts: float = 0.0 + """diameter of duct passage (m)""" + + n_vac_pumps_high: int = 0 + """number of high vacuum pumps""" + + i_vac_pump_dwell: int = 0 + """switch for dwell pumping options: + + - =0 pumping only during t_plant_pulse_dwell + - =1 pumping only during t_plant_pulse_coil_precharge + - =2 pumping during t_plant_pulse_dwell + t_plant_pulse_coil_precharge + + The following are used in the Battes, Day and Rohde pump-down model + See "Basic considerations on the pump-down time in the dwell phase of a pulsed fusion DEMO" + http://dx.doi.org/10.1016/j.fusengdes.2015.07.011)(i_vacuum_pumping=simple') + """ + + f_a_vac_pump_port_plasma_surface: float = 0.0203 + """area of one pumping port as a fraction of plasma surface area""" + + volflow_vac_pumps_max: float = 27.3 + """maximum pumping speed per unit area for deuterium & tritium, molecular flow""" + + f_volflow_vac_pumps_impedance: float = 0.167 + """effective pumping speed reduction factor due to duct impedance""" + + pres_vv_chamber_dwell_start: float = 1.0 + """initial neutral pressure at the beginning of the dwell phase (Pa)""" + + outgasindex: float = 1.0 + """outgassing decay index""" + + outgasfactor: float = 0.0235 + """outgassing prefactor kw: outgassing rate at 1 s per unit area (Pa m s-1)""" + + +CREATE_DICTS_FROM_DATACLASS = VacuumData diff --git a/process/main.py b/process/main.py index cd2d57cc7..21599bf6a 100644 --- a/process/main.py +++ b/process/main.py @@ -707,6 +707,11 @@ def models(self) -> tuple[Model, ...]: self.cs_fatigue, self.cs_coil, self.pfcoil, + self.vacuum, + self.vacuum_vessel, + self._costs_1990, + self.availability, + self.ife, ) def setup_data_structure(self): diff --git a/process/models/availability.py b/process/models/availability.py index e695ac75c..a34cbba1d 100644 --- a/process/models/availability.py +++ b/process/models/availability.py @@ -15,7 +15,6 @@ from process.data_structure import physics_variables as pv from process.data_structure import tfcoil_variables as tfv from process.data_structure import times_variables as tv -from process.data_structure import vacuum_variables as vacv from process.models.tfcoil.base import TFConductorModel logger = logging.getLogger(__name__) @@ -375,7 +374,9 @@ def avail_2(self, output: bool): # Vacuum systems # Number of redundant pumps - cv.redun_vac = math.floor(vacv.n_vac_pumps_high * cv.redun_vacp / 100.0 + 0.5e0) + cv.redun_vac = math.floor( + self.data.vacuum.n_vac_pumps_high * cv.redun_vacp / 100.0 + 0.5e0 + ) u_unplanned_vacuum = self.calc_u_unplanned_vacuum(output) @@ -1018,7 +1019,7 @@ def calc_u_unplanned_vacuum(self, output: bool) -> float: cryo_main_time = 1.0e0 / 6.0e0 # Total pumps = pumps + redundant pumps - total_pumps = vacv.n_vac_pumps_high + cv.redun_vac + total_pumps = self.data.vacuum.n_vac_pumps_high + cv.redun_vac # Cryopump failure rate per machine operational period # From "Selected component failure rate values from fusion @@ -1059,7 +1060,7 @@ def calc_u_unplanned_vacuum(self, output: bool) -> float: self.outfile, "Number of pumps (excluding redundant pumps)", "(n_vac_pumps_high)", - vacv.n_vac_pumps_high, + self.data.vacuum.n_vac_pumps_high, "OP ", ) po.ovarin( @@ -1184,7 +1185,9 @@ def avail_st(self, output: bool): # Vacuum systems # Number of redundant pumps - cv.redun_vac = math.floor(vacv.n_vac_pumps_high * cv.redun_vacp / 100.0 + 0.5e0) + cv.redun_vac = math.floor( + self.data.vacuum.n_vac_pumps_high * cv.redun_vacp / 100.0 + 0.5e0 + ) u_unplanned_vacuum = self.calc_u_unplanned_vacuum(output) diff --git a/process/models/costs/costs.py b/process/models/costs/costs.py index 981bd40e8..533c9a3f7 100644 --- a/process/models/costs/costs.py +++ b/process/models/costs/costs.py @@ -5,6 +5,7 @@ from process.core import constants from process.core import process_output as po from process.core.exceptions import ProcessValueError +from process.core.model import Model from process.data_structure import ( build_variables, buildings_variables, @@ -22,14 +23,13 @@ structure_variables, tfcoil_variables, times_variables, - vacuum_variables, ) from process.models.tfcoil.base import TFConductorModel logger = logging.getLogger(__name__) -class Costs: +class Costs(Model): def __init__(self): self.outfile = constants.NOUT @@ -1990,13 +1990,13 @@ def acc224(self): This routine evaluates the Account 224 (vacuum system) costs. The costs are scaled from TETRA reactor code runs. """ - if vacuum_variables.i_vacuum_pump_type == 1: + if self.data.vacuum.i_vacuum_pump_type == 1: cost_variables.c2241 = ( - 1.0e-6 * vacuum_variables.n_vac_pumps_high * cost_variables.UCCPMP + 1.0e-6 * self.data.vacuum.n_vac_pumps_high * cost_variables.UCCPMP ) else: cost_variables.c2241 = ( - 1.0e-6 * vacuum_variables.n_vac_pumps_high * cost_variables.uctpmp + 1.0e-6 * self.data.vacuum.n_vac_pumps_high * cost_variables.UCTPMP ) cost_variables.c2241 = cost_variables.fkind * cost_variables.c2241 @@ -2004,7 +2004,7 @@ def acc224(self): # Account 224.2 : Backing pumps cost_variables.c2242 = ( - 1.0e-6 * vacuum_variables.n_vv_vacuum_ducts * cost_variables.UCBPMP + 1.0e-6 * self.data.vacuum.n_vv_vacuum_ducts * cost_variables.UCBPMP ) cost_variables.c2242 = cost_variables.fkind * cost_variables.c2242 @@ -2012,8 +2012,8 @@ def acc224(self): cost_variables.c2243 = ( 1.0e-6 - * vacuum_variables.n_vv_vacuum_ducts - * vacuum_variables.dlscal + * self.data.vacuum.n_vv_vacuum_ducts + * self.data.vacuum.dlscal * cost_variables.UCDUCT ) cost_variables.c2243 = cost_variables.fkind * cost_variables.c2243 @@ -2023,8 +2023,8 @@ def acc224(self): cost_variables.c2244 = ( 1.0e-6 * 2.0e0 - * vacuum_variables.n_vv_vacuum_ducts - * (vacuum_variables.dia_vv_vacuum_ducts * 1.2e0) ** 1.4e0 + * self.data.vacuum.n_vv_vacuum_ducts + * (self.data.vacuum.dia_vv_vacuum_ducts * 1.2e0) ** 1.4e0 * cost_variables.UCVALV ) cost_variables.c2244 = cost_variables.fkind * cost_variables.c2244 @@ -2033,8 +2033,8 @@ def acc224(self): cost_variables.c2245 = ( 1.0e-6 - * vacuum_variables.n_vv_vacuum_ducts - * vacuum_variables.m_vv_vacuum_duct_shield + * self.data.vacuum.n_vv_vacuum_ducts + * self.data.vacuum.m_vv_vacuum_duct_shield * cost_variables.UCVDSH ) cost_variables.c2245 = cost_variables.fkind * cost_variables.c2245 diff --git a/process/models/ife.py b/process/models/ife.py index e0f32b984..c9384406a 100644 --- a/process/models/ife.py +++ b/process/models/ife.py @@ -19,7 +19,6 @@ ife_variables, physics_variables, structure_variables, - vacuum_variables, ) MATERIALS = [ @@ -2432,11 +2431,11 @@ def ifevac(self):

The calculated values are hard-wired; they are based loosely on those for a tokamak of 6m major radius. F/MI/PJK/LOGBOOK12, p.87 """ - vacuum_variables.dlscal = 2.0 - vacuum_variables.n_vv_vacuum_ducts = 16 - vacuum_variables.m_vv_vacuum_duct_shield = 0.0 - vacuum_variables.dia_vv_vacuum_ducts = 0.3 - vacuum_variables.n_vac_pumps_high = 32 + self.data.vacuum.dlscal = 2.0 + self.data.vacuum.n_vv_vacuum_ducts = 16 + self.data.vacuum.m_vv_vacuum_duct_shield = 0.0 + self.data.vacuum.dia_vv_vacuum_ducts = 0.3 + self.data.vacuum.n_vac_pumps_high = 32 def _material_string_generator(chmatv, fwmatv, v1matv, blmatv, v2matv, shmatv, v3matv): diff --git a/process/models/vacuum.py b/process/models/vacuum.py index cafb85e9e..f03c4c828 100644 --- a/process/models/vacuum.py +++ b/process/models/vacuum.py @@ -14,7 +14,6 @@ physics_variables, tfcoil_variables, times_variables, - vacuum_variables, ) from process.models.blankets.blanket_library import dshellvol, eshellvol from process.models.build import FwBlktVVShape @@ -60,17 +59,17 @@ def run(self, output: bool = False): * constants.UMASS ) - self.i_vacuum_pumping = vacuum_variables.i_vacuum_pumping + self.i_vacuum_pumping = self.data.vacuum.i_vacuum_pumping # i_vacuum_pumping required to be compared to a b string # as this is what f2py returns if self.i_vacuum_pumping == "old": ( pumpn, - vacuum_variables.n_vv_vacuum_ducts, - vacuum_variables.dlscal, - vacuum_variables.m_vv_vacuum_duct_shield, - vacuum_variables.dia_vv_vacuum_ducts, + self.data.vacuum.n_vv_vacuum_ducts, + self.data.vacuum.dlscal, + self.data.vacuum.m_vv_vacuum_duct_shield, + self.data.vacuum.dia_vv_vacuum_ducts, ) = self.vacuum( physics_variables.p_fusion_total_mw, physics_variables.rmajor, @@ -97,12 +96,12 @@ def run(self, output: bool = False): output=output, ) # MDK pumpn is real: convert to integer by rounding. - vacuum_variables.n_vac_pumps_high = math.floor(pumpn + 0.5e0) + self.data.vacuum.n_vac_pumps_high = math.floor(pumpn + 0.5e0) elif self.i_vacuum_pumping == "simple": - vacuum_variables.n_iter_vacuum_pumps = self.vacuum_simple(output=output) + self.data.vacuum.n_iter_vacuum_pumps = self.vacuum_simple(output=output) else: logger.error( - f"i_vacuum_pumping is invalid: {vacuum_variables.i_vacuum_pumping}" + f"i_vacuum_pumping is invalid: {self.data.vacuum.i_vacuum_pumping}" ) def vacuum_simple(self, output) -> float: @@ -124,15 +123,15 @@ def vacuum_simple(self, output) -> float: # Issue #304 n_iter_vacuum_pumps = ( physics_variables.molflow_plasma_fuelling_required - / vacuum_variables.molflow_vac_pumps + / self.data.vacuum.molflow_vac_pumps ) # Pump-down: # Pumping speed per pump m3/s pumpspeed = ( - vacuum_variables.volflow_vac_pumps_max - * vacuum_variables.f_a_vac_pump_port_plasma_surface - * vacuum_variables.f_volflow_vac_pumps_impedance + self.data.vacuum.volflow_vac_pumps_max + * self.data.vacuum.f_a_vac_pump_port_plasma_surface + * self.data.vacuum.f_volflow_vac_pumps_impedance * physics_variables.a_plasma_surface / tfcoil_variables.n_tf_coils ) @@ -140,10 +139,10 @@ def vacuum_simple(self, output) -> float: wallarea = (physics_variables.a_plasma_surface / 1084.0e0) * 2000.0e0 # Required pumping speed for pump-down pumpdownspeed = ( - vacuum_variables.outgasfactor + self.data.vacuum.outgasfactor * wallarea - / vacuum_variables.pres_vv_chamber_base - ) * times_variables.t_plant_pulse_dwell ** (-vacuum_variables.outgasindex) + / self.data.vacuum.pres_vv_chamber_base + ) * times_variables.t_plant_pulse_dwell ** (-self.data.vacuum.outgasindex) # Number of pumps required for pump-down npumpdown = pumpdownspeed / pumpspeed @@ -318,7 +317,7 @@ def vacuum( # nitrogen, DT, helium, DT again sp = ( [1.95, 1.8, 1.8, 1.8] - if vacuum_variables.i_vacuum_pump_type == 0 + if self.data.vacuum.i_vacuum_pump_type == 0 else [9.0, 25.0, 5.0, 25.0] ) @@ -336,8 +335,8 @@ def vacuum( area = plasma_sarea * (aw + dsol) / aw - ogas = vacuum_variables.outgrat_fw * area * 10.0e0 # Outgassing rate (Pa-m^3/s) - s.append(ogas / vacuum_variables.pres_vv_chamber_base) + ogas = self.data.vacuum.outgrat_fw * area * 10.0e0 # Outgassing rate (Pa-m^3/s) + s.append(ogas / self.data.vacuum.pres_vv_chamber_base) # Pumpdown between burns # s(2) = net pump speed (DT) required for pumpdown between burns (m^3/s) @@ -345,7 +344,7 @@ def vacuum( # t_plant_pulse_dwell = dwell time between burns (s) pend = ( - 0.5e0 * nplasma * k * vacuum_variables.temp_vv_chamber_gas_burn_end + 0.5e0 * nplasma * k * self.data.vacuum.temp_vv_chamber_gas_burn_end ) # pressure in plasma chamber after burn (Pa) pstart = 0.01e0 * pend # pressure in chamber before start of burn (Pa) @@ -356,9 +355,9 @@ def vacuum( volume = plasma_vol * (aw + dsol) * (aw + dsol) / (aw * aw) # dwell pumping options - if (vacuum_variables.i_vac_pump_dwell == 1) or (t_plant_pulse_dwell == 0): + if (self.data.vacuum.i_vac_pump_dwell == 1) or (t_plant_pulse_dwell == 0): tpump = times_variables.t_plant_pulse_coil_precharge - elif vacuum_variables.i_vac_pump_dwell == 2: + elif self.data.vacuum.i_vac_pump_dwell == 2: tpump = t_plant_pulse_dwell + times_variables.t_plant_pulse_coil_precharge else: tpump = t_plant_pulse_dwell @@ -375,12 +374,12 @@ def vacuum( fhe = source / (frate * 4.985e5) s.extend( ( - (source / vacuum_variables.pres_div_chamber_burn / fhe), + (source / self.data.vacuum.pres_div_chamber_burn / fhe), # Removal of dt on steady state basis # s(4) = net speed (D-T) required to remove dt at fuelling rate (m^3/s) ( (frate * 4.985e5 - source) - / (vacuum_variables.pres_div_chamber_burn * (1.0e0 - fhe)) + / (self.data.vacuum.pres_div_chamber_burn * (1.0e0 - fhe)) ), ), ) @@ -514,7 +513,7 @@ def vacuum( # If cryopumps are used then an additional pump is required # for continuous operation with regeneration. - if vacuum_variables.i_vacuum_pump_type == 1: + if self.data.vacuum.i_vacuum_pump_type == 1: pumpn *= 2.0e0 # Information for costing routine @@ -541,7 +540,7 @@ def vacuum( self.outfile, "First wall outgassing rate (Pa m/s)", "(outgrat_fw)", - vacuum_variables.outgrat_fw, + self.data.vacuum.outgrat_fw, ) process_output.ovarre( self.outfile, "Total outgassing load (Pa m3/s)", "(ogas)", ogas, "OP " @@ -550,7 +549,7 @@ def vacuum( self.outfile, "Base pressure required (Pa)", "(pres_vv_chamber_base)", - vacuum_variables.pres_vv_chamber_base, + self.data.vacuum.pres_vv_chamber_base, ) process_output.ovarre( self.outfile, "Required N2 pump speed (m3/s)", "(s(1))", s[0], "OP " @@ -577,7 +576,7 @@ def vacuum( self.outfile, "Allowable pumping time switch", "(i_vac_pump_dwell)", - vacuum_variables.i_vac_pump_dwell, + self.data.vacuum.i_vac_pump_dwell, ) process_output.ovarre( self.outfile, @@ -613,7 +612,7 @@ def vacuum( self.outfile, "Divertor chamber gas pressure (Pa)", "(pres_div_chamber_burn)", - vacuum_variables.pres_div_chamber_burn, + self.data.vacuum.pres_div_chamber_burn, ) process_output.ovarre( self.outfile, @@ -660,7 +659,7 @@ def vacuum( process_output.oblnkl(self.outfile) i_fw_blkt_shared_coolant = ( - "cryo " if vacuum_variables.i_vacuum_pump_type == 1 else "turbo" + "cryo " if self.data.vacuum.i_vacuum_pump_type == 1 else "turbo" ) process_output.oblnkl(self.outfile) diff --git a/tests/unit/test_availability.py b/tests/unit/test_availability.py index a992e670a..c2ee4e386 100644 --- a/tests/unit/test_availability.py +++ b/tests/unit/test_availability.py @@ -12,17 +12,16 @@ from process.data_structure import physics_variables as pv from process.data_structure import tfcoil_variables as tfv from process.data_structure import times_variables as tv -from process.models.availability import Availability @pytest.fixture -def availability(): +def availability(process_models): """Provides Availability object for testing. :return availability: initialised Availability object :type availability: process.availability.Availability """ - return Availability() + return process_models.availability @pytest.mark.parametrize( diff --git a/tests/unit/test_costs_1990.py b/tests/unit/test_costs_1990.py index 4e8abb1b5..911ebd76e 100644 --- a/tests/unit/test_costs_1990.py +++ b/tests/unit/test_costs_1990.py @@ -23,19 +23,17 @@ structure_variables, tfcoil_variables, times_variables, - vacuum_variables, ) -from process.models.costs.costs import Costs @pytest.fixture -def costs(): - """Provides Pulse object for testing. +def costs(process_models): + """Provides Costs object for testing. - :returns: initialised Pulse object - :rtype: process.pulse.Pulse + :returns: initialised Costs object + :rtype: process.costs.Costs """ - return Costs() + return process_models._costs_1990 def acc2261_param(**kwargs): @@ -3226,26 +3224,40 @@ def test_acc224(acc224param, monkeypatch, costs): monkeypatch.setattr(cost_variables, "fkind", acc224param.fkind) - monkeypatch.setattr(vacuum_variables, "dlscal", acc224param.dlscal) + monkeypatch.setattr( + costs.data.vacuum, + "dlscal", + acc224param.dlscal, + ) monkeypatch.setattr( - vacuum_variables, "m_vv_vacuum_duct_shield", acc224param.m_vv_vacuum_duct_shield + costs.data.vacuum, + "m_vv_vacuum_duct_shield", + acc224param.m_vv_vacuum_duct_shield, ) monkeypatch.setattr( - vacuum_variables, "n_vac_pumps_high", acc224param.n_vac_pumps_high + costs.data.vacuum, + "n_vac_pumps_high", + acc224param.n_vac_pumps_high, ) monkeypatch.setattr( - vacuum_variables, "dia_vv_vacuum_ducts", acc224param.dia_vv_vacuum_ducts + costs.data.vacuum, + "dia_vv_vacuum_ducts", + acc224param.dia_vv_vacuum_ducts, ) monkeypatch.setattr( - vacuum_variables, "i_vacuum_pump_type", acc224param.i_vacuum_pump_type + costs.data.vacuum, + "i_vacuum_pump_type", + acc224param.i_vacuum_pump_type, ) monkeypatch.setattr( - vacuum_variables, "n_vv_vacuum_ducts", acc224param.n_vv_vacuum_ducts + costs.data.vacuum, + "n_vv_vacuum_ducts", + acc224param.n_vv_vacuum_ducts, ) monkeypatch.setattr(cost_variables, "c22", acc224param.c22) diff --git a/tests/unit/test_vacuum.py b/tests/unit/test_vacuum.py index aea71c4ed..6ba9cc46f 100644 --- a/tests/unit/test_vacuum.py +++ b/tests/unit/test_vacuum.py @@ -5,28 +5,26 @@ from process.data_structure import physics_variables as pv from process.data_structure import tfcoil_variables as tfv from process.data_structure import times_variables as tv -from process.data_structure import vacuum_variables as vacv -from process.models.vacuum import Vacuum, VacuumVessel @pytest.fixture -def vacuum(): - """Provides Vacuum object for testing. +def vacuum(process_models): + """Fixture to get the Vacuum instance from process_models. :return vacuum: initialised Vacuum object :type vacuum: process.vacuum.Vacuum """ - return Vacuum() + return process_models.vacuum @pytest.fixture -def vacuum_vessel(): - """Provides Vacuum object for testing. +def vacuum_vessel(process_models): + """Fixture to get the VacuumVessel instance from process_models. - :return vacuum: initialised Vacuum object - :type vacuum: process.vacuum.Vacuum + :return vacuum: initialised VacuumVessel object + :type vacuum: process.vacuum.VacuumVessel """ - return VacuumVessel() + return process_models.vacuum_vessel class TestVacuum: @@ -47,13 +45,15 @@ def test_simple_model(self, monkeypatch, vacuum): monkeypatch.setattr(pv, "a_plasma_surface", 1500.3146527709359) monkeypatch.setattr(tfv, "n_tf_coils", 18) monkeypatch.setattr(tv, "t_plant_pulse_dwell", 500) - monkeypatch.setattr(vacv, "outgasfactor", 0.0235) - monkeypatch.setattr(vacv, "outgasindex", 1) - monkeypatch.setattr(vacv, "pres_vv_chamber_base", 0.0005) - monkeypatch.setattr(vacv, "f_a_vac_pump_port_plasma_surface", 0.0203) - monkeypatch.setattr(vacv, "f_volflow_vac_pumps_impedance", 0.4) - monkeypatch.setattr(vacv, "volflow_vac_pumps_max", 27.3) - monkeypatch.setattr(vacv, "molflow_vac_pumps", 1.2155e22) + monkeypatch.setattr(vacuum.data.vacuum, "outgasfactor", 0.0235) + monkeypatch.setattr(vacuum.data.vacuum, "outgasindex", 1) + monkeypatch.setattr(vacuum.data.vacuum, "pres_vv_chamber_base", 0.0005) + monkeypatch.setattr( + vacuum.data.vacuum, "f_a_vac_pump_port_plasma_surface", 0.0203 + ) + monkeypatch.setattr(vacuum.data.vacuum, "f_volflow_vac_pumps_impedance", 0.4) + monkeypatch.setattr(vacuum.data.vacuum, "volflow_vac_pumps_max", 27.3) + monkeypatch.setattr(vacuum.data.vacuum, "molflow_vac_pumps", 1.2155e22) n_iter_vacuum_pumps = vacuum.vacuum_simple(output=False) @@ -67,12 +67,16 @@ def test_old_model(self, monkeypatch, vacuum): monkeypatch.setattr(pv, "p_fusion_total_mw", 2115.3899563651776) monkeypatch.setattr(pv, "temp_plasma_electron_vol_avg_kev", 15.872999999999999) monkeypatch.setattr(tv, "t_plant_pulse_coil_precharge", 30) - monkeypatch.setattr(vacv, "i_vac_pump_dwell", 0) - monkeypatch.setattr(vacv, "i_vacuum_pump_type", 1) - monkeypatch.setattr(vacv, "pres_vv_chamber_base", 0.00050000000000000001) - monkeypatch.setattr(vacv, "pres_div_chamber_burn", 0.35999999999999999) - monkeypatch.setattr(vacv, "outgrat_fw", 1.3000000000000001e-08) - monkeypatch.setattr(vacv, "temp_vv_chamber_gas_burn_end", 300) + monkeypatch.setattr(vacuum.data.vacuum, "i_vac_pump_dwell", 0) + monkeypatch.setattr(vacuum.data.vacuum, "i_vacuum_pump_type", 1) + monkeypatch.setattr( + vacuum.data.vacuum, "pres_vv_chamber_base", 0.00050000000000000001 + ) + monkeypatch.setattr( + vacuum.data.vacuum, "pres_div_chamber_burn", 0.35999999999999999 + ) + monkeypatch.setattr(vacuum.data.vacuum, "outgrat_fw", 1.3000000000000001e-08) + monkeypatch.setattr(vacuum.data.vacuum, "temp_vv_chamber_gas_burn_end", 300) ndiv = 1 pfusmw = 2115.3899563651776