def test_customIsotopics(self): with self.assertRaises(yamlize.YamlizingError): CustomIsotopics.load("MOX: {input format: applesauce}") with self.assertRaises(yamlize.YamlizingError): CustomIsotopics.load("MOX: {input format: number densities, density: -0.1}") with self.assertRaises(yamlize.YamlizingError): CustomIsotopics.load( "MOX: {input format: number densities, density: 1.5, FAKENUC234: 0.000286}" )
def _resolveNuclides(self, cs): """Expands the density of any elemental nuclides to its natural isotopics.""" from armi import utils # expand burn-chain to only contain nuclides, no elements actives = set() inerts = set() undefBurnChainActiveNuclides = set() if self.nuclideFlags is None: self.nuclideFlags = genDefaultNucFlags() for nucFlag in self.nuclideFlags: nucFlag.prepForCase(actives, inerts, undefBurnChainActiveNuclides) inerts -= actives self.customIsotopics = self.customIsotopics or CustomIsotopics() self.elementsToExpand = [] elementalsToSkip = self._selectNuclidesToExpandForModeling(cs) # if elementalsToSkip=[CR], we expand everything else. e.g. CR -> CR (unchanged) nucsFromInput = actives | inerts # join for elemental in nuclideBases.instances: if not isinstance(elemental, nuclideBases.NaturalNuclideBase): continue if elemental.name not in nucsFromInput: continue # we've now confirmed this elemental is in the problem if elemental in elementalsToSkip: continue nucsInProblem = actives if elemental.name in actives else inerts nucsInProblem.remove(elemental.name) self.elementsToExpand.append(elemental.element) for nb in elemental.element.getNaturalIsotopics(): nucsInProblem.add(nb.name) if self.elementsToExpand: runLog.info( "Expanding {} 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 that the burn-chain may not be complete if undefBurnChainActiveNuclides: runLog.info( tabulate.tabulate( [[ "Nuclides truncating the burn-chain:", utils.createFormattedStrWithDelimiter( list(undefBurnChainActiveNuclides)), ]], tablefmt="plain", ), single=True, )