def invoke(self): from armi.nuclearDataIO import isotxs from armi.nuclearDataIO import xsLibraries runLog.setVerbosity(0) refIsotxs = isotxs.readBinary(self.args.reference) # flux = read_broad_group_flux(refIsotxs.neutronEnergyGroups) for fname in self.args.comparisonFiles: cmpIsotxs = isotxs.readBinary(fname) xsLibraries.compare(refIsotxs, cmpIsotxs) # , flux)
def invoke(self): from armi.nuclearDataIO import isotxs from armi.nuclearDataIO import xsLibraries runLog.setVerbosity(0) refIsotxs = isotxs.readBinary(self.args.reference) for fname in self.args.comparisonFiles: cmpIsotxs = isotxs.readBinary(fname) xsLibraries.compare(refIsotxs, cmpIsotxs)
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"])
def testMakeTable(self): obj = loadTestBlock() obj.p.mgFlux = range(33) core = obj.getAncestorWithFlags(Flags.CORE) core.lib = isotxs.readBinary(ISOAA_PATH) table = cst.makeReactionRateTable(obj) self.assertEqual(len(table), len(obj.getNuclides()))
def test_mapper(self): # Switch to MC2v2 setting to make sure the isotopic/elemental expansions are compatible # with actually doing some math using the ISOAA test microscopic library _o, r = test_reactors.loadTestReactor( customSettings={"xsKernel": "MC2v2"}) applyDummyFlux(r) r.core.lib = isotxs.readBinary(ISOAA_PATH) mapper = globalFluxInterface.GlobalFluxResultMapper() mapper.r = r mapper._renormalizeNeutronFluxByBlock(100) self.assertAlmostEqual(r.core.calcTotalParam("power", generationNum=2), 100) mapper._updateDerivedParams() self.assertGreater(r.core.p.maxPD, 0.0) self.assertGreater(r.core.p.maxFlux, 0.0) mapper.updateDpaRate() block = r.core.getFirstBlock() self.assertGreater(block.p.detailedDpaRate, 0) self.assertEqual(block.p.detailedDpa, 0) opts = globalFluxInterface.GlobalFluxOptions("test") dosemapper = globalFluxInterface.DoseResultsMapper(1000, opts) dosemapper.apply(r) self.assertGreater(block.p.detailedDpa, 0) mapper.clearFlux() self.assertFalse(block.p.mgFlux)
def setUpClass(cls): random.seed(987324987234) # so it's always the same cls.o, cls.r = test_reactors.loadTestReactor( TEST_ROOT, customSettings={"xsKernel": "MC2v2"}) cls.r.core.lib = isotxs.readBinary(ISOAA_PATH) # make the mesh a little non-uniform a = cls.r.core[4] a[2].setHeight(a[2].getHeight() * 1.05)
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()
""" Plotting a multi-group scatter matrix ===================================== Here we plot scatter matrices from an ISOTXS microscopic cross section library. We plot the inelastic scatter cross section of U235 as well as the (n,2n) source matrix. See Also: :py:mod:`ISOTXS <armi.nuclearDataIO.isotxs>` format. """ import matplotlib.pyplot as plt from armi.utils import units from armi.tests import ISOAA_PATH from armi.nuclearDataIO import isotxs from armi.nuclearDataIO import xsNuclides import armi armi.configure() lib = isotxs.readBinary(ISOAA_PATH) u235 = lib.getNuclide("U235", "AA") xsNuclides.plotScatterMatrix(u235.micros.inelasticScatter, "U-235 inelastic") plt.figure() xsNuclides.plotScatterMatrix(u235.micros.n2nScatter, "U-235 n,2n src")
def ISOTXS(fName="ISOTXS"): # load a library that is in the ARMI tree. This should # be a small library with LFPs, Actinides, structure, and coolant from armi.nuclearDataIO import isotxs return isotxs.readBinary(fName)
def test_compareDifferentComponentsOfAnXSLibrary(self): self.assertTrue(xsLibraries.compare(self.isotxsAA, self.isotxsAA)) self.assertTrue(xsLibraries.compare(self.pmatrxAA, self.pmatrxAA)) aa = isotxs.readBinary(ISOTXS_AA) del aa[aa.nuclideLabels[0]] self.assertFalse(xsLibraries.compare(aa, self.isotxsAA))
def mergeXSLibrariesInWorkingDirectory(lib, xsLibrarySuffix="", mergeGammaLibs=False): """ Merge neutron (ISOTXS) and gamma (GAMISO/PMATRX) library data into the provided library. Parameters ---------- lib : obj ISOTXS library object xsLibrarySuffix : str, optional XS library suffix used to determine which ISOTXS files are merged together, typically something like `-doppler`. If empty string, will merge everything without suffix (indicated by a `-`). mergeGammaLibs : bool, optional If True, the GAMISO and PMATRX files that correspond to the ISOTXS library will be merged. Note: if these files do not exist this will fail. """ from armi import nuclearDataIO from armi.nuclearDataIO import isotxs from armi.nuclearDataIO import gamiso from armi.nuclearDataIO import pmatrx xsLibFiles = getISOTXSLibrariesToMerge( xsLibrarySuffix, [iso for iso in glob.glob(_ISOTXS_EXT + "*")]) librariesToMerge = [] neutronVelocities = { } # Dictionary of neutron velocities from each ISOTXS file for xsLibFilePath in sorted(xsLibFiles): xsID = re.search("ISO([A-Z0-9]{2})", xsLibFilePath).group( 1) # get XS ID from the cross section library name xsFileTypes = "ISOTXS" if not mergeGammaLibs else "ISOTXS, GAMISO, and PMATRX" runLog.info("Retrieving {} data for XS ID {}{}".format( xsFileTypes, xsID, xsLibrarySuffix)) if xsLibFilePath in lib.isotxsMetadata.fileNames: runLog.extra( "Skipping merge of {} because data already exists in the library" .format(xsLibFilePath)) continue neutronLibrary = isotxs.readBinary(xsLibFilePath) neutronVelocities[xsID] = neutronLibrary.neutronVelocity librariesToMerge.append(neutronLibrary) if mergeGammaLibs: dummyNuclides = [ nuc for nuc in neutronLibrary.nuclides if isinstance(nuc._base, nuclideBases.DummyNuclideBase) ] # GAMISO data gamisoLibraryPath = nuclearDataIO.getExpectedGAMISOFileName( xsID=xsID) gammaLibrary = gamiso.readBinary(gamisoLibraryPath) addedDummyData = gamiso.addDummyNuclidesToLibrary( gammaLibrary, dummyNuclides) # Add DUMMY nuclide data not produced by MC2-3 if addedDummyData: gamisoDummyPath = os.path.abspath( os.path.join(os.getcwd(), gamisoLibraryPath)) gamiso.writeBinary(gammaLibrary, gamisoDummyPath) gammaLibraryDummyData = gamiso.readBinary(gamisoDummyPath) librariesToMerge.append(gammaLibraryDummyData) else: librariesToMerge.append(gammaLibrary) # PMATRX data pmatrxLibraryPath = nuclearDataIO.getExpectedPMATRXFileName( xsID=xsID) pmatrxLibrary = pmatrx.readBinary(pmatrxLibraryPath) addedDummyData = pmatrx.addDummyNuclidesToLibrary( pmatrxLibrary, dummyNuclides) # Add DUMMY nuclide data not produced by MC2-3 if addedDummyData: pmatrxDummyPath = os.path.abspath( os.path.join(os.getcwd(), pmatrxLibraryPath)) pmatrx.writeBinary(pmatrxLibrary, pmatrxDummyPath) pmatrxLibraryDummyData = pmatrx.readBinary(pmatrxDummyPath) librariesToMerge.append(pmatrxLibraryDummyData) else: librariesToMerge.append(pmatrxLibrary) for library in librariesToMerge: lib.merge(library) return neutronVelocities
def setUpClass(cls): cls.lib = isotxs.readBinary(ISOAA_PATH)
def test_getReactionRates(self): """ test: getReactionRates getReactionRates """ mgFlux1 = [ 0.0860473241399844, 0.104859413902775, 0.958730499751868, 0.0608613995961131, 0.286847241591555, 0.255889308191141, 0.0116901206385536, 0.713409716738126, 0.430296361167501, 0.807797711781478, 0.0337645123548413, 0.486499349955704, 0.734614285636136, 0.74230952191973, 0.262181249681019, 0.499163237742064, 0.522320530090222, 0.269684933319214, 0.286697941919085, 0.173049285638012, 0.881264543688633, 0.99461769495224, 0.267737005223648, 0.957400117341211, 0.767927939604005, 0.149702253058259, 0.332924880721111, 0.611969570430789, 0.227989279697323, 0.411852641375799, 0.500275641106796, 0.654655431372318, 0.223981131922656, ] lib = isotxs.readBinary(ISOAA_PATH) loc = locations.Location(i1=1, i2=1, axial=1) nDens = 0.02 # arbitrary number density for U235 c = UnshapedVolumetricComponent("testComponent", "Custom", 0.0, 0.0, volume=1) c.setNumberDensity("U235", nDens) b = blocks.Block("testBlock", location=loc) b.add(c) b.p.mgFlux = mgFlux1[:33] b.p.xsType = "A" a = assemblies.Assembly("testAssembly") a.spatialGrid = grids.axialUnitGrid(1, a) a.add(b) r = getEmptyHexReactor() a.spatialLocator = r.core.spatialGrid[0, 0, 0] r.core.add(a) r.core.lib = lib aB = batch.Batch("testBatch") aB.add(b) # reference data made with this ISOTXS and this MG flux spectrum referenceRxRateData = { "nG": 2.10693674, "nF": 6.500339249, "n2n": 0.001446367, "nA": 0, "nP": 0, "n3n": 0, } referenceXsData = { "nG": 7.162060679, "nF": 22.09645085, "n2n": 0.004916601, "nA": 0, "nP": 0, "n3n": 0, } u235 = lib["U235AA"] assert not hasattr(u235.micros, "n3n") for armiObject in [c, b, a, r, aB]: rxnRates = armiObject.getReactionRates("U235") for rxName, rxRate in rxnRates.items(): self.assertAlmostEqual(rxRate, referenceRxRateData[rxName], 6) xsTable = armiObject.getCrossSectionTable(nuclides=["U235"]) u235Zaid = 92235 for rxName, rxRate in xsTable[u235Zaid].items(): self.assertAlmostEqual(rxRate, referenceXsData[rxName], 6)
def setUp(self): self.o, self.r = test_reactors.loadTestReactor( TEST_ROOT, customSettings={"xsKernel": "MC2v2"}) self.r.core.lib = isotxs.readBinary(ISOAA_PATH) self.converter = uniformMesh.NeutronicsUniformMeshConverter()
def setUpClass(cls): # load a library that is in the ARMI tree. This should # be a small library with LFPs, Actinides, structure, and coolant cls.lib = isotxs.readBinary(ISOAA_PATH)