Skip to content

Add blkt type enum#4212

Open
chris-ashe wants to merge 3 commits intomainfrom
add_blkt_type_enum
Open

Add blkt type enum#4212
chris-ashe wants to merge 3 commits intomainfrom
add_blkt_type_enum

Conversation

@chris-ashe
Copy link
Copy Markdown
Collaborator

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 April 29, 2026 10:10
@chris-ashe chris-ashe requested a review from a team as a code owner April 29, 2026 10:10
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

Introduces an IntEnum to represent blanket model types (i_blanket_type) and replaces hard-coded blanket type integers with enum members in several core/model locations.

Changes:

  • Added BlktModelTypes(IntEnum) (currently covering CCFE HCPB and DCLL) to centralize blanket type identifiers.
  • Updated blanket type checks in core execution/output paths and in the power model to use the enum.
  • Updated DCLL-specific geometry branching in the blanket library to use the enum.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
process/models/power.py Uses BlktModelTypes instead of magic blanket-type integers in thermal efficiency logic.
process/models/blankets/blanket_library.py Adds BlktModelTypes enum and updates DCLL type branching to use it.
process/core/output.py Uses BlktModelTypes for selecting which blanket model’s output to write.
process/core/init.py Uses BlktModelTypes in validation logic for CCFE HCPB blanket settings.
process/core/caller.py Uses BlktModelTypes for selecting which blanket model to run.

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

Comment thread process/core/caller.py
from process.core.solver import constraints
from process.core.solver.iteration_variables import set_scaled_iteration_variable
from process.core.solver.objectives import objective_function
from process.models.blankets.blanket_library import BlktModelTypes
Copy link

Copilot AI Apr 29, 2026

Choose a reason for hiding this comment

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

Importing BlktModelTypes from process.models.blankets.blanket_library couples the core caller to the full blanket library import graph. Consider relocating the enum to a lightweight module (or importing locally) so selecting a blanket model doesn't require importing blanket_library.py at module import time.

Copilot uses AI. Check for mistakes.
Comment thread process/models/power.py Outdated
Comment on lines 1869 to 1874
if fwbs_variables.i_thermal_electric_conversion == 0:
# CCFE HCPB Model
if fwbs_variables.i_blanket_type == 1:
if fwbs_variables.i_blanket_type == BlktModelTypes.CCFE_HCPB:
# HCPB, efficiency taken from M. Kovari 2016
# "PROCESS": A systems code for fusion power plants - Part 2: Engineering
# https://www.sciencedirect.com/science/article/pii/S0920379616300072
Copy link

Copilot AI Apr 29, 2026

Choose a reason for hiding this comment

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

After switching to BlktModelTypes.CCFE_HCPB here, the corresponding else branch immediately below still calls logger.log(...) with only a message and text that references blanket type 1. logger.log requires a level argument and will raise TypeError if that branch is hit; update it to logger.warning/info(...) (or logger.log(logging.<LEVEL>, ...)) and make the message consistent with the enum.

Copilot uses AI. Check for mistakes.
Comment thread process/models/power.py Outdated
Comment on lines 1881 to 1886
elif fwbs_variables.i_thermal_electric_conversion == 1:
# CCFE HCPB Model
if fwbs_variables.i_blanket_type == 1:
if fwbs_variables.i_blanket_type == BlktModelTypes.CCFE_HCPB:
# HCPB, efficiency taken from M. Kovari 2016
# "PROCESS": A systems code for fusion power plants - Part 2: Engineering
# https://www.sciencedirect.com/science/article/pii/S0920379616300072
Copy link

Copilot AI Apr 29, 2026

Choose a reason for hiding this comment

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

The else branch for this blanket-type check (just below this block) uses logger.log(...) without providing a log level and references blanket type 1 in the message. This will raise at runtime if non-CCFE-HCPB blanket types use i_thermal_electric_conversion == 1; switch to logger.warning/info(...) (or logger.log(logging.<LEVEL>, ...)) and update the message to reference BlktModelTypes.CCFE_HCPB consistently.

Copilot uses AI. Check for mistakes.
Comment thread process/models/power.py
Comment on lines +28 to 29
from process.models.blankets.blanket_library import BlktModelTypes

Copy link

Copilot AI Apr 29, 2026

Choose a reason for hiding this comment

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

Importing BlktModelTypes from process.models.blankets.blanket_library pulls in blanket_library's heavy dependencies (e.g., CoolProp via process.core.coolprop_interface) just to access an enum. Consider moving BlktModelTypes into a lightweight module (e.g., process.data_structure.fwbs_variables or a small process.models.blankets.types module) and importing from there to reduce coupling and import-time side effects.

Suggested change
from process.models.blankets.blanket_library import BlktModelTypes
def _get_blkt_model_types():
from process.models.blankets.blanket_library import BlktModelTypes
return BlktModelTypes
class _BlktModelTypesProxy:
def __getattr__(self, name):
return getattr(_get_blkt_model_types(), name)
BlktModelTypes = _BlktModelTypesProxy()

Copilot uses AI. Check for mistakes.
Comment on lines +42 to +46
class BlktModelTypes(IntEnum):
"""Enum for blanket model types. `i_blanket_type`"""

CCFE_HCPB = 1
DCLL = 5
Copy link

Copilot AI Apr 29, 2026

Choose a reason for hiding this comment

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

Defining BlktModelTypes inside blanket_library.py makes any import of the enum also import the full blanket library (numpy + CoolProp interface, etc.). To avoid unnecessary heavyweight imports in core modules, consider relocating this enum to a lightweight module (e.g., process.data_structure.fwbs_variables where i_blanket_type is defined) and importing it here instead.

Copilot uses AI. Check for mistakes.
Comment thread process/core/output.py
@@ -1,5 +1,6 @@
from process import data_structure
from process.core.log import logging_model_handler
from process.models.blankets.blanket_library import BlktModelTypes
Copy link

Copilot AI Apr 29, 2026

Choose a reason for hiding this comment

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

Importing BlktModelTypes from process.models.blankets.blanket_library introduces an eager dependency on the full blanket library (and its heavy imports) even for cases that return early (stellarator/IFE). Consider importing the enum from a lightweight module (or doing a local import inside write) to avoid unnecessary import-time side effects.

Copilot uses AI. Check for mistakes.
Comment thread process/core/init.py
)
from process.data_structure.tfcoil_variables import init_tfcoil_variables
from process.data_structure.times_variables import init_times_variables
from process.models.blankets.blanket_library import BlktModelTypes
Copy link

Copilot AI Apr 29, 2026

Choose a reason for hiding this comment

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

Importing BlktModelTypes from process.models.blankets.blanket_library pulls in the full blanket library (including CoolProp interface) during core initialization. Consider moving the enum to a lightweight module (e.g., process.data_structure.fwbs_variables) to reduce import-time coupling and potential side effects.

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

Codecov Report

❌ Patch coverage is 50.00000% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 52.12%. Comparing base (25b9f07) to head (10f6b05).

Files with missing lines Patch % Lines
process/models/power.py 25.00% 3 Missing ⚠️
process/core/caller.py 33.33% 2 Missing ⚠️
process/core/output.py 33.33% 2 Missing ⚠️
process/models/blankets/blanket_library.py 80.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4212      +/-   ##
==========================================
+ Coverage   52.10%   52.12%   +0.01%     
==========================================
  Files         148      148              
  Lines       30389    30397       +8     
==========================================
+ Hits        15835    15843       +8     
  Misses      14554    14554              

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

Copy link
Copy Markdown
Collaborator

@je-cook je-cook left a comment

Choose a reason for hiding this comment

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

this needs the pre validation with the enum so we cant pass unknown values through the system

i_blanket_type = BlktModelTypes(i_blanket_type)

@clmould clmould self-assigned this Apr 29, 2026
chris-ashe and others added 2 commits April 29, 2026 15:11
Co-authored-by: Copilot <copilot@github.com>
…readability and maintainability

Co-authored-by: Copilot <copilot@github.com>
…cy in power calculations

Co-authored-by: Copilot <copilot@github.com>
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.

5 participants