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: 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[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

writeDBEveryNode()[source]

Write the database at the end of the time node.

interactEOC(cycle=None)[source]

Dont write; this state doesn’t tend to be important since its decay only step.

Notes

The same time is available at start of next cycle.

interactEOL()[source]

DB’s should be closed at run’s end. (End of Life).

closeDB()[source]

Close the DB, writing to file.

interactError()[source]

Get shutdown state information even if the run encounters an error.

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.

distributable()[source]
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.

ARMI expects the reload DB to have been made in the same version of ARMI as you are running. ARMI does not gaurantee that a DB from a decade ago will be easily used to restart a run.

loadState(cycle, timeNode, timeStepName='', fileName=None)[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: 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[ArmiObject], params: Optional[Sequence[str]] = None, timeSteps: Optional[MutableSequence[Tuple[int, int]]] = None, byLocation: bool = False) Dict[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