Add coolant type enum#4297
Open
chris-ashe wants to merge 5 commits into
Open
Conversation
Codecov Report❌ Patch coverage is 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. 🚀 New features to boost your workflow:
|
Contributor
There was a problem hiding this comment.
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_typefrom a string input/data value to an integer (1/2) and updated selected regression inputs accordingly. - Updated unit tests to use
CoolantType.HELIUM/CoolantType.WATERinstead 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 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}", |
| ), | ||
| "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' |
| # 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, |
| # 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, |
…ata for first wall coolant type
5b53e62 to
f7e07cb
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request standardizes the representation of coolant types throughout the codebase by introducing a new
CoolantTypeenum. 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
CoolantTypeEnumCoolantTypeenum inprocess/models/engineering/pumping.pyto represent coolant types as integer values with full names, replacing string-based representations.CoolantTypeinstead of raw strings or integers.2. Data Structure and Input Handling Updates
i_fw_coolant_typeinFWBSDataand input variable definitions fromstrtoint, with updated choices and documentation.3. Model and Logic Refactoring
CoolantTypefor all coolant type checks and assignments, improving clarity and reducing errors.4. Consistent Use in Property and Calculation Calls
FluidProperties.ofand other relevant functions to useCoolantType(...).full_nameor.nameas appropriate, ensuring correct mapping to fluid property libraries.5. Output and Plotting Improvements
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: