예제 #1
0
    def test_mergeFailsWithNonIsotxsFiles(self):
        dummyFileName = "ISOSOMEFILE"
        with open(dummyFileName, "w") as someFile:
            someFile.write("hi")

        try:
            with mockRunLogs.BufferLog() as log:
                lib = xsLibraries.IsotxsLibrary()
                with self.assertRaises(OSError):
                    xsLibraries.mergeXSLibrariesInWorkingDirectory(
                        lib, "ISOTXS", "")
                self.assertIn(dummyFileName, log.getStdoutValue())
        finally:
            os.remove(dummyFileName)

        dummyFileName = "ISOtopics.txt"
        with open(dummyFileName, "w") as file:
            file.write(
                "This is a file that starts with the letters 'ISO' but will"
                " break the regular expression search.")

        try:
            with mockRunLogs.BufferLog() as log:
                lib = xsLibraries.IsotxsLibrary()
                xsLibraries.mergeXSLibrariesInWorkingDirectory(lib)
                self.assertIn(
                    f"Ignoring file {dummyFileName} in the merging of ISOXX files",
                    log.getStdoutValue(),
                )
        finally:
            os.remove(dummyFileName)
예제 #2
0
 def test_canRemoveIsotopes(self):
     emptyXSLib = xsLibraries.IsotxsLibrary()
     emptyXSLib.merge(self.libAA)
     self.__class__.libAA = None
     emptyXSLib.merge(self.libAB)
     self.__class__.libAB = None
     for nucId in [
             "ZR93_7",
             "ZR95_7",
             "XE1287",
             "XE1297",
             "XE1307",
             "XE1317",
             "XE1327",
             "XE1337",
             "XE1347",
             "XE1357",
             "XE1367",
     ]:
         nucLabel = nuclideBases.byMccId[nucId].label
         del emptyXSLib[nucLabel + "AA"]
         del emptyXSLib[nucLabel + "AB"]
     self.assertEqual(set(self.libLumped.nuclideLabels),
                      set(emptyXSLib.nuclideLabels))
     self.getWriteFunc()(emptyXSLib, self.testFileName)
     self.assertTrue(filecmp.cmp(self.getLibLumpedPath(),
                                 self.testFileName))
예제 #3
0
파일: pmatrx.py 프로젝트: MattGreav/test
def _read(fileName, fileMode):
    lib = xsLibraries.IsotxsLibrary()
    return _readWrite(
        lib,
        fileName,
        fileMode,
        lambda containerKey: xsNuclides.XSNuclide(lib, containerKey),
    )
예제 #4
0
    def _mergeISOTXS(self):
        """Merge all the ISOTXS files together so that can be run for global flux."""

        # Create an empty ISOTXS library to be filled in with XS data
        lib = xsLibraries.IsotxsLibrary()

        neutronVelocities = xsLibraries.mergeXSLibrariesInWorkingDirectory(lib)
        latticePhysicsInterface.setBlockNeutronVelocities(self.r, neutronVelocities)

        isotxs.writeBinary(lib, neutronics.ISOTXS)
예제 #5
0
 def test_mergeTwoXSLibFiles(self):
     emptyXSLib = xsLibraries.IsotxsLibrary()
     emptyXSLib.merge(self.libAA)
     self.__class__.libAA = None
     emptyXSLib.merge(self.libAB)
     self.__class__.libAB = None
     self.assertEqual(set(self.libCombined.nuclideLabels),
                      set(emptyXSLib.nuclideLabels))
     self.assertTrue(xsLibraries.compare(emptyXSLib, self.libCombined))
     self.getWriteFunc()(emptyXSLib, self.testFileName)
     self.assertTrue(filecmp.cmp(self.getLibAA_ABPath(), self.testFileName))
예제 #6
0
 def setUpClass(cls):
     cls.isotxsAA = isotxs.readBinary(ISOTXS_AA)
     cls.gamisoAA = gamiso.readBinary(GAMISO_AA)
     cls.pmatrxAA = pmatrx.readBinary(PMATRX_AA)
     cls.xsLib = xsLibraries.IsotxsLibrary()
     cls.xsLibGenerationErrorStack = None
     try:
         cls.xsLib.merge(copy.deepcopy(cls.isotxsAA))
         cls.xsLib.merge(copy.deepcopy(cls.gamisoAA))
         cls.xsLib.merge(copy.deepcopy(cls.pmatrxAA))
     except:
         cls.xsLibGenerationErrorStack = traceback.format_exc()
예제 #7
0
 def test_mergeFailsWithNonIsotxsFiles(self):
     dummyFileName = "ISOSOMEFILE"
     with open(dummyFileName, "w") as someFile:
         someFile.write("hi")
     try:
         with mockRunLogs.BufferLog() as log:
             lib = xsLibraries.IsotxsLibrary()
             with self.assertRaises(exceptions.IsotxsError):
                 xsLibraries.mergeXSLibrariesInWorkingDirectory(lib, "ISOTXS", "")
             self.assertTrue(dummyFileName in log.getStdoutValue())
     finally:
         os.remove(dummyFileName)
예제 #8
0
 def test_nuclide_modifyingNuclideAttributesUpdatesTheIsotxsNuclide(self):
     lib = xsLibraries.IsotxsLibrary()
     nuc = nuclideBases.byName["FE"]
     nrAA = xsNuclides.XSNuclide(lib, "FEAA")
     lib["FEAA"] = nrAA
     nrAA.isotxsMetadata["nuclideId"] = nuc.mc2id
     nrAA.updateBaseNuclide()
     self.assertEqual(len(nuc.trans), len(nrAA.trans))
     nuc.trans.append("whatever")
     self.assertEqual(len(nuc.trans), len(nrAA.trans))
     self.assertEqual("whatever", nuc.trans[-1])
     self.assertEqual("whatever", nrAA.trans[-1])
예제 #9
0
 def test_mergeMccV2FilesRemovesTheFileWideChi(self):
     isoaa = isotxs.readBinary(ISOAA_PATH)
     self.assertAlmostEqual(1.0, sum(isoaa.isotxsMetadata["chi"]), 5)
     self.assertAlmostEqual(1, isoaa.isotxsMetadata["fileWideChiFlag"])
     someIsotxs = xsLibraries.IsotxsLibrary()
     # semi-copy...
     someIsotxs.merge(isoaa)
     self.assertAlmostEqual(1.0, sum(someIsotxs.isotxsMetadata["chi"]), 5)
     self.assertEqual(1, someIsotxs.isotxsMetadata["fileWideChiFlag"])
     # OK, now I need to delete all the nuclides, so we can merge again.
     for key in someIsotxs.nuclideLabels:
         del someIsotxs[key]
     someIsotxs.merge(isotxs.readBinary(ISOAA_PATH))
     self.assertEqual(None, someIsotxs.isotxsMetadata["chi"])
예제 #10
0
 def test_cannotMergeXSLibsWithDifferentGammaGroupStructures(self):
     dummyXsLib = xsLibraries.IsotxsLibrary()
     dummyXsLib.gammaEnergyUpperBounds = [1, 2, 3]
     with self.assertRaises(properties.ImmutablePropertyError):
         dummyXsLib.merge(self.libCombined)
예제 #11
0
 def test_mergeEmptyXSLibWithOtherEssentiallyClonesTheOther(self):
     emptyXSLib = xsLibraries.IsotxsLibrary()
     emptyXSLib.merge(self.libAA)
     self.__class__.libAA = None
     self.getWriteFunc()(emptyXSLib, self.testFileName)
     self.assertTrue(filecmp.cmp(self.getLibAAPath(), self.testFileName))
예제 #12
0
파일: test_gamiso.py 프로젝트: ntouran/armi
 def setUp(self):
     self.xsLib = xsLibraries.IsotxsLibrary()