Skip to content

Commit

Permalink
Merge 5cca38f into 7bd160d
Browse files Browse the repository at this point in the history
  • Loading branch information
onufer committed Aug 25, 2022
2 parents 7bd160d + 5cca38f commit a153055
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 72 deletions.
2 changes: 1 addition & 1 deletion armi/materials/zr.py
Expand Up @@ -130,7 +130,7 @@ def linearExpansionPercent(self, Tk=None, Tc=None):
Tk = getTk(Tc, Tk)
self.checkPropertyTempRange("linear expansion percent", Tk)

if Tk >= 291.62 and Tk < 1137:
if Tk >= 293 and Tk < 1137:
return (
-0.111 + (2.325e-4 * Tk) + (5.595e-7 * Tk ** 2) - (1.768e-10 * Tk ** 3)
)
Expand Down
4 changes: 0 additions & 4 deletions armi/reactor/blueprints/tests/test_blockBlueprints.py
Expand Up @@ -321,9 +321,6 @@ def test_explicitFlags(self):

# TODO: This test passes, but shouldn't.
def test_densityConsistentWithComponentConstructor(self):
# when comparing to 3D density, the comparison is not quite correct.
# We need a bigger delta, this will be investigated/fixed in another PR
biggerDelta = 0.001 # g/cc
a1 = self.blueprints.assemDesigns.bySpecifier["IC"].construct(
self.cs, self.blueprints
)
Expand All @@ -336,7 +333,6 @@ def test_densityConsistentWithComponentConstructor(self):
self.assertAlmostEqual(
clad.getMassDensity(),
clad.material.density3(Tc=clad.temperatureInC),
delta=biggerDelta,
)

self.assertAlmostEqual(
Expand Down
46 changes: 21 additions & 25 deletions armi/reactor/components/component.py
Expand Up @@ -232,27 +232,11 @@ def __init__(
self.temperatureInC = Thot
self.material = None
self.setProperties(material)
self.tInputWarning(Tinput)
self.applyMaterialMassFracsToNumberDensities() # not necessary when duplicating...
self.setType(name)
self.p.mergeWith = mergeWith
self.p.customIsotopicsName = isotopics

def tInputWarning(self, Tinput):
"""
Check whether thermal expansion factor is 0.0% exactly at T=Tinput
"""
expansionFactor = (
self.material.linearExpansionPercent(Tc=self.inputTemperatureInC) / 100.0
)
if not (abs(expansionFactor) < 1.0e-6):
runLog.warning(
f"Thermal expansion for {self.material} at Tinput = {Tinput} is non-zero "
f"({expansionFactor}). The modeled density for this material will be off "
f"by a factor of {(1 + expansionFactor) ** 2}.",
single=True,
)

@property
def temperatureInC(self):
"""Return the hot temperature in Celsius."""
Expand Down Expand Up @@ -360,14 +344,15 @@ def applyMaterialMassFracsToNumberDensities(self):
"""
# note, that this is not the actual material density, but rather 2D expanded
# `density3` is 3D density
# call getProperty to cache and improve speed
density = self.material.getProperty("density", Tc=self.temperatureInC)

self.p.numberDensities = densityTools.getNDensFromMasses(
density, self.material.p.massFrac
)
self.applyHotHeightDensityReduction()
self.applyHotHeightDensityReduction(initialColdMaterialExpansion=True)

def applyHotHeightDensityReduction(self):
def applyHotHeightDensityReduction(self, initialColdMaterialExpansion=False):
"""
Adjust number densities to account for hot block heights (axial expansion)
(crucial for preserving 3D density).
Expand All @@ -382,13 +367,24 @@ def applyHotHeightDensityReduction(self):
--------
self.applyMaterialMassFracsToNumberDensities
"""
# this is the same as getThermalExpansionFactor but doesn't fail
# on non-fluid materials that have 0 or undefined thermal expansion
# (we don't want materials to fail on __init__ which calls this)
axialExpansionFactor = 1.0 + self.material.linearExpansionFactor(
self.temperatureInC, self.inputTemperatureInC
)
self.changeNDensByFactor(1.0 / axialExpansionFactor)
if initialColdMaterialExpansion:
# material needs to be expanded from the material's cold temp to hot,
# not components cold temp, so we don't use mat.linearExpansionFactor or
# component.getThermalExpansionFactor.
# materials don't typically define the temperature for which their ref dens
# is defined so linearExpansionPercent must be called
coldMatAxialExpansionFactor = (
1.0 + self.material.linearExpansionPercent(Tc=self.temperatureInC) / 100
)
self.changeNDensByFactor(1.0 / coldMatAxialExpansionFactor)
else:
# this is the same as getThermalExpansionFactor but doesn't fail
# on non-fluid materials that have 0 or undefined thermal expansion
# (we don't want materials to fail on __init__ which calls this)
# axialExpansionFactor = 1.0 + self.material.linearExpansionFactor(
# self.temperatureInC, self.inputTemperatureInC
# )
self.changeNDensByFactor(1.0 / self.getThermalExpansionFactor())

def getProperties(self):
"""Return the active Material object defining thermo-mechanical properties."""
Expand Down
22 changes: 10 additions & 12 deletions armi/reactor/tests/test_components.py
Expand Up @@ -499,9 +499,9 @@ def test_changeNumberDensities(self):
class TestComponentExpansion(unittest.TestCase):
# when comparing to 3D density, the comparison is not quite correct.
# We need a bigger delta, this will be investigated/fixed in another PR
biggerDelta = 0.01 # g/cc
tWarm = 50
tHot = 500
coldOuterDiameter = 1.0

def test_ExpansionConservationHotHeightDefined(self):
"""
Expand All @@ -513,9 +513,9 @@ def test_ExpansionConservationHotHeightDefined(self):
inputHeightsConsideredHot = True (the default)
"""
hotHeight = 1.0
coldOuterDiameter = 1.0
circle1 = Circle("circle", "HT9", 20, self.tWarm, coldOuterDiameter)
circle2 = Circle("circle", "HT9", 20, self.tHot, coldOuterDiameter)

circle1 = Circle("circle", "HT9", 20, self.tWarm, self.coldOuterDiameter)
circle2 = Circle("circle", "HT9", 20, self.tHot, self.coldOuterDiameter)

# mass density is proportional to Fe number density and derived from
# all the number densities and atomic masses
Expand Down Expand Up @@ -547,15 +547,16 @@ def test_ExpansionConservationHotHeightDefined(self):
circle.getMassDensity(),
circle.material.density(Tc=circle.temperatureInC),
)
# 2D density is off by the thermal exp factor
# 2D density is off by the material thermal exp factor
percent = circle.material.linearExpansionPercent(Tc=circle.temperatureInC)
thermalExpansionFactorFromColdMatTemp = 1 + percent / 100
self.assertAlmostEqual(
circle.getMassDensity() * circle.getThermalExpansionFactor(),
circle.getMassDensity() * thermalExpansionFactorFromColdMatTemp,
circle.material.density(Tc=circle.temperatureInC),
)
self.assertAlmostEqual(
circle.getMassDensity(),
circle.material.density3(Tc=circle.temperatureInC),
delta=self.biggerDelta,
)
# Change temp forward and backward and show equal
oldArea = circle1.getArea()
Expand Down Expand Up @@ -604,7 +605,6 @@ def test_ExpansionConservationHotHeightDefined(self):
self.assertAlmostEqual(
circle1.getMassDensity(),
circle1.material.density3(Tc=circle2.temperatureInC),
delta=self.biggerDelta,
)
# change back to old temp
circle1.changeNDensByFactor(circle1.getThermalExpansionFactor())
Expand All @@ -628,8 +628,8 @@ def test_ExpansionConservationColdHeightDefined(self):
inputHeightsConsideredHot = False
"""
coldHeight = 1.0
circle1 = Circle("circle", "HT9", 20, self.tWarm, 1.0)
circle2 = Circle("circle", "HT9", 20, self.tHot, 1.0)
circle1 = Circle("circle", "HT9", 20, self.tWarm, self.coldOuterDiameter)
circle2 = Circle("circle", "HT9", 20, self.tHot, self.coldOuterDiameter)
# same as 1 but we will make like 2
circle1AdjustTo2 = Circle("circle", "HT9", 20, self.tWarm, 1.0)

Expand All @@ -650,7 +650,6 @@ def test_ExpansionConservationColdHeightDefined(self):
self.assertAlmostEqual(
circle.getMassDensity(),
circle.material.density3(Tc=circle.temperatureInC),
delta=self.biggerDelta,
)
# total mass consistent between hot and cold
# Hot height will be taller
Expand All @@ -660,7 +659,6 @@ def test_ExpansionConservationColdHeightDefined(self):
* circle.getArea(cold=True)
* circle.material.density3(Tc=circle.inputTemperatureInC),
hotHeight * circle.getArea() * circle.getMassDensity(),
delta=self.biggerDelta,
)


Expand Down

0 comments on commit a153055

Please sign in to comment.