Beispiel #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)
Beispiel #2
0
    def getTimeIndices(self, a=None, boc=False, moc=False, eoc=False):
        r"""
        Generate a list of timestep indices where valid history data exist for the given criteria.

        Parameters
        ----------
        a : Assembly, optional
            If given, only generate time indices where the assembly `a` is in the core. Default: All assemblies.

        boc, moc, eoc : bool, optional
            Will return boc/moc/eoc timenodes in every cycle. If any of these are true, allNodes becomes False

        Returns
        -------
        timeIndices : list
            A list of integers where history data exists.

        Examples
        --------
        If there are 5 nodes per cycle (burnSteps = 4),
        0 1 2 3 4 | 5 6 7 8 9 | 10 11 12 13 14 | ...:

        >>> getTimeIndices(moc=True):
        [2, 7, 12, ...]

        See Also
        --------
        getTimeSteps : gets time in years where the assembly is in the core

        """
        timeIndices = []
        for globalNode in range(
                utils.getTimeStepNum(self.r.p.cycle, self.r.p.timeNode,
                                     self.cs) + 1):
            if a is None:
                timeIndices.append(globalNode)
            else:
                fBlock = a.getFirstBlock(Flags.FUEL)
                if fBlock is None:
                    blockLocationLabel = None
                else:
                    blockLocationLabel = self._blockLocationAtTimenode(
                        fBlock, globalNode)
                    runLog.info(
                        "Location label of {} at timestep {} is {}".format(
                            fBlock, globalNode, blockLocationLabel))
                # only add this timestep if it's around for this assembly.
                if blockLocationLabel is not None:
                    bLoc = locations.Location(label=blockLocationLabel)
                    if bLoc.isInCore():
                        timeIndices.append(globalNode)

        return self.filterTimeIndices(timeIndices, boc, moc, eoc)
Beispiel #3
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)
Beispiel #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)
                        )
                    )
Beispiel #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)