def setUpClass(cls): geom = systemLayoutInput.SystemLayoutInput() geom.readGeomFromStream(GEOM_INPUT) bp = blueprints.Blueprints.load(BLUEPRINT_INPUT_LINKS) cs = settings.Settings() bp._prepConstruction(cs) cls.baseCase = cases.Case(cs=cs, bp=bp, geom=geom)
def _collectSymmetry(oldDB): """Read symmetry and geomType off old-style geometry input str in DB.""" geomPath = "/inputs/geomFile" if geomPath in oldDB: geom = systemLayoutInput.SystemLayoutInput() geom.readGeomFromStream(io.StringIO(oldDB["inputs/geomFile"][()])) return {"symmetry": geom.symmetry, "geomType": geom.geomType}
def migrate(bp: Blueprints, cs): """ Apply migrations to the input structure. This is a good place to perform migrations that address changes to the system design description (settings, blueprints, geom file). We have access to all three here, so we can even move stuff between files. Namely, this: * creates a grid blueprint to represent the core layout from the old ``geomFile`` setting, and applies that grid to a ``core`` system. * moves the radial and azimuthal submesh values from the ``geomFile`` to the assembly designs, but only if they are uniform (this is limiting, but could be made more sophisticated in the future, if there is need) This allows settings-driven core map to still be used for backwards compatibility. At some point once the input stabilizes, we may wish to move this out to the dedicated migration portion of the code, and not perform the migration so implicitly. """ from armi.reactor.blueprints import gridBlueprint if bp.systemDesigns is None: bp.systemDesigns = Systems() if bp.gridDesigns is None: bp.gridDesigns = gridBlueprint.Grids() if "core" in [rd.name for rd in bp.gridDesigns]: raise ValueError("Cannot auto-create a 2nd `core` grid. Adjust input.") geom = systemLayoutInput.SystemLayoutInput() geom.readGeomFromFile(os.path.join(cs.inputDirectory, cs["geomFile"])) gridDesigns = geom.toGridBlueprints("core") for design in gridDesigns: bp.gridDesigns[design.name] = design if "core" in [rd.name for rd in bp.systemDesigns]: raise ValueError( "Core map is defined in both the ``geometry`` setting and in " "the blueprints file. Only one definition may exist. " "Update inputs." ) bp.systemDesigns["core"] = SystemBlueprint("core", "core", Triplet()) if geom.geomType in (geometry.GeomType.RZT, geometry.GeomType.RZ): aziMeshes = {indices[4] for indices, _ in geom.assemTypeByIndices.items()} radMeshes = {indices[5] for indices, _ in geom.assemTypeByIndices.items()} if len(aziMeshes) > 1 or len(radMeshes) > 1: raise ValueError( "The system layout described in {} has non-uniform " "azimuthal and/or radial submeshing. This migration is currently " "only smart enough to handle a single radial and single azimuthal " "submesh for all assemblies.".format(cs["geomFile"]) ) radMesh = next(iter(radMeshes)) aziMesh = next(iter(aziMeshes)) for _, aDesign in bp.assemDesigns.items(): aDesign.radialMeshPoints = radMesh aDesign.azimuthalMeshPoints = aziMesh
def _setGeomType(self): if self.cs["geomFile"]: with directoryChangers.DirectoryChanger(self.cs.inputDirectory, dumpOnException=False): geom = systemLayoutInput.SystemLayoutInput() geom.readGeomFromFile(self.cs["geomFile"]) self.geomType, self.coreSymmetry = geom.geomType, geom.symmetry
def test_geomFile(self): geom = systemLayoutInput.SystemLayoutInput() geom.readGeomFromStream(io.StringIO(RTH_GEOM)) gridDesign = geom.toGridBlueprints("test_grid")[0] self.assertEqual(gridDesign.name, "test_grid") self.assertEqual(gridDesign.geom, "thetarz") self.assertEqual(gridDesign.symmetry, "eighth periodic") self.assertEqual(gridDesign.geom, "thetarz")
def setUp(self): self.suite = cases.CaseSuite(settings.Settings()) geom = systemLayoutInput.SystemLayoutInput() geom.readGeomFromStream(io.StringIO(GEOM_INPUT)) bp = blueprints.Blueprints.load(BLUEPRINT_INPUT) self.c1 = cases.Case(cs=settings.Settings(), geom=geom, bp=bp) self.c1.cs.path = "c1.yaml" self.suite.add(self.c1) self.c2 = cases.Case(cs=settings.Settings(), geom=geom, bp=bp) self.c2.cs.path = "c2.yaml" self.suite.add(self.c2)
def test_independentVariables(self): """Ensure that independentVariables added to a case move with it.""" geom = systemLayoutInput.SystemLayoutInput() geom.readGeomFromStream(io.StringIO(GEOM_INPUT)) bp = blueprints.Blueprints.load(BLUEPRINT_INPUT) cs = settings.Settings(ARMI_RUN_PATH) cs["verbosity"] = "important" baseCase = cases.Case(cs, bp=bp, geom=geom) with directoryChangers.TemporaryDirectoryChanger() as cwd: # ensure we are not in IN_USE_TEST_ROOT vals = {"cladThickness": 1, "control strat": "good", "enrich": 0.9} case = baseCase.clone() case._independentVariables = vals # pylint: disable=protected-access case.writeInputs() newCs = settings.Settings(fName=case.title + ".yaml") newCase = cases.Case(newCs) for name, val in vals.items(): self.assertEqual(newCase.independentVariables[name], val)
def test_geomFile(self): geom = systemLayoutInput.SystemLayoutInput() geom.readGeomFromStream(io.StringIO(RTH_GEOM)) gridDesign = geom.toGridBlueprints("test_grid")[0]