Skip to content

Commit

Permalink
Merge 8d3de41 into f9c6cfa
Browse files Browse the repository at this point in the history
  • Loading branch information
albeanth authored Apr 21, 2022
2 parents f9c6cfa + 8d3de41 commit 4b8cc31
Show file tree
Hide file tree
Showing 8 changed files with 1,298 additions and 473 deletions.
46 changes: 46 additions & 0 deletions armi/materials/fakeMaterial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
"""fake test materials for unit tests in armi.reactor.converters.tests.test_axialExpansionChanger"""
from armi.materials.ht9 import HT9
from armi.utils import units


class Fake(HT9): # pylint: disable=abstract-method
"""Fake material used to verify armi.reactor.converters.axialExpansionChanger
Notes
-----
- specifically used armi.reactor.converters.tests.test_axialExpansionChanger.py:TestAxialExpansionHeight
to verify axialExpansionChanger produces expected heights from hand calculation
- also used to verify mass and height conservation resulting from even amounts of expansion
and contraction. See armi.reactor.converters.tests.test_axialExpansionChanger.py:TestConservation
"""

name = "Fake"

def __init__(self):
HT9.__init__(self)

def linearExpansionPercent(self, Tk=None, Tc=None):
""" A fake linear expansion percent"""
Tc = units.getTc(Tc, Tk)
return 0.02 * Tc


class FakeException(HT9): # pylint: disable=abstract-method
"""Fake material used to verify armi.reactor.converters.tests.test_axialExpansionChanger.py:TestExceptions
Notes
-----
- the only difference between this and `class Fake(HT9)` above is that the thermal expansion factor
is higher to ensure that a negative block height is caught in
armi.reactor.converters.tests.test_axialExpansionChanger.py:TestExceptions:test_AssemblyAxialExpansionException.
"""

name = "FakeException"

def __init__(self):
HT9.__init__(self)

def linearExpansionPercent(self, Tk=None, Tc=None):
""" A fake linear expansion percent"""
Tc = units.getTc(Tc, Tk)
return 0.08 * Tc
94 changes: 0 additions & 94 deletions armi/reactor/assemblies.py
Original file line number Diff line number Diff line change
Expand Up @@ -1196,100 +1196,6 @@ def countBlocksWithFlags(self, blockTypeSpec=None):
"""
return len(self.getBlocks(blockTypeSpec))

def axiallyExpandBlockHeights(self, heightList, nucNamesToConserveMass):
"""
Takes a list of new fuel block heights and then scales the fuel blocks to the
new heights, adjusting densities to preserve mass
Adjusts the height of the lowest plenum block to keep total assembly height
constant.
Parameters
----------
heightList : list of floats
Entry 0 represents the height (in cm) of the bottom fuel block closest to
the grid plate Entry n represents the height (in cm) of the top fuel block
closest to the plenum
nucNamesToConserveMass : list
The nuclides to conserve mass of
See Also
--------
axiallyExpand : expands blocks uniformly. could be combined.
"""
if self.countBlocksWithFlags(Flags.FUEL) != len(heightList):
raise RuntimeError(
"number of blocks {} and len of height list {} not equal in "
"assembly {}. Cannot axially expand".format(
self.countBlocksWithFlags(Flags.FUEL), len(heightList), self
)
)

initialHeight = self.getHeight()

cumulativeHeightAdded = 0.0
for b, newHeight in zip(self.getBlocks(Flags.FUEL), heightList):
originalHeight = b.getHeight()
b.setHeight(newHeight, conserveMass=True, adjustList=nucNamesToConserveMass)
cumulativeHeightAdded += newHeight - originalHeight

# shrink/grow plenum accordingly to keep T/H parameters, etc. consistent.
plenumBlocks = self.getBlocks(Flags.PLENUM)
if not plenumBlocks:
runLog.warning(
"No plenum blocks found in {0}. Axial expansion is modifying the "
"total assembly height and volume.".format(self)
)
# Alter assembly number density to account conserve attoms during volume
# change.
# This is analogous to what happens to component/block number density
# during `armi.reactor.blocks.Block.adjustDensity`, which gets called when
# block heights change.
if self.p.detailedNDens is not None:
self.p.detailedNDens *= initialHeight / (
initialHeight + cumulativeHeightAdded
)
else:
plenumBlock = plenumBlocks[-1] # adjust the top plenum block
plenumHeight = plenumBlock.getHeight()
if cumulativeHeightAdded < plenumHeight:
plenumBlock.setHeight(plenumHeight - cumulativeHeightAdded)
else:
raise RuntimeError(
"Cannot subtract {0} cm from plenum block "
"that is only {1} tall.".format(cumulativeHeightAdded, plenumHeight)
)

def axiallyExpand(self, percent, adjustList):
"""
Axially expands an entire assembly.
Parameters
----------
percent : float
Number from 0 to 100 to make this assembly grow by that much.
If you pass a negative number, the code will actually shrink the assembly by
that percent.
adjustList : list
Nuclides to modify. Omit things like sodium to let it flow.
See Also
--------
axiallyExpandBlockHeights : allows non-uniform expansions. Does the work.
"""
growFrac = percent / 100.0
fuelBlockHeights = []
for b in self.getBlocks(Flags.FUEL):
heightOriginal = b.getHeight()
if growFrac > 0:
fuelBlockHeights.append(heightOriginal * (1.0 + growFrac))
else:
# NOTICE THE SIGN SWITCH! SINCE WE GAVE NEGATIVE NUMBER AS AN INDICATOR!
fuelBlockHeights.append(heightOriginal * (1.0 / (1.0 - growFrac)))

self.axiallyExpandBlockHeights(fuelBlockHeights, adjustList)

def getDim(self, typeSpec, dimName):
"""
Search through blocks in this assembly and find the first component of compName.
Expand Down
Loading

0 comments on commit 4b8cc31

Please sign in to comment.