Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TD_frac updates and consistency #1114

Closed
wants to merge 35 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
7439a46
Lookup nuclides in the ISOTXS based on their nuclide labels
keckler Aug 3, 2022
bf5c629
Add tests on getReactionRates and getReactionRateDict
keckler Aug 3, 2022
8e6d110
Add to the changelog
keckler Aug 3, 2022
3491057
Merge branch 'terrapower:main' into main
keckler Aug 3, 2022
e30afaa
Merge branch 'main' of https://github.com/terrapower/armi
keckler Aug 9, 2022
3008c03
Merge branch 'main' of https://github.com/keckler/armi
keckler Sep 22, 2022
1b28757
Merge branch 'main' of https://github.com/terrapower/armi
keckler Sep 22, 2022
6ce53ae
Merge branch 'terrapower:main' into main
keckler Sep 28, 2022
921a48d
Merge branch 'terrapower:main' into main
keckler Sep 30, 2022
1b006b7
Merge branch 'main' of https://github.com/terrapower/armi
keckler Oct 5, 2022
414b3fd
Merge branch 'main' of https://github.com/keckler/armi
keckler Oct 6, 2022
acf3364
Merge branch 'main' of https://github.com/terrapower/armi
keckler Oct 6, 2022
ea53fb1
Merge branch 'terrapower:main' into main
keckler Oct 17, 2022
615739f
Merge branch 'main' of https://github.com/keckler/armi
keckler Nov 23, 2022
4c82111
Merge branch 'main' of https://github.com/terrapower/armi
keckler Nov 23, 2022
e7657eb
Merge branch 'main' of https://github.com/terrapower/armi
keckler Dec 30, 2022
33e0fbe
Make theoretical density adjustment an inherent part of SimpleSolid a…
keckler Jan 23, 2023
dd7ee23
Propogate changes to MOX, ThO2, and UO2
keckler Jan 23, 2023
70c38dc
Add tests for UO2
keckler Jan 23, 2023
dcfa4a2
Propogate changes to B4C
keckler Jan 23, 2023
dff8896
Test setTD and adjustTD
keckler Jan 23, 2023
7d04398
Merge branch 'main' of https://github.com/terrapower/armi into TD_frac
keckler Jan 23, 2023
4363d69
Update changelog
keckler Jan 23, 2023
6660b2b
Make sure cache is cleared before testing adjustTD
keckler Jan 23, 2023
589d4e1
Revert "Propogate changes to B4C"
keckler Jan 24, 2023
5acedac
Merge branch 'main' of https://github.com/terrapower/armi into TD_frac
keckler Jan 24, 2023
c4799c9
Remove deleted file
keckler Jan 24, 2023
beef32d
Remove comment
keckler Jan 24, 2023
b67d44f
Remove duplicate setting of theoreticalDensityFrac in UraniumOxide
keckler Jan 25, 2023
8d978fe
Remove mat_props mentions in docstring, it is not accurate or useful …
keckler Jan 30, 2023
4be3440
Update Material docstrings related to TD
keckler Jan 30, 2023
5eb1899
Merge branch 'main' into TD_frac
keckler Jan 30, 2023
e045239
Merge branch 'terrapower:main' into main
keckler Jan 31, 2023
b6b9f36
Merge branch 'main' of https://github.com/terrapower/armi
keckler Jan 31, 2023
34285c5
Merge branch 'main' into TD_frac
keckler Jan 31, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 38 additions & 8 deletions armi/materials/material.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,7 @@
"""
Base Material classes.

All temperatures are in K, but Tc can be specified and the functions will convert for you.

.. warning:: ARMI uses these objects for all material properties. Under the hood,
A system called MAT_PROPS is in charge of several material properties. It
is a more industrial-strength material property system that is currently
a TerraPower proprietary system. You will see references to it in this module.

Most temperatures may be specified in either K or C and the functions will convert for you.
"""
# pylint: disable=unused-argument
import copy
Expand All @@ -43,6 +37,26 @@
class Material:
"""
A material is made up of elements or isotopes. It has bulk properties like mass density.

Attributes
----------
parent : Component
The component to which this material belongs
massFrac : dict
Mass fractions for all nuclides in the material keyed on the nuclide symbols
refDens : float
A reference density used by some materials, for instance `SimpleSolid`s,
during thermal expansion
theoreticalDensityFrac : float
Fraction of the material's density in reality, which is commonly different
from 1.0 in solid materials due to the manufacturing process.
Can often be set from the blueprints input via the TD_frac material modification.
For programmatic setting, use `adjustTD()`.

Notes
-----
Specific material classes may have many more attributes specific to the implementation
for that material.
"""

DATA_SOURCE = "ARMI"
Expand Down Expand Up @@ -72,7 +86,7 @@ def __init__(self):
self.parent = None
self.massFrac = {}
self.refDens = 0.0
self.theoreticalDensityFrac = 0.0
self.theoreticalDensityFrac = 1.0
self.cached = {}
self._backupCache = None

Expand Down Expand Up @@ -669,6 +683,15 @@ def heatCapacity(self, Tk=None, Tc=None):
f"Material {type(self).__name__} does not implement heatCapacity"
)

def getTD(self):
"""Get the fraction of theoretical density for this material."""
return self.theoreticalDensityFrac

def adjustTD(self, val):
"""Set or change the fraction of theoretical density for this material."""
self.theoreticalDensityFrac = val
self.clearCache()


class Fluid(Material):
"""A material that fills its container. Could also be a gas."""
Expand Down Expand Up @@ -782,6 +805,13 @@ def linearExpansionPercent(self, Tk: float = None, Tc: float = None) -> float:
def density3(self, Tk: float = None, Tc: float = None) -> float:
return 0.0

def density(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.
"""
return Material.density(self, Tk=Tk, Tc=Tc) * self.getTD()


class FuelMaterial(Material):
"""
Expand Down
2 changes: 0 additions & 2 deletions armi/materials/mox.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ def applyInputParams(
label="Zero theoretical density",
)
self.adjustTD(td)
else:
self.adjustTD(1.00) # default to fully dense.

if mass_frac_PU02 is not None:
self.setMassFracPuO2(mass_frac_PU02)
Expand Down
20 changes: 15 additions & 5 deletions armi/materials/tests/test_materials.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,16 @@ def test_getChildren(self):
def test_getChildrenWithFlags(self):
self.assertEqual(len(self.mat.getChildrenWithFlags("anything")), 0)

def test_TD(self):
self.assertEqual(self.mat.getTD(), self.mat.theoreticalDensityFrac)

self.mat.clearCache()
self.mat._setCache("dummy", 666)
self.assertEqual(self.mat.cached, {"dummy": 666})
self.mat.adjustTD(0.5)
self.assertEqual(0.5, self.mat.theoreticalDensityFrac)
self.assertEqual(self.mat.cached, {})

def test_duplicate(self):
mat = self.mat.duplicate()

Expand Down Expand Up @@ -643,11 +653,6 @@ def test_duplicate(self):
def test_propertyValidTemperature(self):
self.assertGreater(len(self.mat.propertyValidTemperature), 0)

def test_adjustTD(self):
self.assertEqual(self.mat.theoreticalDensityFrac, 1.0)
self.mat.adjustTD(0.123)
self.assertEqual(self.mat.theoreticalDensityFrac, 0.123)


class Thorium_TestCase(_Material_Test, unittest.TestCase):
MAT_CLASS = materials.Thorium
Expand Down Expand Up @@ -695,6 +700,11 @@ def test_density(self):
accuracy = 4
self.assertAlmostEqual(cur, ref, accuracy)

# make sure that material modifications are correctly applied
self.mat.applyInputParams(TD_frac=0.1)
cur = self.mat.density3(Tc=25)
self.assertAlmostEqual(cur, ref * 0.1, accuracy)

def test_linearExpansion(self):
cur = self.mat.linearExpansion(400)
ref = 9.67e-6
Expand Down
50 changes: 50 additions & 0 deletions armi/materials/tests/test_uraniumOxide.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Copyright 2023 TerraPower, LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# 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.

"""
Tests for Uranium Oxide.

Note that more tests for UO2 are in tests/test_materials.py
"""

import unittest

from armi.materials.uraniumOxide import UO2
from armi.materials.tests.test_materials import _Material_Test


class UraniumOxide_TestCase(_Material_Test, unittest.TestCase):
MAT_CLASS = UO2

def setUp(self):
_Material_Test.setUp(self)

def test_applyInputParams(self):
UO2_TD = UO2()
original = UO2_TD.density3(500)
UO2_TD.applyInputParams(TD_frac=0.1)
new = UO2_TD.density3(500)
ratio = new / original
self.assertAlmostEqual(ratio, 0.1)

UO2_TD = UO2()
original = UO2_TD.density(500)
UO2_TD.applyInputParams(TD_frac=0.1)
new = UO2_TD.density(500)
ratio = new / original
self.assertAlmostEqual(ratio, 0.1)


if __name__ == "__main__":
unittest.main()
20 changes: 8 additions & 12 deletions armi/materials/thoriumOxide.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,18 @@
from armi import runLog
from armi.materials.material import FuelMaterial
from armi.utils.units import getTk
from armi.materials.material import Material, FuelMaterial, SimpleSolid


class ThoriumOxide(FuelMaterial):
class ThoriumOxide(FuelMaterial, SimpleSolid):
name = "ThO2"
propertyValidTemperature = {"linear expansion": ((298, 1223), "K")}

def __init__(self):
FuelMaterial.__init__(self)
self.theoreticalDensityFrac = 1.0
self.adjustTD(self.theoreticalDensityFrac)
Material.__init__(self)
self.refDens = 10.00

def adjustTD(self, val):
self.theoreticalDensityFrac = val
self.refDens = 10.00 * val

def getTD(self):
return self.theoreticalDensityFrac

def applyInputParams(self, TD_frac, *args, **kwargs):
def applyInputParams(self, TD_frac=None, *args, **kwargs):
if TD_frac is not None:
if TD_frac > 1.0:
runLog.warning(
Expand Down Expand Up @@ -105,6 +98,9 @@ def meltingPoint(self):
r"""melting point in K from IAEA TE 1450"""
return 3643.0

def density3(self, Tk=None, Tc=None):
return Material.density3(self, Tk, Tc) * self.getTD()


class ThO2(ThoriumOxide):
"""Another name for ThoriumOxide."""
Expand Down
11 changes: 0 additions & 11 deletions armi/materials/uraniumOxide.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ class UraniumOxide(material.FuelMaterial, material.SimpleSolid):
"heat capacity": "ORNL/TM-2000/351",
}

theoreticalDensityFrac = 1.0 # Default value

thermalScatteringLaws = (
tsl.byNbAndCompound[nb.byName["U"], tsl.UO2],
tsl.byNbAndCompound[nb.byName["O"], tsl.UO2],
Expand Down Expand Up @@ -105,15 +103,8 @@ class UraniumOxide(material.FuelMaterial, material.SimpleSolid):

def __init__(self):
material.FuelMaterial.__init__(self)
self.theoreticalDensityFrac = 1.0
self.refDens = self.density3(Tk=self.refTempK)

def adjustTD(self, val: float) -> None:
self.theoreticalDensityFrac = val

def getTD(self) -> float:
return self.theoreticalDensityFrac

def applyInputParams(
self, U235_wt_frac: float = None, TD_frac: float = None, *args, **kwargs
) -> None:
Expand All @@ -136,8 +127,6 @@ def applyInputParams(
label="Zero theoretical density",
)
self.adjustTD(td)
else:
self.adjustTD(1.00) # default to fully dense.

material.FuelMaterial.applyInputParams(self, *args, **kwargs)

Expand Down
1 change: 1 addition & 0 deletions doc/release/0.2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Bug fixes
#. Fixed a bug where the material namespace order for test_axialExpansionChanger.py was persisting beyond the tests. (`PR#1046 https://github.com/terrapower/armi/pull/1046`_)
#. A bug was fixed in `PR#1022 <https://github.com/terrapower/armi/pull/1022>`_ where the gaseous fission products were not being removed from the core directly, but instead the fission yields within the lumped fission products were being adjusted.
#. Fixed a bug where non-fuel depletable components were not being initialized with all nuclides with the ``explicitFissionProducts`` model (`PR#1067 https://github.com/terrapower/armi/pull/1067`_)
#. Fixed a bug in which the TD_frac material modification on UraniumOxide and MOX materials was not being applied correctly in density calculations
#. Bug fix to ensure consistency between cross section group manager and lattice physics interface for tight coupling. (`PR#1118 <https://github.com/terrapower/armi/pull/1118>`_)
#. Bug fix to update pseudo density to physical density in densityTimesHeatCapacity materials method. (`PR#1129 <https://github.com/terrapower/armi/pull/1129>`_)

Expand Down