diff --git a/tests/test_sourcepoint_batch/geometry.xml b/tests/test_sourcepoint_batch/geometry.xml new file mode 100644 index 000000000..612e46132 --- /dev/null +++ b/tests/test_sourcepoint_batch/geometry.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/tests/test_sourcepoint_batch/materials.xml b/tests/test_sourcepoint_batch/materials.xml new file mode 100644 index 000000000..1f85510e0 --- /dev/null +++ b/tests/test_sourcepoint_batch/materials.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/tests/test_sourcepoint_batch/results.py b/tests/test_sourcepoint_batch/results.py new file mode 100644 index 000000000..9b0f577eb --- /dev/null +++ b/tests/test_sourcepoint_batch/results.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python + +import sys + +# import statepoint +sys.path.append('../../src/utils') +import statepoint + +# read in statepoint file +if len(sys.argv) > 1: + sp = statepoint.StatePoint(sys.argv[1]) +else: + sp = statepoint.StatePoint('statepoint.8.binary') +sp.read_results() +sp.read_source() + +# 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 xyz +xyz = sp.source[0].xyz +for i in xyz: + outstr += "{0:12.6E} ".format(i) +outstr += "\n" + +# write results to file +with open('results_test.dat','w') as fh: + fh.write(outstr) diff --git a/tests/test_sourcepoint_batch/results_true.dat b/tests/test_sourcepoint_batch/results_true.dat new file mode 100644 index 000000000..748df0351 --- /dev/null +++ b/tests/test_sourcepoint_batch/results_true.dat @@ -0,0 +1,3 @@ +k-combined: +0.000000E+00 0.000000E+00 +-9.438655E-02 -4.436810E+00 -2.416825E+00 diff --git a/tests/test_sourcepoint_batch/settings.xml b/tests/test_sourcepoint_batch/settings.xml new file mode 100644 index 000000000..c816fe700 --- /dev/null +++ b/tests/test_sourcepoint_batch/settings.xml @@ -0,0 +1,19 @@ + + + + + + + + 10 + 5 + 1000 + + + + + -4 -4 -4 4 4 4 + + + + diff --git a/tests/test_sourcepoint_batch/test_sourcepoint_batch.py b/tests/test_sourcepoint_batch/test_sourcepoint_batch.py new file mode 100644 index 000000000..78d202e40 --- /dev/null +++ b/tests/test_sourcepoint_batch/test_sourcepoint_batch.py @@ -0,0 +1,44 @@ +#!/usr/bin/env python + +import os +from subprocess import Popen, STDOUT, PIPE, call +import filecmp +from nose_mpi import NoseMPI +import glob + +pwd = os.path.dirname(__file__) + +def setup(): + os.putenv('PWD', pwd) + os.chdir(pwd) + +def test_run(): + openmc_path = pwd + '/../../src/openmc' + if int(NoseMPI.mpi_np) > 0: + proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path], + stderr=STDOUT, stdout=PIPE) + else: + proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE) + print(proc.communicate()[0]) + returncode = proc.returncode + assert returncode == 0 + +def test_statepoint_exists(): + statepoint = glob.glob(pwd + '/statepoint.*') + assert len(statepoint) == 5 + assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5') + +def test_results(): + statepoint = glob.glob(pwd + '/statepoint.8.*') + call(['python', '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 + +def teardown(): + output = glob.glob(pwd + '/statepoint.*') + output.append(pwd + '/results_test.dat') + for f in output: + if os.path.exists(f): + os.remove(f) diff --git a/tests/test_sourcepoint_interval/geometry.xml b/tests/test_sourcepoint_interval/geometry.xml new file mode 100644 index 000000000..612e46132 --- /dev/null +++ b/tests/test_sourcepoint_interval/geometry.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/tests/test_sourcepoint_interval/materials.xml b/tests/test_sourcepoint_interval/materials.xml new file mode 100644 index 000000000..1f85510e0 --- /dev/null +++ b/tests/test_sourcepoint_interval/materials.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/tests/test_sourcepoint_interval/results.py b/tests/test_sourcepoint_interval/results.py new file mode 100644 index 000000000..9b0f577eb --- /dev/null +++ b/tests/test_sourcepoint_interval/results.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python + +import sys + +# import statepoint +sys.path.append('../../src/utils') +import statepoint + +# read in statepoint file +if len(sys.argv) > 1: + sp = statepoint.StatePoint(sys.argv[1]) +else: + sp = statepoint.StatePoint('statepoint.8.binary') +sp.read_results() +sp.read_source() + +# 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 xyz +xyz = sp.source[0].xyz +for i in xyz: + outstr += "{0:12.6E} ".format(i) +outstr += "\n" + +# write results to file +with open('results_test.dat','w') as fh: + fh.write(outstr) diff --git a/tests/test_sourcepoint_interval/results_true.dat b/tests/test_sourcepoint_interval/results_true.dat new file mode 100644 index 000000000..748df0351 --- /dev/null +++ b/tests/test_sourcepoint_interval/results_true.dat @@ -0,0 +1,3 @@ +k-combined: +0.000000E+00 0.000000E+00 +-9.438655E-02 -4.436810E+00 -2.416825E+00 diff --git a/tests/test_sourcepoint_interval/settings.xml b/tests/test_sourcepoint_interval/settings.xml new file mode 100644 index 000000000..d0b8fa71d --- /dev/null +++ b/tests/test_sourcepoint_interval/settings.xml @@ -0,0 +1,19 @@ + + + + + + + + 10 + 5 + 1000 + + + + + -4 -4 -4 4 4 4 + + + + diff --git a/tests/test_sourcepoint_interval/test_sourcepoint_interval.py b/tests/test_sourcepoint_interval/test_sourcepoint_interval.py new file mode 100644 index 000000000..78d202e40 --- /dev/null +++ b/tests/test_sourcepoint_interval/test_sourcepoint_interval.py @@ -0,0 +1,44 @@ +#!/usr/bin/env python + +import os +from subprocess import Popen, STDOUT, PIPE, call +import filecmp +from nose_mpi import NoseMPI +import glob + +pwd = os.path.dirname(__file__) + +def setup(): + os.putenv('PWD', pwd) + os.chdir(pwd) + +def test_run(): + openmc_path = pwd + '/../../src/openmc' + if int(NoseMPI.mpi_np) > 0: + proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path], + stderr=STDOUT, stdout=PIPE) + else: + proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE) + print(proc.communicate()[0]) + returncode = proc.returncode + assert returncode == 0 + +def test_statepoint_exists(): + statepoint = glob.glob(pwd + '/statepoint.*') + assert len(statepoint) == 5 + assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5') + +def test_results(): + statepoint = glob.glob(pwd + '/statepoint.8.*') + call(['python', '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 + +def teardown(): + output = glob.glob(pwd + '/statepoint.*') + output.append(pwd + '/results_test.dat') + for f in output: + if os.path.exists(f): + os.remove(f) diff --git a/tests/test_sourcepoint_latest/geometry.xml b/tests/test_sourcepoint_latest/geometry.xml new file mode 100644 index 000000000..612e46132 --- /dev/null +++ b/tests/test_sourcepoint_latest/geometry.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/tests/test_sourcepoint_latest/materials.xml b/tests/test_sourcepoint_latest/materials.xml new file mode 100644 index 000000000..1f85510e0 --- /dev/null +++ b/tests/test_sourcepoint_latest/materials.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/tests/test_sourcepoint_latest/results.py b/tests/test_sourcepoint_latest/results.py new file mode 100644 index 000000000..8ff10971c --- /dev/null +++ b/tests/test_sourcepoint_latest/results.py @@ -0,0 +1,25 @@ +#!/usr/bin/env python + +import sys + +# import statepoint +sys.path.append('../../src/utils') +import 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) diff --git a/tests/test_sourcepoint_latest/results_test.dat b/tests/test_sourcepoint_latest/results_test.dat new file mode 100644 index 000000000..00a65f913 --- /dev/null +++ b/tests/test_sourcepoint_latest/results_test.dat @@ -0,0 +1,2 @@ +k-combined: +3.011353E-01 2.854556E-03 diff --git a/tests/test_sourcepoint_latest/results_true.dat b/tests/test_sourcepoint_latest/results_true.dat new file mode 100644 index 000000000..748df0351 --- /dev/null +++ b/tests/test_sourcepoint_latest/results_true.dat @@ -0,0 +1,3 @@ +k-combined: +0.000000E+00 0.000000E+00 +-9.438655E-02 -4.436810E+00 -2.416825E+00 diff --git a/tests/test_sourcepoint_latest/settings.xml b/tests/test_sourcepoint_latest/settings.xml new file mode 100644 index 000000000..36c5c7a0d --- /dev/null +++ b/tests/test_sourcepoint_latest/settings.xml @@ -0,0 +1,18 @@ + + + + + + + 10 + 5 + 1000 + + + + + -4 -4 -4 4 4 4 + + + + diff --git a/tests/test_sourcepoint_latest/test_sourcepoint_latest.py b/tests/test_sourcepoint_latest/test_sourcepoint_latest.py new file mode 100644 index 000000000..d26533843 --- /dev/null +++ b/tests/test_sourcepoint_latest/test_sourcepoint_latest.py @@ -0,0 +1,48 @@ +#!/usr/bin/env python + +import os +from subprocess import Popen, STDOUT, PIPE, call +import filecmp +from nose_mpi import NoseMPI +import glob + +pwd = os.path.dirname(__file__) + +def setup(): + os.putenv('PWD', pwd) + os.chdir(pwd) + +def test_run(): + openmc_path = pwd + '/../../src/openmc' + if int(NoseMPI.mpi_np) > 0: + proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path], + stderr=STDOUT, stdout=PIPE) + else: + proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE) + print(proc.communicate()[0]) + returncode = proc.returncode + assert returncode == 0 + +def test_statepoint_exists(): + statepoint = glob.glob(pwd + '/statepoint.10.*') + assert len(statepoint) == 1 + assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5') + source = glob.glob(pwd + '/source.*') + assert len(source) == 1 + assert source[0].endswith('binary') or source[0].endswith('h5') + +def test_results(): + statepoint = glob.glob(pwd + '/statepoint.10.*') + call(['python', '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 + +def teardown(): + output = glob.glob(pwd + '/statepoint.10.*') + output += glob.glob(pwd + '/source.*') + output.append(pwd + '/results_test.dat') + for f in output: + if os.path.exists(f): + os.remove(f)