-
Notifications
You must be signed in to change notification settings - Fork 93
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
Make application of material modifications more robust against incorrect types #2046
base: main
Are you sure you want to change the base?
Conversation
I like the change. But what I would REALLY like is a two test cases, one that hit each version of this exception. Just to be clear about what we expect each type of input to do. Is that too much work? |
Yes, definitely. I actually thought I wrote some tests here, but I don't seem them in my local copy... I guess I was probably just doing one-off testing. Yes, I will write some tests. |
@john-science I added a unit test to the PR that catches the new scenario where the specified material modification is of the wrong type. Specifically, it catches this part: The other part (where the error message would have resulted from a material modification with the wrong name being applied to a component) is already going to be caught by an existing test: armi/armi/reactor/blueprints/tests/test_materialModifications.py Lines 302 to 348 in ee691ab
So I think that this PR is good to go, but me know what you think. |
What is the change?
This PR adds a deeper interrogation of the error conditions that come up during the application of material modifications. The intention is to catch when the user may have specified a material modification of the wrong type in their blueprints, which before would have been silently ignored.
Why is the change being made?
I came across an instance in my own work where a material modification of the wrong type was being specified. This was a bug that had been in my model for multiple years, and I was surprised to find that ARMI did not seem to care to warn me.
The root of this problem is the way that the material modifications infrastructure is designed. Material modifications are applied during the construction of components here:
armi/armi/reactor/blueprints/componentBlueprint.py
Lines 367 to 375 in 1920ff0
As can be seen above, the whole thing is wrapped in a
try/except
, with the only error condition being checked aValueError
. The assumption with that code is that theValueError
will only be triggered when a material modification with an invalid name is passed to the material'sapplyInputParams()
method. That is a very bold assumption, as basically anything could go wrong during the execution ofapplyInputParams()
, includingValueError
s that are indicative of real bugs.As a concrete example, let's look at the material modifications within
UraniumOxide
:https://github.com/terrapower/armi/blob/main/armi/materials/uraniumOxide.py#L109-L132
That material will take
U235_wt_frac
andTD_frac
, both of which should befloat
s. But from my yaml blueprints file it would be entirely possible for me to specify astr
. This would obviously breakUraniumOxide.applyInputParams()
, which would raise aValueError
. However when thatValueError
is raised, thetry/except
aroundapplyInputParams()
will justpass
and the material modification is left at its default value. This would be a bug.Checklist
doc
folder.pyproject.toml
.