Skip to content

Commit

Permalink
resove #820
Browse files Browse the repository at this point in the history
  • Loading branch information
onufer committed Aug 25, 2022
1 parent 7bd160d commit dcb08df
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 36 deletions.
4 changes: 0 additions & 4 deletions armi/reactor/blueprints/tests/test_blockBlueprints.py
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
11 changes: 4 additions & 7 deletions armi/reactor/tests/test_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,6 @@ 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

Expand Down Expand Up @@ -547,15 +546,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 +604,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 Down Expand Up @@ -650,7 +649,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 +658,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 dcb08df

Please sign in to comment.