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

The History Tracker stores history only for certain blocks and assemblies (known as detail assemblies or blocks). These can be input by the user in a variety of ways, through the GUI or the settings system.

  • Detail Assembly Locations BOL (detailAssemLocationsBOL) can be specified on the GUI. This is a list of assembly location strings (e.g. A4003 for ring 4, position3). Assemblies in these locations at beginning-of-life will be activated as detail assemblies.

  • Detail assembly numbers (detailAssemNums) are assemNum params similar to block IDs.

Finally, you can activate the detailAllAssems option to specify all assemblies in the problem as 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.

detailAssemblyNames

List of detail assembly names in the reactor

Type

list

time

list of reactor time in years

Type

list

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 = 'history'
interactBOL()[source]

Called at the Beginning-of-Life of a run, before any cycles start.

interactBOC(cycle=None)[source]

Look for any new assemblies that are asked for and add them to tracking.

interactEOL()[source]

Generate the history reports.

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

getTrackedParams()[source]

Give the list of block parameters that are being tracked.

addDetailAssembly(a)[source]

Track the name of all assemblies flagged for detailed treatment.

getDetailAssemblies()[source]

returns the assemblies that have been signaled as detail assemblies.

getDetailBlocks()[source]

Get all blocks in all detail assemblies.

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.

  • moc, eoc (boc,) – 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

list

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, ...]

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.

writeAssemHistory(a, fName='')[source]

Write the assembly history report to a text file.

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.

unloadBlockHistoryVals()[source]

Remove all cached db reads.

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

list

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

  • a blockStack list where each entry is a dictionary of [param,ts]=val maps (Creates) –

readFromArmi(blockName, historyInterface)[source]

Loads up a working AssemblyHistory object from the history interface

computeBounds()[source]

Finds the min and max values of all params in this assembly history

Returns

  • mins (dict) – Keys are param names, vals are minimum values for that param

  • maxes (dict) – Keys are param names, vals are maximum values for that param

class armi.bookkeeping.historyTracker.HistoryProcessor[source]

Bases: object

Processes stats on a bunch of assembly history files

Original use: computing ranges of operation for testing program

findHistoryFiles(path=None, title=None)[source]

Finds a list of all history files in a directory

Parameters
  • path (str, optional) – The path to look for. Default cwd.

  • title (str, optional) – The case title to limit too. Default: all

Returns

fileList – List of file names of assembly history files.

Return type

list

readAllAssemHistories(path=None, title=None)[source]
Parameters
  • path (str, optional) – The path to look for. Default cwd.

  • title (str, optional) – The case title to limit too. Default: all

Returns

assemHistoryList – List of assembly history objects

Return type

list

printAssemblyStats(assemTypes=None, path=None, title=None, assemHistoryList=None)[source]

Prints statistical report for assemblies of type assemType

Parameters
  • assemType (str or list) – Assembly type e.g. [‘LTA fuel’,’feed fuel’]

  • path (str, optional) – The path to look for. Default cwd.

  • title (str, optional) – The case title to limit too. Default: all

  • assemHistoryList (list of processed assembly histories) – Useful for multiple calls

findHistoriesWithHotPICT(assemTypes=None, path=None, title=None, assemHistoryList=None, pctBounds=[590, 600, 610, 620])[source]

Finds assemblies that have a peak 2-sigma PICT>various temperatures

Parameters
  • assemType (str or list) – Assembly type e.g. [‘LTA fuel’,’feed fuel’]

  • path (str, optional) – The path to look for. Default cwd.

  • title (str, optional) – The case title to limit too. Default: all

  • assemHistoryList (list of processed assembly histories) – Useful for multiple calls

  • pctBounds (list, optional) – The temperatures in C to make histograms for.

  • for by Bruce for materials testing development in BOR-60. Produces very useful figures (Asked) –

  • post-processing. (during) –

plotBounds(filteredSets, filteredBounds, assemTypes)[source]

Plots an incredibly useful figure showing which assemblies have which PICT through the lifetime

This is done after a run in post-processing for documentation of the case.

getValidHistories(assemTypes, path, title=None, assemHistoryList=None)[source]

Loads or filters a set of assembly histories to certain assemtypes

Parameters
  • assemType (str or list) – Assembly type e.g. [‘LTA fuel’,’feed fuel’]

  • path (str, optional) – The path to look or. Default cwd.

  • title (str, optional) – The case title to limit too. Default: all

  • assemHistoryList (list of processed assembly histories) – Useful for multiple calls

Returns

validAssems – The assem histories that match the criteria.

Return type

list

locateBoundingHistories()[source]

Determines which detail assemblies reach the bounds of each tracked parameter.

Returns

minMax – Keys are tracked keys, vals are (minV, maxV, avg, std) where minV and maxV(value, assembly, timestep) tuples for min and max avg is the arithmetic mean and std is the standard deviation for key

Return type

dict

Notes

This basically provides bounding values for each tracked parameter

printBoundingHistories(aType, params, minMax)[source]

Prints a summary of bounding parameter values for all detail assemblies.

Parameters

minMax (dict) – Keys are tracked keys, vals are (value, assembly, timestep) tuples for min and max.

processAll(path, title)[source]