-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathgenerate_endf71_chain.py
More file actions
executable file
·56 lines (44 loc) · 1.74 KB
/
generate_endf71_chain.py
File metadata and controls
executable file
·56 lines (44 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env python3
import os
from pathlib import Path
from zipfile import ZipFile
import openmc.deplete
from utils import download
URLS = [
'https://www.nndc.bnl.gov/endf-b7.1/zips/ENDF-B-VII.1-neutrons.zip',
'https://www.nndc.bnl.gov/endf-b7.1/zips/ENDF-B-VII.1-decay.zip',
'https://www.nndc.bnl.gov/endf-b7.1/zips/ENDF-B-VII.1-nfy.zip'
]
def main():
endf_dir = os.environ.get("OPENMC_ENDF_DATA")
if endf_dir is not None:
endf_dir = Path(endf_dir)
elif all(os.path.isdir(lib) for lib in ("neutrons", "decay", "nfy")):
endf_dir = Path(".")
else:
for url in URLS:
basename = download(url)
with ZipFile(basename, 'r') as zf:
print('Extracting {}...'.format(basename))
zf.extractall()
endf_dir = Path(".")
decay_files = list((endf_dir / "decay").glob("*endf"))
neutron_files = list((endf_dir / "neutrons").glob("*endf"))
fpy_files = list((endf_dir / "nfy").glob("*endf"))
# Remove erroneous Be7 evaluation that can cause problems
decay_files.remove(endf_dir / "decay" / "dec-004_Be_007.endf")
neutron_files.remove(endf_dir / "neutrons" / "n-004_Be_007.endf")
# check files exist
for flist, ftype in [(decay_files, "decay"), (neutron_files, "neutron"),
(fpy_files, "neutron fission product yield")]:
if not flist:
raise IOError("No {} endf files found in {}".format(ftype, endf_dir))
chain = openmc.deplete.Chain.from_endf(
decay_files=decay_files,
fpy_files=fpy_files,
neutron_files=neutron_files,
reactions=list(openmc.deplete.chain.REACTIONS.keys())
)
chain.export_to_xml('chain_endfb71.xml')
if __name__ == '__main__':
main()