def loadTestReactor(inputFilePath=TEST_ROOT, customSettings=None, inputFileName="armiRun.yaml"): r""" Loads a test reactor. Can be used in other test modules. Parameters ---------- inputFilePath : str Path to the directory of the armiRun.yaml input file. customSettings : dict with str keys and values of any type For each key in customSettings, the cs which is loaded from the armiRun.yaml will be overwritten to the value given in customSettings for that key. Returns ------- o : Operator r : Reactor """ # TODO: it would be nice to have this be more stream-oriented. Juggling files is # devilishly difficult. global TEST_REACTOR fName = os.path.join(inputFilePath, inputFileName) customSettings = customSettings or {} isPickeledReactor = fName == ARMI_RUN_PATH and customSettings == {} assemblies.resetAssemNumCounter() if isPickeledReactor and TEST_REACTOR: # return test reactor only if no custom settings are needed. o, r, assemNum = cPickle.loads(TEST_REACTOR) assemblies.setAssemNumCounter(assemNum) settings.setMasterCs(o.cs) o.reattach(r, o.cs) return o, r cs = settings.Settings(fName=fName) # Overwrite settings if desired if customSettings: for settingKey, settingVal in customSettings.items(): cs[settingKey] = settingVal if "verbosity" not in customSettings: runLog.setVerbosity("error") settings.setMasterCs(cs) cs["stationaryBlocks"] = [] cs["nCycles"] = 3 o = operators.factory(cs) r = reactors.loadFromCs(cs) o.initializeInterfaces(r) # put some stuff in the SFP too. for a in range(10): a = o.r.blueprints.constructAssem(o.cs, name="feed fuel") o.r.core.sfp.add(a) o.r.core.regenAssemblyLists() if isPickeledReactor: # cache it for fast load for other future tests # protocol=2 allows for classes with __slots__ but not __getstate__ to be pickled TEST_REACTOR = cPickle.dumps((o, o.r, assemblies.getAssemNum()), protocol=2) return o, o.r
def setUpClass(cls): cs = settings.Settings( fName=os.path.join(TEST_ROOT, "ThRZSettings.yaml")) cls.r = reactors.loadFromCs(cs)