Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 52 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,17 @@ A few categories of scripts are available:

## Produce Cross Section Files

Each generate and convert script produces data from one evaluated library only.
Photon or other data missing from that library are not filled in from another
library. To combine libraries, for example JEFF neutron data with ENDF/B photon
data, run the scripts separately and combine the `cross_sections.xml` files.

Each `cross_sections.xml` written by these scripts starts with an XML comment
that records the data source, the number of entries of each type, the
openmc_data version and script, and any evaluations taken from another library.
OpenMC ignores XML comments, so the comment does not change how the library
loads. `openmc.data.DataLibrary` drops comments when it rewrites a file.

### Convert cross sections

| Script name | Library | Release | Processed by |
Expand Down Expand Up @@ -127,9 +138,14 @@ See `convert_jeff --help` for all options.
| generate_endf | ENDF/B | VII.1<br>VIII.0<br>VIII.1 | NNDC |
| generate_fendl | FENDL | 3.2c<br>3.2b<br>3.2a<br>3.2<br>3.1d<br>3.1a<br>3.0 | |
| generate_jendl | JENDL | 4.0<br>5.0 (neutron, thermal scattering and photon) | NJOY |
| generate_jeff | JEFF | 3.3<br>4.0 (neutron and thermal scattering) | NJOY |
| generate_jeff | JEFF | 3.3\*<br>4.0 (neutron and thermal scattering) | NJOY |
| generate_tendl | TENDL | 2023<br>2025 | |

\* `generate_jeff -r 3.3` substitutes TENDL-2019 evaluations for C13 and O17, because
the JEFF 3.3 evaluations of these nuclides have defective MF=6 data. The C13 and O17
files in the output are therefore TENDL-2019 data, not JEFF. JEFF 4.0 has no
substitutions.


### Download cross sections

Expand All @@ -152,6 +168,41 @@ See `convert_jeff --help` for all options.
|generate_jendl| JENDL | 4.0 | | | | :heavy_check_mark: | |
|convert_tendl| TENDL | 2015<br>2017<br>2019<br>2021| | | :heavy_check_mark: | | | -->

### Combine libraries

The generate and convert scripts never mix libraries, so photon data for a
neutron-only library (JEFF, TENDL) come from a separate run. `combine_libraries`
then merges the `cross_sections.xml` files. Libraries are listed in order of
preference: everything from the first is used, and a later library only adds
entries the earlier ones lack. Give the photon library as a photon-only library,
otherwise its neutron and thermal entries would also fill gaps in the first.

JEFF-4.0 neutron and thermal scattering data with ENDF/B-VIII.1 photon data:

```bash
generate_jeff -r 4.0 # writes jeff-4.0-hdf5/
generate_endf -r viii.1 -p photon # writes endfb-viii.1-hdf5/ (photon only)
combine_libraries \
-l jeff-4.0-hdf5/cross_sections.xml endfb-viii.1-hdf5/cross_sections.xml \
-o jeff-4.0-endfb-viii.1-photon.xml
```

TENDL-2025 neutron data with ENDF/B-VIII.1 photon data:

```bash
generate_tendl -r 2025 # writes tendl-2025-hdf5/
generate_endf -r viii.1 -p photon # writes endfb-viii.1-hdf5/ (photon only)
combine_libraries \
-l tendl-2025-hdf5/cross_sections.xml endfb-viii.1-hdf5/cross_sections.xml \
-o tendl-2025-endfb-viii.1-photon.xml
```

Without `-d` the combined XML is written to the current directory and points at
the original files. With `-d <directory>` the HDF5 files are copied there too.
The combined XML records, as a comment, how many entries of each type came from
which library. Point OpenMC at it with `openmc.config['cross_sections']` or
`OPENMC_CROSS_SECTIONS`.

## Produce Depletion Chain files

### Generate chain files
Expand Down
1 change: 1 addition & 0 deletions src/openmc_data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

from .utils import (
ProgressTracker,
add_provenance,
apply_updates,
calculate_download_size,
download,
Expand Down
3 changes: 2 additions & 1 deletion src/openmc_data/convert/convert_endf.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from pathlib import Path

import openmc.data
from openmc_data import download, extract, all_release_details, get_file_types, calculate_download_size, ProgressTracker
from openmc_data import add_provenance, download, extract, all_release_details, get_file_types, calculate_download_size, ProgressTracker

# Make sure Python version is sufficient
assert sys.version_info >= (3, 6), "Python 3.6+ is required"
Expand Down Expand Up @@ -187,6 +187,7 @@ def main():
# Write cross_sections.xml
print("Writing ", args.destination / "cross_sections.xml")
library.export_to_xml(args.destination / "cross_sections.xml")
add_provenance(args.destination / "cross_sections.xml", "ENDF/B-VII.1")


if __name__ == "__main__":
Expand Down
3 changes: 2 additions & 1 deletion src/openmc_data/convert/convert_fendl.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from urllib.parse import urljoin

import openmc.data
from openmc_data import download, all_release_details, calculate_download_size, get_file_types, ProgressTracker
from openmc_data import add_provenance, download, all_release_details, calculate_download_size, get_file_types, ProgressTracker


class CustomFormatter(
Expand Down Expand Up @@ -291,6 +291,7 @@ def main():
# Write cross_sections.xml
print("Writing ", args.destination / "cross_sections.xml")
library.export_to_xml(args.destination / "cross_sections.xml")
add_provenance(args.destination / "cross_sections.xml", f"FENDL-{args.release}")

# Print any warnings
for warning in output_warnings:
Expand Down
3 changes: 2 additions & 1 deletion src/openmc_data/convert/convert_jeff.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from tempfile import TemporaryDirectory
import warnings

from openmc_data import ProgressTracker, all_release_details, download, extract
from openmc_data import ProgressTracker, add_provenance, all_release_details, download, extract


RELEASES = ("3.2", "3.3", "4.0")
Expand Down Expand Up @@ -293,6 +293,7 @@ def main(argv=None):
del data
library.register_file(output)
library.export_to_xml(stage / "cross_sections.xml")
add_provenance(stage / "cross_sections.xml", f"JEFF-{args.release}")
for name in groups:
(stage / f"{name}.h5").replace(destination / f"{name}.h5")
(stage / "cross_sections.xml").replace(destination / "cross_sections.xml")
Expand Down
3 changes: 2 additions & 1 deletion src/openmc_data/convert/convert_lib80x.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import openmc.data

from openmc_data import ProgressTracker
from openmc_data import ProgressTracker, add_provenance


# Make sure Python version is sufficient
Expand Down Expand Up @@ -107,6 +107,7 @@ def main():

# Write cross_sections.xml
library.export_to_xml(args.destination / 'cross_sections.xml')
add_provenance(args.destination / 'cross_sections.xml', 'ENDF/B-VIII.0 (LANL lib80x)')


if __name__ == '__main__':
Expand Down
36 changes: 8 additions & 28 deletions src/openmc_data/convert/convert_mcnp70.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
"""
Convert ENDF/B-VII.0 ACE data from the MCNP5/6 distribution into an HDF5 library
that can be used by OpenMC. This assumes that you have a directory containing
files named endf70[a-k] and endf70sab. Optionally, if a recent photoatomic
library (e.g., eprdata14) is available, it can also be converted using the
--photon argument.
files named endf70[a-k] and endf70sab. Only the ENDF/B neutron and thermal
scattering data are converted; photoatomic data from other libraries
(e.g. eprdata) are not added. To use them, convert them separately and combine
the cross_sections.xml files.
"""

import argparse
Expand All @@ -15,7 +16,7 @@

import openmc.data

from openmc_data import ProgressTracker
from openmc_data import ProgressTracker, add_provenance


# Make sure Python version is sufficient
Expand All @@ -38,25 +39,21 @@ class CustomFormatter(argparse.ArgumentDefaultsHelpFormatter,
default='earliest', help="Output HDF5 versioning. Use "
"'earliest' for backwards compatibility or 'latest' for "
"performance")
parser.add_argument('-p', '--photon', type=Path,
help='Path to photoatomic data library (eprdata12 or later)')
parser.add_argument('mcnpdata', type=Path,
help="Directory containing endf70[a-k], endf70sab, and mcplib")
help="Directory containing endf70[a-k] and endf70sab")
args = parser.parse_args()


def main():

# Check arguments to make sure they're valid
assert args.mcnpdata.is_dir(), 'mcnpdata argument must be a directory'
if args.photon is not None:
assert args.photon.is_file(), 'photon argument must be an existing file'

# Get a list of all neutron ACE files
endf70 = args.mcnpdata.glob('endf70[a-k]')

# Create output directory if it doesn't exist
(args.destination / 'photon').mkdir(parents=True, exist_ok=True)
args.destination.mkdir(parents=True, exist_ok=True)

library = openmc.data.DataLibrary()

Expand Down Expand Up @@ -121,26 +118,9 @@ def main():
# Register with library
library.register_file(h5_file)

# Handle photoatomic data
if args.photon is not None:
lib = openmc.data.ace.Library(args.photon)

tracker = ProgressTracker(len(lib.tables))
for table in lib.tables:
# Convert first temperature for the table
tracker.starting(table.name)
data = openmc.data.IncidentPhoton.from_ace(table)

# Export HDF5 file
h5_file = args.destination / 'photon' / f'{data.name}.h5'
print(f'Writing {h5_file}...')
data.export_to_hdf5(h5_file, 'w', libver=args.libver)

# Register with library
library.register_file(h5_file)

# Write cross_sections.xml
library.export_to_xml(args.destination / 'cross_sections.xml')
add_provenance(args.destination / 'cross_sections.xml', 'ENDF/B-VII.0 (MCNP endf70)')


if __name__ == '__main__':
Expand Down
34 changes: 7 additions & 27 deletions src/openmc_data/convert/convert_mcnp71.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
"""
Convert ENDF/B-VII.1 ACE data from the MCNP6 distribution into an HDF5 library
that can be used by OpenMC. This assumes that you have a directory containing
subdirectories 'endf71x' and 'ENDF71SaB'. Optionally, if a recent photoatomic
library (e.g., eprdata14) is available, it can also be converted using the
--photon argument.
subdirectories 'endf71x' and 'ENDF71SaB'. Only the ENDF/B neutron and thermal
scattering data are converted; photoatomic data from other libraries
(e.g. eprdata) are not added. To use them, convert them separately and combine
the cross_sections.xml files.
"""

import argparse
Expand All @@ -15,7 +16,7 @@

import openmc.data

from openmc_data import ProgressTracker
from openmc_data import ProgressTracker, add_provenance


# Make sure Python version is sufficient
Expand All @@ -38,8 +39,6 @@ class CustomFormatter(argparse.ArgumentDefaultsHelpFormatter,
default='earliest', help="Output HDF5 versioning. Use "
"'earliest' for backwards compatibility or 'latest' for "
"performance")
parser.add_argument('-p', '--photon', type=Path,
help='Path to photoatomic data library (eprdata12 or later)')
parser.add_argument('mcnpdata', type=Path,
help='Directory containing endf71x and ENDF71SaB')
args = parser.parse_args()
Expand All @@ -49,8 +48,6 @@ def main():

# Check arguments to make sure they're valid
assert args.mcnpdata.is_dir(), 'mcnpdata argument must be a directory'
if args.photon is not None:
assert args.photon.is_file(), 'photon argument must be an existing file'

# Get a list of all ACE files
endf71x = list(args.mcnpdata.glob('endf71x/*/*.7??nc'))
Expand Down Expand Up @@ -85,7 +82,7 @@ def main():
tables[p.stem].append(p)

# Create output directory if it doesn't exist
(args.destination / 'photon').mkdir(parents=True, exist_ok=True)
args.destination.mkdir(parents=True, exist_ok=True)

library = openmc.data.DataLibrary()

Expand Down Expand Up @@ -116,26 +113,9 @@ def main():
# Register with library
library.register_file(h5_file)

# Handle photoatomic data
if args.photon is not None:
lib = openmc.data.ace.Library(args.photon)

tracker = ProgressTracker(len(lib.tables))
for table in lib.tables:
# Convert first temperature for the table
tracker.starting(table.name)
data = openmc.data.IncidentPhoton.from_ace(table)

# Export HDF5 file
h5_file = args.destination / 'photon' / f'{data.name}.h5'
print(f'Writing {h5_file}...')
data.export_to_hdf5(h5_file, 'w', libver=args.libver)

# Register with library
library.register_file(h5_file)

# Write cross_sections.xml
library.export_to_xml(args.destination / 'cross_sections.xml')
add_provenance(args.destination / 'cross_sections.xml', 'ENDF/B-VII.1 (MCNP endf71x)')


if __name__ == '__main__':
Expand Down
3 changes: 2 additions & 1 deletion src/openmc_data/convert/convert_tendl.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from urllib.parse import urljoin

import openmc.data
from openmc_data import download, extract, calculate_download_size, all_release_details, get_file_types, ProgressTracker
from openmc_data import add_provenance, download, extract, calculate_download_size, all_release_details, get_file_types, ProgressTracker


# Make sure Python version is sufficient
Expand Down Expand Up @@ -165,6 +165,7 @@ def main():

# Write cross_sections.xml
library.export_to_xml(args.destination / "cross_sections.xml")
add_provenance(args.destination / "cross_sections.xml", f"TENDL-{args.release}")


if __name__ == "__main__":
Expand Down
3 changes: 2 additions & 1 deletion src/openmc_data/generate/generate_cendl.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from urllib.parse import urljoin

import openmc.data
from openmc_data import download, extract, process_neutron, state_download_size, ProgressTracker
from openmc_data import add_provenance, download, extract, process_neutron, state_download_size, ProgressTracker


class CustomFormatter(argparse.ArgumentDefaultsHelpFormatter,
Expand Down Expand Up @@ -155,6 +155,7 @@ def main():

# Write cross_sections.xml
library.export_to_xml(args.destination / 'cross_sections.xml')
add_provenance(args.destination / 'cross_sections.xml', f'CENDL-{args.release}')


if __name__ == '__main__':
Expand Down
3 changes: 2 additions & 1 deletion src/openmc_data/generate/generate_endf.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from shutil import rmtree, copy, copyfileobj

import openmc.data
from openmc_data import download, process_neutron, process_thermal, state_download_size, ProgressTracker
from openmc_data import add_provenance, download, process_neutron, process_thermal, state_download_size, ProgressTracker

# Make sure Python version is sufficient
assert sys.version_info >= (3, 6), "Python 3.6+ is required"
Expand Down Expand Up @@ -504,6 +504,7 @@ def main():

# Write cross_sections.xml
library.export_to_xml(args.destination / 'cross_sections.xml')
add_provenance(args.destination / 'cross_sections.xml', f'ENDF/B-{args.release.upper()}')


if __name__ == '__main__':
Expand Down
3 changes: 2 additions & 1 deletion src/openmc_data/generate/generate_fendl.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from urllib.parse import urljoin

import openmc.data
from openmc_data import download, extract, process_neutron, state_download_size, all_release_details, ProgressTracker
from openmc_data import add_provenance, download, extract, process_neutron, state_download_size, all_release_details, ProgressTracker


class CustomFormatter(argparse.ArgumentDefaultsHelpFormatter,
Expand Down Expand Up @@ -124,6 +124,7 @@ def main():

# Write cross_sections.xml
library.export_to_xml(args.destination / 'cross_sections.xml')
add_provenance(args.destination / 'cross_sections.xml', f'FENDL-{args.release}')


if __name__ == '__main__':
Expand Down
Loading