Assembly Inventories
This chapter explains what an assembly inventory is, how it’s updated, and how its contents can be explored.
What is the structure of an Inventory?
An Inventory is simply a directory that contains a list of (binary) assembly history files. To use a specific inventory,
this directory must be assigned to the model.inventory_manager.inventory
.
How is an Inventory updated?
Currently, the inventory is updated by two application modes:
When new batches are added in the facility_management application. This will create a new assembly history file within the directory.
The inventory is updated by the core_follow application mode, usually with beginning, and end of cycle material states. Only assemblies loaded in the core for the specific cycle is updated.
Note
Many other application modes (such as reload), will create local copies (or branches) of an inventory. This should be considered as part of that application’s output data, and not the model’s state.
Exploring inventory contents using the Python API
The following basic example shows how to open an inventory, check that it has some assemblies in it, load the first assembly, and check its current U-235 contents:
>>> from inventory.inventories import FlatInventory
>>> inv = FlatInventory('/path/to/MY_REACTOR/My_Inventory', model_path='/path/to/MY_REACTOR/model')
>>> assert (len(inv.assemblies() != 0))
>>> hist = inv.load_history(inv.assemblies()[0])
>>> print(hist.timestamps())
>>> asm = hist.get_at(hist.timestamps()[-1])
>>> print(asm.get_mass('U-235'))
A detailed description of the most important interface elements are given below.
- inventory.inventories.FlatInventory(path, model_path=None)
Loads an inventory object from disk.
- Parameters:
This
FlatInventory
is essentially a dict like object, mapping assembly names toAssemblyHistory
instances. The interface of both objects are described below.Note
The name reflects the fact that the inventory does not store any relational data from the assembly histories it manages. Thus only name, and time based queries are possible.
The created FlatInventory
instance has the following methods that can be used to query its contents:
- inv.has_assembly(name)
Checks if an assembly with given name is currently in the inventory.
- Parameters:
name (str) – Target assembly name.
- inv.timestamps()
Returns a list of datetime entries at which any assembly within the inventory was updated.
- inv.backtrack(to)
Remove all entries in the inventory after a specified time, essentially resetting the inventory state.
- Parameters:
to (datetime) – Target time point. All entries will be removed after this point.
Note
This is similar to manager inventory –backtrack, except that assemblies which only have entries after this date, will not be removed.
Attention
This call can not be undone, so use with caution!
- inv.decay_assemblies(target_time, assemblies='all')
Perform decay (cool down) for assemblies managed by the inventory.
- Parameters:
This will create a new entry at target_time in all targeted assemblies, with new material compositions after performing radioactive decay from the previous saved point.
Note
Currently, although the rate equation is exact, only isotopes with neutron cross sections are stored in the material compositions.
Exploring assembly history files using the Python API
This section describes how to query data from a single assembly history instance, as returned by
inv.load_history
.
Attention
None of the assembly history queries listed below will perform any decay calculations. The only way to currently
decay assemblies to a specific point is through the inv.decay_assemblies
call.
- hist.get_bol()
Return the assembly at Beginning of Life (fresh) conditions.
This returns a complete Assembly instance.
- hist.get_at(time=None)
Retrieve the assembly state at a specific time point in the history.
- Parameters:
time – Target time point. If not specified, the state at the last entry is returned.
This returns a complete Assembly instance.
Note
If time is not one of the saved points (as returned by
hist.timestamps()
), then the state at the closets point less than time is returned. In this case, no decay to the target time is performed.
- hist.backtrack(to)
Similar to
inv.backtrack()
, except that only this assembly history is affected.
- hist.get_mass(isotope, at=None)
Retrieve the total mass of an isotope (or element) at a specific point in the history archive.
- Parameters:
- Returns:
A mass value, representing the total mass of isotope in the assembly at the closest time point less than or equal to at.
- hist.get_delta_mass(isotope, begin=None, end=None)
Retrieve the total mass change of an isotope (or element) between tow points in the history archive.
- Parameters:
isotope (isotope) – Target isotope or element.
begin (datetime) – The first reference point. If not specified, the first time point in the assembly history is assumed (i.e.
hist.timestamps()[0]
).end (datetime) – The second point, which must be after begin. If not specified, the last point in the assembly history is assumed (i.e.
hist.timestamps()[-1]
).
- Returns:
A mass value, representing the total mass change in isotope from begin to end.
- hist.import_inventory(source, steps=None)
Import saved time points from another assembly history into this one.
- Parameters:
source – Another AssemblyHistory instance.
steps – Time points from source that should be copied to this instance. If not specified, all points returned by
hist.timestamps
will be inserted.
Other ways to query Inventory contents
The inventory contents can be view using the CLI via the manager utility. An inventory report can also be added to documents using the inventory_report directive.