diff --git a/armi/materials/tests/test_materials.py b/armi/materials/tests/test_materials.py index c17e33378..d8083e3d6 100644 --- a/armi/materials/tests/test_materials.py +++ b/armi/materials/tests/test_materials.py @@ -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) @@ -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() @@ -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) @@ -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) diff --git a/armi/materials/tests/test_uZr.py b/armi/materials/tests/test_uZr.py index c1ecfaa79..d6072b4f5 100644 --- a/armi/materials/tests/test_uZr.py +++ b/armi/materials/tests/test_uZr.py @@ -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 diff --git a/armi/reactor/components/component.py b/armi/reactor/components/component.py index 36fdac251..50f1e66f8 100644 --- a/armi/reactor/components/component.py +++ b/armi/reactor/components/component.py @@ -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 diff --git a/armi/reactor/composites.py b/armi/reactor/composites.py index 0a4b9124c..55eadbfec 100644 --- a/armi/reactor/composites.py +++ b/armi/reactor/composites.py @@ -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 diff --git a/armi/reactor/tests/test_blocks.py b/armi/reactor/tests/test_blocks.py index ed7ac5506..810a72bcc 100644 --- a/armi/reactor/tests/test_blocks.py +++ b/armi/reactor/tests/test_blocks.py @@ -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() @@ -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 diff --git a/armi/reactor/tests/test_composites.py b/armi/reactor/tests/test_composites.py index a80927d3e..26fccc9a8 100644 --- a/armi/reactor/tests/test_composites.py +++ b/armi/reactor/tests/test_composites.py @@ -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 """ @@ -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 """ @@ -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 """ diff --git a/armi/reactor/tests/test_reactors.py b/armi/reactor/tests/test_reactors.py index c333ff03b..92e7ddde0 100644 --- a/armi/reactor/tests/test_reactors.py +++ b/armi/reactor/tests/test_reactors.py @@ -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))