Esempio n. 1
0
    def test_setMass(self):
        """
        test:
            setMass
            setMasses
        """
        loc = locations.Location(i1=1, i2=1, axial=1)
        mass = 1.0

        aB = batch.Batch("testBatch")
        c = shapes.UnshapedVolumetricComponent(
            "batchMassAdditionComponent", custom.Custom(), 0.0, 0.0, volume=1
        )
        b = blocks.Block("testBlock", location=loc)
        b.add(c)
        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)

        # these armi objects have setMass implemented
        for armiObj in [aB, c, b]:
            for nucName in ["U235"]:
                masses = {nucName: mass}
                armiObj.setMasses(masses)
                self.assertAlmostEqual(armiObj.getMass(nucName), mass, 6)
Esempio n. 2
0
    def test_addMass(self):
        """
        test:
            addMasses
            addMass
            removeMass
            getMasses

        right now it doesn't make sense to add mass to anything other than a
        component, some one else can implement addMass and update this test
        on block, assembly and reactor.
        """

        loc = locations.Location(i1=1, i2=1, axial=1)
        mass = 1.0

        aB = batch.Batch("testBatch")
        c = shapes.UnshapedVolumetricComponent("batchMassAdditionComponent",
                                               custom.Custom(),
                                               0.0,
                                               0.0,
                                               volume=1)
        b = blocks.Block("testBlock", location=loc)
        b.add(c)
        a = assemblies.Assembly("testAssembly")
        a.spatialGrid = grids.axialUnitGrid(1)
        a.add(b)

        r = getEmptyHexReactor()
        a.spatialLocator = r.core.spatialGrid[0, 0, 0]
        r.core.add(a)

        # these armi objects have addMass implemented
        for armiObj in [aB, c]:
            for nucName in ["U235"]:
                masses = {nucName: mass}
                armiObj.addMasses(masses)
                self.assertAlmostEqual(armiObj.getMass(nucName), mass, 6)

                armiObj.removeMass(nucName, mass)
                self.assertAlmostEqual(armiObj.getMass(nucName), 0, 6)

        # create a global lumped fission product collection with a single lfp
        Fpdf = test_lumpedFissionProduct.getDummyLFPFile()
        cLfps = Fpdf.createSingleLFPCollectionFromFile("LFP35")
        self.assertAlmostEqual(aB.getMass(), 0, 6)
        aB.addMass("LFP35", mass, lumpedFissionProducts=cLfps)
        self.assertAlmostEqual(aB.getMass(), mass, 6)

        self.assertAlmostEqual(c.getMass(), 0, 6)
        c.addMass("LFP35", mass, lumpedFissionProducts=cLfps)
        self.assertAlmostEqual(c.getMass(), mass, 6)
Esempio n. 3
0
def makeMgFluxBlock(mgFlux):
    """
    Parameters
    ----------
    mgFlux : numpy array
        volume integrated neutron flux n-cm/s in each energy group

    Returns
    -------
    b : block
        a block with and integrated flux equal to the defined mgFlux vector
    """
    c = ZeroMassComponent("batchFluxAdditionComponent",
                          "Void",
                          0.0,
                          0.0,
                          volume=0.0)
    b = blocks.Block("batchFluxAdditionBlock")
    b.add(c)
    b.p.mgFlux = mgFlux
    return b
Esempio n. 4
0
    def test_getMgFluxes(self):
        """
        test:
            getMgFlux
            getIntegratedMgFlux
        """

        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,
        ]

        loc = locations.Location(i1=1, i2=1, axial=1)

        c = UnshapedVolumetricComponent("testComponent", "Custom", 0.0, 0.0, volume=1)
        b = blocks.Block("testBlock", location=loc)
        b.add(c)
        b.p.mgFlux = mgFlux1
        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)

        aB = batch.Batch("testBatch")
        aB.add(b)

        for armiObject in [c, b, a, r, aB]:
            for refFlux, testFlux in zip(mgFlux1, armiObject.getIntegratedMgFlux()):
                err = math.fabs((testFlux - refFlux) / refFlux)
                try:
                    assert err < 1e-6
                except AssertionError:
                    raise AssertionError(
                        "Integrated MgFlux test is failing for {}".format(
                            type(armiObject)
                        )
                    )

            for refFlux, testFlux in zip(mgFlux1, armiObject.getMgFlux()):
                err = math.fabs((testFlux - refFlux) / refFlux)
                try:
                    assert err < 1e-6
                except AssertionError:
                    raise AssertionError(
                        "Integrated MgFlux test is failing for {}".format(
                            type(armiObject)
                        )
                    )
Esempio n. 5
0
    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)