Skip to content

Instantly share code, notes, and snippets.

@paulromano
Created March 14, 2019 12:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paulromano/5ba4cde5b33e35366074531186ae46d6 to your computer and use it in GitHub Desktop.
Save paulromano/5ba4cde5b33e35366074531186ae46d6 to your computer and use it in GitHub Desktop.
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