armi.bookkeeping.historyTracker module¶
The History Tracker is a bookkeeping interface that accesses and reports time-dependent state information from the database.
At the end of a run, these write text files to show the histories for various follow-on mechanical analysis, fuel performance analysis, etc.
Other interfaces may find this useful as well, to get an assembly history
for fuel performance analysis, etc. This is particularly useful in equilibrium runs,
where the EqHistoryTrackerInterface
will unravel the full history from a single
equilibrium cycle.
Getting history information¶
Loop over blocks, keys, and timesteps of interest and use commands like this:
history.getBlockHistoryVal(armiBlock.getName(), key, ts)
Using the database-based history trackers¶
You can pre-load information before gathering it to get much better performance:
history.preloadBlockHistoryVals(blockNames, historyKeys, timeSteps)
This is essential for performance when history information is going to be accessed in loops over assemblies or blocks. Reading each param directly from the database individually in loops is paralyzingly slow.
Specifying parameters to add to the EOL history report¶
To add state parameters to the list of things that get their history reported, you need to define an interface method called getHistoryParams. It should return a list of block parameters that will become available. For example:
def getHistoryParams(self):
return ['flux', 'percentBu']
When you’d like to access history information, you need to grab the history interface. The history interfaces is present by default in your interface stack. To get it, just call:
history = self.getInterface('history')
Now you can do a few things, such as:
# get some info about what's stored in the history
assemsWithHistory = history.getDetailAssemblies()
timeStepsAvailable = history.getTimeIndices()
# now go out and get some time-dependent block params:
fluxAtTimeStep3 = history.getBlockHistoryVal('B1003A', 'flux', 3)
Specifying blocks and assemblies to track¶
See Detail assemblies.
- armi.bookkeeping.historyTracker.describeInterfaces(cs)[source]¶
Function for exposing interface(s) to other code
- class armi.bookkeeping.historyTracker.HistoryTrackerInterface(r, cs)[source]¶
Bases:
armi.interfaces.Interface
Makes reports of the state that individual assemblies encounter.
- Variables
HistoryTracker that uses the database to look up parameter history rather than storing them in memory.
Warning
If the current timestep history is requested and the database has not yet been written this timestep, the current value of the requested parameter is provided. It is possible that this is not the value that will be written to the database during this time step since many interfaces that change parameters may interact between this call and the database write.
- name: Optional[str] = 'history'¶
The name of the interface. This is undefined for the base class, and must be overridden by any concrete class that extends this one.
- interactBOC(cycle=None)[source]¶
Look for any new assemblies that are asked for and add them to tracking.
- addDetailAssembliesBOL()[source]¶
Find and activate assemblies that the user requested detailed treatment of.
- addDetailAssemsByAssemNums()[source]¶
Activate detail assemblies from input based on assembly number.
This is used to activate detail assembly tracking on assemblies that are not present in the core at BOL.
See also
addDetailAssembliesBOL
Similar but for BOL
- filterTimeIndices(timeIndices, boc=False, moc=False, eoc=False)[source]¶
Takes a list of time indices and filters them down to boc moc or eoc.
- getTimeIndices(a=None, boc=False, moc=False, eoc=False)[source]¶
Generate a list of timestep indices where valid history data exist for the given criteria.
- Parameters
a (Assembly, optional) – If given, only generate time indices where the assembly a is in the core. Default: All assemblies.
boc (bool, optional) – Will return boc/moc/eoc timenodes in every cycle. If any of these are true, allNodes becomes False
moc (bool, optional) – Will return boc/moc/eoc timenodes in every cycle. If any of these are true, allNodes becomes False
eoc (bool, optional) – Will return boc/moc/eoc timenodes in every cycle. If any of these are true, allNodes becomes False
- Returns
timeIndices – A list of integers where history data exists.
- Return type
Examples
If there are 5 nodes per cycle (burnSteps = 4), 0 1 2 3 4 | 5 6 7 8 9 | 10 11 12 13 14 | …:
>>> getTimeIndices(moc=True): [2, 7, 12, ...]
Warning
This is no longer functional, as much of the old history tracking was based on implementation details of the Database, version 2. We now directly support history tracking through the Database, version 3. At some point this code should be removed.
See also
getTimeSteps
gets time in years where the assembly is in the core
- getBOCEOCTimeIndices(assem=None)[source]¶
returns a list of time step indices that only include BOC and EOC, no intermediate ones.
- getAssemParamHistory(a, neededParams)[source]¶
Gets the history typically used for the Alchemy Writer
- Returns
assemHistory – e.g. assemHistory[block][time_step][parameter] = value of parameter at time step on block
- Return type
dict, nested with 3 levels,
- Raises
RuntimeError – When the assembly has no history.
- printFullCoreLocations()[source]¶
Print a report showing the locations of each assembly as functions of time.
This is useful for third-party follow-on analysis of fuel management.
- preloadBlockHistoryVals(names, keys, timesteps)[source]¶
Pre-load block data so it can be more quickly accessed in the future.
Notes
Pre-loading has value because the database is organized in a fashion that is easy/inexpensive to look up data for many of time steps simultaneously. These can then be stored and provided when the specific timestep is requested. The method
getBlockHistoryVal
still looks at the database if the preloaded values don’t have the needed data, so the same results should be given if this method is not called.
- getBlockHistoryVal(name: str, paramName: str, ts: Tuple[int, int])[source]¶
Use the database interface to return the parameter values for the supplied block names, and timesteps.
Notes
If the current timestep history is requested and the database has not yet been written this timestep, the current value of the requested parameter is returned.
- Parameters
name – name of block
paramName – parameter keys of interest
ts – cycle and node from which to load data
- Raises
KeyError – When param not found in database.
- getTimeSteps(a=None)[source]¶
return list of time steps values (in years) that are available.
- Parameters
a (Assembly object, optional) – An assembly object designated a detail assem. If passed, only timesteps where this assembly is in the core will be tracked.
- Returns
timeSteps – times in years that are available in the history
- Return type
See also
getTimeIndices
gets indices where an assembly is in the core
- class armi.bookkeeping.historyTracker.HistoryFile[source]¶
Bases:
object
A general history file that contains the parameter history of an object.
The object may be a block or assembly. This tracks them through time
Originally, these files were just created by the history interface, but it became necessary to read them and post-process them for statistical needs (stats for individual assembly types) so it became an object
They were typically named A234-ahist.txt or so.
- class armi.bookkeeping.historyTracker.AssemblyHistory[source]¶
Bases:
armi.bookkeeping.historyTracker.HistoryFile
History report of a single assembly.
- read(fName)[source]¶
Reads an assembly history file into memory.
- Parameters
fName (str) – The filename to read
[param (Creates a blockStack list where each entry is a dictionary of) –
maps (ts]=val) –