diff --git a/tests/run_tests.py b/tests/run_tests.py index ec0091f16..49975c218 100755 --- a/tests/run_tests.py +++ b/tests/run_tests.py @@ -79,7 +79,8 @@ tests = ['compile', 'normal', 'debug', 'optimize', 'phdf5-omp', 'phdf5-omp-debug', 'phdf5-omp-optimize', 'petsc', 'petsc-debug', 'petsc-optimize', 'phdf5-petsc', 'phdf5-petsc-debug', 'phdf5-petsc-optimize', - 'omp-phdf5-petsc', 'omp-phdf5-petsc-debug', 'omp-phdf5-petsc-optimize'] + 'omp-phdf5-petsc', 'omp-phdf5-petsc-debug', + 'omp-phdf5-petsc-optimize'] if len(sys.argv) > 1: flags = [i for i in sys.argv[1:] if i.startswith('-')] tests_ = [i for i in sys.argv[1:] if not i.startswith('-')] @@ -138,7 +139,7 @@ for name in tests: 'petsc', 'petsc-debug', 'petsc-optimize', 'phdf5-petsc', 'phdf5-petsc-debug', 'phdf5-petsc-optimize', 'omp-phdf5-petsc', 'omp-phdf5-petsc-debug', - 'omp-phdf5-petsc-optimize']: + 'omp-phdf5-petsc-optimize']: run_suite(name=name, mpi=True) # print out summary of results diff --git a/tests/test_cmfd_feed/results.py b/tests/test_cmfd_feed/results.py index f86aaa53e..26bcb36d9 100644 --- a/tests/test_cmfd_feed/results.py +++ b/tests/test_cmfd_feed/results.py @@ -34,7 +34,7 @@ results4 = np.reshape(results4, size4) # 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]) @@ -42,41 +42,41 @@ 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 += "{0:12.6E}\n".format(item) outstr += 'tally 2:\n' for item in results2: - outstr += "{0:12.6E}\n".format(item) + outstr += "{0:12.6E}\n".format(item) outstr += 'tally 3:\n' for item in results3: - outstr += "{0:12.6E}\n".format(item) + outstr += "{0:12.6E}\n".format(item) outstr += 'tally 4:\n' for item in results4: - outstr += "{0:12.6E}\n".format(item) + 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 += "{0:12.6E}\n".format(item) outstr += 'k cmfd\n' for item in sp.k_cmfd: - outstr += "{0:12.6E}\n".format(item) + 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 += "{0:12.6E}\n".format(item) outstr += 'cmfd balance\n' for item in sp.cmfd_balance: - outstr += "{0:12.6E}\n".format(item) + 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 += "{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 += "{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) + outstr += "{0:12.6E}\n".format(item) # write results to file -with open('results_test.dat','w') as fh: +with open('results_test.dat', 'w') as fh: fh.write(outstr) diff --git a/tests/test_cmfd_feed/test_cmfd_feed.py b/tests/test_cmfd_feed/test_cmfd_feed.py index db3678488..59bcad866 100644 --- a/tests/test_cmfd_feed/test_cmfd_feed.py +++ b/tests/test_cmfd_feed/test_cmfd_feed.py @@ -14,17 +14,19 @@ pwd = os.path.dirname(__file__) skipAll = False + def setup(): os.putenv('PWD', pwd) os.chdir(pwd) global skipAll skipAll = False + 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) + stderr=STDOUT, stdout=PIPE) else: proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE) returncode = proc.wait() @@ -36,6 +38,7 @@ def test_run(): raise SkipTest assert returncode == 0 + def test_created_statepoint(): if skipAll: raise SkipTest @@ -43,11 +46,13 @@ def test_created_statepoint(): assert len(statepoint) == 1 assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5') + def test_output_exists(): if skipAll: raise SkipTest assert os.path.exists(pwd + '/tallies.out') + def test_results(): if skipAll: raise SkipTest @@ -55,9 +60,10 @@ def test_results(): 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') + os.rename('results_test.dat', 'results_error.dat') assert compare + def teardown(): output = glob.glob(pwd + '/statepoint.20.*') output.append(pwd + '/tallies.out') @@ -65,4 +71,3 @@ def teardown(): for f in output: if os.path.exists(f): os.remove(f) - diff --git a/tests/test_cmfd_jfnk/results.py b/tests/test_cmfd_jfnk/results.py index f86aaa53e..26bcb36d9 100644 --- a/tests/test_cmfd_jfnk/results.py +++ b/tests/test_cmfd_jfnk/results.py @@ -34,7 +34,7 @@ results4 = np.reshape(results4, size4) # 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]) @@ -42,41 +42,41 @@ 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 += "{0:12.6E}\n".format(item) outstr += 'tally 2:\n' for item in results2: - outstr += "{0:12.6E}\n".format(item) + outstr += "{0:12.6E}\n".format(item) outstr += 'tally 3:\n' for item in results3: - outstr += "{0:12.6E}\n".format(item) + outstr += "{0:12.6E}\n".format(item) outstr += 'tally 4:\n' for item in results4: - outstr += "{0:12.6E}\n".format(item) + 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 += "{0:12.6E}\n".format(item) outstr += 'k cmfd\n' for item in sp.k_cmfd: - outstr += "{0:12.6E}\n".format(item) + 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 += "{0:12.6E}\n".format(item) outstr += 'cmfd balance\n' for item in sp.cmfd_balance: - outstr += "{0:12.6E}\n".format(item) + 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 += "{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 += "{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) + outstr += "{0:12.6E}\n".format(item) # write results to file -with open('results_test.dat','w') as fh: +with open('results_test.dat', 'w') as fh: fh.write(outstr) diff --git a/tests/test_cmfd_jfnk/test_cmfd_jfnk.py b/tests/test_cmfd_jfnk/test_cmfd_jfnk.py index db3678488..59bcad866 100644 --- a/tests/test_cmfd_jfnk/test_cmfd_jfnk.py +++ b/tests/test_cmfd_jfnk/test_cmfd_jfnk.py @@ -14,17 +14,19 @@ pwd = os.path.dirname(__file__) skipAll = False + def setup(): os.putenv('PWD', pwd) os.chdir(pwd) global skipAll skipAll = False + 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) + stderr=STDOUT, stdout=PIPE) else: proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE) returncode = proc.wait() @@ -36,6 +38,7 @@ def test_run(): raise SkipTest assert returncode == 0 + def test_created_statepoint(): if skipAll: raise SkipTest @@ -43,11 +46,13 @@ def test_created_statepoint(): assert len(statepoint) == 1 assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5') + def test_output_exists(): if skipAll: raise SkipTest assert os.path.exists(pwd + '/tallies.out') + def test_results(): if skipAll: raise SkipTest @@ -55,9 +60,10 @@ def test_results(): 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') + os.rename('results_test.dat', 'results_error.dat') assert compare + def teardown(): output = glob.glob(pwd + '/statepoint.20.*') output.append(pwd + '/tallies.out') @@ -65,4 +71,3 @@ def teardown(): for f in output: if os.path.exists(f): os.remove(f) - diff --git a/tests/test_cmfd_nofeed/results.py b/tests/test_cmfd_nofeed/results.py index f86aaa53e..26bcb36d9 100644 --- a/tests/test_cmfd_nofeed/results.py +++ b/tests/test_cmfd_nofeed/results.py @@ -34,7 +34,7 @@ results4 = np.reshape(results4, size4) # 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]) @@ -42,41 +42,41 @@ 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 += "{0:12.6E}\n".format(item) outstr += 'tally 2:\n' for item in results2: - outstr += "{0:12.6E}\n".format(item) + outstr += "{0:12.6E}\n".format(item) outstr += 'tally 3:\n' for item in results3: - outstr += "{0:12.6E}\n".format(item) + outstr += "{0:12.6E}\n".format(item) outstr += 'tally 4:\n' for item in results4: - outstr += "{0:12.6E}\n".format(item) + 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 += "{0:12.6E}\n".format(item) outstr += 'k cmfd\n' for item in sp.k_cmfd: - outstr += "{0:12.6E}\n".format(item) + 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 += "{0:12.6E}\n".format(item) outstr += 'cmfd balance\n' for item in sp.cmfd_balance: - outstr += "{0:12.6E}\n".format(item) + 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 += "{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 += "{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) + outstr += "{0:12.6E}\n".format(item) # write results to file -with open('results_test.dat','w') as fh: +with open('results_test.dat', 'w') as fh: fh.write(outstr) diff --git a/tests/test_cmfd_nofeed/test_cmfd_nofeed.py b/tests/test_cmfd_nofeed/test_cmfd_nofeed.py index feb4a0657..07176a8f2 100644 --- a/tests/test_cmfd_nofeed/test_cmfd_nofeed.py +++ b/tests/test_cmfd_nofeed/test_cmfd_nofeed.py @@ -13,17 +13,19 @@ pwd = os.path.dirname(__file__) skipAll = False + def setup(): os.putenv('PWD', pwd) os.chdir(pwd) global skipAll skipAll = False + 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) + stderr=STDOUT, stdout=PIPE) else: proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE) returncode = proc.wait() @@ -35,6 +37,7 @@ def test_run(): raise SkipTest assert returncode == 0 + def test_created_statepoint(): if skipAll: raise SkipTest @@ -42,11 +45,13 @@ def test_created_statepoint(): assert len(statepoint) == 1 assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5') + def test_output_exists(): if skipAll: raise SkipTest assert os.path.exists(pwd + '/tallies.out') + def test_results(): if skipAll: raise SkipTest @@ -54,9 +59,10 @@ def test_results(): 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') + os.rename('results_test.dat', 'results_error.dat') assert compare + def teardown(): output = glob.glob(pwd + '/statepoint.20.*') output.append(pwd + '/tallies.out') @@ -64,4 +70,3 @@ def teardown(): for f in output: if os.path.exists(f): os.remove(f) -