Esempio n. 1
0
    def _mapStateFromReactorToOther(self, sourceReactor, destReactor):
        UniformMeshGeometryConverter._mapStateFromReactorToOther(
            self, sourceReactor, destReactor)

        def paramSetter(armiObject, vals, paramNames):
            for paramName, val in zip(paramNames, vals):
                armiObject.p[paramName] = val

        def paramGetter(armiObject, paramNames):
            paramVals = []
            for paramName in paramNames:
                paramVals.append(armiObject.p[paramName])
            return numpy.array(paramVals)

        def fluxSetter(block, flux, _paramNames):
            block.p.mgFlux = list(flux)

        def fluxGetter(block, _paramNames):
            val = block.p.mgFlux
            if val is None or len(val) == 0:
                # so the merger can detect and just use incremental value.
                return None
            else:
                return numpy.array(val)

        def adjointFluxSetter(block, flux, _paramNames):
            block.p.adjMgFlux = list(flux)

        def adjointFluxGetter(block, _paramNames):
            val = block.p.adjMgFlux
            if not val:
                # so the merger can detect and just use incremental value.
                return None
            else:
                return numpy.array(val)

        for paramName in self.reactorParamNames:
            destReactor.core.p[paramName] = sourceReactor.core.p[paramName]

        for aSource in sourceReactor.core:
            aDest = destReactor.core.getAssemblyByName(aSource.getName())
            _setStateFromOverlaps(aSource, aDest, fluxSetter, fluxGetter,
                                  ["mgFlux"])
            _setStateFromOverlaps(aSource, aDest, adjointFluxSetter,
                                  adjointFluxGetter, ["adjMgFlux"])
            _setStateFromOverlaps(aSource, aDest, paramSetter, paramGetter,
                                  self.blockParamNames)
            # Now recalculate derived params with the mapped flux to minimize
            # potential numerical diffusion (e.g. control rod tip into large coolant)

        if destReactor.core.lib is not None:
            runLog.extra(
                f"Computing block-level reaction rates for {destReactor.core}")
            for b in aDest:
                globalFluxInterface.calcReactionRates(b,
                                                      destReactor.core.p.keff,
                                                      destReactor.core.lib)
Esempio n. 2
0
    def _mapStateFromReactorToOther(self, sourceReactor, destReactor):
        UniformMeshGeometryConverter._mapStateFromReactorToOther(
            self, sourceReactor, destReactor
        )

        def paramSetter(armiObject, vals, paramNames):
            for paramName, val in zip(paramNames, vals):
                armiObject.p[paramName] = val

        def paramGetter(armiObject, paramNames):
            paramVals = []
            for paramName in paramNames:
                paramVals.append(armiObject.p[paramName])
            return numpy.array(paramVals)

        def fluxSetter(block, flux, _paramNames):
            block.p.mgFlux = list(flux)

        def fluxGetter(block, _paramNames):
            val = block.p.mgFlux
            if val is None or len(val) == 0:
                # so the merger can detect and just use incremental value.
                return None
            else:
                return numpy.array(val)

        def adjointFluxSetter(block, flux, _paramNames):
            block.p.adjMgFlux = list(flux)

        def adjointFluxGetter(block, _paramNames):
            val = block.p.adjMgFlux
            if val is None or len(val) == 0:
                # so the merger can detect and just use incremental value.
                return None
            else:
                return numpy.array(val)

        for paramName in self.reactorParamNames:
            destReactor.core.p[paramName] = sourceReactor.core.p[paramName]

        for aSource in sourceReactor.core:
            aDest = destReactor.core.getAssemblyByName(aSource.getName())
            _setStateFromOverlaps(aSource, aDest, fluxSetter, fluxGetter, ["mgFlux"])
            _setStateFromOverlaps(
                aSource, aDest, adjointFluxSetter, adjointFluxGetter, ["adjMgFlux"]
            )
            _setStateFromOverlaps(
                aSource, aDest, paramSetter, paramGetter, self.blockParamNames
            )

            # If requested, the reaction rates will be calculated based on the
            # mapped neutron flux and the XS library.
            if self.calcReactionRates:
                for b in aDest:
                    globalFluxInterface.calcReactionRates(
                        b, destReactor.core.p.keff, destReactor.core.lib
                    )
Esempio n. 3
0
    def test_calcReactionRates(self):
        """
        Test that the reaction rate code executes and sets a param > 0.0.

        .. warning: This does not validate the reaction rate calculation.
        """
        b = test_blocks.loadTestBlock()
        test_blocks.applyDummyData(b)
        self.assertAlmostEqual(b.p.rateAbs, 0.0)
        globalFluxInterface.calcReactionRates(b, 1.01, b.r.core.lib)
        self.assertGreater(b.p.rateAbs, 0.0)
Esempio n. 4
0
    def _mapStateFromReactorToOther(self, sourceReactor, destReactor):
        UniformMeshGeometryConverter._mapStateFromReactorToOther(
            self, sourceReactor, destReactor)

        def paramSetter(block, vals, paramNames):
            for paramName, val in zip(paramNames, vals):
                block.p[paramName] = val

        def paramGetter(block, paramNames):
            paramVals = []
            for paramName in paramNames:
                val = block.p[paramName]
                if not val:
                    paramVals.append(None)
                else:
                    paramVals.append(val)
            return numpy.array(paramVals, dtype=object)

        def multiGroupParamSetter(block, multiGroupVals, paramNames):
            for paramName, val in zip(paramNames, multiGroupVals):
                block.p[paramName] = numpy.array(val)

        def multiGroupParamGetter(block, paramNames):
            paramVals = []
            for paramName in paramNames:
                val = block.p[paramName]
                if val is None or len(val) == 0:
                    paramVals.append(None)
                else:
                    paramVals.append(numpy.array(val))
            return numpy.array(paramVals, dtype=object)

        for paramName in self.reactorParamNames:
            destReactor.core.p[paramName] = sourceReactor.core.p[paramName]

        for aSource in sourceReactor.core:
            aDest = destReactor.core.getAssemblyByName(aSource.getName())

            # Map the multi-group flux parameters
            _setStateFromOverlaps(
                aSource,
                aDest,
                multiGroupParamSetter,
                multiGroupParamGetter,
                self.blockMultigroupParamNames,
            )

            # Map the detailed axial expansion parameters
            _setStateFromOverlaps(
                aSource,
                aDest,
                paramSetter,
                paramGetter,
                self.blockDetailedAxialExpansionParamNames,
            )

            # If requested, the reaction rates will be calculated based on the
            # mapped neutron flux and the XS library.
            if self.calcReactionRates:
                for b in aDest:
                    globalFluxInterface.calcReactionRates(
                        b, destReactor.core.p.keff, destReactor.core.lib)