Skip to content

Add enum for thermal to electric conversion model types and update us…#4209

Open
chris-ashe wants to merge 1 commit intomainfrom
add_i_therm_electric_conversion_enum
Open

Add enum for thermal to electric conversion model types and update us…#4209
chris-ashe wants to merge 1 commit intomainfrom
add_i_therm_electric_conversion_enum

Conversation

@chris-ashe
Copy link
Copy Markdown
Collaborator

…age in power calculations

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.

…age in power calculations

Co-authored-by: Copilot <copilot@github.com>
Copilot AI review requested due to automatic review settings April 28, 2026 15:58
@chris-ashe chris-ashe requested a review from a team as a code owner April 28, 2026 15:58
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 typed IntEnum for the thermal→electric conversion model switch (i_thermal_electric_conversion) and updates the power model logic (and documentation) to use the named enum values instead of raw integers.

Changes:

  • Add ElectricConversionModelTypes (IntEnum) in process/models/power.py.
  • Refactor component_thermal_powers() and plant_thermal_efficiency() to compare against enum members.
  • Fix documentation: “User input” corresponds to i_thermal_electric_conversion = 2.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
process/models/power.py Adds enum and updates conversion-model branching logic to use enum members.
documentation/source/eng-models/power-requirements.md Corrects the documented value for the “User input” conversion model.

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

Comment thread process/models/power.py
Comment on lines +1954 to +1957
elif (
i_thermal_electric_conversion
== ElectricConversionModelTypes.SUPERCRITICAL_CO2_CYCLE
):
Copy link

Copilot AI Apr 28, 2026

Choose a reason for hiding this comment

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

There don’t appear to be unit tests covering the i_thermal_electric_conversion steam Rankine (3) / s-CO2 (4) paths in plant_thermal_efficiency(). Adding focused tests for these options would help catch enum/branch regressions like this one and validate the temperature→efficiency correlations.

Copilot uses AI. Check for mistakes.
Comment thread process/models/power.py
elif fwbs_variables.i_thermal_electric_conversion == 4:
elif (
i_thermal_electric_conversion
== ElectricConversionModelTypes.SUPERCRITICAL_CO2_CYCLE
Copy link

Copilot AI Apr 28, 2026

Choose a reason for hiding this comment

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

ElectricConversionModelTypes defines SUPERCRITICAL_CO2_BRAYTON_CYCLE, but this branch compares against ElectricConversionModelTypes.SUPERCRITICAL_CO2_CYCLE, which will raise AttributeError at runtime when i_thermal_electric_conversion == 4. Rename the enum member or update this comparison to use the defined name (and keep naming consistent with the docs: “Supercritical CO2 Brayton Cycle”).

Suggested change
== ElectricConversionModelTypes.SUPERCRITICAL_CO2_CYCLE
== ElectricConversionModelTypes.SUPERCRITICAL_CO2_BRAYTON_CYCLE

Copilot uses AI. Check for mistakes.
Comment thread process/models/power.py
Comment on lines +1882 to +1884
i_thermal_electric_conversion = ElectricConversionModelTypes(
fwbs_variables.i_thermal_electric_conversion
)
Copy link

Copilot AI Apr 28, 2026

Choose a reason for hiding this comment

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

Casting fwbs_variables.i_thermal_electric_conversion to ElectricConversionModelTypes will raise a ValueError for out-of-range values, so the final else branch that logs an out-of-range message can never execute. Either remove that else branch (since input is validated elsewhere) or wrap the enum conversion in try/except ValueError and handle/log invalid values there.

Suggested change
i_thermal_electric_conversion = ElectricConversionModelTypes(
fwbs_variables.i_thermal_electric_conversion
)
try:
i_thermal_electric_conversion = ElectricConversionModelTypes(
fwbs_variables.i_thermal_electric_conversion
)
except ValueError as exc:
logger.error(
"i_thermal_electric_conversion=%s is out of range for "
"ElectricConversionModelTypes",
fwbs_variables.i_thermal_electric_conversion,
)
raise ProcessValueError(
"Invalid i_thermal_electric_conversion: "
f"{fwbs_variables.i_thermal_electric_conversion}"
) from exc

Copilot uses AI. Check for mistakes.
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 46.66667% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 52.11%. Comparing base (25b9f07) to head (8217e95).

Files with missing lines Patch % Lines
process/models/power.py 46.66% 8 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4209   +/-   ##
=======================================
  Coverage   52.10%   52.11%           
=======================================
  Files         148      148           
  Lines       30389    30398    +9     
=======================================
+ Hits        15835    15842    +7     
- Misses      14554    14556    +2     

☔ View full report in Codecov by Sentry.
📢 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.

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