Exemplo n.º 1
0
    def _distributeReactor(self, cs):
        runLog.debug("Sending the Reactor object")
        r = self.broadcast(self.r)

        if isinstance(r, reactors.Reactor):
            runLog.debug("Received reactor")
        else:
            raise RuntimeError(
                "Failed to transmit reactor, received: {}".format(r))

        if armi.MPI_RANK == 0:
            # on the master node this unfortunately created a __deepcopy__ of the reactor, delete it
            del r
        else:
            # maintain original reactor object on master
            self.r = r
            self.o.r = r

        self.r.o = self.o

        runLog.debug("The reactor has {} assemblies".format(
            len(self.r.core.getAssemblies())))
        numAssemblies = self.broadcast(assemblies.getAssemNum())
        assemblies.setAssemNumCounter(numAssemblies)
        # attach here so any interface actions use a properly-setup reactor.
        self.o.reattach(self.r, cs)  # sets r and cs
Exemplo n.º 2
0
    def _undoGeometryTransformations(self):
        """
        Restore original data model state and/or apply results to it.

        Notes
        -----
        These transformations occur in the opposite order than that which they were applied in.
        Otherwise, the uniform mesh guy would try to add info to assem's on the source reactor
        that don't exist.

        See Also
        --------
        _performGeometryTransformations
        """
        geomConverter = self.geomConverters.get("edgeAssems")
        if geomConverter:
            geomConverter.scaleParamsRelatedToSymmetry(
                self.r, paramsToScaleSubset=self.options.paramsToScaleSubset)
            geomConverter.removeEdgeAssemblies(self.r.core)

        meshConverter = self.geomConverters.get("axial")
        if meshConverter:
            meshConverter.applyStateToOriginal()
            self.r = meshConverter._sourceReactor  # pylint: disable=protected-access;

        nAssemsBeforeConversion = [
            converter.getAssemblyModuleCounter()
            for converter in (geomConverter, meshConverter)
            if converter is not None
        ]
        if nAssemsBeforeConversion:
            assemblies.setAssemNumCounter(min(nAssemsBeforeConversion))

        # clear the converters in case this function gets called twice
        self.geomConverters = {}
Exemplo n.º 3
0
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