mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 13:45:36 -04:00
Use argparse choices for libver in xsgen scripts
This commit is contained in:
parent
0460d9a538
commit
c76e77f7f8
5 changed files with 33 additions and 45 deletions
|
|
@ -57,9 +57,10 @@ parser.add_argument('--xsdata', help='Serpent xsdata file that lists '
|
|||
'ACE libraries')
|
||||
parser.add_argument('--fission_energy_release', help='HDF5 file containing '
|
||||
'fission energy release data')
|
||||
parser.add_argument('--latest_hdf5', help='Use latest HDF5 format for '
|
||||
'performance over backwards compatibility',
|
||||
action='store_true')
|
||||
parser.add_argument('--libver', choices=['earliest', 'latest'],
|
||||
default='earliest', help="Output HDF5 versioning. Use "
|
||||
"'earliest' for backwards compatibility or 'latest' for "
|
||||
"performance")
|
||||
args = parser.parse_args()
|
||||
|
||||
if not os.path.isdir(args.destination):
|
||||
|
|
@ -121,10 +122,6 @@ else:
|
|||
|
||||
nuclides = {}
|
||||
library = openmc.data.DataLibrary()
|
||||
if args.latest_hdf5:
|
||||
libver = 'latest'
|
||||
else:
|
||||
libver = 'earliest'
|
||||
|
||||
for filename in ace_libraries:
|
||||
# Check that ACE library exists
|
||||
|
|
@ -158,7 +155,7 @@ for filename in ace_libraries:
|
|||
# Determine filename
|
||||
outfile = os.path.join(args.destination,
|
||||
neutron.name.replace('.', '_') + '.h5')
|
||||
neutron.export_to_hdf5(outfile, 'w', libver=libver)
|
||||
neutron.export_to_hdf5(outfile, 'w', libver=args.libver)
|
||||
|
||||
# Register with library
|
||||
library.register_file(outfile)
|
||||
|
|
@ -174,7 +171,7 @@ for filename in ace_libraries:
|
|||
.format(table.name, neutron.name))
|
||||
neutron.add_temperature_from_ace(table, args.metastable)
|
||||
neutron.export_to_hdf5(nuclides[name] + '_1', 'w',
|
||||
libver=libver)
|
||||
libver=args.libver)
|
||||
os.rename(nuclides[name] + '_1', nuclides[name])
|
||||
except Exception as e:
|
||||
print('Failed to convert {}: {}'.format(table.name, e))
|
||||
|
|
@ -196,7 +193,7 @@ for filename in ace_libraries:
|
|||
# Determine filename
|
||||
outfile = os.path.join(args.destination,
|
||||
thermal.name.replace('.', '_') + '.h5')
|
||||
thermal.export_to_hdf5(outfile, 'w', libver=libver)
|
||||
thermal.export_to_hdf5(outfile, 'w', libver=args.libver)
|
||||
|
||||
# Register with library
|
||||
library.register_file(outfile)
|
||||
|
|
@ -213,7 +210,7 @@ for filename in ace_libraries:
|
|||
.format(table.name,thermal.name))
|
||||
thermal.add_temperature_from_ace(table)
|
||||
thermal.export_to_hdf5(nuclides[name] + '_1', 'w',
|
||||
libver=libver)
|
||||
libver=args.libver)
|
||||
os.rename(nuclides[name] + '_1', nuclides[name])
|
||||
except Exception as e:
|
||||
print('Failed to convert {}: {}'.format(table.name, e))
|
||||
|
|
|
|||
|
|
@ -26,9 +26,10 @@ parser = argparse.ArgumentParser(
|
|||
)
|
||||
parser.add_argument('-d', '--destination', default='mcnp_endfb70',
|
||||
help='Directory to create new library in')
|
||||
parser.add_argument('--latest_hdf5', help='Use latest HDF5 format for '
|
||||
'performance over backwards compatibility',
|
||||
action='store_true')
|
||||
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', help='Directory containing endf70[a-k] and endf70sab')
|
||||
args = parser.parse_args()
|
||||
assert os.path.isdir(args.mcnpdata)
|
||||
|
|
@ -41,10 +42,6 @@ if not os.path.isdir(args.destination):
|
|||
os.mkdir(args.destination)
|
||||
|
||||
library = openmc.data.DataLibrary()
|
||||
if args.latest_hdf5:
|
||||
libver = 'latest'
|
||||
else:
|
||||
libver = 'earliest'
|
||||
|
||||
for path in sorted(endf70):
|
||||
print('Loading data from {}...'.format(path))
|
||||
|
|
@ -69,7 +66,7 @@ for path in sorted(endf70):
|
|||
# Export HDF5 file
|
||||
h5_file = os.path.join(args.destination, data.name + '.h5')
|
||||
print('Writing {}...'.format(h5_file))
|
||||
data.export_to_hdf5(h5_file, 'w', libver=libver)
|
||||
data.export_to_hdf5(h5_file, 'w', libver=args.libver)
|
||||
|
||||
# Register with library
|
||||
library.register_file(h5_file)
|
||||
|
|
@ -98,7 +95,7 @@ if os.path.exists(endf70sab):
|
|||
# Export HDF5 file
|
||||
h5_file = os.path.join(args.destination, data.name + '.h5')
|
||||
print('Writing {}...'.format(h5_file))
|
||||
data.export_to_hdf5(h5_file, 'w', libver=libver)
|
||||
data.export_to_hdf5(h5_file, 'w', libver=args.libver)
|
||||
|
||||
# Register with library
|
||||
library.register_file(h5_file)
|
||||
|
|
|
|||
|
|
@ -28,9 +28,10 @@ parser.add_argument('-d', '--destination', default='mcnp_endfb71',
|
|||
help='Directory to create new library in')
|
||||
parser.add_argument('-f', '--fission_energy_release',
|
||||
help='HDF5 file containing fission energy release data')
|
||||
parser.add_argument('--latest_hdf5', help='Use latest HDF5 format for '
|
||||
'performance over backwards compatibility',
|
||||
action='store_true')
|
||||
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', help='Directory containing endf71x and ENDF71SaB')
|
||||
args = parser.parse_args()
|
||||
assert os.path.isdir(args.mcnpdata)
|
||||
|
|
@ -54,10 +55,6 @@ if not os.path.isdir(args.destination):
|
|||
os.mkdir(args.destination)
|
||||
|
||||
library = openmc.data.DataLibrary()
|
||||
if args.latest_hdf5:
|
||||
libver = 'latest'
|
||||
else:
|
||||
libver = 'earliest'
|
||||
|
||||
for basename, xs_list in sorted(suffixes.items()):
|
||||
# Convert first temperature for the table
|
||||
|
|
@ -87,7 +84,7 @@ for basename, xs_list in sorted(suffixes.items()):
|
|||
# Export HDF5 file
|
||||
h5_file = os.path.join(args.destination, data.name + '.h5')
|
||||
print('Writing {}...'.format(h5_file))
|
||||
data.export_to_hdf5(h5_file, 'w', libver=libver)
|
||||
data.export_to_hdf5(h5_file, 'w', libver=args.libver)
|
||||
|
||||
# Register with library
|
||||
library.register_file(h5_file)
|
||||
|
|
|
|||
|
|
@ -43,9 +43,10 @@ parser.add_argument('-b', '--batch', action='store_true',
|
|||
help='supresses standard in')
|
||||
parser.add_argument('-d', '--destination', default='jeff-3.2-hdf5',
|
||||
help='Directory to create new library in')
|
||||
parser.add_argument('--latest_hdf5', help='Use latest HDF5 format for '
|
||||
'performance over backwards compatibility',
|
||||
action='store_true')
|
||||
parser.add_argument('--libver', choices=['earliest', 'latest'],
|
||||
default='earliest', help="Output HDF5 versioning. Use "
|
||||
"'earliest' for backwards compatibility or 'latest' for "
|
||||
"performance")
|
||||
args = parser.parse_args()
|
||||
|
||||
response = input(download_warning) if not args.batch else 'y'
|
||||
|
|
@ -168,10 +169,6 @@ if not os.path.isdir(args.destination):
|
|||
os.mkdir(args.destination)
|
||||
|
||||
library = openmc.data.DataLibrary()
|
||||
if args.latest_hdf5:
|
||||
libver = 'latest'
|
||||
else:
|
||||
libver = 'earliest'
|
||||
|
||||
for name, filenames in sorted(tables.items()):
|
||||
# Convert first temperature for the table
|
||||
|
|
@ -186,7 +183,7 @@ for name, filenames in sorted(tables.items()):
|
|||
# Export HDF5 file
|
||||
h5_file = os.path.join(args.destination, data.name + '.h5')
|
||||
print('Writing {}...'.format(h5_file))
|
||||
data.export_to_hdf5(h5_file, 'w', libver=libver)
|
||||
data.export_to_hdf5(h5_file, 'w', libver=args.libver)
|
||||
|
||||
# Register with library
|
||||
library.register_file(h5_file)
|
||||
|
|
@ -229,7 +226,7 @@ for name, filenames in sorted(tables.items()):
|
|||
# Export HDF5 file
|
||||
h5_file = os.path.join(args.destination, data.name + '.h5')
|
||||
print('Writing {}...'.format(h5_file))
|
||||
data.export_to_hdf5(h5_file, 'w', libver=libver)
|
||||
data.export_to_hdf5(h5_file, 'w', libver=args.libver)
|
||||
|
||||
# Register with library
|
||||
library.register_file(h5_file)
|
||||
|
|
|
|||
|
|
@ -33,9 +33,10 @@ parser = argparse.ArgumentParser(
|
|||
)
|
||||
parser.add_argument('-b', '--batch', action='store_true',
|
||||
help='supresses standard in')
|
||||
parser.add_argument('--latest_hdf5', help='Use latest HDF5 format for '
|
||||
'performance over backwards compatibility',
|
||||
action='store_true')
|
||||
parser.add_argument('--libver', choices=['earliest', 'latest'],
|
||||
default='earliest', help="Output HDF5 versioning. Use "
|
||||
"'earliest' for backwards compatibility or 'latest' for "
|
||||
"performance")
|
||||
args = parser.parse_args()
|
||||
|
||||
|
||||
|
|
@ -160,8 +161,7 @@ fer_file = os.path.join(data_dir, 'fission_Q_data_endfb71.h5')
|
|||
# Call the ace-to-hdf5 conversion script
|
||||
pwd = os.path.dirname(os.path.realpath(__file__))
|
||||
ace2hdf5 = os.path.join(pwd, 'openmc-ace-to-hdf5')
|
||||
args_out = [ace2hdf5, '-d', 'nndc_hdf5', '--fission_energy_release', fer_file]
|
||||
if args.latest_hdf5:
|
||||
args_out += ['--latest_hdf5']
|
||||
args_out += ace_files
|
||||
subprocess.call(args_out)
|
||||
subprocess.call([ace2hdf5,
|
||||
'-d', 'nndc_hdf5',
|
||||
'--fission_energy_release', fer_file,
|
||||
'--libver', args.libver] + ace_files)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue