Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raise error in invalid xsTypeNum condition #2042

Merged
merged 3 commits into from
Jan 3, 2025
Merged
Show file tree
Hide file tree
Changes from 2 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
7 changes: 6 additions & 1 deletion armi/physics/neutronics/crossSectionGroupManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def getXSTypeNumberFromLabel(xsTypeLabel: str) -> int:
return int("".join(["{:02d}".format(ord(si)) for si in xsTypeLabel]))


def getXSTypeLabelFromNumber(xsTypeNumber: int) -> int:
def getXSTypeLabelFromNumber(xsTypeNumber: int) -> str:
"""
Convert a XSID label (e.g. 65) to an XS label (e.g. 'A').

Expand All @@ -107,6 +107,11 @@ def getXSTypeLabelFromNumber(xsTypeNumber: int) -> int:
if xsTypeNumber > ord("Z"):
# two digit. Parse
return chr(int(str(xsTypeNumber)[:2])) + chr(int(str(xsTypeNumber)[2:]))
elif xsTypeNumber < ord("A"):
raise ValueError(
f"Cannot convert invalid xsTypeNumber `{xsTypeNumber}` to char "
"The number must be >= 65 (corresponding to 'A')"
john-science marked this conversation as resolved.
Show resolved Hide resolved
)
else:
return chr(xsTypeNumber)
except ValueError:
Expand Down
8 changes: 4 additions & 4 deletions armi/reactor/tests/test_assemblies.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ def setUp(self):
"residence": 4.0,
"smearDensity": 0.6996721711791459,
"timeToLimit": 2.7e5,
"xsTypeNum": 40,
"xsTypeNum": 65,
"zbottom": 97.3521,
"ztop": 111.80279999999999,
}
Expand Down Expand Up @@ -776,9 +776,9 @@ def test_calcTotalParam(self):
# Set the 1st block to have higher params than the rest.
self.blockParamsTemp = {}
for key, val in self.blockParams.items():
b.p[key] = self.blockParamsTemp[key] = (
val * i
) # Iterate with i in self.assemNum, so higher assemNums get the high values.
# Iterate with i in self.assemNum, so higher assemNums get the high values.
if key != "xsTypeNum": # must keep valid
b.p[key] = self.blockParamsTemp[key] = val * i

b.setHeight(self.height)
b.setType("fuel")
Expand Down
4 changes: 2 additions & 2 deletions armi/utils/tests/test_reportPlotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ def test_xsHistoryVsTime(self):
class HistTester:
def __init__(self):
self.xsHistory = {
1: [[0, 1], [0, 2], [0, 3]],
2: [[0, 5], [0, 6], [0, 7]],
65: [[0, 1], [0, 2], [0, 3]],
66: [[0, 5], [0, 6], [0, 7]],
}

history = HistTester()
Expand Down