Skip to content

Commit

Permalink
Merge 4274aec into 571e4f5
Browse files Browse the repository at this point in the history
  • Loading branch information
Nebbychadnezzar committed Feb 7, 2024
2 parents 571e4f5 + 4274aec commit 47e8a94
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 3 deletions.
9 changes: 6 additions & 3 deletions armi/nuclearDataIO/cccc/nhflux.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,11 @@ def readWrite(self):
# Read the hex ordering map between DIF3D nodal and DIF3D GEODST. Also read index
# pointers to incoming partial currents on outer reactor surface (these don't
# belong to any assembly). Incoming partial currents are non-zero due to flux
# extrapolation
self._rwGeodstCoordMap2D()
# extrapolation. This record is only required when nSurf is greater than 1. It
# is equal to 1 for VARSRC files, which are a subset of NHFLUX files; VARSRC files
# do not have a 2D record (or 4D or 5D records).
if self._metadata["nSurf"] > 1:
self._rwGeodstCoordMap2D()

# Number of energy groups
ng = self._metadata["ngroup"]
Expand Down Expand Up @@ -318,7 +321,7 @@ def readWrite(self):
self._data.fluxMomentsAll[:, z, :, gEff]
)

# Process currents
# Process currents, but only if iwnhfl is not equal to 1
if self._metadata["iwnhfl"] != 1:
# Loop through axial nodes
for z in range(nz):
Expand Down
54 changes: 54 additions & 0 deletions armi/nuclearDataIO/cccc/tests/test_nhflux.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,3 +191,57 @@ def test_write(self):
actualData = f2.read()
for expected, actual in zip(expectedData, actualData):
self.assertEqual(expected, actual)


class TestNhfluxVariantVarsrc(unittest.TestCase):
@classmethod
def setUpClass(cls):
"""
Load NHFLUX data from binary file. This file was produced using VARIANT v11.0
and is identical to the file used in TestNhfluxVariant.
"""
cls.nhf = nhflux.NhfluxStreamVariant.readBinary(SIMPLE_HEXZ_NHFLUX_VARIANT)

# Make the data structure match the format for VARSRC
cls.nhf.metadata["nSurf"] = 1
cls.nhf.metadata["iwnhfl"] = 1
cls.emptyDatasets = [
"incomingPointersToAllAssemblies",
"externalCurrentPointers",
"geodstCoordMap",
"outgoingPCSymSecPointers",
"ingoingPCSymSecPointers",
"partialCurrentsHexAll",
"partialCurrentsHex_extAll",
"partialCurrentsZAll",
]
for zeroDataset in cls.emptyDatasets:
setattr(cls.nhf, zeroDataset, np.array([]))

def test_writeRead(self):
"""
Write out the modified data structure to file. Then, we read it back in and make
sure it matches the data currently in memory.
"""
filename = "VARSRC"
with TemporaryDirectoryChanger():
nhflux.NhfluxStreamVariant.writeBinary(self.nhf, filename)
writtenVarsrc = nhflux.NhfluxStreamVariant.readBinary(filename)

# Make sure the metadata matches
self.assertEqual(len(writtenVarsrc.metadata), len(self.nhf.metadata))
for key in writtenVarsrc.metadata:
self.assertEqual(writtenVarsrc.metadata[key], self.nhf.metadata[key])

# Make sure that the flux moments match identically
self.assertTrue(
np.isclose(
writtenVarsrc.fluxMoments, self.nhf.fluxMoments, rtol=0.0, atol=0.0
).all()
)

# Make sure all other datasets are empty, since the reader should not be trying
# to populate them.
for zeroDataset in self.emptyDatasets:
dataset = getattr(self.nhf, zeroDataset)
self.assertEqual(dataset.shape, (0,))

0 comments on commit 47e8a94

Please sign in to comment.