From f723b062741950e6174f1b87a08155419e9e1cfa Mon Sep 17 00:00:00 2001 From: mn3981 Date: Fri, 31 Jul 2026 16:21:20 +0100 Subject: [PATCH 1/4] Add dataclasses for vacuum pump specifications and flow rates --- process/models/vacuum.py | 63 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/process/models/vacuum.py b/process/models/vacuum.py index b305bd93ea..4cd1ecd511 100644 --- a/process/models/vacuum.py +++ b/process/models/vacuum.py @@ -2,6 +2,7 @@ import logging import math +from dataclasses import dataclass, field import numpy as np @@ -15,6 +16,68 @@ logger = logging.getLogger(__name__) +@dataclass +class VacuumFlowRates: + """Dataclass for vacuum pump flow rates for different gases in m³/s""" + + nitrogen: float + deuterium_tritium: float + helium: float + deuterium_tritium_again: float + + +@dataclass +class VacuumPump: + """Base dataclass for vacuum pump specifications""" + + name: str + """Name of the vacuum pump type""" + volflow_pump: VacuumFlowRates + """Volumetric flow rates of the vacuum pump for different gases in m³/s""" + description: str = "" + """Description of the vacuum pump""" + + +@dataclass +class TurbomolecularPump(VacuumPump): + """Turbomolecular pump with magnetic bearing specifications + + Nominal speed of 2.0 m^3/s + """ + + name: str = "Turbomolecular" + volflow_pump: VacuumFlowRates = field( + default_factory=lambda: VacuumFlowRates( + nitrogen=1.95, + deuterium_tritium=1.8, + helium=1.8, + deuterium_tritium_again=1.8, + ) + ) + description: str = ( + "Turbomolecular pump (magnetic bearing) with nominal speed 2.0 m³/s" + ) + + +@dataclass +class CryoPump(VacuumPump): + """Compound cryopump specifications + + Nominal speed of 10 m³/s + """ + + name: str = "Cryopump" + volflow_pump: VacuumFlowRates = field( + default_factory=lambda: VacuumFlowRates( + nitrogen=9.0, + deuterium_tritium=25.0, + helium=5.0, + deuterium_tritium_again=25.0, + ) + ) + description: str = "Compound cryopump with nominal speed 10 m³/s" + + class Vacuum(Model): """Module containing vacuum system routines From 8a2213d522f0831c4aeaec012575b8235f0e7e45 Mon Sep 17 00:00:00 2001 From: mn3981 Date: Fri, 31 Jul 2026 16:43:58 +0100 Subject: [PATCH 2/4] Refactor vacuum pump dataclass to use VacuumSpecies for flow rates and add multiplier field --- process/models/vacuum.py | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/process/models/vacuum.py b/process/models/vacuum.py index 4cd1ecd511..e50196be83 100644 --- a/process/models/vacuum.py +++ b/process/models/vacuum.py @@ -17,8 +17,8 @@ @dataclass -class VacuumFlowRates: - """Dataclass for vacuum pump flow rates for different gases in m³/s""" +class VacuumSpecies: + """Dataclass for different particle species in the vacuum system""" nitrogen: float deuterium_tritium: float @@ -32,8 +32,17 @@ class VacuumPump: name: str """Name of the vacuum pump type""" - volflow_pump: VacuumFlowRates + volflow_pump: VacuumSpecies """Volumetric flow rates of the vacuum pump for different gases in m³/s""" + xmult: VacuumSpecies = field( + default_factory=lambda: VacuumSpecies( + nitrogen=1.0e0, + deuterium_tritium=0.423e0, + helium=0.378e0, + deuterium_tritium_again=0.423e0, + ) + ) + """Multiplier to convert conductance from gas species i to nitrogen""" description: str = "" """Description of the vacuum pump""" @@ -46,8 +55,8 @@ class TurbomolecularPump(VacuumPump): """ name: str = "Turbomolecular" - volflow_pump: VacuumFlowRates = field( - default_factory=lambda: VacuumFlowRates( + volflow_pump: VacuumSpecies = field( + default_factory=lambda: VacuumSpecies( nitrogen=1.95, deuterium_tritium=1.8, helium=1.8, @@ -67,8 +76,8 @@ class CryoPump(VacuumPump): """ name: str = "Cryopump" - volflow_pump: VacuumFlowRates = field( - default_factory=lambda: VacuumFlowRates( + volflow_pump: VacuumSpecies = field( + default_factory=lambda: VacuumSpecies( nitrogen=9.0, deuterium_tritium=25.0, helium=5.0, From ce5125fa61f15c6c683e1457bbb97066073676dd Mon Sep 17 00:00:00 2001 From: mn3981 Date: Fri, 31 Jul 2026 17:09:59 +0100 Subject: [PATCH 3/4] Enhance VacuumPump dataclass with species method for flow rate and conductance multiplier retrieval --- process/models/vacuum.py | 42 ++++++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/process/models/vacuum.py b/process/models/vacuum.py index e50196be83..965dddb69c 100644 --- a/process/models/vacuum.py +++ b/process/models/vacuum.py @@ -2,7 +2,7 @@ import logging import math -from dataclasses import dataclass, field +from dataclasses import dataclass, field, fields import numpy as np @@ -46,6 +46,22 @@ class VacuumPump: description: str = "" """Description of the vacuum pump""" + def species(self): + """Yield species name, pump speed, and conductance multiplier. + + Yields + ------ + tuple[str, float, float] + Species name, volumetric flow rate, and conductance multiplier. + """ + for species_field in fields(self.volflow_pump): + species_name = species_field.name + yield ( + species_name, + getattr(self.volflow_pump, species_name), + getattr(self.xmult, species_name), + ) + @dataclass class TurbomolecularPump(VacuumPump): @@ -361,18 +377,15 @@ def vacuum( # thickness thcsh = thshldi / 3.0e0 - # Multiplier to convert conductance from gas species i to nitrogen - xmult = [1.0e0, 0.423e0, 0.378e0, 0.423e0] - # nitrogen, D-T, helium, D-T again nduct = ntf * ndiv # Speed of high-vacuum pumps (m^3/s) # nitrogen, DT, helium, DT again - sp = ( - [1.95, 1.8, 1.8, 1.8] + pump = ( + TurbomolecularPump() if VacuumPumpType(self.data.vacuum.i_vacuum_pump_type) == VacuumPumpType.TURBOMOLECULAR - else [9.0, 25.0, 5.0, 25.0] + else CryoPump() ) # Calculate required pumping speeds @@ -450,17 +463,22 @@ def vacuum( ceff = np.full(4, 1e-6) d = np.full(4, 1e-6) - for i in range(4): - sss = nduct / (1.0e0 / sp[i] / pumpn + 1.0e0 / cmax * xmult[i] / xmult[imax]) + pump_species = tuple(pump.species()) + + for i, (_, volflow_pump_species, x_multiplier) in enumerate(pump_species): + sss = nduct / ( + 1.0e0 / volflow_pump_species / pumpn + + 1.0e0 / cmax * x_multiplier / pump_species[imax][2] + ) if sss > s[i]: continue imax = i ccc = 2.0e0 * s[i] / nduct - pumpn1 = 1.0e0 / (sp[i] * (nduct / s[i] - 1.0e0 / ccc)) - pumpn2 = 1.01e0 * s[i] / (sp[i] * nduct) + pumpn1 = 1.0e0 / (volflow_pump_species * (nduct / s[i] - 1.0e0 / ccc)) + pumpn2 = 1.01e0 * s[i] / (volflow_pump_species * nduct) pumpn = max(pumpn, pumpn1, pumpn2) - ceff[i] = 1.0e0 / (nduct / s[i] - 1.0e0 / (sp[i] * pumpn)) + ceff[i] = 1.0e0 / (nduct / s[i] - 1.0e0 / (volflow_pump_species * pumpn)) ceff, nflag, d1max = self._newton_method_duct_diameter( d, i, s, xmult, l1, l2, l3, ntf, r0, aw, ritf, thcsh, ceff From 1093362174fdf59eb18e899f3e07a1067821518d Mon Sep 17 00:00:00 2001 From: mn3981 Date: Fri, 31 Jul 2026 17:12:55 +0100 Subject: [PATCH 4/4] Make VacuumSpecies and VacuumPump dataclasses immutable by adding frozen=True --- process/models/vacuum.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/process/models/vacuum.py b/process/models/vacuum.py index 965dddb69c..f7a57467ac 100644 --- a/process/models/vacuum.py +++ b/process/models/vacuum.py @@ -16,7 +16,7 @@ logger = logging.getLogger(__name__) -@dataclass +@dataclass(frozen=True) class VacuumSpecies: """Dataclass for different particle species in the vacuum system""" @@ -26,7 +26,7 @@ class VacuumSpecies: deuterium_tritium_again: float -@dataclass +@dataclass(frozen=True) class VacuumPump: """Base dataclass for vacuum pump specifications""" @@ -63,7 +63,7 @@ def species(self): ) -@dataclass +@dataclass(frozen=True) class TurbomolecularPump(VacuumPump): """Turbomolecular pump with magnetic bearing specifications @@ -84,7 +84,7 @@ class TurbomolecularPump(VacuumPump): ) -@dataclass +@dataclass(frozen=True) class CryoPump(VacuumPump): """Compound cryopump specifications