Merge branch 'develop' into double-constants

Conflicts:
	tests/test_trigger_batch_interval/results_true.dat
	tests/test_trigger_no_batch_interval/results_true.dat
	tests/test_trigger_tallies/results_true.dat
This commit is contained in:
Paul Romano 2015-07-05 10:40:57 +07:00
commit 8331902dfb
225 changed files with 1160 additions and 218586 deletions

View file

@ -1,42 +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.19.binary')
sp.read_results()
# extract tally results and convert to vector
sum1 = sp._tallies[1]._sum
sum_sq1 = sp._tallies[1]._sum_sq
results1 = np.concatenate([sum1, sum_sq1])
sum2 = sp._tallies[2]._sum
sum_sq2 = sp._tallies[2]._sum_sq
results2 = np.concatenate([sum2, sum_sq2])
results = np.concatenate([results1.flatten(), results2.flatten()])
# 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)

View file

@ -1,27 +1,28 @@
k-combined:
9.851940E-01 4.283950E-03
tallies:
tally 1:
1.972289E+01
4.489781E+00
4.356175E+00
1.523311E+01
1.972289E+01
4.489781E+00
4.356175E+00
1.523311E+01
2.779778E+01
1.440247E+00
1.355797E+00
1.658397E+01
2.779778E+01
4.489781E+00
1.440247E+00
4.356175E+00
1.355797E+00
1.523311E+01
1.658397E+01
1.972289E+01
4.489781E+00
4.356175E+00
1.523311E+01
2.779778E+01
4.489781E+00
1.440247E+00
4.356175E+00
1.355797E+00
1.523311E+01
1.658397E+01
tally 2:
1.972289E+01
2.779778E+01
4.489781E+00
1.440247E+00
4.356175E+00
1.355797E+00
1.523311E+01
1.658397E+01

View 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.19.*'))
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.19.*'))
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.19.*'))
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.19.*', True)
harness.main()