Add vaccum pump dataclass - #4493
Conversation
…d add multiplier field
…nductance multiplier retrieval
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4493 +/- ##
==========================================
+ Coverage 49.30% 49.35% +0.05%
==========================================
Files 151 151
Lines 29611 29642 +31
==========================================
+ Hits 14599 14630 +31
Misses 15012 15012 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| @dataclass(frozen=True) | ||
| class TurbomolecularPump(VacuumPump): | ||
| """Turbomolecular pump with magnetic bearing specifications | ||
|
|
||
| Nominal speed of 2.0 m^3/s | ||
| """ | ||
|
|
||
| name: str = "Turbomolecular" | ||
| volflow_pump: VacuumSpecies = field( | ||
| default_factory=lambda: VacuumSpecies( | ||
| 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(frozen=True) | ||
| class CryoPump(VacuumPump): | ||
| """Compound cryopump specifications | ||
|
|
||
| Nominal speed of 10 m³/s | ||
| """ | ||
|
|
||
| name: str = "Cryopump" | ||
| volflow_pump: VacuumSpecies = field( | ||
| default_factory=lambda: VacuumSpecies( | ||
| 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" |
There was a problem hiding this comment.
Since these dataclasses are frozen couldn't we just make some instances of the base dataclass. E.g.
CRYO_PUMP = VacuumPump(
"Cryopump",
VacuumSpecies(
nitrogen=9.0,
deuterium_tritium=25.0,
helium=5.0,
deuterium_tritium_again=25.0,
),
"Compound cryopump with nominal speed 10 m³/s"
)There was a problem hiding this comment.
My only concern would be is if we ever need to add different pumps to different systems. We would then have the same class instance declared manually everywhere instead of just having a single cryopump definition that could be called
There was a problem hiding this comment.
Because this class is frozen the same object could be used everywhere, right (it cannot should not be mutated)? Unless we are saying that the volflow_pump would be different in these different use cases?
| 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), | ||
| ) |
There was a problem hiding this comment.
I think that this species almost negates the use of a dataclass
| xmult: VacuumSpecies = field( | ||
| default_factory=lambda: VacuumSpecies( | ||
| nitrogen=1.0e0, | ||
| deuterium_tritium=0.423e0, | ||
| helium=0.378e0, | ||
| deuterium_tritium_again=0.423e0, | ||
| ) |
There was a problem hiding this comment.
Are these values constant? If so, this would make more sense as an enum
This pull request refactors the vacuum pump modeling in
process/models/vacuum.pyto use structured dataclasses for pump and gas species properties, replacing the previous use of raw lists and constants. This makes the code more maintainable, readable, and less error-prone. The main computational logic is updated to use these new dataclasses, improving clarity and extensibility.Vacuum pump and species modeling:
VacuumSpecies(to represent gas species parameters) andVacuumPump(as a base for pump specifications), along with concrete subclassesTurbomolecularPumpandCryoPumpfor specific pump types. These replace hardcoded lists and constants for pump and species properties.vacuumfunction now instantiate and use these dataclasses instead of raw lists.Computational logic updates:
vacuumfunction to access pump speeds and conductance multipliers via the new dataclass structure, improving code clarity and reducing indexing errors. [1] [2] [3]General improvements:
dataclassesand related utilities to support the new structure.## DescriptionChecklist
I confirm that I have completed the following checks: