def _updateBlueprints(self):
        from armi.reactor import blueprints
        from armi.reactor.blueprints import isotopicOptions

        # modify nuclide expansion flags as well b/c the main DRAGON lib only has C12.
        bp = blueprints.loadFromCs(self.cs)
        bp.nuclideFlags = isotopicOptions.genDefaultNucFlags()
        bp.nuclideFlags["C"].expandTo = ["C12"]
        bp.nuclideFlags["W"].expandTo = ["W182", "W183", "W184", "W186"]
        return bp
Beispiel #2
0
def buildCase():
    """Build input components and a case."""
    bp = blueprints.Blueprints()
    bp.customIsotopics = isotopicOptions.CustomIsotopics()
    bp.nuclideFlags = isotopicOptions.genDefaultNucFlags()

    components = buildComponents()
    bp.blockDesigns = buildBlocks(components)
    bp.assemDesigns = buildAssemblies(bp.blockDesigns)
    bp.gridDesigns = buildGrids()
    bp.systemDesigns = buildSystems()

    cs = caseSettings.Settings()
    cs.path = None
    cs.caseTitle = "scripted-case"
    case = cases.Case(cs=cs, bp=bp)

    return case
Beispiel #3
0
    def _resolveNuclides(self, cs):
        """
        Process elements and determine how to expand them to natural isotopics.

        Also builds meta-data about which nuclides are in the problem.

        This system works by building a dictionary in the
        ``elementsToExpand`` attribute with ``Element`` keys
        and list of ``NuclideBase`` values.

        The actual expansion of elementals to isotopics occurs during
        :py:meth:`Component construction <armi.reactor.blueprints.componentBlueprint.
        ComponentBlueprint._constructMaterial>`.
        """

        from armi import utils

        actives = set()
        inerts = set()
        undefBurnChainActiveNuclides = set()
        if self.nuclideFlags is None:
            self.nuclideFlags = isotopicOptions.genDefaultNucFlags()

        self.elementsToExpand = []
        for nucFlag in self.nuclideFlags:
            # this returns any nuclides that are flagged specifically for expansion by input
            expandedElements = nucFlag.fileAsActiveOrInert(
                actives, inerts, undefBurnChainActiveNuclides)
            self.elementsToExpand.extend(expandedElements)

        inerts -= actives
        self.customIsotopics = self.customIsotopics or isotopicOptions.CustomIsotopics(
        )
        (
            elementalsToKeep,
            expansions,
        ) = isotopicOptions.autoSelectElementsToKeepFromSettings(cs)

        nucsFromInput = actives | inerts  # join

        # Flag all elementals for expansion unless they've been flagged otherwise by
        # user input or automatic lattice/datalib rules.
        for elemental in nuclideBases.instances:
            if not isinstance(elemental, nuclideBases.NaturalNuclideBase):
                # `elemental` may be a NaturalNuclideBase or a NuclideBase
                # skip all NuclideBases
                continue

            if elemental in elementalsToKeep:
                continue

            if elemental.name in actives:
                currentSet = actives
                actives.remove(elemental.name)
            elif elemental.name in inerts:
                currentSet = inerts
                inerts.remove(elemental.name)
            else:
                # This was not specified in the nuclide flags at all.
                # If a material with this in its composition is brought in
                # it's nice from a user perspective to allow it.
                # But current behavior is that all nuclides in problem
                # must be declared up front.
                continue

            self.elementsToExpand.append(elemental.element)

            if (elemental.name in self.nuclideFlags
                    and self.nuclideFlags[elemental.name].expandTo):
                # user-input has precedence
                newNuclides = [
                    nuclideBases.byName[nn] for nn in self.nuclideFlags[
                        elemental.element.symbol].expandTo
                ]
            elif (elemental in expansions
                  and elemental.element.symbol in self.nuclideFlags):
                # code-specific expansion required
                newNuclides = expansions[elemental]
                # overlay code details onto nuclideFlags for other parts of the code
                # that will use them.
                # CRAP: would be better if nuclideFlags did this upon reading s.t.
                # order didn't matter. On the other hand, this is the only place in
                # the code where NuclideFlags get built and have user settings around
                # (hence "resolve").
                # This must be updated because the operative expansion code just uses the flags
                #
                # Also, if this element is not in nuclideFlags at all, we just don't add it
                self.nuclideFlags[elemental.element.symbol].expandTo = [
                    nb.name for nb in newNuclides
                ]
            else:
                # expand to all possible natural isotopics
                newNuclides = elemental.element.getNaturalIsotopics()

            for nb in newNuclides:
                currentSet.add(nb.name)

        if self.elementsToExpand:
            runLog.info(
                "Will expand {} elementals to have natural isotopics".format(
                    ", ".join(element.symbol
                              for element in self.elementsToExpand)))

        self.activeNuclides = ordered_set.OrderedSet(sorted(actives))
        self.inertNuclides = ordered_set.OrderedSet(sorted(inerts))
        self.allNuclidesInProblem = ordered_set.OrderedSet(
            sorted(actives.union(inerts)))

        # Inform user which nuclides are truncating the burn chain.
        if undefBurnChainActiveNuclides:
            runLog.info(
                tabulate.tabulate(
                    [[
                        "Nuclides truncating the burn-chain:",
                        utils.createFormattedStrWithDelimiter(
                            list(undefBurnChainActiveNuclides)),
                    ]],
                    tablefmt="plain",
                ),
                single=True,
            )