Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 62 additions & 16 deletions process/models/blankets/blanket_library.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""This library contains routines that can be shared by the blanket modules used in PROCESS."""

import logging
from enum import IntEnum

import numpy as np

Expand Down Expand Up @@ -39,6 +40,13 @@
# FCI Flow Channel Insert


class FWBlktCoolantLoopTypes(IntEnum):
"""Enumeration for first wall and blanket coolant loop types. `i_fw_blkt_shared_coolant`."""

SHARED_LOOP = 0
SEPARATE_LOOPS = 1


class BlanketLibrary(Model):
def __init__(self, fw):
self.outfile = constants.NOUT
Expand Down Expand Up @@ -663,15 +671,22 @@ def primary_coolant_properties(self, output: bool):
fwbs_variables.i_fw_coolant_type == "Helium"
and fwbs_variables.i_blkt_coolant_type == 2
):
fwbs_variables.i_fw_blkt_shared_coolant = 1
fwbs_variables.i_fw_blkt_shared_coolant = (
FWBlktCoolantLoopTypes.SEPARATE_LOOPS
)
if (
fwbs_variables.i_fw_coolant_type == "Water"
and fwbs_variables.i_blkt_coolant_type == 1
):
fwbs_variables.i_fw_blkt_shared_coolant = 1
fwbs_variables.i_fw_blkt_shared_coolant = (
FWBlktCoolantLoopTypes.SEPARATE_LOOPS
)

# If FW and BB have same coolant...
if fwbs_variables.i_fw_blkt_shared_coolant == 0:
i_fw_blkt_shared_coolant = FWBlktCoolantLoopTypes(
fwbs_variables.i_fw_blkt_shared_coolant
)
Comment on lines +686 to +688
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.

FWBlktCoolantLoopTypes(...) will raise ValueError if fwbs_variables.i_fw_blkt_shared_coolant is 2, but the input layer currently allows choices=[0, 1, 2] for this variable (process/core/input.py:1915-1917). This introduces a runtime crash vs the prior numeric comparison logic. Either (a) extend the enum to cover the 2 case (and document what it means), (b) tighten input validation to only allow 0/1, or (c) avoid casting here and compare the raw value to the enum members (since IntEnum already compares equal to int). Consider adding a unit test to cover the non-0/1 path so this can’t regress.

Suggested change
i_fw_blkt_shared_coolant = FWBlktCoolantLoopTypes(
fwbs_variables.i_fw_blkt_shared_coolant
)
# Compare the raw value directly to the IntEnum member rather than
# coercing it to FWBlktCoolantLoopTypes. The input layer currently
# permits values beyond the defined enum members, and IntEnum values
# compare equal to ints without raising ValueError for those cases.
i_fw_blkt_shared_coolant = fwbs_variables.i_fw_blkt_shared_coolant

Copilot uses AI. Check for mistakes.
if i_fw_blkt_shared_coolant == FWBlktCoolantLoopTypes.SHARED_LOOP:
# Use FW inlet temp and BB outlet temp
mid_temp = (
fwbs_variables.temp_fw_coolant_in + fwbs_variables.temp_blkt_coolant_out
Expand Down Expand Up @@ -750,7 +765,10 @@ def primary_coolant_properties(self, output: bool):
)

# FW (or FW/BB)
if fwbs_variables.i_fw_blkt_shared_coolant == 1:
if (
fwbs_variables.i_fw_blkt_shared_coolant
== FWBlktCoolantLoopTypes.SEPARATE_LOOPS
):
po.osubhd(self.outfile, "First Wall :")

po.ovarst(
Expand Down Expand Up @@ -782,7 +800,10 @@ def primary_coolant_properties(self, output: bool):
"OP ",
)

if fwbs_variables.i_fw_blkt_shared_coolant == 0:
if (
fwbs_variables.i_fw_blkt_shared_coolant
== FWBlktCoolantLoopTypes.SHARED_LOOP
):
po.ovarre(
self.outfile,
"Outlet Temperature (Celcius)",
Expand All @@ -801,7 +822,10 @@ def primary_coolant_properties(self, output: bool):
)

# BB
if fwbs_variables.i_fw_blkt_shared_coolant == 1:
if (
fwbs_variables.i_fw_blkt_shared_coolant
== FWBlktCoolantLoopTypes.SEPARATE_LOOPS
):
po.osubhd(self.outfile, "Breeding Blanket :")

if fwbs_variables.i_blkt_coolant_type == 1:
Expand Down Expand Up @@ -2073,15 +2097,19 @@ def thermo_hydraulic_model(self, output: bool):
fwbs_variables.i_fw_coolant_type == "Helium"
and fwbs_variables.i_blkt_coolant_type == 2
):
fwbs_variables.i_fw_blkt_shared_coolant = 1
fwbs_variables.i_fw_blkt_shared_coolant = (
FWBlktCoolantLoopTypes.SEPARATE_LOOPS
)
if (
fwbs_variables.i_fw_coolant_type == "Water"
and fwbs_variables.i_blkt_coolant_type == 1
):
fwbs_variables.i_fw_blkt_shared_coolant = 1
fwbs_variables.i_fw_blkt_shared_coolant = (
FWBlktCoolantLoopTypes.SEPARATE_LOOPS
)

# If FW and BB have the same coolant...
if fwbs_variables.i_fw_blkt_shared_coolant == 0:
if fwbs_variables.i_fw_blkt_shared_coolant == FWBlktCoolantLoopTypes.SHARED_LOOP:
# Fraction of heat to be removed by IB/OB FW
if fwbs_variables.i_blkt_dual_coolant == 2:
f_nuc_fwi = (
Expand Down Expand Up @@ -2132,7 +2160,10 @@ def thermo_hydraulic_model(self, output: bool):
) * fwbs_variables.temp_fw_coolant_in
inlet_tempo = fwoutleto

elif fwbs_variables.i_fw_blkt_shared_coolant == 1:
elif (
fwbs_variables.i_fw_blkt_shared_coolant
== FWBlktCoolantLoopTypes.SEPARATE_LOOPS
):
fwoutleti = fwbs_variables.temp_fw_coolant_out
inlet_tempi = fwbs_variables.temp_blkt_coolant_in
fwoutleto = fwbs_variables.temp_fw_coolant_out
Expand Down Expand Up @@ -2316,7 +2347,7 @@ def thermo_hydraulic_model(self, output: bool):

# Pumping Power
# If FW and BB have the same coolant...
if fwbs_variables.i_fw_blkt_shared_coolant == 0:
if fwbs_variables.i_fw_blkt_shared_coolant == FWBlktCoolantLoopTypes.SHARED_LOOP:
# Total pressure drop in the first wall/blanket (Pa)
if i_p_coolant_pumping == PumpingPowerModelTypes.MECHANICAL:
if fwbs_variables.i_blkt_inboard == 1:
Expand Down Expand Up @@ -2351,7 +2382,10 @@ def thermo_hydraulic_model(self, output: bool):
)

# If FW and BB have different coolants...
elif fwbs_variables.i_fw_blkt_shared_coolant == 1:
elif (
fwbs_variables.i_fw_blkt_shared_coolant
== FWBlktCoolantLoopTypes.SEPARATE_LOOPS
):
if i_p_coolant_pumping == PumpingPowerModelTypes.MECHANICAL:
# Total pressure drop in the first wall (Pa)
deltap_fw = deltap_fwi + deltap_fwo
Expand Down Expand Up @@ -2508,7 +2542,10 @@ def thermo_hydraulic_model(self, output: bool):
"(pres_fw_coolant)",
fwbs_variables.pres_fw_coolant,
)
if fwbs_variables.i_fw_blkt_shared_coolant == 1:
if (
fwbs_variables.i_fw_blkt_shared_coolant
== FWBlktCoolantLoopTypes.SEPARATE_LOOPS
):
po.ovarre(
self.outfile,
"First wall coolant mass flow rate (kg/s)",
Expand Down Expand Up @@ -2562,7 +2599,10 @@ def thermo_hydraulic_model(self, output: bool):
"(pres_blkt_coolant)",
fwbs_variables.pres_blkt_coolant,
)
if fwbs_variables.i_fw_blkt_shared_coolant == 1:
if (
fwbs_variables.i_fw_blkt_shared_coolant
== FWBlktCoolantLoopTypes.SEPARATE_LOOPS
):
po.ovarre(
self.outfile,
"Blanket coolant mass flow rate (kg/s)",
Expand All @@ -2572,7 +2612,10 @@ def thermo_hydraulic_model(self, output: bool):
)

# Total primary coolant mass flow rate (if they are the same coolant)
if fwbs_variables.i_fw_blkt_shared_coolant == 0:
if (
fwbs_variables.i_fw_blkt_shared_coolant
== FWBlktCoolantLoopTypes.SHARED_LOOP
):
po.ovarre(
self.outfile,
"Total (FW+BB) primary coolant mass flow rate(kg/s)",
Expand Down Expand Up @@ -2628,7 +2671,10 @@ def thermo_hydraulic_model(self, output: bool):
# Pumping Power
po.osubhd(self.outfile, "Mechanical pumping power: ")

if fwbs_variables.i_fw_blkt_shared_coolant == 1:
if (
fwbs_variables.i_fw_blkt_shared_coolant
== FWBlktCoolantLoopTypes.SEPARATE_LOOPS
):
po.ovarre(
self.outfile,
"Mechanical pumping power for FW (MW)",
Expand Down
Loading