Skip to content

Commit

Permalink
Merge branch 'main' into toasted_panko
Browse files Browse the repository at this point in the history
  • Loading branch information
john-science authored Nov 23, 2023
2 parents 6a00237 + f5681d7 commit a9c75f9
Show file tree
Hide file tree
Showing 7 changed files with 118 additions and 52 deletions.
42 changes: 6 additions & 36 deletions armi/materials/tests/test_materials.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,7 @@ def setUp(self):
self.mat = self.MAT_CLASS()

def test_isPicklable(self):
"""Test that all materials are picklable so we can do MPI communication of state.
.. test:: Test the material base class.
:id: T_ARMI_MAT_PROPERTIES0
:tests: R_ARMI_MAT_PROPERTIES
"""
"""Test that all materials are picklable so we can do MPI communication of state."""
stream = pickle.dumps(self.mat)
mat = pickle.loads(stream)

Expand All @@ -50,21 +45,11 @@ def test_isPicklable(self):
)

def test_density(self):
"""Test that all materials produce a zero density from density.
.. test:: Test the material base class.
:id: T_ARMI_MAT_PROPERTIES1
:tests: R_ARMI_MAT_PROPERTIES
"""
"""Test that all materials produce a zero density from density."""
self.assertNotEqual(self.mat.density(500), 0)

def test_TD(self):
"""Test the material density.
.. test:: Test the material base class.
:id: T_ARMI_MAT_PROPERTIES2
:tests: R_ARMI_MAT_PROPERTIES
"""
"""Test the material density."""
self.assertEqual(self.mat.getTD(), self.mat.theoreticalDensityFrac)

self.mat.clearCache()
Expand Down Expand Up @@ -96,12 +81,7 @@ def test_duplicate(self):
self.assertEqual(mat.theoreticalDensityFrac, self.mat.theoreticalDensityFrac)

def test_cache(self):
"""Test the material cache.
.. test:: Test the material base class.
:id: T_ARMI_MAT_PROPERTIES4
:tests: R_ARMI_MAT_PROPERTIES
"""
"""Test the material cache."""
self.mat.clearCache()
self.assertEqual(len(self.mat.cached), 0)

Expand All @@ -112,23 +92,13 @@ def test_cache(self):
self.assertEqual(val, "Noether")

def test_densityKgM3(self):
"""Test the density for kg/m^3.
.. test:: Test the material base class.
:id: T_ARMI_MAT_PROPERTIES5
:tests: R_ARMI_MAT_PROPERTIES
"""
"""Test the density for kg/m^3."""
dens = self.mat.density(500)
densKgM3 = self.mat.densityKgM3(500)
self.assertEqual(dens * 1000.0, densKgM3)

def test_pseudoDensityKgM3(self):
"""Test the pseudo density for kg/m^3.
.. test:: Test the material base class.
:id: T_ARMI_MAT_PROPERTIES6
:tests: R_ARMI_MAT_PROPERTIES
"""
"""Test the pseudo density for kg/m^3."""
dens = self.mat.pseudoDensity(500)
densKgM3 = self.mat.pseudoDensityKgM3(500)
self.assertEqual(dens * 1000.0, densKgM3)
Expand Down
99 changes: 96 additions & 3 deletions armi/materials/tests/test_uZr.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,109 @@
# limitations under the License.

"""Tests for simplified UZr material."""
import unittest
from unittest import TestCase
import pickle

from armi.materials.tests import test_materials
from armi.materials.uZr import UZr


class UZR_TestCase(test_materials._Material_Test, unittest.TestCase):
class UZR_TestCase(TestCase):

MAT_CLASS = UZr

def setUp(self):
self.mat = self.MAT_CLASS()

def test_isPicklable(self):
"""Test that materials are picklable so we can do MPI communication of state.
.. test:: Test the material base class has temp-dependent thermal conductivity curves.
:id: T_ARMI_MAT_PROPERTIES0
:tests: R_ARMI_MAT_PROPERTIES
"""
stream = pickle.dumps(self.mat)
mat = pickle.loads(stream)

# check a property that is sometimes interpolated.
self.assertEqual(
self.mat.thermalConductivity(500), mat.thermalConductivity(500)
)

def test_TD(self):
"""Test the material theoretical density.
.. test:: Test the material base class has temp-dependent TD curves.
:id: T_ARMI_MAT_PROPERTIES2
:tests: R_ARMI_MAT_PROPERTIES
"""
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):
"""Test the material duplication.
.. test:: Materials shall calc mass fracs at init.
:id: T_ARMI_MAT_FRACS
:tests: R_ARMI_MAT_FRACS
"""
mat = self.mat.duplicate()

self.assertEqual(len(mat.massFrac), len(self.mat.massFrac))
for key in self.mat.massFrac:
self.assertEqual(mat.massFrac[key], self.mat.massFrac[key])

self.assertEqual(mat.parent, self.mat.parent)
self.assertEqual(mat.refDens, self.mat.refDens)
self.assertEqual(mat.theoreticalDensityFrac, self.mat.theoreticalDensityFrac)

def test_cache(self):
"""Test the material cache."""
self.mat.clearCache()
self.assertEqual(len(self.mat.cached), 0)

self.mat._setCache("Emmy", "Noether")
self.assertEqual(len(self.mat.cached), 1)

val = self.mat._getCached("Emmy")
self.assertEqual(val, "Noether")

def test_densityKgM3(self):
"""Test the density for kg/m^3.
.. test:: Test the material base class has temp-dependent density.
:id: T_ARMI_MAT_PROPERTIES5
:tests: R_ARMI_MAT_PROPERTIES
"""
dens = self.mat.density(500)
densKgM3 = self.mat.densityKgM3(500)
self.assertEqual(dens * 1000.0, densKgM3)

def test_pseudoDensityKgM3(self):
"""Test the pseudo density for kg/m^3.
.. test:: Test the material base class has temp-dependent 2D density.
:id: T_ARMI_MAT_PROPERTIES6
:tests: R_ARMI_MAT_PROPERTIES
"""
dens = self.mat.pseudoDensity(500)
densKgM3 = self.mat.pseudoDensityKgM3(500)
self.assertEqual(dens * 1000.0, densKgM3)

def test_density(self):
"""Test that all materials produce a zero density from density.
.. test:: Test the material base class has temp-dependent density.
:id: T_ARMI_MAT_PROPERTIES1
:tests: R_ARMI_MAT_PROPERTIES
"""
self.assertNotEqual(self.mat.density(500), 0)

cur = self.mat.density(400)
ref = 15.94
delta = ref * 0.01
Expand Down
4 changes: 4 additions & 0 deletions armi/reactor/components/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,10 @@ class Component(composites.Composite, metaclass=ComponentType):
:id: I_ARMI_COMP_DEF
:implements: R_ARMI_COMP_DEF
.. impl:: Order components by there outermost diameter (using the < operator).
:id: I_ARMI_COMP_ORDER
:implements: R_ARMI_COMP_ORDER
Attributes
----------
temperatureInC : float
Expand Down
4 changes: 2 additions & 2 deletions armi/reactor/composites.py
Original file line number Diff line number Diff line change
Expand Up @@ -673,8 +673,8 @@ def hasFlags(self, typeID: TypeSpec, exact=False):
Determine if this object is of a certain type.
.. impl:: Flags can be queried.
:id: I_ARMI_CMP_HAS_FLAGS
:implements: R_ARMI_CMP_HAS_FLAGS
:id: I_ARMI_CMP_FLAG
:implements: R_ARMI_CMP_FLAG
.. impl:: Composites have flags
:id: I_ARMI_CMP_FLAG
Expand Down
3 changes: 1 addition & 2 deletions armi/reactor/tests/test_blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ def getComponentData(component):


class TestDetailedNDensUpdate(unittest.TestCase):
def setUp(self):
def test_updateDetailedNdens(self):
from armi.reactor.blueprints.tests.test_blockBlueprints import FULL_BP

cs = settings.Settings()
Expand All @@ -318,7 +318,6 @@ def setUp(self):
a.add(buildSimpleFuelBlock())
self.r.core.add(a)

def test_updateDetailedNdens(self):
# get first block in assembly with 'fuel' key
block = self.r.core[0][0]
# get nuclides in first component in block
Expand Down
12 changes: 4 additions & 8 deletions armi/reactor/tests/test_composites.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,11 @@ def setUp(self):
def test_composite(self):
"""Test basic Composite things.
.. test:: Components are a physical part of the reactor.
.. test:: Composites are a physical part of the reactor.
:id: T_ARMI_CMP0
:tests: R_ARMI_CMP
.. test:: Components are part of a hierarchical model.
.. test:: Composites are part of a hierarchical model.
:id: T_ARMI_CMP_CHILDREN0
:tests: R_ARMI_CMP_CHILDREN
"""
Expand All @@ -136,11 +136,11 @@ def test_iterComponents(self):
def test_getChildren(self):
"""Test the get children method.
.. test:: Components are a physical part of the reactor.
.. test:: Composites are a physical part of the reactor.
:id: T_ARMI_CMP1
:tests: R_ARMI_CMP
.. test:: Components are part of a hierarchical model.
.. test:: Composites are part of a hierarchical model.
:id: T_ARMI_CMP_CHILDREN1
:tests: R_ARMI_CMP_CHILDREN
"""
Expand Down Expand Up @@ -253,10 +253,6 @@ def test_hasFlags(self):
"""Ensure flags are queryable.
.. test:: Flags can be queried.
:id: T_ARMI_CMP_HAS_FLAGS
:tests: R_ARMI_CMP_HAS_FLAGS
.. test:: Composites have flags
:id: T_ARMI_CMP_FLAG
:tests: R_ARMI_CMP_FLAG
"""
Expand Down
6 changes: 5 additions & 1 deletion armi/reactor/tests/test_reactors.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,12 @@ def test_coreSfp(self):
:tests: R_ARMI_R
.. test:: The reactor object includes a core and an SFP.
:id: T_ARMI_R_CHILDREN
:id: T_ARMI_R_CHILDREN1
:tests: R_ARMI_R_CHILDREN
.. test:: Components are a physical part of the reactor.
:id: T_ARMI_CMP2
:tests: R_ARMI_CMP
"""
self.assertTrue(isinstance(self.r.core, reactors.Core))
self.assertTrue(isinstance(self.r.sfp, SpentFuelPool))
Expand Down

0 comments on commit a9c75f9

Please sign in to comment.