Exemplo n.º 1
0
    def setUpClass(cls):
        # Not using a directory changer since it isn't important that we go back in the
        # first place, and we don't want to get tangled with the directory change below.
        # We need to be in the TUTORIAL_DIR in the first place so that for `filesToMove`
        # to work right.
        os.chdir(TUTORIAL_DIR)

        # Make sure to do this work in a temporary directory to avoid race conditions
        # when running tests in parallel with xdist.
        cls.dirChanger = directoryChangers.TemporaryDirectoryChanger(
            filesToMove=TUTORIAL_FILES)
        cls.dirChanger.__enter__()
        runTutorialNotebook()

        reloadCs = settings.Settings(f"{CASE_TITLE}.yaml")

        newSettings = {}
        newSettings["db"] = True
        newSettings["reloadDBName"] = pathlib.Path(
            f"{CASE_TITLE}.h5").absolute()
        newSettings["runType"] = "Snapshots"
        newSettings["loadStyle"] = "fromDB"
        newSettings["detailAssemLocationsBOL"] = ["001-001"]

        reloadCs = reloadCs.modified(newSettings=newSettings)
        reloadCs.caseTitle = "armiRun"

        o = armi_init(cs=reloadCs)
        cls.o = o
Exemplo n.º 2
0
    def test_loadC5G7(self):
        """
        Load the C5G7 case from input and check basic counts.
        (Also, check that we are getting warnings when reading the YAML.)
        """
        with mockRunLogs.BufferLog() as mock:
            # we should start with a clean slate
            self.assertEqual("", mock._outputStream)
            runLog.LOG.startLog("test_loadC5G7")
            runLog.LOG.setVerbosity(WARNING)

            # ingest the settings file
            Mode.setMode(Mode.BATCH)
            o = armi_init(fName=TEST_INPUT_TITLE + ".yaml")
            b = o.r.core.getFirstBlock(Flags.MOX)

            # test warnings are being logged for malformed isotopics info in the settings file
            streamVal = mock._outputStream
            self.assertGreater(streamVal.count("[warn]"), 32, msg=streamVal)
            self.assertGreater(streamVal.count("custom isotopics"),
                               32,
                               msg=streamVal)
            self.assertIn("Uranium Oxide", streamVal, msg=streamVal)
            self.assertIn("SaturatedWater", streamVal, msg=streamVal)
            self.assertIn("invalid settings: fakeBad",
                          streamVal,
                          msg=streamVal)

            # test that there are 100 of each high, medium, and low MOX pins
            fuelPinsHigh = b.getComponent(Flags.HIGH | Flags.MOX)
            self.assertEqual(fuelPinsHigh.getDimension("mult"), 100)

            # test the Guide Tube dimensions
            gt = b.getComponent(Flags.GUIDE_TUBE)
            self.assertEqual(gt.getDimension("mult"), 24)
Exemplo n.º 3
0
    def test_loadC5G7(self):
        """
        Load the C5G7 case from input and check basic counts.
        """
        o = armi_init(fName=TEST_INPUT_TITLE + ".yaml")
        b = o.r.core.getFirstBlock(Flags.MOX)
        # there are 100 of each high, medium, and low MOX pins
        fuelPinsHigh = b.getComponent(Flags.HIGH | Flags.MOX)
        self.assertEqual(fuelPinsHigh.getDimension("mult"), 100)

        gt = b.getComponent(Flags.GUIDE_TUBE)
        self.assertEqual(gt.getDimension("mult"), 24)
Exemplo n.º 4
0
    def invoke(self):
        srcDB = db.databaseFactory(
            dbName=self.args.srcDB, permission=db.Permissions.READ_ONLY_FME
        )
        tarDB = db.databaseFactory(
            dbName=self.args.tarDB, permission=db.Permissions.CREATE_FILE_TIE
        )

        cs = settings.Settings(fName=self.args.csPath)

        with directoryChangers.DirectoryChanger(cs.inputDirectory):
            o = armi_init(cs=cs)
            db.copyDatabase(o.r, srcDB, tarDB)
Exemplo n.º 5
0
    def test_runAndLoadC5G7(self):
        """
        Run C5G7 in basic no-op app and load from the result from DB.

        This ensures that these kinds of cases can be read from DB.
        """
        def _loadLocs(o, locs):
            for b in o.r.core.getBlocks():
                indices = b.spatialLocator.getCompleteIndices()
                locs[indices] = b.spatialLocator.getGlobalCoordinates()

        o = armi_init(fName=TEST_INPUT_TITLE + ".yaml")
        locsInput, locsDB = {}, {}
        _loadLocs(o, locsInput)
        o.operate()
        o2 = db.loadOperator(TEST_INPUT_TITLE + ".h5", 0, 0)
        _loadLocs(o2, locsDB)

        for indices, coordsInput in sorted(locsInput.items()):
            coordsDB = locsDB[indices]
            self.assertTrue(numpy.allclose(coordsInput, coordsDB))