Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Convert MCNP endf66[a-c] library to OpenMC HDF5
#!/usr/bin/env python3
from pathlib import Path
import openmc.data
output = Path('endf66_hdf5')
output.mkdir()
mcnpdata = Path('/opt/mcnp/6.1/MCNP_DATA/xdata')
lib = openmc.data.DataLibrary()
files = ['endf66a', 'endf66b', 'endf66c']
for f in files:
acelib = openmc.data.ace.Library(mcnpdata / f)
for t in acelib.tables:
try:
print('Converting {}...'.format(t.name))
nuc = openmc.data.IncidentNeutron.from_ace(t)
except Exception as e:
print('Could not process {}: {}'.format(t.name, e))
continue
path = output / '{}.h5'.format(nuc.name)
nuc.export_to_hdf5(path)
lib.register_file(path)
lib.export_to_xml(output / 'cross_sections.xml')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment