Ejemplo n.º 1
0
def main():
    # Main entry point into ARMI
    try:
        armi.configure(apps.App())
        code = ArmiCLI().run()
        # sys exit interprets None as 0
        sys.exit(code)
    except Exception as ee:  # pylint: disable=broad-except
        import traceback

        # TODO: change to critical after critical no longer throws an exception.
        print(
            "[CRIT {:03} ] Unhandled exception in __main__ on {}.".format(
                armi.MPI_RANK, armi.MPI_NODENAME),
            file=sys.__stderr__,
        )
        print(
            "[CRIT {:03} ] Stack trace: {}".format(armi.MPI_RANK,
                                                   traceback.format_exc()),
            file=sys.__stderr__,
        )
        if armi.MPI_SIZE > 1:
            print(
                "[CRIT {:03} ] killing all MPI tasks from __main__.\n".format(
                    armi.MPI_RANK),
                file=sys.__stderr__,
            )
            # cleanTempDirs has @atexit.register so it should be called at the end, but mpi.Abort in main
            # will not allow for @atexit.register or except/finally code to be called so calling here as well
            armi.cleanTempDirs()
            # .Abort will not allow for @atexit.register or except/finally code to be called
            armi.MPI_COMM.Abort(errorcode=-1)
        raise SystemExit(1)
Ejemplo n.º 2
0
def pytest_sessionstart(session):
    import armi
    from armi import apps

    print("Initializing generic ARMI Framework application")
    armi.configure(apps.App())
    cs = caseSettings.Settings()
    settings.setMasterCs(cs)
Ejemplo n.º 3
0
def pytest_sessionstart(session):
    import armi
    from armi import apps
    from armi.nucDirectory import nuclideBases

    print("Initializing generic ARMI Framework application")
    armi.configure(apps.App())
    cs = caseSettings.Settings()
    settings.setMasterCs(cs)
    # Need to init burnChain.
    # see armi.cases.case.Case._initBurnChain
    with open(cs["burnChainFileName"]) as burnChainStream:
        nuclideBases.imposeBurnChain(burnChainStream)
Ejemplo n.º 4
0
Plot a chart of the nuclides
============================

Use the nuclide directory of ARMI to plot a chart of the nuclides 
coloring the squares with the natural abundance. 

.. admonition:: More details

    Our :ref:`extended tutorial for nuclides </user/tutorials/nuclide_demo.ipynb>` and
    detailed :py:mod:`nucDirectory docs <armi.nucDirectory>` may also be of interest.
"""
import matplotlib.pyplot as plt

from armi.nucDirectory import nuclideBases
import armi

armi.configure()

xyc = []
for name, base in nuclideBases.byName.items():
    if not base.a:
        continue
    xyc.append((base.a - base.z, base.z, base.abundance or 0.5))
x, y, c = zip(*xyc)
plt.figure(figsize=(12, 8))
plt.scatter(x, y, c=c, marker="s", s=6)
plt.title("Chart of the nuclides")
plt.xlabel("Number of neutrons (N)")
plt.ylabel("Number of protons (Z)")
plt.show()
Ejemplo n.º 5
0
# serve to show the default.

import pathlib
import re
import warnings

import sphinx_rtd_theme

import armi
from armi.context import RES
from armi import apps
from armi.bookkeeping import tests as bookkeepingTests
from armi.utils.dochelpers import *

# Configure the baseline framework "App" for framework doc building
armi.configure(apps.App())

# some examples have import armi;armi.configure() in them that are intended
# to be copy/pasted by new users. However, armi will crash with param locks if it is
# configured twice. We often use if armi.isConfigured() to guard against
# issues here, but prefer not to highlight that somewhat confusing
# conditional if a user is just copy pasting fresh code
# ("How on Earth," they might wonder "would it already be configured!?"). Thus,
# we tell armi to simply disable future configure calls with this advanced flag
armi._ignoreConfigures = True

APIDOC_REL = ".apidocs"
SOURCE_DIR = os.path.join("..", "armi")
APIDOC_DIR = APIDOC_REL
_TUTORIAL_FILES = [
    pathlib.Path(SOURCE_DIR) / "tests" / "tutorials" / fName
Ejemplo n.º 6
0
def pytest_sessionstart(session):
    import armi

    armi.configure(dragonTestingApp.DragonTestingApp())
Ejemplo n.º 7
0
code rather than by writing the textual input files directly.
In ARMI you can either make the ARMI reactor objects directly,
or you can define Blueprints objects. The benefit of making Blueprints
objects is that they can in turn be used to create both ARMI reactor
objects as well as textual input itself. This is nice when you want to
have traceable input files associated with a run that was developed
programmatically (e.g. for parameter sweeps).

This example shows how to make Blueprints objects programmatically completely
from scratch.

"""
import matplotlib.pyplot as plt
from armi import configure

configure(permissive=True)
# pylint: disable=wrong-import-position
from armi.reactor import blueprints
from armi import settings
from armi.settings import caseSettings
from armi.reactor.blueprints import isotopicOptions
from armi.reactor.blueprints import assemblyBlueprint
from armi.reactor.blueprints import blockBlueprint
from armi.reactor.blueprints import componentBlueprint
from armi.reactor.blueprints import gridBlueprint
from armi.reactor.blueprints import reactorBlueprint
from armi.utils import plotting
from armi import cases


def buildCase():
Ejemplo n.º 8
0
accurate cross sections.

By automating these kinds of geometry conversions, ARMI allows core designers to maintain
the design in real geometry while still performing appropriate approximations for
efficient analysis.

.. warning:: 
    This uses :py:mod:`armi.reactor.converters.blockConverters`, which
    currently only works on a constrained set of hex-based geometries. For your systems,
    consider these an example and starting point and build your own converters as
    appropriate.

"""

from armi.reactor.tests import test_reactors
from armi.reactor.flags import Flags
from armi.reactor.converters import blockConverters
import armi

armi.configure(permissive=True)

_o, r = test_reactors.loadTestReactor()

bFuel = r.core.getBlocks(Flags.FUEL)[0]
bControl = r.core.getBlocks(Flags.CONTROL)[0]
converter = blockConverters.HexComponentsToCylConverter(sourceBlock=bControl,
                                                        driverFuelBlock=bFuel,
                                                        numExternalRings=1)
converter.convert()
converter.plotConvertedBlock()
Ejemplo n.º 9
0
 def test_overConfigured(self):
     with self.assertRaises(RuntimeError):
         armi.configure()
Ejemplo n.º 10
0
import asyncio
import os
import pytest
import time
import unittest
import test.support

# wxpython is an optional dependency, and without it we cant do much of anything. This
# should raise a unittest.SkipTest if it can't find wx, signalling to pytest to skip the
# rest of the module. Neat!
wx = test.support.import_module("wx")

from armi import configure, getApp

if getApp() is None:
    configure()
from armi.utils import gridEditor

_SECONDS_PER_TICK = 0.05


def _wait(num_ticks: int) -> None:
    time.sleep(num_ticks * _SECONDS_PER_TICK)


def _findPointInWindow(window: wx.Window,
                       offsetFromLeft: float = 0.5,
                       offsetFromTop: float = 0.5) -> wx.Point:
    """Given a window, return a point in it. Defaults to the center of the window object.

    If offsets are smaller than 0 or greater than 1, this would return a point outside the window object.
Ejemplo n.º 11
0
def pytest_sessionstart(session):
    print("Initializing generic ARMI Framework application")
    configure(apps.App())
    bootstrapArmiTestEnv()
Ejemplo n.º 12
0
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import math
import pathlib
import sys

import matplotlib.pyplot as plt

import armi
import dif3ddemo

from bench_data import *

armi.configure(dif3ddemo.Dif3dDragonApp())

from armi.bookkeeping.db import Database3
from armi.reactor.flags import Flags
from armi.physics.neutronics import energyGroups
from armi.utils import units


def normalizeFlux(flux, _energy):
    """
    Normalize to equal peak flux. This helps simplify things because the energy ranges
    are so different.
    """

    norm = 1.0 / max(flux)
Ejemplo n.º 13
0
 def test_overConfigured(self):
     with self.assertRaises(exceptions.OverConfiguredError):
         armi.configure()
Ejemplo n.º 14
0
def main():
    import armi

    armi.configure(app.Dif3dDragonApp())

    code = ArmiCLI().run()
Ejemplo n.º 15
0
"""
Main module for example app.

Code here runs whenever you run this application.
"""
# FYI: The "tutorial-" comments are used in documentation building
# for `making_your_first_app.rst` in ARMI documentation.
# (That's also why the imports aren't all at the top)

# tutorial-configure-start
import armi

from myapp import app

armi.configure(app.ExampleApp())
# tutorial-configure-end

# tutorial-material-start
from armi import materials

materials.setMaterialNamespaceOrder(["myapp.materials", "armi.materials"])
# tutorial-material-end

# tutorial-entry-point-start
import sys
from armi.cli import ArmiCLI


def main():
    code = ArmiCLI().run()
    sys.exit(code)
Ejemplo n.º 16
0
 def tearDown(self):
     configure(self._backupApp, permissive=True)