Add coolant type enum#4297
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #4297 +/- ##
==========================================
+ Coverage 48.69% 48.79% +0.09%
==========================================
Files 151 151
Lines 29290 29340 +50
==========================================
+ Hits 14263 14316 +53
+ Misses 15027 15024 -3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
| # 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, |
| 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" | ||
| ), |
| # 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) | ||
| ) |
| ), | ||
| "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]), |
| # 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, |
5b53e62 to
f7e07cb
Compare
39fd250 to
b5f65bf
Compare
…ata for first wall coolant type
…s in BlanketLibrary
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
b5f65bf to
ac24383
Compare
clmould
left a comment
There was a problem hiding this comment.
A few small changes, but all good otherwise
| (5 / 3) | ||
| if self.data.fwbs.i_blkt_coolant_type == CoolantType.HELIUM | ||
| else (4 / 3) | ||
| ) |
There was a problem hiding this comment.
Copilot has a comment here, I'm not sure if it needs doing so just mentioning it to you here
There was a problem hiding this comment.
We can always add the adiabatic index as an attribute to the enum if we want
There was a problem hiding this comment.
I think that using gamma = ( (5 / 3) if primary_coolant_switch == CoolantType.HELIUM else (4 / 3) )
should work as the primary_coolant_switch is either i_blkt_coolant_type or i_fw_coolant_type anyway, so this should ensure the right one is used?
Co-authored-by: clmould <86794332+clmould@users.noreply.github.com>
Co-authored-by: clmould <86794332+clmould@users.noreply.github.com>
Co-authored-by: clmould <86794332+clmould@users.noreply.github.com>
Co-authored-by: clmould <86794332+clmould@users.noreply.github.com>
Co-authored-by: clmould <86794332+clmould@users.noreply.github.com>
| (5 / 3) | ||
| if self.data.fwbs.i_blkt_coolant_type == CoolantType.HELIUM | ||
| else (4 / 3) | ||
| ) |
There was a problem hiding this comment.
I think that using gamma = ( (5 / 3) if primary_coolant_switch == CoolantType.HELIUM else (4 / 3) )
should work as the primary_coolant_switch is either i_blkt_coolant_type or i_fw_coolant_type anyway, so this should ensure the right one is used?
|
|
||
| textstr_fw = "\n".join(( | ||
| rf"Coolant type: {i_fw_coolant_type}", | ||
| rf"Coolant type: {CoolantType(i_fw_coolant_type).full_name}", |
There was a problem hiding this comment.
| rf"Coolant type: {CoolantType(i_fw_coolant_type).full_name}", | |
| rf"Coolant type: {i_fw_coolant_type}", |
This should work now, as i_fw_coolant_type is read in from the mfile, so is now already read in as 'Helium' , didn't realise this when i made my suggestions earlier!
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: