Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add script to generate depletion chain from ENDF/B-VIII.0 #86

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
57 changes: 57 additions & 0 deletions depletion/generate_endf80_chain.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/usr/bin/env python3

import argparse
from pathlib import Path
from zipfile import ZipFile

from openmc.deplete import Chain

from utils import download

URLS = [
'https://www.nndc.bnl.gov/endf-b8.0/zips/ENDF-B-VIII.0_neutrons.zip',
'https://www.nndc.bnl.gov/endf-b8.0/zips/ENDF-B-VIII.0_decay.zip',
'https://www.nndc.bnl.gov/endf-b8.0/zips/ENDF-B-VIII.0_nfy.zip'
]


def main(chain_path, release, endf_path=None):
if endf_path is not None:
endf_path = Path(endf_path)
elif all(Path(lib).is_dir() for lib in ("neutrons", "decay", "nfy")):
endf_path = Path(".")
else:
# Download and extract zip files
for url in URLS:
basename = download(url)
with ZipFile(basename, 'r') as zf:
print(f'Extracting {basename}...')
zf.extractall()

# Rename extracted directories
Path('ENDF-B-VIII.0_decay').rename('decay')
Path('ENDF-B-VIII.0_neutrons').rename('neutrons')
Path('ENDF-B-VIII.0_nfy').rename('nfy')
endf_path = Path.cwd()

decay_files = list((endf_path / "decay").glob("*endf"))
neutron_files = list((endf_path / "neutrons").glob("*endf"))
nfy_files = list((endf_path / "nfy").glob("*endf"))

# check files exist
for flist, ftype in [(decay_files, "decay"), (neutron_files, "neutron"),
(nfy_files, "neutron fission product yield")]:
if not flist:
raise IOError(f"No {ftype} endf files found in {endf_path}")

chain = Chain.from_endf(decay_files, nfy_files, neutron_files)
chain.export_to_xml(chain_path)


if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('--chain-path', default='chain_endfb80.xml')
parser.add_argument('--endf-path', type=Path, default=None)
args = parser.parse_args()

main(args.chain_path, args.endf_path)