diff --git a/.github/workflows/test_package.yml b/.github/workflows/test_package.yml index d2f2676..ce3138b 100644 --- a/.github/workflows/test_package.yml +++ b/.github/workflows/test_package.yml @@ -52,9 +52,6 @@ jobs: run: | convert_fendl --help convert_jeff --help - convert_lib80x --help - convert_mcnp70 --help - convert_mcnp71 --help convert_endf --help convert_tendl --help diff --git a/.github/workflows/test_processing.yml b/.github/workflows/test_processing.yml index 35f814c..cac6e5a 100644 --- a/.github/workflows/test_processing.yml +++ b/.github/workflows/test_processing.yml @@ -48,10 +48,6 @@ jobs: cd .. pip install . - # Convert scripts that require MCNP nuclear data are not tested because - # the CI doesn't contain that nuclear data. - # convert_lib80x.py convert_mcnp70.py convert_mcnp71.py files are not tested here - - name: test default convert_fendl if: inputs.script == 'convert_fendl' run: | diff --git a/README.md b/README.md index 6f9392f..cfbe7be 100644 --- a/README.md +++ b/README.md @@ -93,14 +93,11 @@ loads. `openmc.data.DataLibrary` drops comments when it rewrites a file. ### Convert cross sections -| Script name | Library | Release | Processed by | -|-|-|-|-| -|convert_mcnp70 | ENDF/B | VII.0 | LANL | -|convert_mcnp71 | ENDF/B | VII.1 | LANL | -|convert_endf | ENDF/B | VII.1 | NNDC | -|convert_lib80x | ENDF/B | VIII.0 | LANL | +| Script name | Library | Release | +|-|-|-| +|convert_endf | ENDF/B | VII.1 | |convert_fendl | FENDL | 3.2c
3.2b
3.2a
3.2
3.1d
3.1a
3.1
3.0
2.1 | -|convert_jeff | JEFF | 3.2
3.3
4.0 (default) | OECD/NEA | +|convert_jeff | JEFF | 3.2
3.3
4.0 (default) | |convert_tendl | TENDL | 2015
2017
2019
2021 | #### JEFF ACE conversion @@ -132,14 +129,14 @@ See `convert_jeff --help` for all options. ### Generate cross sections -| Script name | Library | Release | Processed by | -|-|-|-|-| -| generate_cendl | CENDL | 3.1
3.2 | | -| generate_endf | ENDF/B | VII.1
VIII.0
VIII.1 | NNDC | -| generate_fendl | FENDL | 3.2c
3.2b
3.2a
3.2
3.1d
3.1a
3.0 | | -| generate_jendl | JENDL | 4.0
5.0 (neutron, thermal scattering and photon) | NJOY | -| generate_jeff | JEFF | 3.3\*
4.0 (neutron and thermal scattering) | NJOY | -| generate_tendl | TENDL | 2023
2025 | | +| Script name | Library | Release | +|-|-|-| +| generate_cendl | CENDL | 3.1
3.2 | +| generate_endf | ENDF/B | VII.1
VIII.0
VIII.1 | +| generate_fendl | FENDL | 3.2c
3.2b
3.2a
3.2
3.1d
3.1a
3.0 | +| generate_jendl | JENDL | 4.0
5.0 (neutron, thermal scattering and photon) | +| generate_jeff | JEFF | 3.3\*
4.0 (neutron and thermal scattering) | +| generate_tendl | TENDL | 2023
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 @@ -149,24 +146,21 @@ substitutions. ### Download cross sections -| Script name | Library | Release | Processed by | Neutron temperatures (K) | -|-|-|-|-|-| -| download_endf | ENDF/B | VII.1
VIII.0
VIII.1 | NNDC | 250, 293.6, 600, 900, 1200, 2500 | -| download_jeff | JEFF | 3.3
4.0 | OpenMC development team | 250, 293.6, 600, 900, 1200, 2500 | -| download_tendl | TENDL | 2019
2021 | | 293.6 | - - +| Script name | Library | Release | Neutron temperatures (K) | +|-|-|-|-| +| download_endf | ENDF/B | VII.1
VIII.0
VIII.1 | 250, 293.6, 600, 900, 1200, 2500 | +| download_jeff | JEFF | 3.3
4.0 | 250, 293.6, 600, 900, 1200, 2500 | +| download_tendl | TENDL | 2019
2021 | 293.6 | + + ### Combine libraries diff --git a/pyproject.toml b/pyproject.toml index 251ea4c..b514d37 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -66,9 +66,6 @@ include-package-data = false [project.scripts] convert_fendl = "openmc_data.convert.convert_fendl:main" convert_jeff = "openmc_data.convert.convert_jeff:main" -convert_lib80x = "openmc_data.convert.convert_lib80x:main" -convert_mcnp70 = "openmc_data.convert.convert_mcnp70:main" -convert_mcnp71 = "openmc_data.convert.convert_mcnp71:main" convert_endf = "openmc_data.convert.convert_endf:main" convert_tendl = "openmc_data.convert.convert_tendl:main" diff --git a/src/openmc_data/convert/convert_lib80x.py b/src/openmc_data/convert/convert_lib80x.py deleted file mode 100755 index e943dbd..0000000 --- a/src/openmc_data/convert/convert_lib80x.py +++ /dev/null @@ -1,114 +0,0 @@ -#!/usr/bin/env python3 - -""" -Convert ENDF/B-VIII.0 ACE data from LANL into an HDF5 library -that can be used by OpenMC. This assumes that you have a directory containing -subdirectories 'Lib80x' and 'ENDF80SaB'. -""" - -import argparse -from collections import defaultdict -from pathlib import Path -import sys - -import openmc.data - -from openmc_data import ProgressTracker, add_provenance - - -# Make sure Python version is sufficient -assert sys.version_info >= (3, 6), "Python 3.6+ is required" - - - -class CustomFormatter(argparse.ArgumentDefaultsHelpFormatter, - argparse.RawDescriptionHelpFormatter): - pass - - -parser = argparse.ArgumentParser( - description=__doc__, - formatter_class=CustomFormatter -) -parser.add_argument('-d', '--destination', type=Path, default=Path('lib80x_hdf5'), - help='Directory to create new library in') -parser.add_argument('--libver', choices=['earliest', 'latest'], - default='earliest', help="Output HDF5 versioning. Use " - "'earliest' for backwards compatibility or 'latest' for " - "performance") -parser.add_argument('datadir', type=Path, - help='Directory containing Lib80x and ENDF80SaB/ENDF80SaB2') - -args = parser.parse_args() - - -def main(): - - assert args.datadir.is_dir() - # Get a list of all ACE files - lib80x = list(args.datadir.glob('Lib80x/**/*.80?nc')) - if (args.datadir / 'ENDF80SaB2').is_dir(): - thermal_dir = args.datadir / 'ENDF80SaB2' - else: - thermal_dir = args.datadir / 'ENDF80SaB' - lib80sab = list(thermal_dir.glob('**/*.??t')) - - # Find and fix B10 ACE files - b10files = list(args.datadir.glob('Lib80x/**/5010.80?nc')) - nxs1_position = 523 - for filename in b10files: - with open(filename, 'r+') as fh: - # Read NXS(1) - fh.seek(nxs1_position) - nxs1 = int(fh.read(5)) - - # Increase length to match actual length of XSS, but make sure this - # isn't done twice by checking the current length - if nxs1 < 86870: - fh.seek(nxs1_position) - fh.write(str(nxs1 + 53)) - - # Group together tables for the same nuclide - tables = defaultdict(list) - for p in sorted(lib80x + lib80sab): - tables[p.stem].append(p) - - # Create output directory if it doesn't exist - args.destination.mkdir(parents=True, exist_ok=True) - - library = openmc.data.DataLibrary() - - sorted_tables = sorted(tables.items()) - tracker = ProgressTracker(len(sorted_tables)) - for name, paths in sorted_tables: - # Convert first temperature for the table - p = paths[0] - tracker.starting(p) - if p.name.endswith('t'): - data = openmc.data.ThermalScattering.from_ace(p) - else: - data = openmc.data.IncidentNeutron.from_ace(p, 'mcnp') - - # For each higher temperature, add cross sections to the existing table - for p in paths[1:]: - print(f'Adding: {p}') - if p.name.endswith('t'): - data.add_temperature_from_ace(p) - else: - data.add_temperature_from_ace(p, 'mcnp') - - # Export HDF5 file - h5_file = args.destination / 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-VIII.0 (LANL lib80x)') - - -if __name__ == '__main__': - main() diff --git a/src/openmc_data/convert/convert_mcnp70.py b/src/openmc_data/convert/convert_mcnp70.py deleted file mode 100755 index 1869013..0000000 --- a/src/openmc_data/convert/convert_mcnp70.py +++ /dev/null @@ -1,127 +0,0 @@ -#!/usr/bin/env python3 - -""" -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. 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 -from collections import defaultdict -from pathlib import Path -import sys - -import openmc.data - -from openmc_data import ProgressTracker, add_provenance - - -# Make sure Python version is sufficient -assert sys.version_info >= (3, 6), "Python 3.6+ is required" - - - -class CustomFormatter(argparse.ArgumentDefaultsHelpFormatter, - argparse.RawDescriptionHelpFormatter): - pass - - -parser = argparse.ArgumentParser( - description=__doc__, - formatter_class=CustomFormatter -) -parser.add_argument('-d', '--destination', type=Path, default=Path('mcnp_endfb70'), - help='Directory to create new library in') -parser.add_argument('--libver', choices=['earliest', 'latest'], - default='earliest', help="Output HDF5 versioning. Use " - "'earliest' for backwards compatibility or 'latest' for " - "performance") -parser.add_argument('mcnpdata', type=Path, - 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' - - # 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.mkdir(parents=True, exist_ok=True) - - library = openmc.data.DataLibrary() - - for path in sorted(endf70): - print(f'Loading data from {path}...') - lib = openmc.data.ace.Library(path) - - # Group together tables for the same nuclide - tables = defaultdict(list) - for table in lib.tables: - zaid, xs = table.name.split('.') - tables[zaid].append(table) - - neutron_groups = sorted(tables.items()) - tracker = ProgressTracker(len(neutron_groups)) - for zaid, tables in neutron_groups: - # Convert first temperature for the table - tracker.starting(tables[0].name) - data = openmc.data.IncidentNeutron.from_ace(tables[0], 'mcnp') - - # For each higher temperature, add cross sections to the existing table - for table in tables[1:]: - print(f'Adding: {table.name}') - data.add_temperature_from_ace(table, 'mcnp') - - # Export HDF5 file - h5_file = args.destination / 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) - - # Handle S(a,b) tables - endf70sab = args.mcnpdata / 'endf70sab' - if endf70sab.exists(): - lib = openmc.data.ace.Library(endf70sab) - - # Group together tables for the same nuclide - tables = defaultdict(list) - for table in lib.tables: - name, xs = table.name.split('.') - tables[name].append(table) - - sab_groups = sorted(tables.items()) - tracker = ProgressTracker(len(sab_groups)) - for zaid, tables in sab_groups: - # Convert first temperature for the table - tracker.starting(tables[0].name) - data = openmc.data.ThermalScattering.from_ace(tables[0]) - - # For each higher temperature, add cross sections to the existing table - for table in tables[1:]: - print(f'Adding: {table.name}') - data.add_temperature_from_ace(table) - - # Export HDF5 file - h5_file = args.destination / 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__': - main() diff --git a/src/openmc_data/convert/convert_mcnp71.py b/src/openmc_data/convert/convert_mcnp71.py deleted file mode 100755 index cbb6f08..0000000 --- a/src/openmc_data/convert/convert_mcnp71.py +++ /dev/null @@ -1,122 +0,0 @@ -#!/usr/bin/env python3 - -""" -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'. 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 -from collections import defaultdict -from pathlib import Path -import sys - -import openmc.data - -from openmc_data import ProgressTracker, add_provenance - - -# Make sure Python version is sufficient -assert sys.version_info >= (3, 6), "Python 3.6+ is required" - - - -class CustomFormatter(argparse.ArgumentDefaultsHelpFormatter, - argparse.RawDescriptionHelpFormatter): - pass - - -parser = argparse.ArgumentParser( - description=__doc__, - formatter_class=CustomFormatter -) -parser.add_argument('-d', '--destination', type=Path, default=Path('mcnp_endfb71'), - help='Directory to create new library in') -parser.add_argument('--libver', choices=['earliest', 'latest'], - default='earliest', help="Output HDF5 versioning. Use " - "'earliest' for backwards compatibility or 'latest' for " - "performance") -parser.add_argument('mcnpdata', type=Path, - help='Directory containing endf71x and ENDF71SaB') -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' - - # Get a list of all ACE files - endf71x = list(args.mcnpdata.glob('endf71x/*/*.7??nc')) - endf71sab = list(args.mcnpdata.glob('ENDF71SaB/*.??t')) - - # Check for fixed H1 files and remove old ones if present - hydrogen = args.mcnpdata / 'endf71x' / 'H' - if (hydrogen / '1001.720nc').is_file(): - for i in range(10, 17): - endf71x.remove(hydrogen / f'1001.7{i}nc') - - # There's a bug in H-Zr at 1200 K - thermal = args.mcnpdata / 'ENDF71SaB' - endf71sab.remove(thermal / 'h-zr.27t') - - # Check for updated TSL files and remove old ones if present - checks = [ - ('sio2', 10, range(20, 37)), - ('u-o2', 30, range(20, 28)), - ('zr-h', 30, range(20, 28)) - ] - for material, good, bad in checks: - if (thermal / f'{material}.{good}t').is_file(): - for suffix in bad: - f = thermal / f'{material}.{suffix}t' - if f.is_file(): - endf71sab.remove(f) - - # Group together tables for the same nuclide - tables = defaultdict(list) - for p in sorted(endf71x + endf71sab): - tables[p.stem].append(p) - - # Create output directory if it doesn't exist - args.destination.mkdir(parents=True, exist_ok=True) - - library = openmc.data.DataLibrary() - - sorted_tables = sorted(tables.items()) - tracker = ProgressTracker(len(sorted_tables)) - for name, paths in sorted_tables: - # Convert first temperature for the table - p = paths[0] - tracker.starting(p) - if p.name.endswith('t'): - data = openmc.data.ThermalScattering.from_ace(p) - else: - data = openmc.data.IncidentNeutron.from_ace(p, 'mcnp') - - # For each higher temperature, add cross sections to the existing table - for p in paths[1:]: - print(f'Adding: {p}') - if p.name.endswith('t'): - data.add_temperature_from_ace(p) - else: - data.add_temperature_from_ace(p, 'mcnp') - - # Export HDF5 file - h5_file = args.destination / 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__': - main()