Combining MGXS Libraries

Hi All,

I’m new to MGXS mode, and am curious about its capabilities. In particular, is there a way to combine MGXS libraries into a single library? I’m interested in generating MGXS data for individual materials in separate OpenMC simulations, and then dumping the results to the same pkl or hdf5 file for later use.

I see that there are the build_hdf5_store() and dump_to_file() methods for saving MGXS libraries as HDF5 or pickled files, but is there a similar way to append those saved MGXS libraries with new MGXS data, or combine multiple HDF5 or pkl files into a single file?

Thanks!

Hi @kevinm387! The build_hdf5_store and dump_to_file methods don’t really write information to HDF5/pickle files in a way that would allow them to be naturally combined. I would note though that the dump_to_file method just uses the Python pickle standard library module, so you could achieve what you want by pickling a list of Library objects:

mgxs_lib1 = openmc.mgxs.Library(...)
mgxs_lib2 = openmc.mgxs.Library(...)
libs = [mgxs_lib1, mgxs_lib2]

# Pickle libraries together
with open(filename, 'wb') as f:
    pickle.dump(libs, f)

and unpickling them would look like:

with open(filename, 'rb') as f:
    libs = pickle.load(f)

Thanks @paulromano! This should work well for what I need.