openmc-data 0.2.5__py3-none-any.whl → 0.2.7__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- openmc_data/__init__.py +1 -1
- openmc_data/_version.py +2 -2
- openmc_data/convert/convert_endf.py +10 -25
- openmc_data/convert/convert_fendl.py +19 -33
- openmc_data/convert/convert_jeff32.py +4 -4
- openmc_data/convert/convert_jeff33.py +4 -4
- openmc_data/convert/convert_tendl.py +6 -10
- openmc_data/depletion/add_branching_ratios.py +3 -2
- openmc_data/depletion/generate_endf71_chain_casl.py +4 -2
- openmc_data/depletion/generate_endf_chain.py +4 -2
- openmc_data/depletion/generate_jeff_chain.py +4 -2
- openmc_data/depletion/generate_serpent_fissq.py +4 -2
- openmc_data/depletion/generate_tendl_chain.py +4 -2
- openmc_data/depletion/reduce_chain.py +41 -8
- openmc_data/generate/generate_endf.py +2 -6
- openmc_data/generate/generate_fendl.py +124 -0
- openmc_data/generate/generate_jendl.py +1 -1
- openmc_data/urls.py +392 -254
- openmc_data/utils.py +26 -5
- {openmc_data-0.2.5.dist-info → openmc_data-0.2.7.dist-info}/METADATA +1 -1
- {openmc_data-0.2.5.dist-info → openmc_data-0.2.7.dist-info}/RECORD +25 -24
- {openmc_data-0.2.5.dist-info → openmc_data-0.2.7.dist-info}/entry_points.txt +1 -0
- {openmc_data-0.2.5.dist-info → openmc_data-0.2.7.dist-info}/LICENSE +0 -0
- {openmc_data-0.2.5.dist-info → openmc_data-0.2.7.dist-info}/WHEEL +0 -0
- {openmc_data-0.2.5.dist-info → openmc_data-0.2.7.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
Download FENDL data from IAEA and convert it to a HDF5 library for
|
|
5
|
+
use with OpenMC.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
import argparse
|
|
9
|
+
import ssl
|
|
10
|
+
from multiprocessing import Pool
|
|
11
|
+
from pathlib import Path
|
|
12
|
+
from urllib.parse import urljoin
|
|
13
|
+
|
|
14
|
+
import openmc.data
|
|
15
|
+
from openmc_data import download, extract, process_neutron, state_download_size, all_release_details
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class CustomFormatter(argparse.ArgumentDefaultsHelpFormatter,
|
|
19
|
+
argparse.RawDescriptionHelpFormatter):
|
|
20
|
+
pass
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
parser = argparse.ArgumentParser(
|
|
24
|
+
description=__doc__,
|
|
25
|
+
formatter_class=CustomFormatter
|
|
26
|
+
)
|
|
27
|
+
parser.add_argument('-d', '--destination', type=Path, default=None,
|
|
28
|
+
help='Directory to create new library in')
|
|
29
|
+
parser.add_argument('--download', action='store_true',
|
|
30
|
+
help='Download files from JAEA')
|
|
31
|
+
parser.add_argument('--no-download', dest='download', action='store_false',
|
|
32
|
+
help='Do not download files from JAEA')
|
|
33
|
+
parser.add_argument('--extract', action='store_true',
|
|
34
|
+
help='Extract tar/zip files')
|
|
35
|
+
parser.add_argument('--no-extract', dest='extract', action='store_false',
|
|
36
|
+
help='Do not extract tar/zip files')
|
|
37
|
+
parser.add_argument('--libver', choices=['earliest', 'latest'],
|
|
38
|
+
default='latest', help="Output HDF5 versioning. Use "
|
|
39
|
+
"'earliest' for backwards compatibility or 'latest' for "
|
|
40
|
+
"performance")
|
|
41
|
+
parser.add_argument('-r', '--release', choices=["3.2b", "3.2a", "3.2", "3.1d", "3.1a", "3.0"], default="3.2b",
|
|
42
|
+
help="The nuclear data library release version. "
|
|
43
|
+
"The options currently supported are 3.2b, 3.2a, 3.2, 3.1d, 3.1a, 3.0")
|
|
44
|
+
parser.add_argument('--cleanup', action='store_true',
|
|
45
|
+
help="Remove download directories when data has "
|
|
46
|
+
"been processed")
|
|
47
|
+
parser.add_argument('--no-cleanup', dest='cleanup', action='store_false',
|
|
48
|
+
help="Do not remove download directories when data has "
|
|
49
|
+
"been processed")
|
|
50
|
+
parser.set_defaults(download=True, extract=True, cleanup=False)
|
|
51
|
+
args = parser.parse_args()
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def main():
|
|
55
|
+
|
|
56
|
+
library_name = 'fendl'
|
|
57
|
+
|
|
58
|
+
cwd = Path.cwd()
|
|
59
|
+
|
|
60
|
+
endf_files_dir = cwd.joinpath('-'.join([library_name, args.release, 'endf']))
|
|
61
|
+
download_path = cwd.joinpath('-'.join([library_name, args.release, 'download']))
|
|
62
|
+
# the destination is decided after the release is known
|
|
63
|
+
# to avoid putting the release in a folder with a misleading name
|
|
64
|
+
if args.destination is None:
|
|
65
|
+
args.destination = Path('-'.join([library_name, args.release, 'hdf5']))
|
|
66
|
+
|
|
67
|
+
# This dictionary contains all the unique information about each release.
|
|
68
|
+
# This can be exstened to accommodated new releases
|
|
69
|
+
details = all_release_details[library_name][args.release]['neutron']['endf']
|
|
70
|
+
|
|
71
|
+
# ==============================================================================
|
|
72
|
+
# DOWNLOAD FILES FROM WEBSITE
|
|
73
|
+
|
|
74
|
+
if args.download:
|
|
75
|
+
state_download_size(details['compressed_file_size'], details['uncompressed_file_size'], 'GB')
|
|
76
|
+
for f in details['compressed_files']:
|
|
77
|
+
# Establish connection to URL
|
|
78
|
+
download(
|
|
79
|
+
urljoin(details['base_url'], f),
|
|
80
|
+
context=ssl._create_unverified_context(),
|
|
81
|
+
output_path=download_path,
|
|
82
|
+
as_browser=True
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
# ==============================================================================
|
|
86
|
+
# EXTRACT FILES FROM TGZ
|
|
87
|
+
if args.extract:
|
|
88
|
+
extract(
|
|
89
|
+
compressed_files=[download_path/ f for f in details['compressed_files']],
|
|
90
|
+
extraction_dir=endf_files_dir,
|
|
91
|
+
del_compressed_file=args.cleanup
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
# ==============================================================================
|
|
95
|
+
# GENERATE HDF5 LIBRARY -- NEUTRON FILES
|
|
96
|
+
|
|
97
|
+
# Get a list of all ENDF files
|
|
98
|
+
neutron_files = endf_files_dir.glob(details['endf_files'])
|
|
99
|
+
|
|
100
|
+
# Create output directory if it doesn't exist
|
|
101
|
+
args.destination.mkdir(parents=True, exist_ok=True)
|
|
102
|
+
|
|
103
|
+
library = openmc.data.DataLibrary()
|
|
104
|
+
|
|
105
|
+
with Pool() as pool:
|
|
106
|
+
results = []
|
|
107
|
+
for filename in sorted(neutron_files):
|
|
108
|
+
func_args = (filename, args.destination, args.libver)
|
|
109
|
+
r = pool.apply_async(process_neutron, func_args)
|
|
110
|
+
results.append(r)
|
|
111
|
+
|
|
112
|
+
for r in results:
|
|
113
|
+
r.wait()
|
|
114
|
+
|
|
115
|
+
# Register with library
|
|
116
|
+
for p in sorted((args.destination).glob('*.h5')):
|
|
117
|
+
library.register_file(p)
|
|
118
|
+
|
|
119
|
+
# Write cross_sections.xml
|
|
120
|
+
library.export_to_xml(args.destination / 'cross_sections.xml')
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
if __name__ == '__main__':
|
|
124
|
+
main()
|
|
@@ -66,7 +66,7 @@ def main():
|
|
|
66
66
|
|
|
67
67
|
# This dictionary contains all the unique information about each release.
|
|
68
68
|
# This can be exstened to accommodated new releases
|
|
69
|
-
details = all_release_details[library_name][args.release]['neutron']
|
|
69
|
+
details = all_release_details[library_name][args.release]['neutron']['endf']
|
|
70
70
|
|
|
71
71
|
# ==============================================================================
|
|
72
72
|
# DOWNLOAD FILES FROM WEBSITE
|