Skip to content

Commit

Permalink
Adding units to Material methods that lack them. (#1356)
Browse files Browse the repository at this point in the history
  • Loading branch information
john-science authored Jul 21, 2023
1 parent dac6979 commit 56762e2
Showing 1 changed file with 28 additions and 31 deletions.
59 changes: 28 additions & 31 deletions armi/materials/material.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,43 +400,44 @@ def volumetricExpansion(self, Tk=None, Tc=None):
pass

def getTemperatureAtDensity(
self, targetDensity: float, temperatureGuessInC: float
self, targetDensity: float, tempGuessInC: float
) -> float:
"""Get the temperature at which the perturbed density occurs."""
"""Get the temperature at which the perturbed density occurs (in Celcius)."""
# 0 at tempertature of targetDensity
densFunc = lambda temp: self.density(Tc=temp) - targetDensity
# is a numpy array if fsolve is called
tAtTargetDensity = float(fsolve(densFunc, temperatureGuessInC))
tAtTargetDensity = float(fsolve(densFunc, tempGuessInC))
return tAtTargetDensity

@property
def liquidPorosity(self) -> float:
"""Fraction of the material that is liquid void (unitless)."""
return 0.0 if self.parent is None else self.parent.liquidPorosity

@property
def gasPorosity(self) -> float:
"""Fraction of the material that is gas void (unitless)."""
return 0.0 if self.parent is None else self.parent.gasPorosity

def pseudoDensity(self, Tk: float = None, Tc: float = None) -> float:
"""
Return density that preserves mass when thermally expanded in 2D.
Return density that preserves mass when thermally expanded in 2D (in g/cm^3).
Warning
-------
This density will not agree with the component density since this method only expands in 2 dimensions.
The component has been manually expanded axially with the manually entered block hot height.
The density returned by this should be a factor of 1 + dLL higher than the density on the component.
density should be in agreement at both cold and hot temperatures as long as the block height is correct for
the specified temperature.
In the case of Fluids, density and density are the same as density is not driven by linear expansion, but
rather an explicit density function dependent on Temperature. linearExpansionPercent is zero for a fluid.
This will not typically agree with ``Material.density()`` or ``Component.density()``
since this method only expands in 2 dimensions. Depending on your use of
``inputHeightsConsideredHot`` and ``Component.temperatureInC``, ``Material.psuedoDensity()``
may be a factor of (1+dLL) different than ``Material.density()`` or ``Component.density()``.
In the case of fluids, density and pseudoDensity are the same as density is not driven by
linear expansion, but rather an explicit density function dependent on temperature.
``Material.linearExpansionPercent()`` is zero for a fluid.
See Also
--------
armi.materials.density:
component density should be in agreement with this density
armi.reactor.blueprints._applyBlockDesign:
2D expansion and axial density reduction occurs here.
density
armi.reactor.components.component.Component.density
"""
Tk = getTk(Tc, Tk)
dLL = self.linearExpansionPercent(Tk=Tk)
Expand All @@ -449,22 +450,22 @@ def pseudoDensity(self, Tk: float = None, Tc: float = None) -> float:
self.refDens = 0.0

f = (1.0 + dLL / 100.0) ** 2
return self.refDens / f # g/cm^3
return self.refDens / f

def pseudoDensityKgM3(self, Tk: float = None, Tc: float = None) -> float:
"""
Return density that preserves mass when thermally expanded in 2D in units of kg/m^3.
See Also
--------
armi.materials.density:
density:
Arguments are forwarded to the g/cc version
"""
return self.pseudoDensity(Tk, Tc) * 1000.0

def density(self, Tk: float = None, Tc: float = None) -> float:
"""
Return density that preserves mass when thermally expanded in 3D.
Return density that preserves mass when thermally expanded in 3D (in g/cm^3).
Notes
-----
Expand Down Expand Up @@ -492,21 +493,21 @@ def densityKgM3(self, Tk: float = None, Tc: float = None) -> float:
See Also
--------
armi.materials.density:
density:
Arguments are forwarded to the g/cc version
"""
return self.density(Tk, Tc) * 1000.0

def getCorrosionRate(self, Tk: float = None, Tc: float = None) -> float:
"""Given a temperature, get the corrosion rate of the material."""
"""Given a temperature, get the corrosion rate of the material (in microns/year)."""
return 0.0

def yieldStrength(self, Tk: float = None, Tc: float = None) -> float:
"""Returns yield strength at given T in MPa."""
pass

def thermalConductivity(self, Tk: float = None, Tc: float = None) -> float:
"""Thermal conductivity in given T in K."""
"""Thermal conductivity for given T (in units of W/m/K)."""
pass

def getProperty(
Expand Down Expand Up @@ -674,19 +675,14 @@ def getTempChangeForDensityChange(
deltaT = linearChange / linearExpansion
if not quiet:
runLog.info(
"The linear expansion for {} at initial temperature of {} C is {}.\nA change in density of {} "
"percent at would require a change in temperature of {} C.".format(
self.getName(),
Tc,
linearExpansion,
(densityFrac - 1.0) * 100.0,
deltaT,
),
f"The linear expansion for {self.getName()} at initial temperature of {Tc} C is {linearExpansion}.\n"
f"A change in density of {(densityFrac - 1.0) * 100.0} percent at would require a change in temperature of {deltaT} C.",
single=True,
)
return deltaT

def heatCapacity(self, Tk=None, Tc=None):
"""Returns heat capacity in units of J/kg/C."""
raise NotImplementedError(
f"Material {type(self).__name__} does not implement heatCapacity"
)
Expand Down Expand Up @@ -738,7 +734,7 @@ def getTempChangeForDensityChange(

def density(self, Tk=None, Tc=None):
"""
Return the density at the specified temperature for 3D expansion.
Return the density at the specified temperature for 3D expansion (in g/cm^3).
Notes
-----
Expand Down Expand Up @@ -795,12 +791,13 @@ def linearExpansionPercent(self, Tk: float = None, Tc: float = None) -> float:
return 100 * ((density1 / density2) ** (1.0 / 3.0) - 1)

def density(self, Tk: float = None, Tc: float = None) -> float:
"""Material density (in g/cm^3)."""
return 0.0

def pseudoDensity(self, Tk: float = None, Tc: float = None) -> float:
"""
The same method as the parent class, but with the ability to apply a
non-unity theoretical density.
non-unity theoretical density (in g/cm^3).
"""
return Material.pseudoDensity(self, Tk=Tk, Tc=Tc) * self.getTD()

Expand Down

0 comments on commit 56762e2

Please sign in to comment.