-
Notifications
You must be signed in to change notification settings - Fork 90
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
Updates for pin-related functionality #1990
base: main
Are you sure you want to change the base?
Changes from 23 commits
76e36f3
80b673e
cf7ea6c
87a1c2a
6b69a6b
7041ee4
33ec45b
98c13f5
567253f
eda57f5
29f5878
07e0e7f
67ced79
9072ba1
829b40b
7c32499
5319cb7
1408ac6
fd4e9ff
f7bf4a5
ac34e2b
0e2659e
ba0acf3
9f7a1e0
937057c
e657ce9
fe246d9
bb03ca2
1f869aa
fb66716
9f7168d
0cacf6c
df62010
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,7 @@ | |
import re | ||
|
||
import numpy as np | ||
from typing import Optional | ||
|
||
from armi import materials | ||
from armi import runLog | ||
|
@@ -31,6 +32,7 @@ | |
from armi.nucDirectory import nuclideBases | ||
from armi.reactor import composites | ||
from armi.reactor import flags | ||
from armi.reactor import grids | ||
from armi.reactor import parameters | ||
from armi.reactor.components import componentParameters | ||
from armi.utils import densityTools | ||
|
@@ -1262,6 +1264,72 @@ def getIntegratedMgFlux(self, adjoint=False, gamma=False): | |
|
||
return pinFluxes[self.p.pinNum - 1] * self.getVolume() | ||
|
||
def getPinMgFluxes( | ||
self, adjoint: Optional[bool] = False, gamma: Optional[bool] = False | ||
) -> np.ndarray: | ||
"""Retrieves the pin multigroup fluxes for the component. | ||
|
||
Parameters | ||
---------- | ||
adjoint : bool, optional | ||
Return adjoint flux instead of real | ||
gamma : bool, optional | ||
Whether to return the neutron flux or the gamma flux. | ||
|
||
Returns | ||
------- | ||
np.ndarray | ||
A ``(N, nGroup)`` array of pin multigroup fluxes, where ``N`` is the | ||
equivalent to the multiplicity of the component (``self.p.mult``) | ||
and ``nGroup`` is the number of energy groups of the flux. | ||
|
||
Raises | ||
------ | ||
ValueError | ||
If the location(s) of the component are not aligned with pin indices | ||
from the block. This would happen if this component is not actually | ||
a pin. | ||
""" | ||
# Get the (i, j, k) location of all pins from the parent block | ||
# FIXME: This should be changed to just using Block.getPinLocations once Drew's PR is merged | ||
indicesAll = [] | ||
for clad in self.parent.getChildrenWithFlags(flags.Flags.CLAD): | ||
if isinstance(clad.spatialLocator, grids.MultiIndexLocation): | ||
indicesAll.extend(clad.spatialLocator.indices) | ||
else: | ||
indicesAll.append(clad.spatialLocator.indices) | ||
john-science marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
# Retrieve the indices of this component | ||
indices = self.spatialLocator.indices | ||
if not isinstance(indices, list): | ||
indices = [indices] | ||
|
||
# Map this component's indices to block's pin indices | ||
getIndex = lambda ind: next( | ||
(i for i, indA in enumerate(indicesAll) if np.all(ind == indA)), | ||
None, | ||
) | ||
indexMap = list(map(getIndex, indices)) | ||
drewj-tp marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if None in indexMap: | ||
msg = f"Failed to retrieve pin indices for component {self}." | ||
runLog.error(msg) | ||
raise ValueError(msg) | ||
|
||
# Get the parameter name we are trying to retrieve | ||
if gamma: | ||
if adjoint: | ||
raise ValueError("Adjoint gamma flux is currently unsupported.") | ||
else: | ||
param = "pinMgFluxesGamma" | ||
else: | ||
if adjoint: | ||
param = "pinMgFluxesAdj" | ||
else: | ||
param = "pinMgFluxes" | ||
|
||
# Return pin fluxes | ||
return self.parent.p.get(param)[indexMap] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the parameter try:
return self.parent.p.get(param)[indexMap]
except Exception as ee:
msg = f"Failure getting {param} from {self} via parent {self.parent}"
runLog.error(msg)
runLog.error(ee)
raise ValueError(msg) from ee or just allowing the raised exception to pass up, replacing the |
||
|
||
def density(self) -> float: | ||
"""Returns the mass density of the object in g/cc.""" | ||
density = composites.Composite.density(self) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did we check with the users of this to ensure that this doesn't need to be configurable? Specifically for pin performance evaluations? @sammiller11235?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. We were told that, for now, we are only concerned with fuel and control assemblies.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prior to this we only got fuel.