mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 13:45:36 -04:00
Updated tests to use Python TestHarness
This commit is contained in:
parent
13744b1f8b
commit
e610f0147d
216 changed files with 1197 additions and 8530 deletions
|
|
@ -1,24 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
|
||||
sys.path.insert(0, '../..')
|
||||
from openmc.statepoint import StatePoint
|
||||
|
||||
# read in statepoint file
|
||||
if len(sys.argv) > 1:
|
||||
sp = StatePoint(sys.argv[1])
|
||||
else:
|
||||
sp = StatePoint('statepoint.10.binary')
|
||||
sp.read_results()
|
||||
|
||||
# set up output string
|
||||
outstr = ''
|
||||
|
||||
# write out k-combined
|
||||
outstr += 'k-combined:\n'
|
||||
outstr += "{0:12.6E} {1:12.6E}\n".format(sp.k_combined[0], sp.k_combined[1])
|
||||
|
||||
# write results to file
|
||||
with open('results_test.dat','w') as fh:
|
||||
fh.write(outstr)
|
||||
58
tests/test_basic/test_basic.py
Normal file → Executable file
58
tests/test_basic/test_basic.py
Normal file → Executable file
|
|
@ -1,60 +1,10 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
import sys
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
sys.path.insert(0, '..')
|
||||
from testing_harness import TestHarness
|
||||
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call([sys.executable, 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
try:
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_results()
|
||||
finally:
|
||||
teardown()
|
||||
harness = TestHarness('statepoint.10.*')
|
||||
harness.execute_test()
|
||||
|
|
|
|||
|
|
@ -1,92 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
import numpy as np
|
||||
|
||||
sys.path.insert(0, '../..')
|
||||
import openmc
|
||||
from openmc.statepoint import StatePoint
|
||||
|
||||
# read in statepoint file
|
||||
if len(sys.argv) > 1:
|
||||
sp = StatePoint(sys.argv[1])
|
||||
else:
|
||||
sp = StatePoint('statepoint.20.binary')
|
||||
|
||||
sp.read_results()
|
||||
|
||||
# extract tally results and convert to vector
|
||||
tally1 = sp.get_tally(scores=['flux'], filters=[openmc.Filter('mesh', [1])], \
|
||||
estimator='tracklength')
|
||||
tally2 = sp.get_tally(scores=['flux'], filters=[openmc.Filter('mesh', [2])], \
|
||||
estimator='analog')
|
||||
tally3 = sp.get_tally(scores=['nu-fission'], \
|
||||
filters=[openmc.Filter('mesh', [2])], estimator='analog')
|
||||
tally4 = sp.get_tally(scores=['current'], filters=[openmc.Filter('mesh', [2]), \
|
||||
openmc.Filter('surface', [1,2,3,4,5,6])], \
|
||||
estimator='analog')
|
||||
|
||||
results1 = np.zeros((tally1.sum.size + tally1.sum.size, ))
|
||||
results1[0::2] = tally1.sum.ravel()
|
||||
results1[1::2] = tally1.sum_sq.ravel()
|
||||
|
||||
results2 = np.zeros((tally2.sum.size + tally2.sum.size, ))
|
||||
results2[0::2] = tally2.sum.ravel()
|
||||
results2[1::2] = tally2.sum_sq.ravel()
|
||||
|
||||
results3 = np.zeros((tally3.sum.size + tally3.sum.size, ))
|
||||
results3[0::2] = tally3.sum.ravel()
|
||||
results3[1::2] = tally3.sum_sq.ravel()
|
||||
|
||||
results4 = np.zeros((tally4.sum.size + tally4.sum.size, ))
|
||||
results4[0::2] = tally4.sum.ravel()
|
||||
results4[1::2] = tally4.sum_sq.ravel()
|
||||
|
||||
# set up output string
|
||||
outstr = ''
|
||||
|
||||
# write out k-combined
|
||||
outstr += 'k-combined:\n'
|
||||
outstr += "{0:12.6E} {1:12.6E}\n".format(sp.k_combined[0], sp.k_combined[1])
|
||||
|
||||
# write out tally results
|
||||
outstr += 'tally 1:\n'
|
||||
for item in results1:
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
outstr += 'tally 2:\n'
|
||||
for item in results2:
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
outstr += 'tally 3:\n'
|
||||
for item in results3:
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
outstr += 'tally 4:\n'
|
||||
for item in results4:
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
|
||||
# write out cmfd answers
|
||||
outstr += 'cmfd indices\n'
|
||||
for item in sp._cmfd_indices:
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
outstr += 'k cmfd\n'
|
||||
for item in sp._k_cmfd:
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
outstr += 'cmfd entropy\n'
|
||||
for item in sp._cmfd_entropy:
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
outstr += 'cmfd balance\n'
|
||||
for item in sp._cmfd_balance:
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
outstr += 'cmfd dominance ratio\n'
|
||||
for item in sp._cmfd_dominance:
|
||||
outstr += "{0:10.3E}\n".format(item)
|
||||
outstr += 'cmfd openmc source comparison\n'
|
||||
for item in sp._cmfd_srccmp:
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
outstr += 'cmfd source\n'
|
||||
cmfdsrc = np.reshape(sp._cmfd_src, np.product(sp._cmfd_indices), order='F')
|
||||
for item in cmfdsrc:
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
|
||||
# write results to file
|
||||
with open('results_test.dat', 'w') as fh:
|
||||
fh.write(outstr)
|
||||
|
|
@ -1,68 +1,61 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
import sys
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.20.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
sys.path.insert(0, '..')
|
||||
from testing_harness import *
|
||||
|
||||
|
||||
def test_output_exists():
|
||||
assert os.path.exists(os.path.join(cwd, 'tallies.out')), 'Tally output file does not exist.'
|
||||
class CMFDTestHarness(TestHarness):
|
||||
def _get_results(self):
|
||||
"""Digest info in the statepoint and create a simpler ASCII file."""
|
||||
# Read the statepoint file.
|
||||
statepoint = glob.glob(os.path.join(os.getcwd(), self._sp_name))[0]
|
||||
sp = StatePoint(statepoint)
|
||||
sp.read_results()
|
||||
|
||||
# Write out k-combined.
|
||||
outstr = 'k-combined:\n'
|
||||
form = '{0:12.6E} {1:12.6E}\n'
|
||||
outstr += form.format(sp.k_combined[0], sp.k_combined[1])
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.20.*'))
|
||||
call([sys.executable, 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare, 'Results do not agree.'
|
||||
# Write out tally data.
|
||||
if self._tallies:
|
||||
tally_num = 1
|
||||
for tally_ind in sp._tallies:
|
||||
tally = sp._tallies[tally_ind]
|
||||
results = np.zeros((tally._sum.size*2, ))
|
||||
results[0::2] = tally._sum.ravel()
|
||||
results[1::2] = tally._sum_sq.ravel()
|
||||
results = ['{0:12.6E}'.format(x) for x in results]
|
||||
|
||||
outstr += 'tally ' + str(tally_num) + ':\n'
|
||||
outstr += '\n'.join(results) + '\n'
|
||||
tally_num += 1
|
||||
|
||||
# Write out CMFD data.
|
||||
outstr += 'cmfd indices\n'
|
||||
outstr += '\n'.join(['{0:12.6E}'.format(x) for x in sp._cmfd_indices])
|
||||
outstr += '\nk cmfd\n'
|
||||
outstr += '\n'.join(['{0:12.6E}'.format(x) for x in sp._k_cmfd])
|
||||
outstr += '\ncmfd entropy\n'
|
||||
outstr += '\n'.join(['{0:12.6E}'.format(x) for x in sp._cmfd_entropy])
|
||||
outstr += '\ncmfd balance\n'
|
||||
outstr += '\n'.join(['{0:12.6E}'.format(x) for x in sp._cmfd_balance])
|
||||
outstr += '\ncmfd dominance ratio\n'
|
||||
outstr += '\n'.join(['{0:10.3E}'.format(x) for x in sp._cmfd_dominance])
|
||||
outstr += '\ncmfd openmc source comparison\n'
|
||||
outstr += '\n'.join(['{0:12.6E}'.format(x) for x in sp._cmfd_srccmp])
|
||||
outstr += '\ncmfd source\n'
|
||||
cmfdsrc = np.reshape(sp._cmfd_src, np.product(sp._cmfd_indices),
|
||||
order='F')
|
||||
outstr += '\n'.join(['{0:12.6E}'.format(x) for x in cmfdsrc])
|
||||
outstr += '\n'
|
||||
|
||||
# Write results to a file.
|
||||
with open('results_test.dat','w') as fh:
|
||||
fh.write(outstr)
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.20.*'))
|
||||
output.append(os.path.join(cwd, 'tallies.out'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
try:
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_output_exists()
|
||||
test_results()
|
||||
finally:
|
||||
teardown()
|
||||
harness = CMFDTestHarness('statepoint.20.*', True)
|
||||
harness.execute_test()
|
||||
|
|
|
|||
|
|
@ -1,92 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
import numpy as np
|
||||
|
||||
sys.path.insert(0, '../..')
|
||||
import openmc
|
||||
from openmc.statepoint import StatePoint
|
||||
|
||||
# read in statepoint file
|
||||
if len(sys.argv) > 1:
|
||||
sp = StatePoint(sys.argv[1])
|
||||
else:
|
||||
sp = StatePoint('statepoint.20.binary')
|
||||
|
||||
sp.read_results()
|
||||
|
||||
# extract tally results and convert to vector
|
||||
tally1 = sp.get_tally(scores=['flux'], filters=[openmc.Filter('mesh', [1])], \
|
||||
estimator='tracklength')
|
||||
tally2 = sp.get_tally(scores=['flux'], filters=[openmc.Filter('mesh', [2])], \
|
||||
estimator='analog')
|
||||
tally3 = sp.get_tally(scores=['nu-fission'], \
|
||||
filters=[openmc.Filter('mesh', [2])], estimator='analog')
|
||||
tally4 = sp.get_tally(scores=['current'], filters=[openmc.Filter('mesh', [2]), \
|
||||
openmc.Filter('surface', [1,2,3,4,5,6])], \
|
||||
estimator='analog')
|
||||
|
||||
results1 = np.zeros((tally1.sum.size + tally1.sum.size, ))
|
||||
results1[0::2] = tally1.sum.ravel()
|
||||
results1[1::2] = tally1.sum_sq.ravel()
|
||||
|
||||
results2 = np.zeros((tally2.sum.size + tally2.sum.size, ))
|
||||
results2[0::2] = tally2.sum.ravel()
|
||||
results2[1::2] = tally2.sum_sq.ravel()
|
||||
|
||||
results3 = np.zeros((tally3.sum.size + tally3.sum.size, ))
|
||||
results3[0::2] = tally3.sum.ravel()
|
||||
results3[1::2] = tally3.sum_sq.ravel()
|
||||
|
||||
results4 = np.zeros((tally4.sum.size + tally4.sum.size, ))
|
||||
results4[0::2] = tally4.sum.ravel()
|
||||
results4[1::2] = tally4.sum_sq.ravel()
|
||||
|
||||
# set up output string
|
||||
outstr = ''
|
||||
|
||||
# write out k-combined
|
||||
outstr += 'k-combined:\n'
|
||||
outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1])
|
||||
|
||||
# write out tally results
|
||||
outstr += 'tally 1:\n'
|
||||
for item in results1:
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
outstr += 'tally 2:\n'
|
||||
for item in results2:
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
outstr += 'tally 3:\n'
|
||||
for item in results3:
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
outstr += 'tally 4:\n'
|
||||
for item in results4:
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
|
||||
# write out cmfd answers
|
||||
outstr += 'cmfd indices\n'
|
||||
for item in sp._cmfd_indices:
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
outstr += 'k cmfd\n'
|
||||
for item in sp._k_cmfd:
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
outstr += 'cmfd entropy\n'
|
||||
for item in sp._cmfd_entropy:
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
outstr += 'cmfd balance\n'
|
||||
for item in sp._cmfd_balance:
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
outstr += 'cmfd dominance ratio\n'
|
||||
for item in sp._cmfd_dominance:
|
||||
outstr += "{0:10.3E}\n".format(item)
|
||||
outstr += 'cmfd openmc source comparison\n'
|
||||
for item in sp._cmfd_srccmp:
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
outstr += 'cmfd source\n'
|
||||
cmfdsrc = np.reshape(sp._cmfd_src, np.product(sp._cmfd_indices), order='F')
|
||||
for item in cmfdsrc:
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
|
||||
# write results to file
|
||||
with open('results_test.dat', 'w') as fh:
|
||||
fh.write(outstr)
|
||||
|
|
@ -1,69 +1,61 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
import sys
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
sys.path.insert(0, '..')
|
||||
from testing_harness import *
|
||||
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.20.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
class CMFDTestHarness(TestHarness):
|
||||
def _get_results(self):
|
||||
"""Digest info in the statepoint and create a simpler ASCII file."""
|
||||
# Read the statepoint file.
|
||||
statepoint = glob.glob(os.path.join(os.getcwd(), self._sp_name))[0]
|
||||
sp = StatePoint(statepoint)
|
||||
sp.read_results()
|
||||
|
||||
# Write out k-combined.
|
||||
outstr = 'k-combined:\n'
|
||||
form = '{0:12.6E} {1:12.6E}\n'
|
||||
outstr += form.format(sp.k_combined[0], sp.k_combined[1])
|
||||
|
||||
def test_output_exists():
|
||||
assert os.path.exists(os.path.join(cwd, 'tallies.out')), 'Tally output file does not exist.'
|
||||
# Write out tally data.
|
||||
if self._tallies:
|
||||
tally_num = 1
|
||||
for tally_ind in sp._tallies:
|
||||
tally = sp._tallies[tally_ind]
|
||||
results = np.zeros((tally._sum.size*2, ))
|
||||
results[0::2] = tally._sum.ravel()
|
||||
results[1::2] = tally._sum_sq.ravel()
|
||||
results = ['{0:12.6E}'.format(x) for x in results]
|
||||
|
||||
outstr += 'tally ' + str(tally_num) + ':\n'
|
||||
outstr += '\n'.join(results) + '\n'
|
||||
tally_num += 1
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.20.*'))
|
||||
call([sys.executable, 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare, 'Results do not agree.'
|
||||
# Write out CMFD data.
|
||||
outstr += 'cmfd indices\n'
|
||||
outstr += '\n'.join(['{0:12.6E}'.format(x) for x in sp._cmfd_indices])
|
||||
outstr += '\nk cmfd\n'
|
||||
outstr += '\n'.join(['{0:12.6E}'.format(x) for x in sp._k_cmfd])
|
||||
outstr += '\ncmfd entropy\n'
|
||||
outstr += '\n'.join(['{0:12.6E}'.format(x) for x in sp._cmfd_entropy])
|
||||
outstr += '\ncmfd balance\n'
|
||||
outstr += '\n'.join(['{0:12.6E}'.format(x) for x in sp._cmfd_balance])
|
||||
outstr += '\ncmfd dominance ratio\n'
|
||||
outstr += '\n'.join(['{0:10.3E}'.format(x) for x in sp._cmfd_dominance])
|
||||
outstr += '\ncmfd openmc source comparison\n'
|
||||
outstr += '\n'.join(['{0:12.6E}'.format(x) for x in sp._cmfd_srccmp])
|
||||
outstr += '\ncmfd source\n'
|
||||
cmfdsrc = np.reshape(sp._cmfd_src, np.product(sp._cmfd_indices),
|
||||
order='F')
|
||||
outstr += '\n'.join(['{0:12.6E}'.format(x) for x in cmfdsrc])
|
||||
outstr += '\n'
|
||||
|
||||
# Write results to a file.
|
||||
with open('results_test.dat','w') as fh:
|
||||
fh.write(outstr)
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.20.*'))
|
||||
output.append(os.path.join(cwd, 'tallies.out'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
try:
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_output_exists()
|
||||
test_results()
|
||||
finally:
|
||||
teardown()
|
||||
harness = CMFDTestHarness('statepoint.20.*', True)
|
||||
harness.execute_test()
|
||||
|
|
|
|||
|
|
@ -1,37 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
import numpy as np
|
||||
|
||||
sys.path.insert(0, '../..')
|
||||
from openmc.statepoint import StatePoint
|
||||
|
||||
# read in statepoint file
|
||||
if len(sys.argv) > 1:
|
||||
sp = StatePoint(sys.argv[1])
|
||||
else:
|
||||
sp = StatePoint('statepoint.10.binary')
|
||||
|
||||
sp.read_results()
|
||||
|
||||
# extract tally results and convert to vector
|
||||
tally = sp._tallies[1]
|
||||
results = np.zeros((tally._sum.size + tally._sum.size, ))
|
||||
results[0::2] = tally._sum.ravel()
|
||||
results[1::2] = tally._sum_sq.ravel()
|
||||
|
||||
# set up output string
|
||||
outstr = ''
|
||||
|
||||
# write out k-combined
|
||||
outstr += 'k-combined:\n'
|
||||
outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1])
|
||||
|
||||
# write out tally results
|
||||
outstr += 'tallies:\n'
|
||||
for item in results:
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
|
||||
# write results to file
|
||||
with open('results_test.dat','w') as fh:
|
||||
fh.write(outstr)
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
k-combined:
|
||||
2.913599E-01 6.738749E-03
|
||||
tallies:
|
||||
tally 1:
|
||||
6.420923E+01
|
||||
5.190738E+02
|
||||
|
|
|
|||
63
tests/test_confidence_intervals/test_confidence_intervals.py
Normal file → Executable file
63
tests/test_confidence_intervals/test_confidence_intervals.py
Normal file → Executable file
|
|
@ -1,65 +1,10 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
import sys
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
sys.path.insert(0, '..')
|
||||
from testing_harness import TestHarness
|
||||
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_created_output():
|
||||
assert os.path.exists(os.path.join(cwd, 'tallies.out')), 'Tally output file does not exist.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call([sys.executable, 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
output.append(os.path.join(cwd, 'tallies.out'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
try:
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_created_output()
|
||||
test_results()
|
||||
finally:
|
||||
teardown()
|
||||
harness = TestHarness('statepoint.10.*', True)
|
||||
harness.execute_test()
|
||||
|
|
|
|||
|
|
@ -1,25 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
|
||||
sys.path.insert(0, '../..')
|
||||
from openmc.statepoint import StatePoint
|
||||
|
||||
# read in statepoint file
|
||||
if len(sys.argv) > 1:
|
||||
sp = StatePoint(sys.argv[1])
|
||||
else:
|
||||
sp = StatePoint('statepoint.10.binary')
|
||||
|
||||
sp.read_results()
|
||||
|
||||
# set up output string
|
||||
outstr = ''
|
||||
|
||||
# write out k-combined
|
||||
outstr += 'k-combined:\n'
|
||||
outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1])
|
||||
|
||||
# write results to file
|
||||
with open('results_test.dat','w') as fh:
|
||||
fh.write(outstr)
|
||||
|
|
@ -1,60 +1,10 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
import sys
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
sys.path.insert(0, '..')
|
||||
from testing_harness import TestHarness
|
||||
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call([sys.executable, 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
try:
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_results()
|
||||
finally:
|
||||
teardown()
|
||||
harness = TestHarness('statepoint.10.*')
|
||||
harness.execute_test()
|
||||
|
|
|
|||
|
|
@ -1,25 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
|
||||
sys.path.insert(0, '../..')
|
||||
from openmc.statepoint import StatePoint
|
||||
|
||||
# read in statepoint file
|
||||
if len(sys.argv) > 1:
|
||||
sp = StatePoint(sys.argv[1])
|
||||
else:
|
||||
sp = StatePoint('statepoint.10.binary')
|
||||
|
||||
sp.read_results()
|
||||
|
||||
# set up output string
|
||||
outstr = ''
|
||||
|
||||
# write out k-combined
|
||||
outstr += 'k-combined:\n'
|
||||
outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1])
|
||||
|
||||
# write results to file
|
||||
with open('results_test.dat','w') as fh:
|
||||
fh.write(outstr)
|
||||
|
|
@ -1,60 +1,10 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
import sys
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
sys.path.insert(0, '..')
|
||||
from testing_harness import TestHarness
|
||||
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call([sys.executable, 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob('statepoint.10.*')
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
try:
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_results()
|
||||
finally:
|
||||
teardown()
|
||||
harness = TestHarness('statepoint.10.*')
|
||||
harness.execute_test()
|
||||
|
|
|
|||
|
|
@ -1,25 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
|
||||
sys.path.insert(0, '../..')
|
||||
from openmc.statepoint import StatePoint
|
||||
|
||||
# read in statepoint file
|
||||
if len(sys.argv) > 1:
|
||||
sp = StatePoint(sys.argv[1])
|
||||
else:
|
||||
sp = StatePoint('statepoint.10.binary')
|
||||
|
||||
sp.read_results()
|
||||
|
||||
# set up output string
|
||||
outstr = ''
|
||||
|
||||
# write out k-combined
|
||||
outstr += 'k-combined:\n'
|
||||
outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1])
|
||||
|
||||
# write results to file
|
||||
with open('results_test.dat','w') as fh:
|
||||
fh.write(outstr)
|
||||
|
|
@ -1,60 +1,10 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
import sys
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
sys.path.insert(0, '..')
|
||||
from testing_harness import TestHarness
|
||||
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call([sys.executable, 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
try:
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_results()
|
||||
finally:
|
||||
teardown()
|
||||
harness = TestHarness('statepoint.10.*')
|
||||
harness.execute_test()
|
||||
|
|
|
|||
|
|
@ -1,25 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
|
||||
sys.path.insert(0, '../..')
|
||||
from openmc.statepoint import StatePoint
|
||||
|
||||
# read in statepoint file
|
||||
if len(sys.argv) > 1:
|
||||
sp = StatePoint(sys.argv[1])
|
||||
else:
|
||||
sp = StatePoint('statepoint.10.binary')
|
||||
|
||||
sp.read_results()
|
||||
|
||||
# set up output string
|
||||
outstr = ''
|
||||
|
||||
# write out k-combined
|
||||
outstr += 'k-combined:\n'
|
||||
outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1])
|
||||
|
||||
# write results to file
|
||||
with open('results_test.dat','w') as fh:
|
||||
fh.write(outstr)
|
||||
|
|
@ -1,60 +1,10 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
import sys
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
sys.path.insert(0, '..')
|
||||
from testing_harness import TestHarness
|
||||
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob('statepoint.10.*')
|
||||
call([sys.executable, 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
try:
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_results()
|
||||
finally:
|
||||
teardown()
|
||||
harness = TestHarness('statepoint.10.*')
|
||||
harness.execute_test()
|
||||
|
|
|
|||
|
|
@ -1,25 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
|
||||
sys.path.insert(0, '../..')
|
||||
from openmc.statepoint import StatePoint
|
||||
|
||||
# read in statepoint file
|
||||
if len(sys.argv) > 1:
|
||||
sp = StatePoint(sys.argv[1])
|
||||
else:
|
||||
sp = StatePoint('statepoint.7.binary')
|
||||
|
||||
sp.read_results()
|
||||
|
||||
# set up output string
|
||||
outstr = ''
|
||||
|
||||
# write out k-combined
|
||||
outstr += 'k-combined:\n'
|
||||
outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1])
|
||||
|
||||
# write results to file
|
||||
with open('results_test.dat','w') as fh:
|
||||
fh.write(outstr)
|
||||
|
|
@ -1,60 +1,10 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
import sys
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
sys.path.insert(0, '..')
|
||||
from testing_harness import TestHarness
|
||||
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.7.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.7.*'))
|
||||
call([sys.executable, 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.7.*'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
try:
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_results()
|
||||
finally:
|
||||
teardown()
|
||||
harness = TestHarness('statepoint.7.*')
|
||||
harness.execute_test()
|
||||
|
|
|
|||
|
|
@ -1,25 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
|
||||
sys.path.insert(0, '../..')
|
||||
from openmc.statepoint import StatePoint
|
||||
|
||||
# read in statepoint file
|
||||
if len(sys.argv) > 1:
|
||||
sp = StatePoint(sys.argv[1])
|
||||
else:
|
||||
sp = StatePoint('statepoint.10.binary')
|
||||
|
||||
sp.read_results()
|
||||
|
||||
# set up output string
|
||||
outstr = ''
|
||||
|
||||
# write out k-combined
|
||||
outstr += 'k-combined:\n'
|
||||
outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1])
|
||||
|
||||
# write results to file
|
||||
with open('results_test.dat','w') as fh:
|
||||
fh.write(outstr)
|
||||
|
|
@ -1,60 +1,10 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
import sys
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
sys.path.insert(0, '..')
|
||||
from testing_harness import TestHarness
|
||||
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call([sys.executable, 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
try:
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_results()
|
||||
finally:
|
||||
teardown()
|
||||
harness = TestHarness('statepoint.10.*')
|
||||
harness.execute_test()
|
||||
|
|
|
|||
|
|
@ -1,25 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
|
||||
sys.path.insert(0, '../..')
|
||||
from openmc.statepoint import StatePoint
|
||||
|
||||
# read in statepoint file
|
||||
if len(sys.argv) > 1:
|
||||
sp = StatePoint(sys.argv[1])
|
||||
else:
|
||||
sp = StatePoint('statepoint.10.binary')
|
||||
|
||||
sp.read_results()
|
||||
|
||||
# set up output string
|
||||
outstr = ''
|
||||
|
||||
# write out k-combined
|
||||
outstr += 'k-combined:\n'
|
||||
outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1])
|
||||
|
||||
# write results to file
|
||||
with open('results_test.dat','w') as fh:
|
||||
fh.write(outstr)
|
||||
|
|
@ -1,60 +1,10 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
import sys
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
sys.path.insert(0, '..')
|
||||
from testing_harness import TestHarness
|
||||
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call([sys.executable, 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
try:
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_results()
|
||||
finally:
|
||||
teardown()
|
||||
harness = TestHarness('statepoint.10.*')
|
||||
harness.execute_test()
|
||||
|
|
|
|||
|
|
@ -1,31 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
import numpy as np
|
||||
|
||||
sys.path.insert(0, '../..')
|
||||
from openmc.statepoint import StatePoint
|
||||
|
||||
# read in statepoint file
|
||||
if len(sys.argv) > 1:
|
||||
sp = StatePoint(sys.argv[1])
|
||||
else:
|
||||
sp = StatePoint('statepoint.10.binary')
|
||||
|
||||
sp.read_results()
|
||||
|
||||
# set up output string
|
||||
outstr = ''
|
||||
|
||||
# write out k-combined
|
||||
outstr += 'k-combined:\n'
|
||||
outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1])
|
||||
|
||||
# write out tally results
|
||||
outstr += 'entropy:\n'
|
||||
for item in sp._entropy:
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
|
||||
# write results to file
|
||||
with open('results_test.dat','w') as fh:
|
||||
fh.write(outstr)
|
||||
|
|
@ -1,61 +1,33 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
import sys
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
sys.path.insert(0, '..')
|
||||
from testing_harness import *
|
||||
|
||||
|
||||
def test_run():
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
class EntropyTestHarness(TestHarness):
|
||||
def _get_results(self):
|
||||
"""Digest info in the statepoint and create a simpler ASCII file."""
|
||||
# Read the statepoint file.
|
||||
statepoint = glob.glob(os.path.join(os.getcwd(), self._sp_name))[0]
|
||||
sp = StatePoint(statepoint)
|
||||
sp.read_results()
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
# Write out k-combined.
|
||||
outstr = 'k-combined:\n'
|
||||
form = '{0:12.6E} {1:12.6E}\n'
|
||||
outstr += form.format(sp.k_combined[0], sp.k_combined[1])
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call([sys.executable, 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare, 'Results do not agree.'
|
||||
# Write out entropy data.
|
||||
outstr += 'entropy:\n'
|
||||
results = ['{0:12.6E}'.format(x) for x in sp._entropy]
|
||||
outstr += '\n'.join(results) + '\n'
|
||||
|
||||
# Write results to a file.
|
||||
with open('results_test.dat','w') as fh:
|
||||
fh.write(outstr)
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
try:
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_results()
|
||||
finally:
|
||||
teardown()
|
||||
harness = EntropyTestHarness('statepoint.10.*')
|
||||
harness.execute_test()
|
||||
|
|
|
|||
|
|
@ -1,37 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
import numpy as np
|
||||
|
||||
sys.path.insert(0, '../..')
|
||||
from openmc.statepoint import StatePoint
|
||||
|
||||
# read in statepoint file
|
||||
if len(sys.argv) > 1:
|
||||
sp = StatePoint(sys.argv[1])
|
||||
else:
|
||||
sp = StatePoint('statepoint.10.binary')
|
||||
|
||||
sp.read_results()
|
||||
|
||||
# extract tally results and convert to vector
|
||||
tally = sp._tallies[1]
|
||||
results = np.empty((tally._sum.size + tally._sum.size, ), dtype=np.float64)
|
||||
results[0::2] = tally._sum.ravel()
|
||||
results[1::2] = tally._sum_sq.ravel()
|
||||
|
||||
# set up output string
|
||||
outstr = ''
|
||||
|
||||
# write out k-combined
|
||||
outstr += 'k-combined:\n'
|
||||
outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1])
|
||||
|
||||
# write out tally results
|
||||
outstr += 'tallies:\n'
|
||||
for item in results:
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
|
||||
# write results to file
|
||||
with open('results_test.dat','w') as fh:
|
||||
fh.write(outstr)
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
k-combined:
|
||||
1.093844E+00 1.626801E-02
|
||||
tallies:
|
||||
tally 1:
|
||||
0.000000E+00
|
||||
0.000000E+00
|
||||
1.517577E+01
|
||||
|
|
|
|||
|
|
@ -1,65 +1,10 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
import sys
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
sys.path.insert(0, '..')
|
||||
from testing_harness import TestHarness
|
||||
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_output_exists():
|
||||
assert os.path.exists(os.path.join(cwd, 'tallies.out')), 'Tally output file does not exist.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call([sys.executable, 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
output.append(os.path.join(cwd, 'tallies.out'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
try:
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_output_exists()
|
||||
test_results()
|
||||
finally:
|
||||
teardown()
|
||||
harness = TestHarness('statepoint.10.*', True)
|
||||
harness.execute_test()
|
||||
|
|
|
|||
|
|
@ -1,37 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
import numpy as np
|
||||
|
||||
sys.path.insert(0, '../..')
|
||||
from openmc.statepoint import StatePoint
|
||||
|
||||
# read in statepoint file
|
||||
if len(sys.argv) > 1:
|
||||
sp = StatePoint(sys.argv[1])
|
||||
else:
|
||||
sp = StatePoint('statepoint.10.binary')
|
||||
|
||||
sp.read_results()
|
||||
|
||||
# extract tally results and convert to vector
|
||||
tally = sp._tallies[1]
|
||||
results = np.empty((tally._sum.size + tally._sum.size, ), dtype=np.float64)
|
||||
results[0::2] = tally._sum.ravel()
|
||||
results[1::2] = tally._sum_sq.ravel()
|
||||
|
||||
# set up output string
|
||||
outstr = ''
|
||||
|
||||
# write out k-combined
|
||||
outstr += 'k-combined:\n'
|
||||
outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1])
|
||||
|
||||
# write out tally results
|
||||
outstr += 'tallies:\n'
|
||||
for item in results:
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
|
||||
# write results to file
|
||||
with open('results_test.dat','w') as fh:
|
||||
fh.write(outstr)
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
k-combined:
|
||||
1.093844E+00 1.626801E-02
|
||||
tallies:
|
||||
tally 1:
|
||||
0.000000E+00
|
||||
0.000000E+00
|
||||
7.449502E+01
|
||||
|
|
|
|||
|
|
@ -1,62 +1,10 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
import sys
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
sys.path.insert(0, '..')
|
||||
from testing_harness import TestHarness
|
||||
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
|
||||
def test_output_exists():
|
||||
assert os.path.exists(os.path.join(cwd, 'tallies.out')), 'Tally output file does not exist.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call([sys.executable, 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
output.append(os.path.join(cwd, 'tallies.out'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
try:
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_output_exists()
|
||||
test_results()
|
||||
finally:
|
||||
teardown()
|
||||
harness = TestHarness('statepoint.10.*', True)
|
||||
harness.execute_test()
|
||||
|
|
|
|||
14
tests/test_filter_distribcell/case-1/results_true.dat
Normal file
14
tests/test_filter_distribcell/case-1/results_true.dat
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
k-combined:
|
||||
0.000000E+00 0.000000E+00
|
||||
tally 1:
|
||||
8.565980E-03
|
||||
7.337601E-05
|
||||
8.045879E-03
|
||||
6.473617E-05
|
||||
9.027116E-03
|
||||
8.148882E-05
|
||||
7.326285E-03
|
||||
5.367445E-05
|
||||
tally 2:
|
||||
3.296526E-02
|
||||
1.086708E-03
|
||||
11
tests/test_filter_distribcell/case-2/results_true.dat
Normal file
11
tests/test_filter_distribcell/case-2/results_true.dat
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
k-combined:
|
||||
0.000000E+00 0.000000E+00
|
||||
tally 1:
|
||||
7.326285E-03
|
||||
5.367445E-05
|
||||
8.565980E-03
|
||||
7.337601E-05
|
||||
9.027116E-03
|
||||
8.148882E-05
|
||||
8.045879E-03
|
||||
6.473617E-05
|
||||
1
tests/test_filter_distribcell/case-3/results_true.dat
Normal file
1
tests/test_filter_distribcell/case-3/results_true.dat
Normal file
|
|
@ -0,0 +1 @@
|
|||
f5873c6ca03a2c75f5094b7297059285788bb93c450466606914805cdb24fd2664c3872ed42a8c6665a272070ab6b08b0a53b02612bcd993e10329aec2f1d313
|
||||
|
|
@ -1,95 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
import numpy as np
|
||||
|
||||
sys.path.insert(0, '../..')
|
||||
from openmc.statepoint import StatePoint
|
||||
from openmc import Filter
|
||||
|
||||
# read in statepoint file
|
||||
sp3 = StatePoint(sys.argv[1])
|
||||
sp2 = StatePoint(sys.argv[2])
|
||||
sp1 = StatePoint(sys.argv[3])
|
||||
sp1.read_results()
|
||||
sp2.read_results()
|
||||
sp3.read_results()
|
||||
sp1.compute_stdev()
|
||||
sp2.compute_stdev()
|
||||
sp3.compute_stdev()
|
||||
|
||||
# analyze sp1
|
||||
# compare distrib sum to cell
|
||||
sp1_t1 = sp1.tallies[1]
|
||||
sp1_t2 = sp1.tallies[2]
|
||||
|
||||
sp1_t1_d1 = sp1_t1.get_values(scores=['total'], filters=['distribcell'],
|
||||
filter_bins=[(0,)], value='mean')
|
||||
sp1_t1_d2 = sp1_t1.get_values(scores=['total'], filters=['distribcell'],
|
||||
filter_bins=[(1,)], value='mean')
|
||||
sp1_t1_d3 = sp1_t1.get_values(scores=['total'], filters=['distribcell'],
|
||||
filter_bins=[(2,)], value='mean')
|
||||
sp1_t1_d4 = sp1_t1.get_values(scores=['total'], filters=['distribcell'],
|
||||
filter_bins=[(3,)], value='mean')
|
||||
sp1_t1_sum = sp1_t1_d1 + sp1_t1_d2 + sp1_t1_d3 + sp1_t1_d4
|
||||
|
||||
cell_filter = sp1_t2.find_filter(filter_type='cell')
|
||||
sp1_t2_c201 = sp1_t2.get_values(scores=['total'], value='mean')
|
||||
|
||||
|
||||
# analyze sp2
|
||||
sp2_t1 = sp2.tallies[1]
|
||||
sp2_t1_c201 = sp2_t1.get_values(scores=['total'], filters=['cell'],
|
||||
filter_bins=[(2,)], value='mean')
|
||||
sp2_t1_c203 = sp2_t1.get_values(scores=['total'], filters=['cell'],
|
||||
filter_bins=[(4,)], value='mean')
|
||||
sp2_t1_c205 = sp2_t1.get_values(scores=['total'], filters=['cell'],
|
||||
filter_bins=[(6,)], value='mean')
|
||||
sp2_t1_c207 = sp2_t1.get_values(scores=['total'], filters=['cell'],
|
||||
filter_bins=[(8,)], value='mean')
|
||||
|
||||
|
||||
# analyze sp3
|
||||
sp3_t1 = sp3.tallies[1]
|
||||
sp3_t2 = sp3.tallies[2]
|
||||
sp3_t3 = sp3.tallies[3]
|
||||
sp3_t4 = sp3.tallies[4]
|
||||
sp3_t5 = sp3.tallies[5]
|
||||
sp3_t6 = sp3.tallies[6]
|
||||
|
||||
sp3_t1_c1 = sp3_t1.get_values(scores=['total'], filters=['cell'],
|
||||
filter_bins=[(1,)], value='mean')
|
||||
sp3_t2_d1 = sp3_t2.get_values(scores=['total'], filters=['distribcell'],
|
||||
filter_bins=[(0,)], value='mean')
|
||||
|
||||
sp3_t3_c60 = sp3_t3.get_values(scores=['total'], filters=['cell'],
|
||||
filter_bins=[(26,)], value='mean')
|
||||
sp3_t4_d = sum(sp3_t4.get_values(scores=['total'], value='mean'))
|
||||
|
||||
sp3_t5_c27 = sp3_t5.get_values(scores=['total'], filters=['cell'],
|
||||
filter_bins=[(19,)], value='mean')
|
||||
sp3_t6_d = sum(sp3_t6.get_values(scores=['total'], value='mean'))
|
||||
|
||||
# set up output string
|
||||
outstr = ''
|
||||
|
||||
outstr += "{0:12.6E}\n".format(sp1_t1_sum)
|
||||
outstr += "{0:12.6E}\n".format(sp1_t2_c201[()])
|
||||
outstr += "{0:12.6E}\n".format(sp2_t1_c201[()])
|
||||
outstr += "{0:12.6E}\n".format(sp1_t1_d4[()])
|
||||
outstr += "{0:12.6E}\n".format(sp2_t1_c203[()])
|
||||
outstr += "{0:12.6E}\n".format(sp1_t1_d1[()])
|
||||
outstr += "{0:12.6E}\n".format(sp2_t1_c205[()])
|
||||
outstr += "{0:12.6E}\n".format(sp1_t1_d3[()])
|
||||
outstr += "{0:12.6E}\n".format(sp2_t1_c207[()])
|
||||
outstr += "{0:12.6E}\n".format(sp1_t1_d2[()])
|
||||
outstr += "{0:12.6E}\n".format(sp3_t1_c1[()])
|
||||
outstr += "{0:12.6E}\n".format(sp3_t2_d1[()])
|
||||
outstr += "{0:12.6E}\n".format(sp3_t3_c60[()])
|
||||
outstr += "{0:12.6E}\n".format(sp3_t4_d)
|
||||
outstr += "{0:12.6E}\n".format(sp3_t5_c27[()])
|
||||
outstr += "{0:12.6E}\n".format(sp3_t6_d)
|
||||
|
||||
# write results to file
|
||||
with open('results_test.dat','w') as fh:
|
||||
fh.write(outstr)
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
3.296526E-02
|
||||
3.296526E-02
|
||||
7.326285E-03
|
||||
7.326285E-03
|
||||
8.565980E-03
|
||||
8.565980E-03
|
||||
9.027116E-03
|
||||
9.027116E-03
|
||||
8.045879E-03
|
||||
8.045879E-03
|
||||
1.820738E+01
|
||||
1.820738E+01
|
||||
1.770306E+01
|
||||
1.770306E+01
|
||||
2.109466E+00
|
||||
2.109466E+00
|
||||
|
|
@ -1,109 +1,119 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
import hashlib
|
||||
import sys
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
from shutil import copyfile
|
||||
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
sys.path.insert(0, '..')
|
||||
from testing_harness import *
|
||||
|
||||
def test_run():
|
||||
|
||||
if opts.mpi_exec != '':
|
||||
opts.mpi_exe = os.path.abspath(opts.mpi_exec)
|
||||
class DistribcellTestHarness(TestHarness):
|
||||
def __init__(self):
|
||||
self._sp_name = None
|
||||
self._tallies = True
|
||||
self._opts = None
|
||||
self._args = None
|
||||
|
||||
opts.exe = os.path.abspath(opts.exe)
|
||||
|
||||
# Call 1
|
||||
os.chdir('case-1')
|
||||
cwd = os.getcwd()
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0
|
||||
def execute_test(self):
|
||||
self._parse_args()
|
||||
base_dir = os.getcwd()
|
||||
try:
|
||||
self._run_openmc()
|
||||
os.chdir(base_dir)
|
||||
self._test_output_created()
|
||||
os.chdir(base_dir)
|
||||
self._get_results()
|
||||
os.chdir(base_dir)
|
||||
self._compare_results()
|
||||
finally:
|
||||
os.chdir(base_dir)
|
||||
self._cleanup()
|
||||
|
||||
# Call 2
|
||||
os.chdir('../case-2')
|
||||
cwd = os.getcwd()
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0
|
||||
|
||||
# Call 3
|
||||
os.chdir('../case-3')
|
||||
cwd = os.getcwd()
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0
|
||||
def _run_openmc(self):
|
||||
dirs = ('case-1', '../case-2', '../case-3')
|
||||
for d in dirs:
|
||||
os.chdir(d)
|
||||
if self._opts.mpi_exec != '':
|
||||
proc = Popen([self._opts.mpi_exec, '-np', self._opts.mpi_np,
|
||||
self._opts.exe, os.getcwd()],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([self._opts.exe, os.getcwd()],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
os.chdir('..')
|
||||
|
||||
def test_created_statepoint():
|
||||
cwd = os.getcwd()
|
||||
statepoint1 = glob.glob(cwd + '/case-1/statepoint.1.*')
|
||||
statepoint2 = glob.glob(cwd + '/case-2/statepoint.1.*')
|
||||
statepoint3 = glob.glob(cwd + '/case-3/statepoint.3.*')
|
||||
assert len(statepoint1) == 1
|
||||
assert len(statepoint2) == 1
|
||||
assert len(statepoint3) == 1
|
||||
string1 = statepoint1.pop()
|
||||
string2 = statepoint2.pop()
|
||||
string3 = statepoint3.pop()
|
||||
assert string1.endswith('binary') or string1.endswith('h5')
|
||||
assert string2.endswith('binary') or string2.endswith('h5')
|
||||
assert string3.endswith('binary') or string3.endswith('h5')
|
||||
def _test_output_created(self):
|
||||
"""Make sure statepoint files have been created."""
|
||||
dirs = ('case-1', '../case-2', '../case-3')
|
||||
sps = ('statepoint.1.*', 'statepoint.1.*', 'statepoint.3.*')
|
||||
tallies_present = (True, True, False)
|
||||
for i in range(len(dirs)):
|
||||
os.chdir(dirs[i])
|
||||
self._tallies = tallies_present[i]
|
||||
self._sp_name = sps[i]
|
||||
TestHarness._test_output_created(self)
|
||||
self._tallies = True
|
||||
|
||||
def test_results():
|
||||
cwd = os.getcwd()
|
||||
statepoint = list()
|
||||
statepoint.append(glob.glob(cwd + '/case-1/statepoint.1.*'))
|
||||
statepoint.append(glob.glob(cwd + '/case-2/statepoint.1.*'))
|
||||
statepoint.append(glob.glob(cwd + '/case-3/statepoint.3.*'))
|
||||
call([sys.executable, 'results.py', statepoint.pop()[0], statepoint.pop()[0], statepoint.pop()[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare
|
||||
|
||||
def teardown():
|
||||
cwd = os.getcwd()
|
||||
output = glob.glob(cwd + '/statepoint.*')
|
||||
output.append(cwd + '/results_test.dat')
|
||||
for f in output:
|
||||
if os.path.exists(str(f)):
|
||||
os.remove(str(f))
|
||||
def _get_results(self):
|
||||
dirs = ('case-1', '../case-2', '../case-3')
|
||||
sps = ('statepoint.1.*', 'statepoint.1.*', 'statepoint.3.*')
|
||||
for i in range(len(dirs)):
|
||||
os.chdir(dirs[i])
|
||||
self._sp_name = sps[i]
|
||||
|
||||
# Read the statepoint file.
|
||||
statepoint = glob.glob(os.path.join(os.getcwd(), self._sp_name))[0]
|
||||
sp = StatePoint(statepoint)
|
||||
sp.read_results()
|
||||
|
||||
# Write out k-combined.
|
||||
outstr = 'k-combined:\n'
|
||||
form = '{0:12.6E} {1:12.6E}\n'
|
||||
outstr += form.format(sp.k_combined[0], sp.k_combined[1])
|
||||
|
||||
# Write out tally data.
|
||||
if self._tallies:
|
||||
tally_num = 1
|
||||
for tally_ind in sp._tallies:
|
||||
tally = sp._tallies[tally_ind]
|
||||
results = np.zeros((tally._sum.size*2, ))
|
||||
results[0::2] = tally._sum.ravel()
|
||||
results[1::2] = tally._sum_sq.ravel()
|
||||
results = ['{0:12.6E}'.format(x) for x in results]
|
||||
|
||||
outstr += 'tally ' + str(tally_num) + ':\n'
|
||||
outstr += '\n'.join(results) + '\n'
|
||||
tally_num += 1
|
||||
|
||||
if i == 2:
|
||||
sha512 = hashlib.sha512()
|
||||
sha512.update(outstr)
|
||||
outstr = sha512.hexdigest()
|
||||
|
||||
# Write results to a file.
|
||||
with open('results_test.dat','w') as fh:
|
||||
fh.write(outstr)
|
||||
|
||||
|
||||
def _compare_results(self):
|
||||
dirs = ('case-1', '../case-2', '../case-3')
|
||||
for d in dirs:
|
||||
os.chdir(d)
|
||||
TestHarness._compare_results(self)
|
||||
|
||||
def _cleanup(self):
|
||||
dirs = ('case-1', '../case-2', '../case-3')
|
||||
for d in dirs:
|
||||
os.chdir(d)
|
||||
TestHarness._cleanup(self)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
try:
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_results()
|
||||
finally:
|
||||
teardown()
|
||||
harness = DistribcellTestHarness()
|
||||
harness.execute_test()
|
||||
|
|
|
|||
|
|
@ -1,37 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
import numpy as np
|
||||
|
||||
sys.path.insert(0, '../..')
|
||||
from openmc.statepoint import StatePoint
|
||||
|
||||
# read in statepoint file
|
||||
if len(sys.argv) > 1:
|
||||
sp = StatePoint(sys.argv[1])
|
||||
else:
|
||||
sp = StatePoint('statepoint.10.binary')
|
||||
|
||||
sp.read_results()
|
||||
|
||||
# extract tally results and convert to vector
|
||||
tally = sp._tallies[1]
|
||||
results = np.zeros((tally._sum.size + tally._sum.size, ))
|
||||
results[0::2] = tally._sum.ravel()
|
||||
results[1::2] = tally._sum_sq.ravel()
|
||||
|
||||
# set up output string
|
||||
outstr = ''
|
||||
|
||||
# write out k-combined
|
||||
outstr += 'k-combined:\n'
|
||||
outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1])
|
||||
|
||||
# write out tally results
|
||||
outstr += 'tallies:\n'
|
||||
for item in results:
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
|
||||
# write results to file
|
||||
with open('results_test.dat','w') as fh:
|
||||
fh.write(outstr)
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
k-combined:
|
||||
1.093844E+00 1.626801E-02
|
||||
tallies:
|
||||
tally 1:
|
||||
2.687671E+01
|
||||
1.475192E+02
|
||||
4.148025E+01
|
||||
|
|
|
|||
|
|
@ -1,65 +1,10 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
import sys
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
sys.path.insert(0, '..')
|
||||
from testing_harness import TestHarness
|
||||
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_output_exists():
|
||||
assert os.path.exists(os.path.join(cwd, 'tallies.out')), 'Tally output file does not exist.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call([sys.executable, 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
output.append(os.path.join(cwd, 'tallies.out'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
try:
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_output_exists()
|
||||
test_results()
|
||||
finally:
|
||||
teardown()
|
||||
harness = TestHarness('statepoint.10.*', True)
|
||||
harness.execute_test()
|
||||
|
|
|
|||
|
|
@ -1,36 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
import numpy as np
|
||||
|
||||
sys.path.insert(0, '../..')
|
||||
from openmc.statepoint import StatePoint
|
||||
|
||||
# read in statepoint file
|
||||
if len(sys.argv) > 1:
|
||||
sp = StatePoint(sys.argv[1])
|
||||
else:
|
||||
sp = StatePoint('statepoint.10.binary')
|
||||
sp.read_results()
|
||||
|
||||
# extract tally results and convert to vector
|
||||
tally = sp._tallies[1]
|
||||
results = np.zeros((tally._sum.size + tally._sum.size, ))
|
||||
results[0::2] = tally._sum.ravel()
|
||||
results[1::2] = tally._sum_sq.ravel()
|
||||
|
||||
# set up output string
|
||||
outstr = ''
|
||||
|
||||
# write out k-combined
|
||||
outstr += 'k-combined:\n'
|
||||
outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1])
|
||||
|
||||
# write out tally results
|
||||
outstr += 'tallies:\n'
|
||||
for item in results:
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
|
||||
# write results to file
|
||||
with open('results_test.dat','w') as fh:
|
||||
fh.write(outstr)
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
k-combined:
|
||||
1.093844E+00 1.626801E-02
|
||||
tallies:
|
||||
tally 1:
|
||||
2.740000E+01
|
||||
1.516786E+02
|
||||
4.163000E+01
|
||||
|
|
|
|||
|
|
@ -1,65 +1,10 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
import sys
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
sys.path.insert(0, '..')
|
||||
from testing_harness import TestHarness
|
||||
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_output_exists():
|
||||
assert os.path.exists(os.path.join(cwd, 'tallies.out')), 'Tally output file does not exist.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call([sys.executable, 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
output.append(os.path.join(cwd, 'tallies.out'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
try:
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_output_exists()
|
||||
test_results()
|
||||
finally:
|
||||
teardown()
|
||||
harness = TestHarness('statepoint.10.*', True)
|
||||
harness.execute_test()
|
||||
|
|
|
|||
|
|
@ -1,36 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
import numpy as np
|
||||
|
||||
sys.path.insert(0, '../..')
|
||||
from openmc.statepoint import StatePoint
|
||||
|
||||
# read in statepoint file
|
||||
if len(sys.argv) > 1:
|
||||
sp = StatePoint(sys.argv[1])
|
||||
else:
|
||||
sp = StatePoint('statepoint.10.binary')
|
||||
sp.read_results()
|
||||
|
||||
# extract tally results and convert to vector
|
||||
tally = sp._tallies[1]
|
||||
results = np.zeros((tally._sum.size + tally._sum.size, ))
|
||||
results[0::2] = tally._sum.ravel()
|
||||
results[1::2] = tally._sum_sq.ravel()
|
||||
|
||||
# set up output string
|
||||
outstr = ''
|
||||
|
||||
# write out k-combined
|
||||
outstr += 'k-combined:\n'
|
||||
outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1])
|
||||
|
||||
# write out tally results
|
||||
outstr += 'tallies:\n'
|
||||
for item in results:
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
|
||||
# write results to file
|
||||
with open('results_test.dat','w') as fh:
|
||||
fh.write(outstr)
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
k-combined:
|
||||
1.093844E+00 1.626801E-02
|
||||
tallies:
|
||||
tally 1:
|
||||
2.470000E+01
|
||||
1.233286E+02
|
||||
0.000000E+00
|
||||
|
|
|
|||
|
|
@ -1,65 +1,10 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
import sys
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
sys.path.insert(0, '..')
|
||||
from testing_harness import TestHarness
|
||||
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_output_exists():
|
||||
assert os.path.exists(os.path.join(cwd, 'tallies.out')), 'Tally output file does not exist.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call([sys.executable, 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
output.append(os.path.join(cwd, 'tallies.out'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
try:
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_output_exists()
|
||||
test_results()
|
||||
finally:
|
||||
teardown()
|
||||
harness = TestHarness('statepoint.10.*', True)
|
||||
harness.execute_test()
|
||||
|
|
|
|||
|
|
@ -1,37 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
import numpy as np
|
||||
|
||||
sys.path.insert(0, '../..')
|
||||
from openmc.statepoint import StatePoint
|
||||
|
||||
# read in statepoint file
|
||||
if len(sys.argv) > 1:
|
||||
sp = StatePoint(sys.argv[1])
|
||||
else:
|
||||
sp = StatePoint('statepoint.10.binary')
|
||||
|
||||
sp.read_results()
|
||||
|
||||
# extract tally results and convert to vector
|
||||
tally = sp._tallies[1]
|
||||
results = np.zeros((tally._sum.size + tally._sum.size, ))
|
||||
results[0::2] = tally._sum.ravel()
|
||||
results[1::2] = tally._sum_sq.ravel()
|
||||
|
||||
# set up output string
|
||||
outstr = ''
|
||||
|
||||
# write out k-combined
|
||||
outstr += 'k-combined:\n'
|
||||
outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1])
|
||||
|
||||
# write out tally results
|
||||
outstr += 'tallies:\n'
|
||||
for item in results:
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
|
||||
# write results to file
|
||||
with open('results_test.dat','w') as fh:
|
||||
fh.write(outstr)
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
k-combined:
|
||||
1.093844E+00 1.626801E-02
|
||||
tallies:
|
||||
tally 1:
|
||||
2.819256E+01
|
||||
1.591068E+02
|
||||
6.599750E+00
|
||||
|
|
|
|||
|
|
@ -1,65 +1,10 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
import sys
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
sys.path.insert(0, '..')
|
||||
from testing_harness import TestHarness
|
||||
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_output_exists():
|
||||
assert os.path.exists(os.path.join(cwd, 'tallies.out')), 'Tally output file does not exist.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call([sys.executable, 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
output.append(os.path.join(cwd, 'tallies.out'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
try:
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_output_exists()
|
||||
test_results()
|
||||
finally:
|
||||
teardown()
|
||||
harness = TestHarness('statepoint.10.*', True)
|
||||
harness.execute_test()
|
||||
|
|
|
|||
|
|
@ -1,37 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
import numpy as np
|
||||
|
||||
sys.path.insert(0, '../..')
|
||||
from openmc.statepoint import StatePoint
|
||||
|
||||
# read in statepoint file
|
||||
if len(sys.argv) > 1:
|
||||
sp = StatePoint(sys.argv[1])
|
||||
else:
|
||||
sp = StatePoint('statepoint.10.binary')
|
||||
|
||||
sp.read_results()
|
||||
|
||||
# extract tally results and convert to vector
|
||||
tally = sp._tallies[1]
|
||||
results = np.zeros((tally._sum.size + tally._sum.size, ))
|
||||
results[0::2] = tally._sum.ravel()
|
||||
results[1::2] = tally._sum_sq.ravel()
|
||||
|
||||
# set up output string
|
||||
outstr = ''
|
||||
|
||||
# write out k-combined
|
||||
outstr += 'k-combined:\n'
|
||||
outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1])
|
||||
|
||||
# write out tally results
|
||||
outstr += 'tallies:\n'
|
||||
for item in results:
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
|
||||
# write results to file
|
||||
with open('results_test.dat','w') as fh:
|
||||
fh.write(outstr)
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
k-combined:
|
||||
1.093844E+00 1.626801E-02
|
||||
tallies:
|
||||
tally 1:
|
||||
0.000000E+00
|
||||
0.000000E+00
|
||||
0.000000E+00
|
||||
|
|
|
|||
|
|
@ -1,65 +1,10 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
import sys
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
sys.path.insert(0, '..')
|
||||
from testing_harness import TestHarness
|
||||
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_output_exists():
|
||||
assert os.path.exists(os.path.join(cwd, 'tallies.out')), 'Tally output file does not exist.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call([sys.executable, 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
output.append(os.path.join(cwd, 'tallies.out'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
try:
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_output_exists()
|
||||
test_results()
|
||||
finally:
|
||||
teardown()
|
||||
harness = TestHarness('statepoint.10.*', True)
|
||||
harness.execute_test()
|
||||
|
|
|
|||
|
|
@ -1,37 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
import numpy as np
|
||||
|
||||
sys.path.insert(0, '../..')
|
||||
from openmc.statepoint import StatePoint
|
||||
|
||||
# read in statepoint file
|
||||
if len(sys.argv) > 1:
|
||||
sp = StatePoint(sys.argv[1])
|
||||
else:
|
||||
sp = StatePoint('statepoint.10.binary')
|
||||
|
||||
sp.read_results()
|
||||
|
||||
# extract tally results and convert to vector
|
||||
tally = sp._tallies[1]
|
||||
results = np.zeros((tally._sum.size + tally._sum.size, ))
|
||||
results[0::2] = tally._sum.ravel()
|
||||
results[1::2] = tally._sum_sq.ravel()
|
||||
|
||||
# set up output string
|
||||
outstr = ''
|
||||
|
||||
# write out k-combined
|
||||
outstr += 'k-combined:\n'
|
||||
outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1])
|
||||
|
||||
# write out tally results
|
||||
outstr += 'tallies:\n'
|
||||
for item in results:
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
|
||||
# write results to file
|
||||
with open('results_test.dat','w') as fh:
|
||||
fh.write(outstr)
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
k-combined:
|
||||
1.093844E+00 1.626801E-02
|
||||
tallies:
|
||||
tally 1:
|
||||
0.000000E+00
|
||||
0.000000E+00
|
||||
0.000000E+00
|
||||
|
|
|
|||
|
|
@ -1,65 +1,10 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
import sys
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
sys.path.insert(0, '..')
|
||||
from testing_harness import TestHarness
|
||||
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_output_exists():
|
||||
assert os.path.exists(os.path.join(cwd, 'tallies.out')), 'Tally output file does not exist.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call([sys.executable, 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
output.append(os.path.join(cwd, 'tallies.out'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
try:
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_output_exists()
|
||||
test_results()
|
||||
finally:
|
||||
teardown()
|
||||
harness = TestHarness('statepoint.10.*', True)
|
||||
harness.execute_test()
|
||||
|
|
|
|||
|
|
@ -1,37 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
import numpy as np
|
||||
|
||||
sys.path.insert(0, '../..')
|
||||
from openmc.statepoint import StatePoint
|
||||
|
||||
# read in statepoint file
|
||||
if len(sys.argv) > 1:
|
||||
sp = StatePoint(sys.argv[1])
|
||||
else:
|
||||
sp = StatePoint('statepoint.10.binary')
|
||||
|
||||
sp.read_results()
|
||||
|
||||
# extract tally results and convert to vector
|
||||
tally = sp._tallies[1]
|
||||
results = np.zeros((tally._sum.size + tally._sum.size, ))
|
||||
results[0::2] = tally._sum.ravel()
|
||||
results[1::2] = tally._sum_sq.ravel()
|
||||
|
||||
# set up output string
|
||||
outstr = ''
|
||||
|
||||
# write out k-combined
|
||||
outstr += 'k-combined:\n'
|
||||
outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1])
|
||||
|
||||
# write out tally results
|
||||
outstr += 'tallies:\n'
|
||||
for item in results:
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
|
||||
# write results to file
|
||||
with open('results_test.dat','w') as fh:
|
||||
fh.write(outstr)
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
k-combined:
|
||||
1.093844E+00 1.626801E-02
|
||||
tallies:
|
||||
tally 1:
|
||||
6.144371E+01
|
||||
7.795909E+02
|
||||
7.330533E+00
|
||||
|
|
|
|||
|
|
@ -1,65 +1,10 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
import sys
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
sys.path.insert(0, '..')
|
||||
from testing_harness import TestHarness
|
||||
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_output_exists():
|
||||
assert os.path.exists(os.path.join(cwd, 'tallies.out')), 'Tally output file does not exist.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call([sys.executable, 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
output.append(os.path.join(cwd, 'tallies.out'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
try:
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_output_exists()
|
||||
test_results()
|
||||
finally:
|
||||
teardown()
|
||||
harness = TestHarness('statepoint.10.*', True)
|
||||
harness.execute_test()
|
||||
|
|
|
|||
|
|
@ -1,33 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
import numpy as np
|
||||
|
||||
sys.path.insert(0, '../..')
|
||||
from openmc.statepoint import StatePoint
|
||||
|
||||
# read in statepoint file
|
||||
if len(sys.argv) > 1:
|
||||
sp = StatePoint(sys.argv[1])
|
||||
else:
|
||||
sp = StatePoint('statepoint.10.binary')
|
||||
|
||||
sp.read_results()
|
||||
|
||||
# extract tally results and convert to vector
|
||||
tally = sp._tallies[1]
|
||||
results = np.zeros((tally._sum.size + tally._sum.size, ))
|
||||
results[0::2] = tally._sum.ravel()
|
||||
results[1::2] = tally._sum_sq.ravel()
|
||||
|
||||
# set up output string
|
||||
outstr = ''
|
||||
|
||||
# write out tally results
|
||||
outstr += 'tallies:\n'
|
||||
for item in results:
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
|
||||
# write results to file
|
||||
with open('results_test.dat','w') as fh:
|
||||
fh.write(outstr)
|
||||
|
|
@ -1,3 +1,3 @@
|
|||
tallies:
|
||||
tally 1:
|
||||
4.483337E+02
|
||||
2.017057E+04
|
||||
|
|
|
|||
|
|
@ -1,65 +1,38 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
import sys
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
sys.path.insert(0, '..')
|
||||
from testing_harness import *
|
||||
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
class FixedSourceTestHarness(TestHarness):
|
||||
def _get_results(self):
|
||||
"""Digest info in the statepoint and create a simpler ASCII file."""
|
||||
# Read the statepoint file.
|
||||
statepoint = glob.glob(os.path.join(os.getcwd(), self._sp_name))[0]
|
||||
sp = StatePoint(statepoint)
|
||||
sp.read_results()
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
# Write out tally data.
|
||||
outstr = ''
|
||||
if self._tallies:
|
||||
tally_num = 1
|
||||
for tally_ind in sp._tallies:
|
||||
tally = sp._tallies[tally_ind]
|
||||
results = np.zeros((tally._sum.size*2, ))
|
||||
results[0::2] = tally._sum.ravel()
|
||||
results[1::2] = tally._sum_sq.ravel()
|
||||
results = ['{0:12.6E}'.format(x) for x in results]
|
||||
|
||||
def test_output_exists():
|
||||
assert os.path.exists(os.path.join(cwd, 'tallies.out')), 'Tally output file does not exist.'
|
||||
outstr += 'tally ' + str(tally_num) + ':\n'
|
||||
outstr += '\n'.join(results) + '\n'
|
||||
tally_num += 1
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call([sys.executable, 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare, 'Results do not agree.'
|
||||
# Write results to a file.
|
||||
with open('results_test.dat','w') as fh:
|
||||
fh.write(outstr)
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
output.append(os.path.join(cwd, 'tallies.out'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
try:
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_output_exists()
|
||||
test_results()
|
||||
finally:
|
||||
teardown()
|
||||
harness = FixedSourceTestHarness('statepoint.10.*', True)
|
||||
harness.execute_test()
|
||||
|
|
|
|||
|
|
@ -1,24 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
|
||||
sys.path.insert(0, '../..')
|
||||
from openmc.statepoint import StatePoint
|
||||
|
||||
# read in statepoint file
|
||||
if len(sys.argv) > 1:
|
||||
sp = StatePoint(sys.argv[1])
|
||||
else:
|
||||
sp = StatePoint('statepoint.10.binary')
|
||||
sp.read_results()
|
||||
|
||||
# set up output string
|
||||
outstr = ''
|
||||
|
||||
# write out k-combined
|
||||
outstr += 'k-combined:\n'
|
||||
outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1])
|
||||
|
||||
# write results to file
|
||||
with open('results_test.dat','w') as fh:
|
||||
fh.write(outstr)
|
||||
|
|
@ -1,60 +1,10 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
import sys
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
sys.path.insert(0, '..')
|
||||
from testing_harness import TestHarness
|
||||
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call([sys.executable, 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
try:
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_results()
|
||||
finally:
|
||||
teardown()
|
||||
harness = TestHarness('statepoint.10.*')
|
||||
harness.execute_test()
|
||||
|
|
|
|||
|
|
@ -1,25 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
|
||||
sys.path.insert(0, '../..')
|
||||
from openmc.statepoint import StatePoint
|
||||
|
||||
# read in statepoint file
|
||||
if len(sys.argv) > 1:
|
||||
sp = StatePoint(sys.argv[1])
|
||||
else:
|
||||
sp = StatePoint('statepoint.10.binary')
|
||||
|
||||
sp.read_results()
|
||||
|
||||
# set up output string
|
||||
outstr = ''
|
||||
|
||||
# write out k-combined
|
||||
outstr += 'k-combined:\n'
|
||||
outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1])
|
||||
|
||||
# write results to file
|
||||
with open('results_test.dat','w') as fh:
|
||||
fh.write(outstr)
|
||||
|
|
@ -1,60 +1,10 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
import sys
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
sys.path.insert(0, '..')
|
||||
from testing_harness import TestHarness
|
||||
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call([sys.executable, 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
try:
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_results()
|
||||
finally:
|
||||
teardown()
|
||||
harness = TestHarness('statepoint.10.*')
|
||||
harness.execute_test()
|
||||
|
|
|
|||
|
|
@ -1,26 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
import numpy as np
|
||||
|
||||
sys.path.insert(0, '../..')
|
||||
from openmc.statepoint import StatePoint
|
||||
|
||||
# read in statepoint file
|
||||
if len(sys.argv) > 1:
|
||||
sp = StatePoint(sys.argv[1])
|
||||
else:
|
||||
sp = StatePoint('statepoint.10.binary')
|
||||
|
||||
sp.read_results()
|
||||
|
||||
# set up output string
|
||||
outstr = ''
|
||||
|
||||
# write out k-combined
|
||||
outstr += 'k-combined:\n'
|
||||
outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1])
|
||||
|
||||
# write results to file
|
||||
with open('results_test.dat','w') as fh:
|
||||
fh.write(outstr)
|
||||
|
|
@ -1,60 +1,10 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
import sys
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
sys.path.insert(0, '..')
|
||||
from testing_harness import TestHarness
|
||||
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call([sys.executable, 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
try:
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_results()
|
||||
finally:
|
||||
teardown()
|
||||
harness = TestHarness('statepoint.10.*')
|
||||
harness.execute_test()
|
||||
|
|
|
|||
|
|
@ -1,26 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
import numpy as np
|
||||
|
||||
sys.path.insert(0, '../..')
|
||||
from openmc.statepoint import StatePoint
|
||||
|
||||
# read in statepoint file
|
||||
if len(sys.argv) > 1:
|
||||
sp = StatePoint(sys.argv[1])
|
||||
else:
|
||||
sp = StatePoint('statepoint.10.binary')
|
||||
|
||||
sp.read_results()
|
||||
|
||||
# set up output string
|
||||
outstr = ''
|
||||
|
||||
# write out k-combined
|
||||
outstr += 'k-combined:\n'
|
||||
outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1])
|
||||
|
||||
# write results to file
|
||||
with open('results_test.dat','w') as fh:
|
||||
fh.write(outstr)
|
||||
|
|
@ -1,60 +1,10 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
import sys
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
sys.path.insert(0, '..')
|
||||
from testing_harness import TestHarness
|
||||
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call([sys.executable, 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
try:
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_results()
|
||||
finally:
|
||||
teardown()
|
||||
harness = TestHarness('statepoint.10.*')
|
||||
harness.execute_test()
|
||||
|
|
|
|||
|
|
@ -1,25 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
|
||||
sys.path.insert(0, '../..')
|
||||
from openmc.statepoint import StatePoint
|
||||
|
||||
# read in statepoint file
|
||||
if len(sys.argv) > 1:
|
||||
sp = StatePoint(sys.argv[1])
|
||||
else:
|
||||
sp = StatePoint('statepoint.10.binary')
|
||||
|
||||
sp.read_results()
|
||||
|
||||
# set up output string
|
||||
outstr = ''
|
||||
|
||||
# write out k-combined
|
||||
outstr += 'k-combined:\n'
|
||||
outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1])
|
||||
|
||||
# write results to file
|
||||
with open('results_test.dat','w') as fh:
|
||||
fh.write(outstr)
|
||||
|
|
@ -1,60 +1,10 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
import sys
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
sys.path.insert(0, '..')
|
||||
from testing_harness import TestHarness
|
||||
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call([sys.executable, 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
try:
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_results()
|
||||
finally:
|
||||
teardown()
|
||||
harness = TestHarness('statepoint.10.*')
|
||||
harness.execute_test()
|
||||
|
|
|
|||
|
|
@ -1,37 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
import numpy as np
|
||||
|
||||
sys.path.insert(0, '../..')
|
||||
from openmc.statepoint import StatePoint
|
||||
|
||||
# read in statepoint file
|
||||
if len(sys.argv) > 1:
|
||||
sp = StatePoint(sys.argv[1])
|
||||
else:
|
||||
sp = StatePoint('statepoint.5.binary')
|
||||
|
||||
sp.read_results()
|
||||
|
||||
# extract tally results and convert to vector
|
||||
tally1 = sp._tallies[1]
|
||||
results1 = np.zeros((tally1._sum.size + tally1._sum.size, ))
|
||||
results1[0::2] = tally1._sum.ravel()
|
||||
results1[1::2] = tally1._sum_sq.ravel()
|
||||
|
||||
# set up output string
|
||||
outstr = ''
|
||||
|
||||
# write out k-combined
|
||||
outstr += 'k-combined:\n'
|
||||
outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1])
|
||||
|
||||
# write out tally results
|
||||
outstr += 'tally 1:\n'
|
||||
for item in results1:
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
|
||||
# write results to file
|
||||
with open('results_test.dat','w') as fh:
|
||||
fh.write(outstr)
|
||||
|
|
@ -1,65 +1,10 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
import sys
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
sys.path.insert(0, '..')
|
||||
from testing_harness import TestHarness
|
||||
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.5.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_output_exists():
|
||||
assert os.path.exists(os.path.join(cwd, 'tallies.out')), 'Tally output file does not exist.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.5.*'))
|
||||
call([sys.executable, 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.5.*'))
|
||||
output.append(os.path.join(cwd, 'tallies.out'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
try:
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_output_exists()
|
||||
test_results()
|
||||
finally:
|
||||
teardown()
|
||||
harness = TestHarness('statepoint.5.*', True)
|
||||
harness.execute_test()
|
||||
|
|
|
|||
|
|
@ -1,25 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
|
||||
sys.path.insert(0, '../..')
|
||||
from openmc.statepoint import StatePoint
|
||||
|
||||
# read in statepoint file
|
||||
if len(sys.argv) > 1:
|
||||
sp = StatePoint(sys.argv[1])
|
||||
else:
|
||||
sp = StatePoint('statepoint.10.binary')
|
||||
|
||||
sp.read_results()
|
||||
|
||||
# set up output string
|
||||
outstr = ''
|
||||
|
||||
# write out k-combined
|
||||
outstr += 'k-combined:\n'
|
||||
outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1])
|
||||
|
||||
# write results to file
|
||||
with open('results_test.dat','w') as fh:
|
||||
fh.write(outstr)
|
||||
|
|
@ -1,60 +1,10 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
import sys
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
sys.path.insert(0, '..')
|
||||
from testing_harness import TestHarness
|
||||
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call([sys.executable, 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
try:
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_results()
|
||||
finally:
|
||||
teardown()
|
||||
harness = TestHarness('statepoint.10.*')
|
||||
harness.execute_test()
|
||||
|
|
|
|||
|
|
@ -1,25 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
|
||||
sys.path.insert(0, '../..')
|
||||
from openmc.statepoint import StatePoint
|
||||
|
||||
# read in statepoint file
|
||||
if len(sys.argv) > 1:
|
||||
sp = StatePoint(sys.argv[1])
|
||||
else:
|
||||
sp = StatePoint('statepoint.10.binary')
|
||||
|
||||
sp.read_results()
|
||||
|
||||
# set up output string
|
||||
outstr = ''
|
||||
|
||||
# write out k-combined
|
||||
outstr += 'k-combined:\n'
|
||||
outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1])
|
||||
|
||||
# write results to file
|
||||
with open('results_test.dat','w') as fh:
|
||||
fh.write(outstr)
|
||||
|
|
@ -1,74 +1,35 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
import sys
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
sys.path.insert(0, '..')
|
||||
from testing_harness import *
|
||||
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
class OutputTestHarness(TestHarness):
|
||||
def _test_output_created(self):
|
||||
"""Make sure output files have been created."""
|
||||
# Check for the statepoint.
|
||||
TestHarness._test_output_created(self)
|
||||
|
||||
def test_summary_exists():
|
||||
summary = glob.glob(os.path.join(cwd, 'summary.*'))
|
||||
assert len(summary) == 1, 'Either multiple or no summary file exists.'
|
||||
assert summary[0].endswith('out') or summary[0].endswith('h5'),\
|
||||
'Summary file is not a binary or hdf5 file.'
|
||||
# Check for the summary.
|
||||
summary = glob.glob(os.path.join(os.getcwd(), 'summary.*'))
|
||||
assert len(summary) == 1, 'Either multiple or no summary file exists.'
|
||||
assert summary[0].endswith('out') or summary[0].endswith('h5'),\
|
||||
'Summary file is not a binary or hdf5 file.'
|
||||
|
||||
def test_cross_sections_exists():
|
||||
assert os.path.exists(os.path.join(cwd, 'cross_sections.out')),\
|
||||
'Cross section output file does not exist.'
|
||||
# Check for the cross sections.
|
||||
assert os.path.exists(os.path.join(os.getcwd(), 'cross_sections.out')),\
|
||||
'Cross section output file does not exist.'
|
||||
|
||||
def test_statepoint_exists():
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
def _cleanup(self):
|
||||
TestHarness._cleanup(self)
|
||||
output = glob.glob(os.path.join(os.getcwd(), 'summary.*'))
|
||||
output.append(os.path.join(os.getcwd(), 'cross_sections.out'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call([sys.executable, 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.10.*')) + glob.glob(os.path.join(cwd, 'summary.*'))
|
||||
output.append(os.path.join(cwd, 'summary.out'))
|
||||
output.append(os.path.join(cwd, 'cross_sections.out'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
try:
|
||||
test_run()
|
||||
test_summary_exists()
|
||||
test_cross_sections_exists()
|
||||
test_statepoint_exists()
|
||||
test_results()
|
||||
finally:
|
||||
teardown()
|
||||
harness = OutputTestHarness('statepoint.10.*')
|
||||
harness.execute_test()
|
||||
|
|
|
|||
|
|
@ -1,37 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
|
||||
sys.path.insert(0, '../..')
|
||||
import openmc.particle_restart as pr
|
||||
|
||||
# read in particle restart file
|
||||
if len(sys.argv) > 1:
|
||||
p = pr.Particle(sys.argv[1])
|
||||
else:
|
||||
p = pr.Particle('particle_12_616.binary')
|
||||
|
||||
# set up output string
|
||||
outstr = ''
|
||||
|
||||
# write out properties
|
||||
outstr += 'current batch:\n'
|
||||
outstr += "{0:12.6E}\n".format(p.current_batch)
|
||||
outstr += 'current gen:\n'
|
||||
outstr += "{0:12.6E}\n".format(p.current_gen)
|
||||
outstr += 'particle id:\n'
|
||||
outstr += "{0:12.6E}\n".format(p.id)
|
||||
outstr += 'run mode:\n'
|
||||
outstr += "{0:12.6E}\n".format(p.run_mode)
|
||||
outstr += 'particle weight:\n'
|
||||
outstr += "{0:12.6E}\n".format(p.weight)
|
||||
outstr += 'particle energy:\n'
|
||||
outstr += "{0:12.6E}\n".format(p.energy)
|
||||
outstr += 'particle xyz:\n'
|
||||
outstr += "{0:12.6E} {1:12.6E} {2:12.6E}\n".format(p.xyz[0],p.xyz[1],p.xyz[2])
|
||||
outstr += 'particle uvw:\n'
|
||||
outstr += "{0:12.6E} {1:12.6E} {2:12.6E}\n".format(p.uvw[0],p.uvw[1],p.uvw[2])
|
||||
|
||||
# write results to file
|
||||
with open('results_test.dat','w') as fh:
|
||||
fh.write(outstr)
|
||||
|
|
@ -1,69 +1,55 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
import sys
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
sys.path.insert(0, '..')
|
||||
from testing_harness import *
|
||||
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
import openmc.particle_restart as pr
|
||||
|
||||
def test_run():
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_restart():
|
||||
particle = glob.glob(os.path.join(cwd, 'particle_12_616.*'))
|
||||
assert len(particle) == 1, 'Either multiple or no particle restart files exist.'
|
||||
assert particle[0].endswith('binary') or \
|
||||
particle[0].endswith('h5'), 'Particle restart file not a binary or hdf5 file.'
|
||||
class ParticleRestartTestHarness(TestHarness):
|
||||
def _test_output_created(self):
|
||||
"""Make sure the restart file has been created."""
|
||||
particle = glob.glob(os.path.join(os.getcwd(), self._sp_name))
|
||||
assert len(particle) == 1, 'Either multiple or no particle restart ' \
|
||||
'files exist.'
|
||||
assert particle[0].endswith('binary') \
|
||||
or particle[0].endswith('h5'), \
|
||||
'Particle restart file is not a binary or hdf5 file.'
|
||||
|
||||
def test_results():
|
||||
particle = glob.glob(os.path.join(cwd, 'particle_12_616.*'))
|
||||
call([sys.executable, 'results.py', particle[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def test_run_restart():
|
||||
particle = glob.glob(os.path.join(cwd, 'particle_12_616.*'))
|
||||
proc = Popen([opts.exe, '-r', particle[0], cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0, 'Particle restart not successful.'
|
||||
def _get_results(self):
|
||||
"""Digest info in the restart file and create a simpler ASCII file."""
|
||||
# Read the particle restart file.
|
||||
particle = glob.glob(os.path.join(os.getcwd(), self._sp_name))[0]
|
||||
p = pr.Particle(particle)
|
||||
|
||||
# Write out the properties.
|
||||
outstr = ''
|
||||
outstr += 'current batch:\n'
|
||||
outstr += "{0:12.6E}\n".format(p.current_batch)
|
||||
outstr += 'current gen:\n'
|
||||
outstr += "{0:12.6E}\n".format(p.current_gen)
|
||||
outstr += 'particle id:\n'
|
||||
outstr += "{0:12.6E}\n".format(p.id)
|
||||
outstr += 'run mode:\n'
|
||||
outstr += "{0:12.6E}\n".format(p.run_mode)
|
||||
outstr += 'particle weight:\n'
|
||||
outstr += "{0:12.6E}\n".format(p.weight)
|
||||
outstr += 'particle energy:\n'
|
||||
outstr += "{0:12.6E}\n".format(p.energy)
|
||||
outstr += 'particle xyz:\n'
|
||||
outstr += "{0:12.6E} {1:12.6E} {2:12.6E}\n".format(p.xyz[0],p.xyz[1],
|
||||
p.xyz[2])
|
||||
outstr += 'particle uvw:\n'
|
||||
outstr += "{0:12.6E} {1:12.6E} {2:12.6E}\n".format(p.uvw[0],p.uvw[1],
|
||||
p.uvw[2])
|
||||
|
||||
# Write results to a file.
|
||||
with open('results_test.dat','w') as fh:
|
||||
fh.write(outstr)
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.*')) + \
|
||||
glob.glob(os.path.join(cwd, 'particle_*')) + \
|
||||
[os.path.join(cwd, 'results_test.dat')]
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
try:
|
||||
test_run()
|
||||
test_created_restart()
|
||||
test_results()
|
||||
test_run_restart()
|
||||
finally:
|
||||
teardown()
|
||||
harness = ParticleRestartTestHarness('particle_12_616.*')
|
||||
harness.execute_test()
|
||||
|
|
|
|||
|
|
@ -1,37 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
|
||||
sys.path.insert(0, '../..')
|
||||
import openmc.particle_restart as pr
|
||||
|
||||
# read in particle restart file
|
||||
if len(sys.argv) > 1:
|
||||
p = pr.Particle(sys.argv[1])
|
||||
else:
|
||||
p = pr.Particle('particle_7_6144.binary')
|
||||
|
||||
# set up output string
|
||||
outstr = ''
|
||||
|
||||
# write out properties
|
||||
outstr += 'current batch:\n'
|
||||
outstr += "{0:12.6E}\n".format(p.current_batch)
|
||||
outstr += 'current gen:\n'
|
||||
outstr += "{0:12.6E}\n".format(p.current_gen)
|
||||
outstr += 'particle id:\n'
|
||||
outstr += "{0:12.6E}\n".format(p.id)
|
||||
outstr += 'run mode:\n'
|
||||
outstr += "{0:12.6E}\n".format(p.run_mode)
|
||||
outstr += 'particle weight:\n'
|
||||
outstr += "{0:12.6E}\n".format(p.weight)
|
||||
outstr += 'particle energy:\n'
|
||||
outstr += "{0:12.6E}\n".format(p.energy)
|
||||
outstr += 'particle xyz:\n'
|
||||
outstr += "{0:12.6E} {1:12.6E} {2:12.6E}\n".format(p.xyz[0],p.xyz[1],p.xyz[2])
|
||||
outstr += 'particle uvw:\n'
|
||||
outstr += "{0:12.6E} {1:12.6E} {2:12.6E}\n".format(p.uvw[0],p.uvw[1],p.uvw[2])
|
||||
|
||||
# write results to file
|
||||
with open('results_test.dat','w') as fh:
|
||||
fh.write(outstr)
|
||||
|
|
@ -1,69 +1,55 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
import sys
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
sys.path.insert(0, '..')
|
||||
from testing_harness import *
|
||||
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
import openmc.particle_restart as pr
|
||||
|
||||
def test_run():
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_restart():
|
||||
particle = glob.glob(os.path.join(cwd, 'particle_7_6144.*'))
|
||||
assert len(particle) == 1, 'Either multiple or no particle restart files exist.'
|
||||
assert particle[0].endswith('binary') or \
|
||||
particle[0].endswith('h5'), 'Particle restart file not a binary or hdf5 file.'
|
||||
class ParticleRestartTestHarness(TestHarness):
|
||||
def _test_output_created(self):
|
||||
"""Make sure the restart file has been created."""
|
||||
particle = glob.glob(os.path.join(os.getcwd(), self._sp_name))
|
||||
assert len(particle) == 1, 'Either multiple or no particle restart ' \
|
||||
'files exist.'
|
||||
assert particle[0].endswith('binary') \
|
||||
or particle[0].endswith('h5'), \
|
||||
'Particle restart file is not a binary or hdf5 file.'
|
||||
|
||||
def test_results():
|
||||
particle = glob.glob(os.path.join(cwd, 'particle_7_6144.*'))
|
||||
call([sys.executable, 'results.py', particle[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def test_run_restart():
|
||||
particle = glob.glob(os.path.join(cwd, 'particle_7_6144.*'))
|
||||
proc = Popen([opts.exe, '-r', particle[0], cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0, 'Particle restart not successful.'
|
||||
def _get_results(self):
|
||||
"""Digest info in the restart file and create a simpler ASCII file."""
|
||||
# Read the particle restart file.
|
||||
particle = glob.glob(os.path.join(os.getcwd(), self._sp_name))[0]
|
||||
p = pr.Particle(particle)
|
||||
|
||||
# Write out the properties.
|
||||
outstr = ''
|
||||
outstr += 'current batch:\n'
|
||||
outstr += "{0:12.6E}\n".format(p.current_batch)
|
||||
outstr += 'current gen:\n'
|
||||
outstr += "{0:12.6E}\n".format(p.current_gen)
|
||||
outstr += 'particle id:\n'
|
||||
outstr += "{0:12.6E}\n".format(p.id)
|
||||
outstr += 'run mode:\n'
|
||||
outstr += "{0:12.6E}\n".format(p.run_mode)
|
||||
outstr += 'particle weight:\n'
|
||||
outstr += "{0:12.6E}\n".format(p.weight)
|
||||
outstr += 'particle energy:\n'
|
||||
outstr += "{0:12.6E}\n".format(p.energy)
|
||||
outstr += 'particle xyz:\n'
|
||||
outstr += "{0:12.6E} {1:12.6E} {2:12.6E}\n".format(p.xyz[0],p.xyz[1],
|
||||
p.xyz[2])
|
||||
outstr += 'particle uvw:\n'
|
||||
outstr += "{0:12.6E} {1:12.6E} {2:12.6E}\n".format(p.uvw[0],p.uvw[1],
|
||||
p.uvw[2])
|
||||
|
||||
# Write results to a file.
|
||||
with open('results_test.dat','w') as fh:
|
||||
fh.write(outstr)
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.*')) + \
|
||||
glob.glob(os.path.join(cwd, 'particle_*')) + \
|
||||
[os.path.join(cwd, 'results_test.dat')]
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
try:
|
||||
test_run()
|
||||
test_created_restart()
|
||||
test_results()
|
||||
test_run_restart()
|
||||
finally:
|
||||
teardown()
|
||||
harness = ParticleRestartTestHarness('particle_7_6144.*')
|
||||
harness.execute_test()
|
||||
|
|
|
|||
|
|
@ -1,45 +1,47 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
import sys
|
||||
from subprocess import Popen, STDOUT, PIPE
|
||||
from optparse import OptionParser
|
||||
sys.path.insert(0, '..')
|
||||
from testing_harness import *
|
||||
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, '-p', cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([opts.exe, '-p', cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
class PlotTestHarness(TestHarness):
|
||||
def execute_test(self):
|
||||
self._parse_args()
|
||||
try:
|
||||
self._run_openmc()
|
||||
self._test_output_created()
|
||||
finally:
|
||||
self._cleanup()
|
||||
|
||||
def test_plot_exists():
|
||||
assert os.path.exists(os.path.join(cwd ,'1_plot.ppm')), 'Plot ppm file does not exist.'
|
||||
|
||||
def teardown():
|
||||
output = [os.path.join(cwd ,'1_plot.ppm')]
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
def _run_openmc(self):
|
||||
if self._opts.mpi_exec != '':
|
||||
proc = Popen([self._opts.mpi_exec, '-np', self._opts.mpi_np,
|
||||
self._opts.exe, '-p', os.getcwd()],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([self._opts.exe, '-p', os.getcwd()],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
|
||||
def _test_output_created(self):
|
||||
"""Make sure *.ppm has been created."""
|
||||
assert os.path.exists(os.path.join(os.getcwd(), '1_plot.ppm')), \
|
||||
'Plot output file does not exist.'
|
||||
|
||||
|
||||
def _cleanup(self):
|
||||
TestHarness._cleanup(self)
|
||||
output = glob.glob(os.path.join(os.getcwd(), '*.ppm'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
try:
|
||||
test_run()
|
||||
test_plot_exists()
|
||||
finally:
|
||||
teardown()
|
||||
harness = PlotTestHarness('statepoint.10.*', True)
|
||||
harness.execute_test()
|
||||
|
|
|
|||
|
|
@ -1,47 +1,47 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
import sys
|
||||
from subprocess import Popen, STDOUT, PIPE
|
||||
from optparse import OptionParser
|
||||
sys.path.insert(0, '..')
|
||||
from testing_harness import *
|
||||
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, '-p', cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([opts.exe, '-p', cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
class PlotTestHarness(TestHarness):
|
||||
def execute_test(self):
|
||||
self._parse_args()
|
||||
try:
|
||||
self._run_openmc()
|
||||
self._test_output_created()
|
||||
finally:
|
||||
self._cleanup()
|
||||
|
||||
def test_plots_exists():
|
||||
assert os.path.exists(os.path.join(cwd ,'1_plot.ppm')), 'Plot 1 result does not exist.'
|
||||
assert os.path.exists(os.path.join(cwd ,'2_plot.ppm')), 'Plot 2 result does not exist.'
|
||||
assert os.path.exists(os.path.join(cwd ,'3_plot.ppm')), 'Plot 3 result does not exist.'
|
||||
|
||||
def teardown():
|
||||
output = [os.path.join(cwd ,'1_plot.ppm'), os.path.join(cwd ,'2_plot.ppm'), os.path.join(cwd ,'3_plot.ppm')]
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
def _run_openmc(self):
|
||||
if self._opts.mpi_exec != '':
|
||||
proc = Popen([self._opts.mpi_exec, '-np', self._opts.mpi_np,
|
||||
self._opts.exe, '-p', os.getcwd()],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([self._opts.exe, '-p', os.getcwd()],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
|
||||
def _test_output_created(self):
|
||||
"""Make sure *.ppm has been created."""
|
||||
assert os.path.exists(os.path.join(os.getcwd(), '1_plot.ppm')), \
|
||||
'Plot output file does not exist.'
|
||||
|
||||
|
||||
def _cleanup(self):
|
||||
TestHarness._cleanup(self)
|
||||
output = glob.glob(os.path.join(os.getcwd(), '*.ppm'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
try:
|
||||
test_run()
|
||||
test_plots_exists()
|
||||
finally:
|
||||
teardown()
|
||||
harness = PlotTestHarness('statepoint.10.*', True)
|
||||
harness.execute_test()
|
||||
|
|
|
|||
|
|
@ -1,45 +1,47 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
import sys
|
||||
from subprocess import Popen, STDOUT, PIPE
|
||||
from optparse import OptionParser
|
||||
sys.path.insert(0, '..')
|
||||
from testing_harness import *
|
||||
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, '-p', cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([opts.exe, '-p', cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
class PlotTestHarness(TestHarness):
|
||||
def execute_test(self):
|
||||
self._parse_args()
|
||||
try:
|
||||
self._run_openmc()
|
||||
self._test_output_created()
|
||||
finally:
|
||||
self._cleanup()
|
||||
|
||||
def test_plot_exists():
|
||||
assert os.path.exists(os.path.join(cwd ,'1_plot.ppm')), 'Plot ppm file does not exist.'
|
||||
|
||||
def teardown():
|
||||
output = [os.path.join(cwd ,'1_plot.ppm')]
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
def _run_openmc(self):
|
||||
if self._opts.mpi_exec != '':
|
||||
proc = Popen([self._opts.mpi_exec, '-np', self._opts.mpi_np,
|
||||
self._opts.exe, '-p', os.getcwd()],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([self._opts.exe, '-p', os.getcwd()],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
|
||||
def _test_output_created(self):
|
||||
"""Make sure *.ppm has been created."""
|
||||
assert os.path.exists(os.path.join(os.getcwd(), '1_plot.ppm')), \
|
||||
'Plot output file does not exist.'
|
||||
|
||||
|
||||
def _cleanup(self):
|
||||
TestHarness._cleanup(self)
|
||||
output = glob.glob(os.path.join(os.getcwd(), '*.ppm'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
try:
|
||||
test_run()
|
||||
test_plot_exists()
|
||||
finally:
|
||||
teardown()
|
||||
harness = PlotTestHarness('statepoint.10.*', True)
|
||||
harness.execute_test()
|
||||
|
|
|
|||
|
|
@ -1,47 +1,47 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
import sys
|
||||
from subprocess import Popen, STDOUT, PIPE
|
||||
from optparse import OptionParser
|
||||
sys.path.insert(0, '..')
|
||||
from testing_harness import *
|
||||
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, '-p', cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([opts.exe, '-p', cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
class PlotTestHarness(TestHarness):
|
||||
def execute_test(self):
|
||||
self._parse_args()
|
||||
try:
|
||||
self._run_openmc()
|
||||
self._test_output_created()
|
||||
finally:
|
||||
self._cleanup()
|
||||
|
||||
def test_plots_exists():
|
||||
assert os.path.exists(os.path.join(cwd ,'1_plot.ppm')), 'Plot 1 result does not exist.'
|
||||
assert os.path.exists(os.path.join(cwd ,'2_plot.ppm')), 'Plot 2 result does not exist.'
|
||||
assert os.path.exists(os.path.join(cwd ,'3_plot.ppm')), 'Plot 3 result does not exist.'
|
||||
|
||||
def teardown():
|
||||
output = [os.path.join(cwd ,'1_plot.ppm'), os.path.join(cwd ,'2_plot.ppm'), os.path.join(cwd ,'3_plot.ppm')]
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
def _run_openmc(self):
|
||||
if self._opts.mpi_exec != '':
|
||||
proc = Popen([self._opts.mpi_exec, '-np', self._opts.mpi_np,
|
||||
self._opts.exe, '-p', os.getcwd()],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([self._opts.exe, '-p', os.getcwd()],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
|
||||
def _test_output_created(self):
|
||||
"""Make sure *.ppm has been created."""
|
||||
assert os.path.exists(os.path.join(os.getcwd(), '1_plot.ppm')), \
|
||||
'Plot output file does not exist.'
|
||||
|
||||
|
||||
def _cleanup(self):
|
||||
TestHarness._cleanup(self)
|
||||
output = glob.glob(os.path.join(os.getcwd(), '*.ppm'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
try:
|
||||
test_run()
|
||||
test_plots_exists()
|
||||
finally:
|
||||
teardown()
|
||||
harness = PlotTestHarness('statepoint.10.*', True)
|
||||
harness.execute_test()
|
||||
|
|
|
|||
|
|
@ -1,25 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
|
||||
sys.path.insert(0, '../..')
|
||||
from openmc.statepoint import StatePoint
|
||||
|
||||
# read in statepoint file
|
||||
if len(sys.argv) > 1:
|
||||
sp = StatePoint(sys.argv[1])
|
||||
else:
|
||||
sp = StatePoint('statepoint.10.binary')
|
||||
|
||||
sp.read_results()
|
||||
|
||||
# set up output string
|
||||
outstr = ''
|
||||
|
||||
# write out k-combined
|
||||
outstr += 'k-combined:\n'
|
||||
outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1])
|
||||
|
||||
# write results to file
|
||||
with open('results_test.dat','w') as fh:
|
||||
fh.write(outstr)
|
||||
|
|
@ -1,60 +1,10 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
import sys
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
sys.path.insert(0, '..')
|
||||
from testing_harness import TestHarness
|
||||
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call([sys.executable, 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
try:
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_results()
|
||||
finally:
|
||||
teardown()
|
||||
harness = TestHarness('statepoint.10.*')
|
||||
harness.execute_test()
|
||||
|
|
|
|||
|
|
@ -1,25 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
|
||||
sys.path.insert(0, '../..')
|
||||
from openmc.statepoint import StatePoint
|
||||
|
||||
# read in statepoint file
|
||||
if len(sys.argv) > 1:
|
||||
sp = StatePoint(sys.argv[1])
|
||||
else:
|
||||
sp = StatePoint('statepoint.10.binary')
|
||||
|
||||
sp.read_results()
|
||||
|
||||
# set up output string
|
||||
outstr = ''
|
||||
|
||||
# write out k-combined
|
||||
outstr += 'k-combined:\n'
|
||||
outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1])
|
||||
|
||||
# write results to file
|
||||
with open('results_test.dat','w') as fh:
|
||||
fh.write(outstr)
|
||||
|
|
@ -1,60 +1,10 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
import sys
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
sys.path.insert(0, '..')
|
||||
from testing_harness import TestHarness
|
||||
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call([sys.executable, 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
try:
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_results()
|
||||
finally:
|
||||
teardown()
|
||||
harness = TestHarness('statepoint.10.*')
|
||||
harness.execute_test()
|
||||
|
|
|
|||
|
|
@ -1,24 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
|
||||
sys.path.insert(0, '../..')
|
||||
import openmc.statepoint as statepoint
|
||||
|
||||
# read in statepoint file
|
||||
if len(sys.argv) > 1:
|
||||
sp = statepoint.StatePoint(sys.argv[1])
|
||||
else:
|
||||
sp = statepoint.StatePoint('statepoint.10.binary')
|
||||
sp.read_results()
|
||||
|
||||
# set up output string
|
||||
outstr = ''
|
||||
|
||||
# write out k-combined
|
||||
outstr += 'k-combined:\n'
|
||||
outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1])
|
||||
|
||||
# write results to file
|
||||
with open('results_test.dat','w') as fh:
|
||||
fh.write(outstr)
|
||||
|
|
@ -1,60 +1,10 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
import sys
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
sys.path.insert(0, '..')
|
||||
from testing_harness import TestHarness
|
||||
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call([sys.executable, 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
try:
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_results()
|
||||
finally:
|
||||
teardown()
|
||||
harness = TestHarness('statepoint.10.*')
|
||||
harness.execute_test()
|
||||
|
|
|
|||
|
|
@ -1,24 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
|
||||
sys.path.insert(0, '../..')
|
||||
import openmc.statepoint as statepoint
|
||||
|
||||
# read in statepoint file
|
||||
if len(sys.argv) > 1:
|
||||
sp = statepoint.StatePoint(sys.argv[1])
|
||||
else:
|
||||
sp = statepoint.StatePoint('statepoint.10.binary')
|
||||
sp.read_results()
|
||||
|
||||
# set up output string
|
||||
outstr = ''
|
||||
|
||||
# write out k-combined
|
||||
outstr += 'k-combined:\n'
|
||||
outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1])
|
||||
|
||||
# write results to file
|
||||
with open('results_test.dat','w') as fh:
|
||||
fh.write(outstr)
|
||||
|
|
@ -1,60 +1,10 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
import sys
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
sys.path.insert(0, '..')
|
||||
from testing_harness import TestHarness
|
||||
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call([sys.executable, 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
try:
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_results()
|
||||
finally:
|
||||
teardown()
|
||||
harness = TestHarness('statepoint.10.*')
|
||||
harness.execute_test()
|
||||
|
|
|
|||
|
|
@ -1,24 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
|
||||
sys.path.insert(0, '../..')
|
||||
import openmc.statepoint as statepoint
|
||||
|
||||
# read in statepoint file
|
||||
if len(sys.argv) > 1:
|
||||
sp = statepoint.StatePoint(sys.argv[1])
|
||||
else:
|
||||
sp = statepoint.StatePoint('statepoint.10.binary')
|
||||
sp.read_results()
|
||||
|
||||
# set up output string
|
||||
outstr = ''
|
||||
|
||||
# write out k-combined
|
||||
outstr += 'k-combined:\n'
|
||||
outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1])
|
||||
|
||||
# write results to file
|
||||
with open('results_test.dat','w') as fh:
|
||||
fh.write(outstr)
|
||||
|
|
@ -1,60 +1,10 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
import sys
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
sys.path.insert(0, '..')
|
||||
from testing_harness import TestHarness
|
||||
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call([sys.executable, 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
try:
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_results()
|
||||
finally:
|
||||
teardown()
|
||||
harness = TestHarness('statepoint.10.*')
|
||||
harness.execute_test()
|
||||
|
|
|
|||
|
|
@ -1,24 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
|
||||
sys.path.insert(0, '../..')
|
||||
from openmc.statepoint import StatePoint
|
||||
|
||||
# read in statepoint file
|
||||
if len(sys.argv) > 1:
|
||||
sp = StatePoint(sys.argv[1])
|
||||
else:
|
||||
sp = StatePoint('statepoint.10.binary')
|
||||
sp.read_results()
|
||||
|
||||
# set up output string
|
||||
outstr = ''
|
||||
|
||||
# write out k-combined
|
||||
outstr += 'k-combined:\n'
|
||||
outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1])
|
||||
|
||||
# write results to file
|
||||
with open('results_test.dat','w') as fh:
|
||||
fh.write(outstr)
|
||||
|
|
@ -1,60 +1,10 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
import sys
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
sys.path.insert(0, '..')
|
||||
from testing_harness import TestHarness
|
||||
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call([sys.executable, 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
try:
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_results()
|
||||
finally:
|
||||
teardown()
|
||||
harness = TestHarness('statepoint.10.*')
|
||||
harness.execute_test()
|
||||
|
|
|
|||
|
|
@ -1,24 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
|
||||
sys.path.insert(0, '../..')
|
||||
import openmc.statepoint as statepoint
|
||||
|
||||
# read in statepoint file
|
||||
if len(sys.argv) > 1:
|
||||
sp = statepoint.StatePoint(sys.argv[1])
|
||||
else:
|
||||
sp = statepoint.StatePoint('statepoint.10.binary')
|
||||
sp.read_results()
|
||||
|
||||
# set up output string
|
||||
outstr = ''
|
||||
|
||||
# write out k-combined
|
||||
outstr += 'k-combined:\n'
|
||||
outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1])
|
||||
|
||||
# write results to file
|
||||
with open('results_test.dat','w') as fh:
|
||||
fh.write(outstr)
|
||||
|
|
@ -1,60 +1,10 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
import sys
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
sys.path.insert(0, '..')
|
||||
from testing_harness import TestHarness
|
||||
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call([sys.executable, 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
try:
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_results()
|
||||
finally:
|
||||
teardown()
|
||||
harness = TestHarness('statepoint.10.*')
|
||||
harness.execute_test()
|
||||
|
|
|
|||
|
|
@ -1,24 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
|
||||
sys.path.insert(0, '../..')
|
||||
import openmc.statepoint as statepoint
|
||||
|
||||
# read in statepoint file
|
||||
if len(sys.argv) > 1:
|
||||
sp = statepoint.StatePoint(sys.argv[1])
|
||||
else:
|
||||
sp = statepoint.StatePoint('statepoint.10.binary')
|
||||
sp.read_results()
|
||||
|
||||
# set up output string
|
||||
outstr = ''
|
||||
|
||||
# write out k-combined
|
||||
outstr += 'k-combined:\n'
|
||||
outstr += "{0:12.6E} {1:12.6E}\n".format(sp._k_combined[0], sp._k_combined[1])
|
||||
|
||||
# write results to file
|
||||
with open('results_test.dat','w') as fh:
|
||||
fh.write(outstr)
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue