Skip to content

Commit

Permalink
Refactoring Material to not subclass Composite (#1062)
Browse files Browse the repository at this point in the history
This PR refactors the Material class to no longer be a subclass of Composite.

It also removes (most, not all) of the statefulness in ARMI Materials. For instance, I removed all Parameters from Material. Some of those I copied over to a simpler class attribute (mat.p.massFrac became mat.massFrac). And some I was able to delete entirely (like yieldStrength and atomFracDenom).

Also, I should note that three parameters (uFrac, puFrac, and zrFrac) applied only to FUEL materials, but were defined by default for all materials. That was fixed.

Stateful things I haven't removed in this PR (because they are going to be tricky):

* ARMI supports Custom materials, which are obviously stateful by design.
* ARMI supports custom isotopics for fuels, which again is a stateful idea.
* The Material class still has a self.parent, which is necessary for a whole LOAD of logic to do with Material.getNuclides().
  • Loading branch information
john-science committed Jan 24, 2023
1 parent 4bed3e8 commit 4699c86
Show file tree
Hide file tree
Showing 55 changed files with 378 additions and 378 deletions.
6 changes: 2 additions & 4 deletions armi/materials/air.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,10 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from armi.utils import units

"""Simple air material"""

from armi.materials import material
from armi.utils.units import getTk
from armi.utils.units import getTk, G_PER_CM3_TO_KG_PER_M3


class Air(material.Fluid):
Expand Down Expand Up @@ -86,7 +84,7 @@ def density(
self.checkPropertyTempRange("density", Tk)
inv_Tk = 1.0 / getTk(Tc, Tk)
rho_kgPerM3 = 1.15675e03 * inv_Tk ** 2 + 3.43413e02 * inv_Tk + 2.99731e-03
return rho_kgPerM3 / units.G_PER_CM3_TO_KG_PER_M3
return rho_kgPerM3 / G_PER_CM3_TO_KG_PER_M3

def specificVolumeLiquid(self, Tk=None, Tc=None):
"""
Expand Down
2 changes: 1 addition & 1 deletion armi/materials/alloy200.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,4 @@ def setDefaultMassFracs(self):
nickleMassFrac -= assumedMassFrac

self.setMassFrac("NI", nickleMassFrac)
self.p.refDens = 8.9
self.refDens = 8.9
16 changes: 7 additions & 9 deletions armi/materials/b4c.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
# limitations under the License.

"""Boron carbide; a very typical reactor control material."""
from armi import runLog
from armi.materials import material
from armi.nucDirectory import nuclideBases
from armi import runLog
from armi.utils.units import getTc

DEFAULT_THEORETICAL_DENSITY_FRAC = 0.90
Expand All @@ -25,7 +25,6 @@
class B4C(material.Material):
name = "B4C"
enrichedNuclide = "B10"

propertyValidTemperature = {"linear expansion percent": ((25, 500), "C")}

def applyInputParams(
Expand All @@ -51,8 +50,8 @@ def applyInputParams(
if TD_frac is not None:
self.updateTD(TD_frac)

def updateTD(self, TD: float) -> None:
self.p.theoreticalDensityFrac = TD
def updateTD(self, td: float) -> None:
self.theoreticalDensityFrac = td
self.clearCache()

def setNewMassFracsFromMassEnrich(self, massEnrichment):
Expand Down Expand Up @@ -127,7 +126,6 @@ def setDefaultMassFracs(self) -> None:
total=55.2547 g.
Mass fractions are computed from this.
"""
massEnrich = self.getMassEnrichmentFromNumEnrich(naturalB10NumberFraction=0.199)

Expand All @@ -137,10 +135,10 @@ def setDefaultMassFracs(self) -> None:
self.setMassFrac("B10", gBoron10)
self.setMassFrac("B11", gBoron11)
self.setMassFrac("C", gCarbon)
self.p.refDens = DEFAULT_MASS_DENSITY
self.refDens = DEFAULT_MASS_DENSITY
# TD reference : Dunner, Heuvel, "Absorber Materials for control rod systems of fast breeder reactors"
# Journal of nuclear materials, 124, 185-194, (1984)."
self.p.theoreticalDensityFrac = (
self.theoreticalDensityFrac = (
DEFAULT_THEORETICAL_DENSITY_FRAC # normally is around 0.88-93.
)

Expand All @@ -165,7 +163,7 @@ def density(self, Tk: float = None, Tc: float = None) -> float:
-----
- applies theoretical density of B4C to parent method
"""
return material.Material.density(self, Tk, Tc) * self.p.theoreticalDensityFrac
return material.Material.density(self, Tk, Tc) * self.theoreticalDensityFrac

def density3(self, Tk: float = None, Tc: float = None) -> float:
"""
Expand All @@ -175,7 +173,7 @@ def density3(self, Tk: float = None, Tc: float = None) -> float:
-----
- applies theoretical density of B4C to parent method
"""
return material.Material.density3(self, Tk, Tc) * self.p.theoreticalDensityFrac
return material.Material.density3(self, Tk, Tc) * self.theoreticalDensityFrac

def linearExpansionPercent(self, Tk: float = None, Tc: float = None) -> float:
"""Boron carbide expansion. Very preliminary"""
Expand Down
3 changes: 1 addition & 2 deletions armi/materials/be9.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ class Be9(Material):

def setDefaultMassFracs(self):
self.setMassFrac("BE9", 1.0)

self.p.refDens = 1.85
self.refDens = 1.85

def linearExpansionPercent(self, Tk=None, Tc=None):
r"""
Expand Down
1 change: 0 additions & 1 deletion armi/materials/californium.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
"""

from armi.materials.material import SimpleSolid
from armi.utils import densityTools


class Californium(SimpleSolid):
Expand Down
6 changes: 3 additions & 3 deletions armi/materials/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def __init__(self):
by a constant user-input density.
"""
Material.__init__(self)
self.p.density = 1.0
self.customDensity = 1.0

def density(self, Tk=None, Tc=None):
r"""
Expand All @@ -50,10 +50,10 @@ def density(self, Tk=None, Tc=None):
CustomLocation materials), so the missing density warning will appear no matter
what.
"""
return self.p.density
return self.customDensity

def setMassFrac(self, *args, **kwargs):
if self.p.density == 1.0:
if self.customDensity == 1.0:
raise ValueError(
"Cannot set mass fractions on Custom materials unless a density "
"is defined."
Expand Down
2 changes: 1 addition & 1 deletion armi/materials/graphite.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def setDefaultMassFracs(self):
Room temperature density from [INL-EXT-16-38241]_, table 2.
"""
self.setMassFrac("C", 1.0)
self.p.refDens = 1.8888
self.refDens = 1.8888

def linearExpansionPercent(self, Tk=None, Tc=None):
"""
Expand Down
11 changes: 6 additions & 5 deletions armi/materials/hastelloyN.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
Hastelloy-N is a high-nickel structural material invented by ORNL for handling molten fluoride salts.
"""

from armi.utils.units import getTk, getTc
from armi.materials.material import Material
from armi.utils.units import getTk, getTc


class HastelloyN(Material):
Expand Down Expand Up @@ -46,6 +46,8 @@ class HastelloyN(Material):
"thermal expansion": ((293.15, 1173.15), "K"),
}

refTempK = 293.15

def setDefaultMassFracs(self):
r"""
Hastelloy N mass fractions
Expand All @@ -64,10 +66,9 @@ def setDefaultMassFracs(self):
self.setMassFrac("W", 0.005) # max.
self.setMassFrac("AL", 0.0025) # max.
self.setMassFrac("TI", 0.0025) # max.
self.setMassFrac("NI", 1.0 - sum(self.p.massFrac.values())) # balance
self.setMassFrac("NI", 1.0 - sum(self.massFrac.values())) # balance

self.p.refTempK = 273.15 + 20
self.p.refDens = 8.86
self.refDens = 8.86

def thermalConductivity(self, Tk=None, Tc=None):
r"""
Expand Down Expand Up @@ -137,7 +138,7 @@ def linearExpansionPercent(self, Tk=None, Tc=None):
%dLL(T) in m/m/K
"""
Tc = getTc(Tc, Tk)
refTempC = getTc(Tk=self.p.refTempK)
refTempC = getTc(Tk=self.refTempK)
return 100.0 * self.meanCoefficientThermalExpansion(Tc=Tc) * (Tc - refTempC)

def meanCoefficientThermalExpansion(self, Tk=None, Tc=None):
Expand Down
4 changes: 2 additions & 2 deletions armi/materials/ht9.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ def setDefaultMassFracs(self):
self.setMassFrac("MO", 0.01)
self.setMassFrac("W", 0.0055)
self.setMassFrac("V", 0.0030)
self.setMassFrac("FE", 1.0 - sum(self.p.massFrac.values()))
self.setMassFrac("FE", 1.0 - sum(self.massFrac.values()))

self.p.refDens = 7.778
self.refDens = 7.778

def linearExpansionPercent(self, Tk=None, Tc=None):
"""
Expand Down
6 changes: 3 additions & 3 deletions armi/materials/inconel600.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ class Inconel600(Material):
"linear expansion percent": "http://www.specialmetals.com/documents/Inconel%20alloy%20600.pdf",
"linear expansion": "http://www.specialmetals.com/documents/Inconel%20alloy%20600.pdf",
}
refTempK = 294.15

def __init__(self):
Material.__init__(self)
self.p.refTempK = 294.15
self.p.refDens = 8.47 # g/cc
self.refDens = 8.47 # g/cc
# Only density measurement presented in the reference.
# Presumed to be performed at 21C since this was the reference temperature for linear expansion measurements.

Expand Down Expand Up @@ -156,7 +156,7 @@ def polyfitLinearExpansionPercent(self, power=2):
-------
list of length 'power' containing the polynomial fit coefficients for linearExpansionPercent
"""
refTempC = getTc(None, Tk=self.p.refTempK)
refTempC = getTc(None, Tk=self.refTempK)
Tc = [100.0, 200.0, 300.0, 400.0, 500.0, 600.0, 700.0, 800.0, 900.0]
alpha_mean = [
1.33e-05,
Expand Down
8 changes: 4 additions & 4 deletions armi/materials/inconel625.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
"""
import numpy

from armi.utils.units import getTc
from armi.materials.material import Material
from armi.utils.units import getTc


class Inconel625(Material):
Expand All @@ -37,11 +37,11 @@ class Inconel625(Material):
"thermalConductivity": "http://www.specialmetals.com/assets/documents/alloys/inconel/inconel-alloy-625.pdf",
"specific heat": "http://www.specialmetals.com/assets/documents/alloys/inconel/inconel-alloy-625.pdf",
}
refTempK = 294.15

def __init__(self):
Material.__init__(self)
self.p.refTempK = 294.15
self.p.refDens = 8.44 # g/cc
self.refDens = 8.44 # g/cc
# Only density measurement presented in the reference.
# Presumed to be performed at 21C since this was the reference temperature for linear expansion measurements.

Expand Down Expand Up @@ -185,7 +185,7 @@ def polyfitLinearExpansionPercent(self, power=2):
-------
list of length 'power' containing the polynomial fit coefficients for linearExpansionPercent
"""
refTempC = getTc(None, Tk=self.p.refTempK)
refTempC = getTc(None, Tk=self.refTempK)
Tc = [93.0, 204.0, 316.0, 427.0, 538.0, 649.0, 760.0, 871.0, 927.0]
alpha_mean = [
1.28e-05,
Expand Down
13 changes: 5 additions & 8 deletions armi/materials/inconel800.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

"""Incoloy 800"""

from armi.utils.units import getTc
from armi.materials.material import Material
from armi.utils.units import getTc


class Inconel800(Material):
Expand All @@ -26,8 +26,8 @@ class Inconel800(Material):
(https://www.specialmetals.com/assets/smc/documents/alloys/incoloy/incoloy-alloy-800.pdf)
"""
name = "Inconel800"

propertyValidTemperature = {"thermal expansion": ((20.0, 800.0), "C")}
refTempK = 294.15

def setDefaultMassFracs(self):
r"""
Expand All @@ -44,12 +44,9 @@ def setDefaultMassFracs(self):
self.setMassFrac("CU", 0.0075) # max.
self.setMassFrac("AL", 0.00375) # ave.
self.setMassFrac("TI", 0.00375) # ave.
self.setMassFrac(
"FE", 1.0 - sum(self.p.massFrac.values())
) # balance, 0.395 min.
self.setMassFrac("FE", 1.0 - sum(self.massFrac.values())) # balance, 0.395 min.

self.p.refTempK = 273.15 + 21.0
self.p.refDens = 7.94
self.refDens = 7.94

def linearExpansionPercent(self, Tk=None, Tc=None):
r"""
Expand All @@ -67,7 +64,7 @@ def linearExpansionPercent(self, Tk=None, Tc=None):
%dLL(T) in m/m/K
"""
Tc = getTc(Tc, Tk)
refTempC = getTc(Tk=self.p.refTempK)
refTempC = getTc(Tk=self.refTempK)
return 100.0 * self.meanCoefficientThermalExpansion(Tc=Tc) * (Tc - refTempC)

def meanCoefficientThermalExpansion(self, Tk=None, Tc=None):
Expand Down
3 changes: 2 additions & 1 deletion armi/materials/inconelPE16.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
Inconel PE16
"""

from armi import runLog
from armi.materials.material import SimpleSolid
from armi.nucDirectory import nuclideBases
from armi import runLog


class InconelPE16(SimpleSolid):
Expand Down Expand Up @@ -62,5 +62,6 @@ def density3(self, Tk=None, Tc=None):
runLog.warning(
"PE16 mass density is not temperature dependent, using room temperature value",
single=True,
label="InconelPE16 density3",
)
return 8.00
6 changes: 3 additions & 3 deletions armi/materials/inconelX750.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ class InconelX750(Material):
"linearExpansionPercent": "http://www.specialmetals.com/documents/Inconel%20alloy%20X-750.pdf",
"linearExpansion": "http://www.specialmetals.com/documents/Inconel%20alloy%20X-750.pdf",
}
refTempK = 294.15

def __init__(self):
Material.__init__(self)
self.p.refTempK = 294.15
self.p.refDens = 8.28 # g/cc
self.refDens = 8.28 # g/cc
# Only density measurement presented in the reference.
# Presumed to be performed at 21C since this was the reference temperature for linear expansion measurements.

Expand Down Expand Up @@ -188,7 +188,7 @@ def polyfitLinearExpansionPercent(self, power=2):
-------
list of length 'power' containing the polynomial fit coefficients for linearExpansionPercent
"""
refTempC = getTc(None, Tk=self.p.refTempK)
refTempC = getTc(None, Tk=self.refTempK)
Tc = [93.3, 204.4, 315.6, 426.7, 537.8, 648.9, 760.0, 871.1, 982.2]
alpha_mean = [
1.260e-05,
Expand Down
2 changes: 1 addition & 1 deletion armi/materials/lead.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
Lead
"""

from armi.utils.units import getTk
from armi.materials import material
from armi.utils.units import getTk


class Lead(material.Fluid):
Expand Down
2 changes: 1 addition & 1 deletion armi/materials/leadBismuth.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@

import math

from armi.utils.units import getTk
from armi.materials import material
from armi.utils.units import getTk


class LeadBismuth(material.Fluid):
Expand Down
8 changes: 4 additions & 4 deletions armi/materials/lithium.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,14 @@ def applyInputParams(self, LI_wt_frac=None, LI6_wt_frac=None, *args, **kwargs):
"The 'LI_wt_frac' material modification for Lithium will be deprecated"
" Update your inputs to use 'LI6_wt_frac' instead.",
single=True,
label="Lithium applyInputParams 1",
)
if LI6_wt_frac is not None:
runLog.warning(
"Both 'LI_wt_frac' and 'LI6_wt_frac' are specified "
f"for {self}. 'LI6_wt_frac' will be used.",
single=True,
label="Lithium applyInputParams 2",
)

LI6_wt_frac = LI6_wt_frac or LI_wt_frac
Expand All @@ -52,7 +54,7 @@ def applyInputParams(self, LI_wt_frac=None, LI6_wt_frac=None, *args, **kwargs):

def density(self, Tk=None, Tc=None):
r"""
Wikipedia.
Wikipedia
Will be liquid above 180C.
"""
Expand All @@ -69,9 +71,7 @@ def boilingPoint(self):
return 1615.0 # K

def thermalConductivity(self, Tk=None, Tc=None):
r"""
Wikipedia
"""
r"""Wikipedia"""
return 84.8 # W/m-K

def heatCapacity(self, Tk=None, Tc=None):
Expand Down
Loading

0 comments on commit 4699c86

Please sign in to comment.