Skip to content

Add vaccum pump dataclass - #4493

Open
chris-ashe wants to merge 4 commits into
mainfrom
add_vaccum_pump_dataclass
Open

Add vaccum pump dataclass#4493
chris-ashe wants to merge 4 commits into
mainfrom
add_vaccum_pump_dataclass

Conversation

@chris-ashe

@chris-ashe chris-ashe commented Jul 31, 2026

Copy link
Copy Markdown
Collaborator

This pull request refactors the vacuum pump modeling in process/models/vacuum.py to 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:

  • Introduced new frozen dataclasses: VacuumSpecies (to represent gas species parameters) and VacuumPump (as a base for pump specifications), along with concrete subclasses TurbomolecularPump and CryoPump for specific pump types. These replace hardcoded lists and constants for pump and species properties.
  • The selection and use of pump specifications in the vacuum function now instantiate and use these dataclasses instead of raw lists.

Computational logic updates:

  • Updated all calculations in the vacuum function to access pump speeds and conductance multipliers via the new dataclass structure, improving code clarity and reducing indexing errors. [1] [2] [3]

General improvements:

  • Added the necessary imports for dataclasses and related utilities to support the new structure.## Description

Checklist

I confirm that I have completed the following checks:

  • My changes follow the PROCESS style guide
  • I have justified any large differences in the regression tests caused by this pull request in the comments.
  • I have added new tests where appropriate for the changes I have made.
  • If I have had to change any existing unit or integration tests, I have justified this change in the pull request comments.
  • If I have made documentation changes, I have checked they render correctly.
  • I have added documentation for my change, if appropriate.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 49.35%. Comparing base (3a4a89a) to head (ad2f590).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@chris-ashe
chris-ashe marked this pull request as ready for review August 5, 2026 07:24
@chris-ashe
chris-ashe requested a review from a team as a code owner August 5, 2026 07:24
@timothy-nunn timothy-nunn self-assigned this Aug 5, 2026
Comment thread process/models/vacuum.py
Comment on lines +66 to +103
@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"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"
)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@timothy-nunn timothy-nunn Aug 6, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Comment thread process/models/vacuum.py
Comment on lines +49 to +63
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),
)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that this species almost negates the use of a dataclass

Comment thread process/models/vacuum.py
Comment on lines +37 to +43
xmult: VacuumSpecies = field(
default_factory=lambda: VacuumSpecies(
nitrogen=1.0e0,
deuterium_tritium=0.423e0,
helium=0.378e0,
deuterium_tritium_again=0.423e0,
)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these values constant? If so, this would make more sense as an enum

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants