Persistent Materials object

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?

Some thoughts:

  1. Material data loading regularly takes more time
  2. A Materials object could load XS data outside of running a model
  3. 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.

https://docs.openmc.org/en/latest/pythonapi/capi.html

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.

1 Like

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

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