Skip to content

Add coolant type enum#4297

Open
chris-ashe wants to merge 5 commits into
mainfrom
add_coolant_type_enum
Open

Add coolant type enum#4297
chris-ashe wants to merge 5 commits into
mainfrom
add_coolant_type_enum

Conversation

@chris-ashe
Copy link
Copy Markdown
Collaborator

@chris-ashe chris-ashe commented Jun 5, 2026

This pull request standardizes the representation of coolant types throughout the codebase by introducing a new CoolantType enum. Previously, coolant types were handled as strings (e.g., "helium" or "water"); now they are represented as integers (1 for helium, 2 for water) with associated names. This change improves type safety, reduces ambiguity, and simplifies comparisons and logic related to coolant types. The update touches core data structures, input handling, engineering models, and plotting/output routines.

Key changes include:

1. Introduction and Adoption of CoolantType Enum

  • Added a new CoolantType enum in process/models/engineering/pumping.py to represent coolant types as integer values with full names, replacing string-based representations.
  • Updated all relevant imports and usages across the codebase to use CoolantType instead of raw strings or integers.

2. Data Structure and Input Handling Updates

  • Changed the type of i_fw_coolant_type in FWBSData and input variable definitions from str to int, with updated choices and documentation.

3. Model and Logic Refactoring

  • Refactored logic in blanket and first wall models to use CoolantType for all coolant type checks and assignments, improving clarity and reducing errors.
  • Updated function signatures and documentation to reflect the change from string to integer coolant type parameters.

4. Consistent Use in Property and Calculation Calls

  • Modified all calls to FluidProperties.of and other relevant functions to use CoolantType(...).full_name or .name as appropriate, ensuring correct mapping to fluid property libraries.

5. Output and Plotting Improvements

  • Updated output and plotting routines to display coolant type using the enum's name, enhancing readability and consistency in generated reports and plots.

These changes collectively make the coolant type handling more robust, maintainable, and less error-prone.## 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.

Copilot AI review requested due to automatic review settings June 5, 2026 14:57
@chris-ashe chris-ashe requested a review from a team as a code owner June 5, 2026 14:57
@chris-ashe chris-ashe marked this pull request as draft June 5, 2026 14:57
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Jun 5, 2026

Codecov Report

❌ Patch coverage is 80.76923% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 48.72%. Comparing base (5e85c12) to head (135dd8d).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
process/models/blankets/blanket_library.py 40.00% 3 Missing ⚠️
process/models/blankets/hcpb.py 66.66% 1 Missing ⚠️
process/models/stellarator/stellarator.py 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4297      +/-   ##
==========================================
+ Coverage   48.68%   48.72%   +0.03%     
==========================================
  Files         151      151              
  Lines       29296    29308      +12     
==========================================
+ Hits        14264    14279      +15     
+ Misses      15032    15029       -3     

☔ 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.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces a CoolantType enum and migrates first-wall / blanket coolant selection logic away from string literals toward a consistent numeric/enum representation across models, inputs, plots, and tests.

Changes:

  • Added CoolantType (IntEnum) and updated model logic to compare coolant types via enum values.
  • Changed i_fw_coolant_type from a string input/data value to an integer (1/2) and updated selected regression inputs accordingly.
  • Updated unit tests to use CoolantType.HELIUM / CoolantType.WATER instead of raw literals.

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 12 comments.

Show a summary per file
File Description
process/models/engineering/pumping.py Adds CoolantType enum used throughout coolant selection and pumping calculations.
process/data_structure/fwbs_variables.py Changes i_fw_coolant_type storage from str to int (1/2).
process/core/input.py Updates input parsing for i_fw_coolant_type to accept integers (1/2).
process/models/fw.py Converts FW CoolProp calls to use CoolantType(...) for fluid selection.
process/models/blankets/blanket_library.py Migrates FW/blanket coolant selection and pumping power calls toward enum/int usage.
process/models/blankets/hcpb.py Uses CoolantType for blanket coolant type assignment and comparisons.
process/models/stellarator/stellarator.py Replaces numeric coolant comparisons with CoolantType checks.
process/core/io/plot/summary.py Updates FW plot annotation to display coolant type via CoolantType(...).
tests/unit/models/test_fw.py Updates FW unit tests to use CoolantType constants.
tests/unit/models/test_costs_1990.py Updates costs unit tests to use CoolantType constants.
tests/unit/models/blankets/test_ccfe_hcpb.py Updates blanket tests to use CoolantType constants.
tests/unit/models/blankets/test_blanket_library.py Updates blanket library tests to use CoolantType constants (incl. pumping-power test data).
tests/regression/input_files/st_regression.IN.DAT Updates FW coolant input value from helium to 1.
tests/regression/input_files/spherical_tokamak_eval.IN.DAT Updates FW coolant input value from helium to 1.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread process/models/engineering/pumping.py Outdated
Comment on lines +16 to +39
def __new__(cls, value: int, name: str):
"""Create a new CoolantType enum member with value and full_name.

Parameters
----------
value : int
The numeric value of the enum member.
full_name : str
The full name description of the plasma current model.

Returns
-------
CoolantType
A new enum member with the specified value and full_name.
"""
obj = int.__new__(cls, value)
obj._value_ = value
obj._name_ = name
return obj

@DynamicClassAttribute
def full_name(self):
"""Return the full name of the coolant type."""
return self._name_
# FW/BB
fw_bb_fluid_properties = FluidProperties.of(
self.data.fwbs.i_fw_coolant_type,
CoolantType(self.data.fwbs.i_fw_coolant_type).name,
) * 0.5
fw_fluid_properties = FluidProperties.of(
self.data.fwbs.i_fw_coolant_type,
CoolantType(self.data.fwbs.i_fw_coolant_type).name,
Comment on lines 2488 to 2494
dpres_coolant=deltap_blkt,
mflow_coolant_total=self.data.blanket.mflow_blkt_coolant_total,
primary_coolant_switch=(
"Helium" if self.data.fwbs.i_blkt_coolant_type == 1 else "Water"
"Helium"
if self.data.fwbs.i_blkt_coolant_type == CoolantType.HELIUM
else "Water"
),
Comment on lines 3363 to +3368
# Adiabatic index for helium or water
gamma = (5 / 3) if self.data.fwbs.i_blkt_coolant_type == 1 else (4 / 3)
gamma = (
(5 / 3)
if self.data.fwbs.i_blkt_coolant_type == CoolantType.HELIUM
else (4 / 3)
)

textstr_fw = "\n".join((
rf"Coolant type: {i_fw_coolant_type}",
rf"Coolant type: {CoolantType(i_fw_coolant_type).name}",
Comment thread process/core/input.py
),
"quench_model": InputVariable("tfcoil", str, choices=["exponential", "linear"]),
"i_fw_coolant_type": InputVariable("fwbs", str, choices=["helium", "water"]),
"i_fw_coolant_type": InputVariable("fwbs", int, choices=[1, 2]),
Comment on lines +2169 to 2172
i_fw_coolant_type = 1
* DESCRIPTION: switch for first wall coolant (can be different from blanket coolant) (default = helium):
* 'helium'
* 'water'
Comment thread process/models/fw.py Outdated
# Calculate inlet coolant fluid properties (fixed pressure)
inlet_coolant_properties = FluidProperties.of(
self.data.fwbs.i_fw_coolant_type,
CoolantType(self.data.fwbs.i_fw_coolant_type).name,
Comment thread process/models/fw.py Outdated
# Calculate outlet coolant fluid properties (fixed pressure)
outlet_coolant_properties = FluidProperties.of(
self.data.fwbs.i_fw_coolant_type,
CoolantType(self.data.fwbs.i_fw_coolant_type).name,
@chris-ashe chris-ashe marked this pull request as ready for review June 5, 2026 15:21
@chris-ashe chris-ashe force-pushed the add_coolant_type_enum branch from 5b53e62 to f7e07cb Compare June 5, 2026 15:22
@chris-ashe chris-ashe requested a review from clmould June 5, 2026 15:42
@clmould clmould self-assigned this Jun 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants