Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New plugin hook for before reactor construction #1945

Merged
merged 7 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions armi/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,15 @@ def onProcessCoreLoading(core, cs, dbLoad) -> None:
constructing a Core from Blueprints, or after loading it from a database.
"""

@staticmethod
@HOOKSPEC
def beforeReactorConstruction(cs) -> None:
"""
Function to call before the reactor is constructed.

TODO fill out. Requirement for this?
opotowsky marked this conversation as resolved.
Show resolved Hide resolved
"""

@staticmethod
@HOOKSPEC
def defineFlags() -> Dict[str, Union[int, flags.auto]]:
Expand Down
13 changes: 13 additions & 0 deletions armi/reactor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@

from typing import Dict, Callable, Union, TYPE_CHECKING

from armi import materials
from armi import plugins

if TYPE_CHECKING:
Expand All @@ -62,6 +63,18 @@
class ReactorPlugin(plugins.ArmiPlugin):
"""Plugin exposing built-in reactor components, blocks, assemblies, etc."""

@staticmethod
@plugins.HOOKIMPL
def beforeReactorConstruction(cs) -> None:
from armi.settings.fwSettings.globalSettings import (
CONF_MATERIAL_NAMESPACE_ORDER,
)

# just before reactor construction, update the material "registry" with user settings,
# if it is set. Often it is set by the application.
opotowsky marked this conversation as resolved.
Show resolved Hide resolved
if cs[CONF_MATERIAL_NAMESPACE_ORDER]:
materials.setMaterialNamespaceOrder(cs[CONF_MATERIAL_NAMESPACE_ORDER])

@staticmethod
@plugins.HOOKIMPL
def defineBlockTypes():
Expand Down
10 changes: 4 additions & 6 deletions armi/reactor/reactors.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from typing import Optional
import copy

from armi import materials
from armi import getPluginManagerOrFail
from armi import runLog
from armi.reactor import composites
from armi.reactor import reactorParameters
Expand All @@ -29,7 +29,6 @@
from armi.reactor.systemLayoutInput import SystemLayoutInput
from armi.settings.fwSettings.globalSettings import (
CONF_GEOM_FILE,
CONF_MATERIAL_NAMESPACE_ORDER,
CONF_SORT_REACTOR,
)
from armi.utils import directoryChangers
Expand Down Expand Up @@ -180,10 +179,9 @@ def factory(cs, bp, geom: Optional[SystemLayoutInput] = None) -> Reactor:
from armi.reactor import blueprints

runLog.header("=========== Constructing Reactor and Verifying Inputs ===========")
# just before reactor construction, update the material "registry" with user settings,
# if it is set. Often it is set by the application.
if cs[CONF_MATERIAL_NAMESPACE_ORDER]:
materials.setMaterialNamespaceOrder(cs[CONF_MATERIAL_NAMESPACE_ORDER])

opotowsky marked this conversation as resolved.
Show resolved Hide resolved
getPluginManagerOrFail().hook.beforeReactorConstruction(cs=cs)

r = Reactor(cs.caseTitle, bp)

if cs[CONF_GEOM_FILE]:
Expand Down
7 changes: 4 additions & 3 deletions doc/release/0.4.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@ New Features
#. Adding ``--skip-inspection`` flag to ``CompareCases`` CLI. (`PR#1842 <https://github.com/terrapower/armi/pull/1842>`_)
#. Allow merging a component with zero area into another component (`PR#1858 <https://github.com/terrapower/armi/pull/1858>`_)
#. Use ``Block.getNumPins()`` in ``HexBlock._rotatePins()``. (`PR#1859 <https://github.com/terrapower/armi/pull/1859>`_)
#. Provide utilities for determining location of a rotated object in a hexagonal lattice (``getIndexOfRotatedCell``). (`PR#1846 <https://github.com/terrapower/armi/1846`)
#. Provide utilities for determining location of a rotated object in a hexagonal lattice (``getIndexOfRotatedCell``). (`PR#1846 <https://github.com/terrapower/armi/1846>`_)
#. Allow merging a component with zero area into another component. (`PR#1858 <https://github.com/terrapower/armi/pull/1858>`_)
#. Provide ``Parameter.hasCategory`` for quickly checking if a parameter is defined with a given category. (`PR#1899 <https://github.com/terrapower/armi/pull/1899>`_)
#. Provide ``ParameterCollection.where`` for efficient iteration over parameters who's definition matches a given condition. (`PR#1899 <https://github.com/terrapower/armi/pull/1899>`_)
#. Plugins can provide the ``getAxialExpansionChanger`` hook to customize axial expansion. (`PR#1870 <https://github.com/terrapower/armi/pull/1870`_)
#. Plugins can provide the ``getAxialExpansionChanger`` hook to customize axial expansion. (`PR#1870 <https://github.com/terrapower/armi/pull/1870>`_)
#. New plugin hook ``beforeReactorConstruction`` added to enable plugins to process case settings before reactor init. (`PR#1945 <https://github.com/terrapower/armi/pull/1945>`_)
#. TBD

API Changes
Expand All @@ -32,7 +33,7 @@ API Changes
#. Removing ``buildEqRingSchedule``. (`PR#1928 <https://github.com/terrapower/armi/pull/1928>`_)
#. Allowing for unknown Flags when opening a DB. (`PR#1844 <https://github.com/terrapower/armi/pull/1835>`_)
#. Removing ``assemblyLists.py`` and the ``AssemblyList`` class. (`PR#1891 <https://github.com/terrapower/armi/pull/1891>`_)
#. Removing ``Assembly.rotatePins`` and ``Block.rotatePins``. Prefer ``Assembly.rotate`` and ``Block.rotate``. (`PR#1846 <https://github.com/terrapower/armi/1846`_)
#. Removing ``Assembly.rotatePins`` and ``Block.rotatePins``. Prefer ``Assembly.rotate`` and ``Block.rotate``. (`PR#1846 <https://github.com/terrapower/armi/1846>`_)
#. Transposing ``pinMgFluxes`` parameters so that leading dimension is pin index (`PR#1937 <https://github.com/terrapower/armi/pull/1937>`)
#. TBD

Expand Down
Loading