示例#1
0
    def _constructMaterial(self, blueprint, matMods):
        nucsInProblem = blueprint.allNuclidesInProblem
        mat = materials.resolveMaterialClassByName(
            self.material)()  # make material with defaults

        if self.isotopics is not None:
            blueprint.customIsotopics.apply(mat, self.isotopics)

        appliedMatMods = False
        if any(matMods):
            try:
                mat.applyInputParams(
                    **matMods
                )  # update material with updated input params from YAML file.
                appliedMatMods = True
            except TypeError:
                # This component does not accept material modification inputs of the names passed in
                # Keep going since the modification could work for another component
                pass

        # expand elementals
        densityTools.expandElementalMassFracsToNuclides(
            mat.p.massFrac, blueprint.elementsToExpand)

        missing = set(mat.p.massFrac.keys()).difference(nucsInProblem)

        if missing:
            raise exceptions.ConsistencyError(
                "The nuclides {} are present in material {} by compositions, but are not "
                "specified in the input file. They need to be added.".format(
                    missing, mat))

        return mat, appliedMatMods
示例#2
0
 def test_findMaterial(self):
     self.assertIs(
         materials.resolveMaterialClassByName(
             "Void", namespaceOrder=["armi.materials"]
         ),
         materials.Void,
     )
     self.assertIs(
         materials.resolveMaterialClassByName(
             "Void", namespaceOrder=["armi.materials.void"]
         ),
         materials.Void,
     )
     self.assertIs(
         materials.resolveMaterialClassByName(
             "Void", namespaceOrder=["armi.materials.mox", "armi.materials.void"]
         ),
         materials.Void,
     )
     with self.assertRaises(ModuleNotFoundError):
         materials.resolveMaterialClassByName(
             "Void", namespaceOrder=["invalid.namespace", "armi.materials.void"]
         )
     with self.assertRaises(KeyError):
         materials.resolveMaterialClassByName(
             "Unobtanium", namespaceOrder=["armi.materials"]
         )
示例#3
0
 def setProperties(self, properties):
     """Apply thermo-mechanical properties of a Material."""
     if isinstance(properties, str):
         mat = materials.resolveMaterialClassByName(properties)()
         # note that the material will not be expanded to natural isotopics
         # here because the user-input blueprints information is not available
     else:
         mat = properties
     self.material = mat
     self.material.parent = self
     self.clearLinkedCache()
示例#4
0
    def _constructMaterial(self, blueprint, matMods):
        nucsInProblem = blueprint.allNuclidesInProblem
        # make material with defaults
        mat = materials.resolveMaterialClassByName(self.material)()

        if self.isotopics is not None:
            # Apply custom isotopics before processing input mods so
            # the input mods have the final word
            blueprint.customIsotopics.apply(mat, self.isotopics)

        # add mass fraction custom isotopics info, since some material modifications need to see them
        # e.g. in the base Material.applyInputParams
        matMods.update(
            {
                "customIsotopics": {
                    k: v.massFracs for k, v in blueprint.customIsotopics.items()
                }
            }
        )
        if len(matMods) > 1:
            # don't apply if only customIsotopics is in there
            try:
                # update material with updated input params from blueprints file.
                mat.applyInputParams(**matMods)
            except TypeError:
                # This component does not accept material modification inputs of the names passed in
                # Keep going since the modification could work for another component
                pass

        expandElementals(mat, blueprint)

        missing = set(mat.p.massFrac.keys()).difference(nucsInProblem)

        if missing:
            raise exceptions.ConsistencyError(
                "The nuclides {} are present in material {} by compositions, but are not "
                "specified in the `nuclide flags` section of the input file. "
                "They need to be added, or custom isotopics need to be applied.".format(
                    missing, mat
                )
            )

        return mat
示例#5
0
 def setProperties(self, properties):
     """Apply thermo-mechanical properties of a Material."""
     self.material = (materials.resolveMaterialClassByName(properties)()
                      if isinstance(properties, str) else properties)
     self.material.parent = self
     self.clearLinkedCache()