예제 #1
0
 def test_nuclide_oldLabelsCauseWarnings(self):
     with mockRunLogs.BufferLog() as logCapture:
         self.assertEqual("", logCapture._outputStream.getvalue())
         pu = nuclideBases.byName["PU239"]
         puNuc = xsNuclides.XSNuclide(None, "PLUTAA")
         puNuc.isotxsMetadata["nuclideId"] = pu.mc2id
         puNuc.updateBaseNuclide()
         self.assertEqual(pu, puNuc._base)
         length = len(logCapture._outputStream.getvalue())
         self.assertGreater(length, 15)
         # now get it with a legitmate same label, length shouldn't change
         puNuc = xsNuclides.XSNuclide(None, "PLUTAB")
         puNuc.isotxsMetadata["nuclideId"] = pu.mc2id
         puNuc.updateBaseNuclide()
         self.assertEqual(pu, puNuc._base)
         self.assertEqual(length, len(logCapture._outputStream.getvalue()))
예제 #2
0
파일: pmatrx.py 프로젝트: MattGreav/test
def _read(fileName, fileMode):
    lib = xsLibraries.IsotxsLibrary()
    return _readWrite(
        lib,
        fileName,
        fileMode,
        lambda containerKey: xsNuclides.XSNuclide(lib, containerKey),
    )
예제 #3
0
 def test_nuclide_creatingNuclidesDoesNotMessWithUnderlyingNuclideDict(self):
     nuc = nuclideBases.byName["U238"]
     self.assertFalse(hasattr(nuc, "xsId"))
     nrAA = xsNuclides.XSNuclide(None, "U238AA")
     nrAA.isotxsMetadata["nuclideId"] = nuc.mc2id
     nrAA.updateBaseNuclide()
     self.assertEqual("AA", nrAA.xsId)
     self.assertFalse(hasattr(nuc, "xsId"))
예제 #4
0
 def test_nuclide_newLabelsDontCauseWarnings(self):
     with mockRunLogs.BufferLog() as logCapture:
         self.assertEqual("", logCapture._outputStream.getvalue())
         fe = nuclideBases.byName["FE"]
         feNuc = xsNuclides.XSNuclide(None, "FEAA")
         feNuc.isotxsMetadata["nuclideId"] = fe.getMcc3Id()
         feNuc.updateBaseNuclide()
         self.assertEqual(fe, feNuc._base)
         self.assertEqual("", logCapture._outputStream.getvalue())
예제 #5
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])
예제 #6
0
def addDummyNuclidesToLibrary(lib, dummyNuclides):
    """
    This method adds DUMMY nuclides to the current GAMISO library.

    Parameters
    ----------
    lib : obj
        GAMISO library object

    dummyNuclides: list
        List of DUMMY nuclide objects that will be copied and added to the GAMISO file

    Notes
    -----
    Since MC2-3 does not write DUMMY nuclide information for GAMISO files, this is necessary to provide a
    consistent set of nuclide-level data across all the nuclides in a
    :py:class:`~armi.nuclearDataIO.xsLibraries.XSLibrary`.
    """
    if not dummyNuclides:
        runLog.important(
            "No dummy nuclide data provided to be added to {}".format(lib))
        return False
    elif len(lib.xsIDs) > 1:
        runLog.warning(
            "Cannot add dummy nuclide data to GAMISO library {} containing data for more than 1 XS ID."
            .format(lib))
        return False

    dummyNuclideKeysAddedToLibrary = []
    for dummyNuclide in dummyNuclides:
        dummyKey = dummyNuclide.nucLabel
        if len(lib.xsIDs):
            dummyKey += lib.xsIDs[0]
        if dummyKey in lib:
            continue

        runLog.debug("Adding {} nuclide data to {}".format(dummyKey, lib))
        newDummy = xsNuclides.XSNuclide(lib, dummyKey)

        # Copy gamiso metadata from the isotxs metadata of the given dummy nuclide
        for kk, vv in dummyNuclide.isotxsMetadata.items():
            if kk in ["jj", "jband"]:
                newDummy.gamisoMetadata[kk] = {}
                for mm in vv:
                    newDummy.gamisoMetadata[kk][mm] = 1
            else:
                newDummy.gamisoMetadata[kk] = vv

        lib[dummyKey] = newDummy
        dummyNuclideKeysAddedToLibrary.append(dummyKey)

    return any(dummyNuclideKeysAddedToLibrary)
예제 #7
0
파일: pmatrx.py 프로젝트: MattGreav/test
def addDummyNuclidesToLibrary(lib, dummyNuclides):
    """
    This method adds DUMMY nuclides to the current PMATRX library.

    Parameters
    ----------
    lib : obj
        PMATRX  library object

    dummyNuclides: list
        List of DUMMY nuclide objects that will be copied and added to the PMATRX file

    Notes
    -----
    Since MC2-3 does not write DUMMY nuclide information for PMATRX files, this is necessary to provide a
    consistent set of nuclide-level data across all the nuclides in a
    :py:class:`~armi.nuclearDataIO.xsLibraries.XSLibrary`.
    """
    if not dummyNuclides:
        runLog.important("No dummy nuclide data provided to be added to {}".format(lib))
        return False
    if len(lib.xsIDs) > 1:
        runLog.warning(
            "Cannot add dummy nuclide data to PMATRX library {} containing data for more than 1 XS ID.".format(
                lib
            )
        )
        return False
    dummyNuclideKeysAddedToLibrary = []
    for dummy in dummyNuclides:
        dummyKey = dummy.nucLabel + lib.xsIDs[0]
        if dummyKey in lib:
            continue
        runLog.debug("Adding {} nuclide data to {}".format(dummyKey, lib))
        newDummy = xsNuclides.XSNuclide(lib, dummyKey)
        newDummy.pmatrxMetadata["hasNeutronHeatingAndDamage"] = False
        newDummy.pmatrxMetadata["maxScatteringOrder"] = 0
        newDummy.pmatrxMetadata["hasGammaHeating"] = False
        newDummy.pmatrxMetadata["numberNeutronXS"] = 0
        newDummy.pmatrxMetadata["collapsingRegionNumber"] = 0
        lib[dummyKey] = newDummy
        dummyNuclideKeysAddedToLibrary.append(dummyKey)

    return any(dummyNuclideKeysAddedToLibrary)
예제 #8
0
 def test_nuclide_createFromLabelFailsOnBadName(self):
     nuc = xsNuclides.XSNuclide(None, "BACONAA")
     nuc.isotxsMetadata["nuclideId"] = "BACN87"
     with self.assertRaises(exceptions.IsotxsError):
         nuc.updateBaseNuclide()