Example #1
0
    def test_SmearDensityFail(self):
        builder = suiteBuilder.FullFactorialSuiteBuilder(self.baseCase)
        builder.addDegreeOfFreedom(
            suiteBuilder.SmearDensityModifier(v) for v in (0.5, 0.6))
        builder.addDegreeOfFreedom(
            suiteBuilder.CladThicknessByIDModifier(v) for v in (0.05, 0.01))
        self.assertEqual(4, len(builder))

        with six.assertRaisesRegex(self, RuntimeError,
                                   "before .*SmearDensityModifier"):
            builder.buildSuite()
Example #2
0
    def test_BluePrintBlockModifier(self):
        """test BluePrintBlockModifier with build suite naming function argument"""

        case_nbr = 1

        builder = suiteBuilder.FullFactorialSuiteBuilder(self.baseCase)

        builder.addDegreeOfFreedom([
            inputModifiers.BluePrintBlockModifier(
                "fuel 1", "clad", "od", float("{:.2f}".format(22 / 7)))
        ])
        builder.addDegreeOfFreedom([
            inputModifiers.BluePrintBlockModifier("block 5", "clad", "od",
                                                  3.14159)
        ])

        def SuiteNaming(index, _case, _mods):
            uniquePart = "{:0>4}".format(index + case_nbr)
            return os.path.join(
                ".",
                "case-suite-testBPBM",
                uniquePart,
                self.baseCase.title + "-" + uniquePart,
            )

        with directoryChangers.TemporaryDirectoryChanger():
            suite = builder.buildSuite(namingFunc=SuiteNaming)
            suite.writeInputs()

            self.assertTrue(os.path.exists("case-suite-testBPBM"))

            yamlfile = open(
                f"case-suite-testBPBM/000{case_nbr}/armi-000{case_nbr}-blueprints.yaml",
                "r",
            )
            bp_dict = yaml.safe_load(yamlfile)
            yamlfile.close()

            self.assertEqual(bp_dict["blocks"]["fuel 1"]["clad"]["od"], 3.14)
            self.assertEqual(bp_dict["blocks"]["block 5"]["clad"]["od"],
                             3.14159)
    def _execute(self):
        # pylint: disable=import-outside-toplevel; need to be configured first
        from armi import cases
        from armi.cases import suiteBuilder
        from armi.cases.inputModifiers.inputModifiers import (
            SettingsModifier,
            MultiSettingModifier,
            FullCoreModifier,
        )

        self._updateSettings()
        bp = self._updateBlueprints()

        baseCase = cases.Case(cs=self.cs, bp=bp)
        builder = suiteBuilder.FullFactorialSuiteBuilder(baseCase)
        problemTypes = [
            SettingsModifier(CONF_NEUTRONICS_KERNEL, "DIF3D-Nodal"),
            SettingsModifier(CONF_NEUTRONICS_KERNEL, "DIF3D-FD"),
            MultiSettingModifier(
                {
                    CONF_NEUTRONICS_KERNEL: "VARIANT",
                    CONF_VARIANT_TRANSPORT_AND_SCATTER_ORDER: "P1P0",
                }
            ),
        ]
        builder.addDegreeOfFreedom(problemTypes)
        solutionTypes = [
            SettingsModifier(CONF_NEUTRONICS_TYPE, "real"),
            # turn off coarse mesh rebalancing in all adjoint cases so they converge.
            MultiSettingModifier(
                {CONF_NEUTRONICS_TYPE: "adjoint", CONF_COARSE_MESH_REBALANCE: -1}
            ),
            MultiSettingModifier(
                {CONF_NEUTRONICS_TYPE: "both", CONF_COARSE_MESH_REBALANCE: -1}
            ),
        ]
        builder.addDegreeOfFreedom(solutionTypes)

        # add a higher-order VARIANT case as well.
        # note that you can't do scattering order beyond P1 with Dragon-produced XS
        builder.addModiferSet(
            [
                MultiSettingModifier(
                    {
                        CONF_NEUTRONICS_KERNEL: "VARIANT",
                        CONF_VARIANT_TRANSPORT_AND_SCATTER_ORDER: "P3P1",
                    }
                ),
            ]
        )
        # need full core too
        builder.addModiferSet(
            [
                FullCoreModifier(),
            ]
        )

        def namingFunc(index, case, _mods):
            number = f"{index:0>4}"
            name = (
                f"{case.cs[CONF_NEUTRONICS_KERNEL]}-"
                f"{case.cs[CONF_NEUTRONICS_TYPE]}-"
                f"{case.bp.gridDesigns['core'].symmetry}"
            )
            return os.path.join(
                ".",
                "case-suite",
                f"{number}-{name}",
                f"{baseCase.title}-{number}",
            )