Skip to content

Commit

Permalink
Adding test crumbs to nuclearDataIO (#1512)
Browse files Browse the repository at this point in the history
  • Loading branch information
john-science authored Dec 1, 2023
1 parent d3b5bd5 commit fffb48e
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 2 deletions.
35 changes: 35 additions & 0 deletions armi/nuclearDataIO/cccc/tests/test_isotxs.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.
"""Tests the workings of the library wrappers."""
import filecmp
import unittest

from armi import nuclearDataIO
from armi.nucDirectory import nuclideBases
from armi.nuclearDataIO import xsLibraries
from armi.nuclearDataIO.cccc import isotxs
from armi.tests import ISOAA_PATH
from armi.utils.directoryChangers import TemporaryDirectoryChanger


class TestIsotxs(unittest.TestCase):
Expand All @@ -30,6 +32,33 @@ def setUpClass(cls):
# be a small library with LFPs, Actinides, structure, and coolant
cls.lib = isotxs.readBinary(ISOAA_PATH)

def test_writeBinary(self):
"""Test reading in an ISOTXS file, and then writing it back out again.
Now, the library here can't guarantee the output will be the same as the
input. But we can guarantee the written file is still valid, by reading
it again.
.. test:: Write ISOTSX binary files.
:id: T_ARMI_NUCDATA_ISOTXS0
:tests: R_ARMI_NUCDATA_ISOTXS
"""
with TemporaryDirectoryChanger():
origLib = isotxs.readBinary(ISOAA_PATH)

fname = self._testMethodName + "temp-aa.isotxs"
isotxs.writeBinary(origLib, fname)
lib = isotxs.readBinary(fname)

# validate the written file is still valid
nucs = lib.nuclides
self.assertTrue(nucs)
self.assertIn("AA", lib.xsIDs)
nuc = lib["U235AA"]
self.assertIsNotNone(nuc)
with self.assertRaises(KeyError):
lib.getNuclide("nonexistent", "zz")

def test_isotxsGeneralData(self):
nucs = self.lib.nuclides
self.assertTrue(nucs)
Expand Down Expand Up @@ -164,6 +193,12 @@ def test_getGAMISOFileName(self):

class Isotxs_merge_Tests(unittest.TestCase):
def test_mergeMccV2FilesRemovesTheFileWideChi(self):
"""Test merging ISOTXS files.
.. test:: Read ISOTXS files.
:id: T_ARMI_NUCDATA_ISOTXS1
:tests: R_ARMI_NUCDATA_ISOTXS
"""
isoaa = isotxs.readBinary(ISOAA_PATH)
self.assertAlmostEqual(1.0, sum(isoaa.isotxsMetadata["chi"]), 5)
self.assertAlmostEqual(1, isoaa.isotxsMetadata["fileWideChiFlag"])
Expand Down
7 changes: 6 additions & 1 deletion armi/nuclearDataIO/cccc/tests/test_pmatrx.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,12 @@ class TestProductionMatrix_FromWritten(TestPmatrx):
"""

def test_writtenIsIdenticalToOriginal(self):
"""Make sure our writer produces something identical to the original."""
"""Make sure our writer produces something identical to the original.
.. test:: Test reading and writing PMATRIX files.
:id: T_ARMI_NUCDATA_PMATRX
:tests: R_ARMI_NUCDATA_PMATRX
"""
origLib = pmatrx.readBinary(test_xsLibraries.PMATRX_AA)

fname = self._testMethodName + "temp-aa.pmatrx"
Expand Down
6 changes: 6 additions & 0 deletions armi/nuclearDataIO/tests/test_xsCollections.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ def test_plotNucXs(self):
self.assertTrue(os.path.exists(fName))

def test_createMacrosFromMicros(self):
"""Test calculating macroscopic cross sections from microscopic cross sections.
.. test:: Compute macroscopic cross sections from microscopic cross sections and number densities.
:id: T_ARMI_NUCDATA_MACRO
:tests: R_ARMI_NUCDATA_MACRO
"""
self.assertEqual(self.mc.minimumNuclideDensity, 1e-13)
self.mc.createMacrosFromMicros(self.microLib, self.block)
totalMacroFissionXs = 0.0
Expand Down
1 change: 0 additions & 1 deletion armi/nuclearDataIO/xsCollections.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,6 @@ def createMacrosFromMicros(
-------
macros : xsCollection.XSCollection
A new XSCollection full of macroscopic cross sections
"""
runLog.debug("Building macroscopic cross sections for {0}".format(block))
if nucNames is None:
Expand Down
4 changes: 4 additions & 0 deletions armi/reactor/converters/tests/test_axialExpansionChanger.py
Original file line number Diff line number Diff line change
Expand Up @@ -857,6 +857,10 @@ def test_coldAssemblyExpansion(self):
:id: T_ARMI_ASSEM_HEIGHT_PRES
:tests: R_ARMI_ASSEM_HEIGHT_PRES
.. test:: Axial expansion can be prescribed in blueprints for core constuction.
:id: T_ARMI_INP_COLD_HEIGHT
:tests: R_ARMI_INP_COLD_HEIGHT
Notes
-----
Two assertions here:
Expand Down

0 comments on commit fffb48e

Please sign in to comment.