Materials data is loaded from storage on running each model instance, which can take a large part of the total runtime for parameter sweeps.
Is it possible to make an object to store material data that would persist in memory across models?
Material data loading regularly takes more time
A Materials object could load XS data outside of running a model
The Materials object would need a function to compare requested XS data to available, then loading additional isotope XS data when requested
Hi Sam, welcome to the OpenMC forum
Openmc.lib might suit your purposes for preloading nuclear data.
When using openmc.lib.init() this would load up the nuclear data in the materials and then you can add to this collection with openmc.lib.load_nuclide.
Also another option to speed up the cross section loading is to use parallel hdf5
Slightly related but you might be keen to hear that we recently removed the need to load cross sections when plotting and also there is a live pull request that removes the need to load cross sections when doing a stocatisc volume calculation.
I have made an example openmc.lib script that performs a parameter study with a changing material definition.
This parameter study also exists as a
normal (non openmc.lib) example so it is easy to compare the time saving.
For this example the nuclear data now gets loaded just once instead of 5 times which saves a decent amount of time as the simulation itself is very quick
This file has been truncated.
This script performs many simulations to find Tritium Breeding Ratio (TBR)
as a function of lithium 6 enrichment while only loading the nuclear data for
the nuclides just once.
As the simulation for TBR is quick and the loading of nuclear data is a relatively
large part of the process this saves a significant amount of time.
Using just the standard openmc python API one would have to load the same
nuclear data for each simulation.
openmc.lib provides Python bindings to the C/C++ API so we can have fine grain
control of the loading of the data, accessing the tallies and changing materials.
# make some python materials
breeder_material = openmc.Material(material_id = 12) # Pb84.2Li15.8
That looks perfect, thanks! I’ll have a look at this and see if I can make use of it. Sorry for the slow replies, struggling to find time for my side project