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

composite.getReactionRates() doesn't work on the core level #1754

Closed
keckler opened this issue Jun 27, 2024 · 2 comments · Fixed by #1771
Closed

composite.getReactionRates() doesn't work on the core level #1754

keckler opened this issue Jun 27, 2024 · 2 comments · Fixed by #1771
Assignees
Labels
bug Something is wrong: Highest Priority

Comments

@keckler
Copy link
Member

keckler commented Jun 27, 2024

Something appears to be wrong with this method:

def getReactionRates(self, nucName, nDensity=None):
"""
Get the reaction rates of a certain nuclide on this object.
Parameters
----------
nucName : str
nuclide name -- e.g. 'U235'
nDensity : float
number Density
Returns
-------
rxnRates : dict
reaction rates (1/s) for nG, nF, n2n, nA and nP
Notes
-----
This is volume integrated NOT (1/cm3-s)
If you set nDensity to 1 this makes 1-group cross section generation easier
"""
rxnRates = {"nG": 0, "nF": 0, "n2n": 0, "nA": 0, "nP": 0, "n3n": 0}
# not all composite objects are iterable (i.e. components), so in that
# case just examine only the object itself
for armiObject in self.getChildren() or [self]:
for rxName, val in armiObject._getReactionRates(
nucName, nDensity=nDensity
).items():
rxnRates[rxName] += val
return rxnRates

I recently loaded up a database and tried to examine some reaction rates as follows:

>  r.core.getReactionRates("U235")
Loading microscopic cross section library `ISOTXS`
 {'nG': 0, 'nF': 0, 'n2n': 0, 'nA': 0, 'nP': 0, 'n3n': 0}

> r.core.getAssemblyWithStringLocation('002-001').getReactionRates("U235")
{'nG': 4.219163274625927e+16,
 'nF': 1.5933660772471552e+17,
 'n2n': 86100493155576.52,
 'nA': 0.0,
 'nP': 0.0,
 'n3n': 0}

>  r.core.getAssemblyWithStringLocation('002-001').getReactionRates("U238")
{'nG': 1.3747239159395538e+17,
 'nF': 2.0985393232144132e+16,
 'n2n': 706063666454843.1,
 'nA': 0.0,
 'nP': 0.0,
 'n3n': 0}

It doesn't make sense that the returned reaction rates for the core as a whole are zero, but non-zero values are returned for individual assemblies from the same core.

@john-science john-science added the bug Something is wrong: Highest Priority label Jun 27, 2024
@john-science
Copy link
Member

john-science commented Jul 3, 2024

Okay, it looks to me like Composite.getReactionRates() calls Composite._getReactionRates(), which assumes you are lower than the Core in the hierarchy:

return getReactionRateDict(
nucName,
self.getAncestorWithFlags(Flags.CORE).lib,
self.getAncestor(lambda x: isinstance(x, Block)).getMicroSuffix(),

It expects the Core to be an ancestor (parent or above), and when you pass it a Core object it just falls through this exception here:

except AttributeError:
runLog.warning(
f"Object {self} does not belong to a core and so has no reaction rates.",

And that returns all zeros.

@keckler
Copy link
Member Author

keckler commented Jul 3, 2024

I agree with your assessment.

Another thing to put on your radar, in case we want to guard against it. I have seen that some blueprints name their assemblies something like Inner core fuel. This automagically gives the assembly the CORE flag. And then the logic that you highlight in your comment above will actually get tripped up, in particular the line

self.getAncestorWithFlags(Flags.CORE).lib

The code will try to get a lib from the assembly object, and obviously it will fail in this. The upshot is that more all-zero dicts are returned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is wrong: Highest Priority
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants