Skip to content

Commit

Permalink
Shortening very long lines in axial expansion
Browse files Browse the repository at this point in the history
  • Loading branch information
john-science committed Jan 30, 2024
1 parent 20af281 commit fcff14f
Showing 1 changed file with 46 additions and 31 deletions.
77 changes: 46 additions & 31 deletions armi/reactor/converters/axialExpansionChanger.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,19 +197,22 @@ def performThermalAxialExpansion(
setFuel: bool = True,
expandFromTinputToThot: bool = False,
):
"""Perform thermal expansion/contraction for an assembly given an axial temperature grid and field.
"""Perform thermal expansion/contraction for an assembly given an axial temperature grid and
field.
.. impl:: Perform thermal expansion/contraction, given an axial temperature distribution over an assembly.
.. impl:: Perform thermal expansion/contraction, given an axial temperature distribution
over an assembly.
:id: I_ARMI_AXIAL_EXP_THERM
:implements: R_ARMI_AXIAL_EXP_THERM
This method performs component-wise thermal expansion for an assembly given a discrete temperature
distribution over the axial length of the Assembly. In ``setAssembly``, the Assembly is prepared
for axial expansion by determining Component-wise axial linkage and checking to see if a dummy Block
is in place (necessary for ensuring conservation properties). The discrete temperature distribution
is then leveraged to update Component temperatures and compute thermal expansion factors
(via ``updateComponentTempsBy1DTempField`` and ``computeThermalExpansionFactors``, respectively).
Finally, the axial expansion is performed in ``axiallyExpandAssembly``.
This method performs component-wise thermal expansion for an assembly given a discrete
temperature distribution over the axial length of the Assembly. In ``setAssembly``, the
Assembly is prepared for axial expansion by determining Component-wise axial linkage and
checking to see if a dummy Block is in place (necessary for ensuring conservation
properties). The discrete temperature distribution is then leveraged to update Component
temperatures and compute thermal expansion factors (via
``updateComponentTempsBy1DTempField`` and ``computeThermalExpansionFactors``,
respectively). Finally, the axial expansion is performed in ``axiallyExpandAssembly``.
Parameters
----------
Expand Down Expand Up @@ -251,10 +254,11 @@ def setAssembly(self, a, setFuel=True, expandFromTinputToThot=False):
Notes
-----
When considering thermal expansion, if there is an axial temperature distribution on the assembly,
the axial expansion methodology will NOT perfectly preseve mass. The magnitude of the gradient of
the temperature distribution is the primary factor in determining the cumulative loss of mass conservation.
Additional details will be documented in :ref:`axialExpansion` of the documentation.
When considering thermal expansion, if there is an axial temperature distribution on the
assembly, the axial expansion methodology will NOT perfectly preseve mass. The magnitude of
the gradient of the temperature distribution is the primary factor in determining the
cumulative loss of mass conservation. Additional details will be documented in
:ref:`axialExpansion` of the documentation.
"""
self.linked = AssemblyAxialLinkage(a)
self.expansionData = ExpansionData(
Expand Down Expand Up @@ -360,7 +364,8 @@ def axiallyExpandAssembly(self):
b.p.z = b.p.zbottom + b.getHeight() / 2.0

_checkBlockHeight(b)
# call component.clearCache to update the component volume, and therefore the masses, of all solid components.
# Call Component.clearCache to update the Component volume, and therefore the masses,
# of all solid components.
for c in getSolidComponents(b):
c.clearCache()
# redo mesh -- functionality based on assembly.calculateZCoords()
Expand Down Expand Up @@ -444,11 +449,13 @@ class AssemblyAxialLinkage:
linkedBlocks : dict
- keys = :py:class:`Block <armi.reactor.blocks.Block>`
- values = list of axially linked blocks; index 0 = lower linked block; index 1: upper linked block.
- values = list of axially linked blocks; index 0 = lower linked block; index 1: upper
linked block.
linkedComponents : dict
- keys = :py:class:`Component <armi.reactor.components.component.Component>`
- values = list of axially linked components; index 0 = lower linked component; index 1: upper linked component.
- values = list of axially linked components; index 0 = lower linked component;
index 1: upper linked component.
See Also
--------
Expand Down Expand Up @@ -549,8 +556,8 @@ def _getLinkedComponents(self, b, c):
errMsg = (
"Multiple component axial linkages have been found for "
f"Component {c}; Block {b}; Assembly {b.parent}."
" This is indicative of an error in the blueprints! Linked components found are"
f"{lstLinkedC[ib]} and {otherC}"
" This is indicative of an error in the blueprints! Linked "
f"components found are {lstLinkedC[ib]} and {otherC}"
)
runLog.error(msg=errMsg)
raise RuntimeError(errMsg)
Expand Down Expand Up @@ -582,9 +589,10 @@ def _determineLinked(componentA, componentB):
Notes
-----
- Requires that shapes have the getCircleInnerDiameter and getBoundingCircleOuterDiameter defined
- For axial linkage to be True, components MUST be solids, the same Component Class, multiplicity, and meet inner
and outer diameter requirements.
- Requires that shapes have the getCircleInnerDiameter and getBoundingCircleOuterDiameter
defined
- For axial linkage to be True, components MUST be solids, the same Component Class,
multiplicity, and meet inner and outer diameter requirements.
- When component dimensions are retrieved, cold=True to ensure that dimensions are evaluated
at cold/input temperatures. At temperature, solid-solid interfaces in ARMI may produce
slight overlaps due to thermal expansion. Handling these potential overlaps are out of scope.
Expand All @@ -602,8 +610,8 @@ def _determineLinked(componentA, componentB):
if isinstance(componentA, UnshapedComponent):
runLog.warning(
f"Components {componentA} and {componentB} are UnshapedComponents "
"and do not have 'getCircleInnerDiameter' or getBoundingCircleOuterDiameter methods; "
"nor is it physical to do so. Instead of crashing and raising an error, "
"and do not have 'getCircleInnerDiameter' or getBoundingCircleOuterDiameter "
"methods; nor is it physical to do so. Instead of crashing and raising an error, "
"they are going to be assumed to not be linked.",
single=True,
)
Expand Down Expand Up @@ -680,12 +688,18 @@ def setExpansionFactors(self, componentLst: List, expFrac: List):
)
raise RuntimeError
if 0.0 in expFrac:
msg = "An expansion fraction, L1/L0, equal to 0.0, is not physical. Expansion fractions should be greater than 0.0."
msg = (
"An expansion fraction, L1/L0, equal to 0.0, is not physical. Expansion fractions "
"should be greater than 0.0."
)
runLog.error(msg)
raise RuntimeError(msg)
for exp in expFrac:
if exp < 0.0:
msg = "A negative expansion fraction, L1/L0, is not physical. Expansion fractions should be greater than 0.0."
msg = (
"A negative expansion fraction, L1/L0, is not physical. Expansion fractions "
"should be greater than 0.0."
)
runLog.error(msg)
raise RuntimeError(msg)
for c, p in zip(componentLst, expFrac):
Expand Down Expand Up @@ -761,17 +775,17 @@ def computeThermalExpansionFactors(self):
for b in self._a:
for c in getSolidComponents(b):
if self.expandFromTinputToThot:
# get thermal expansion factor between c.inputTemperatureInC and c.temperatureInC
# get thermal expansion factor between c.inputTemperatureInC & c.temperatureInC
self._expansionFactors[c] = c.getThermalExpansionFactor()
elif c in self.componentReferenceTemperature:
growFrac = c.getThermalExpansionFactor(
T0=self.componentReferenceTemperature[c]
)
self._expansionFactors[c] = growFrac
else:
# we want expansion factors relative to componentReferenceTemperature not Tinput.
# But for this component there isn't a componentReferenceTemperature,
# so we'll assume that the expansion factor is 1.0.
# We want expansion factors relative to componentReferenceTemperature not
# Tinput. But for this component there isn't a componentReferenceTemperature, so
# we'll assume that the expansion factor is 1.0.
self._expansionFactors[c] = 1.0

def getExpansionFactor(self, c):
Expand Down Expand Up @@ -809,7 +823,8 @@ def _setTargetComponents(self, setFuel):
self.determineTargetComponent(b)

def determineTargetComponent(self, b, flagOfInterest=None):
"""Determines target component, stores it on the block, and appends it to self._componentDeterminesBlockHeight.
"""Determines target component, stores it on the block, and appends it to
self._componentDeterminesBlockHeight.
Parameters
----------
Expand All @@ -832,7 +847,7 @@ def determineTargetComponent(self, b, flagOfInterest=None):
multiple target components found
"""
if flagOfInterest is None:
# Follow expansion of most neutronically important component, fuel first then control/poison
# Follow expansion of most neutronically important component, fuel then control/poison
for targetFlag in TARGET_FLAGS_IN_PREFERRED_ORDER:
componentWFlag = [c for c in b.getChildren() if c.hasFlags(targetFlag)]
if componentWFlag != []:
Expand Down

0 comments on commit fcff14f

Please sign in to comment.