armi.bookkeeping.db.databaseInterface module¶
The database interface provides a way to save the reactor state to a file, throughout a simulation.
- armi.bookkeeping.db.databaseInterface.describeInterfaces(cs)[source]¶
Function for exposing interface(s) to other code
- class armi.bookkeeping.db.databaseInterface.DatabaseInterface(r, cs)[source]¶
Bases:
armi.interfaces.Interface
Handles interactions between the ARMI data model and the persistent data storage system.
This reads/writes the ARMI state to/from the database and helps derive state information that can be derived.
- name: Optional[str] = 'database'¶
The name of the interface. This is undefined for the base class, and must be overridden by any concrete class that extends this one.
- property database¶
Presents the internal database object, if it exists.
- interactBOL()[source]¶
Initialize the database if the main interface was not available. (Begining of Life)
- initDB(fName: Optional[os.PathLike] = None)[source]¶
Open the underlying database to be written to, and write input files to DB.
Notes
Main Interface calls this so that the database is available as early as possible in the run. The database interface interacts near the end of the interface stack (so that all the parameters have been updated) while the Main Interface interacts first.
- interactEveryNode(cycle, node)[source]¶
Write to database.
DBs should receive the state information of the run at each node.
Notes
if tight coupling is enabled, the DB will be written in operator.py::Operator::_timeNodeLoop via writeDBEveryNode
- interactEOC(cycle=None)[source]¶
In case anything changed since last cycle (e.g. rxSwing), update DB. (End of Cycle)
- interactDistributeState() None [source]¶
Reconnect to pre-existing database.
DB is created and managed by the primary node only but we can still connect to it from workers to enable things like history tracking.
- prepRestartRun()[source]¶
Load the data history from the database requested in the case setting reloadDBName.
Reactor state is put at the cycle/node requested in the case settings startCycle and startNode, having loaded the state from all cycles prior to that in the requested database.
Notes
Mixing the use of simple vs detailed cycles settings is allowed, provided that the cycle histories prior to startCycle/startNode are equivalent.
- loadState(cycle, timeNode, timeStepName='', fileName=None, updateGlobalAssemNum=True)[source]¶
Loads a fresh reactor and applies it to the Operator.
Notes
Will load preferentially from the fileName if passed. Otherwise will load from existing database in memory or cs[“reloadDBName”] in that order.
- Raises
RuntimeError – If fileName is specified and that file does not have the time step. If fileName is not specified and neither the database in memory, nor the cs[“reloadDBName”] have the time step specified.
- getHistory(comp: armi.reactor.composites.ArmiObject, params: Optional[Sequence[str]] = None, timeSteps: Optional[MutableSequence[Tuple[int, int]]] = None, byLocation: bool = False) Dict[str, Dict[Tuple[int, int], Any]] [source]¶
Get historical parameter values for a single object.
This is mostly a wrapper around the same function on the
Database3
class, but knows how to return the current value as well.See also
Database3.getHistory
- getHistories(comps: Sequence[armi.reactor.composites.ArmiObject], params: Optional[Sequence[str]] = None, timeSteps: Optional[MutableSequence[Tuple[int, int]]] = None, byLocation: bool = False) Dict[armi.reactor.composites.ArmiObject, Dict[str, Dict[Tuple[int, int], Any]]] [source]¶
Get historical parameter values for one or more objects.
This is mostly a wrapper around the same function on the
Database3
class, but knows how to return the current value as well.See also
Database3.getHistories