mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-26 13:15:39 -04:00
TestHarness adjustments for #402
This commit is contained in:
parent
e05c1e4074
commit
f13351f2ee
25 changed files with 201 additions and 210907 deletions
|
|
@ -2,58 +2,7 @@
|
|||
|
||||
import sys
|
||||
sys.path.insert(0, '..')
|
||||
from testing_harness import *
|
||||
|
||||
|
||||
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])
|
||||
|
||||
# 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)
|
||||
from testing_harness import CMFDTestHarness
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
|||
|
|
@ -2,58 +2,7 @@
|
|||
|
||||
import sys
|
||||
sys.path.insert(0, '..')
|
||||
from testing_harness import *
|
||||
|
||||
|
||||
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])
|
||||
|
||||
# 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)
|
||||
from testing_harness import CMFDTestHarness
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ from testing_harness import *
|
|||
|
||||
class EntropyTestHarness(TestHarness):
|
||||
def _get_results(self):
|
||||
"""Digest info in the statepoint and create a simpler ASCII file."""
|
||||
"""Digest info in the statepoint and return as a string."""
|
||||
# Read the statepoint file.
|
||||
statepoint = glob.glob(os.path.join(os.getcwd(), self._sp_name))[0]
|
||||
sp = StatePoint(statepoint)
|
||||
|
|
@ -23,9 +23,7 @@ class EntropyTestHarness(TestHarness):
|
|||
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)
|
||||
return outstr
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
f5873c6ca03a2c75f5094b7297059285788bb93c450466606914805cdb24fd2664c3872ed42a8c6665a272070ab6b08b0a53b02612bcd993e10329aec2f1d313
|
||||
4ad951a83e28329502830b4161d2b78173768b6d7c8906e5c97aaaa4c3f6e8266762d72fe133a380aa8fae2d2ef85b7cb20be94597b99a72736f9f5c8152555e
|
||||
|
|
@ -14,104 +14,29 @@ class DistribcellTestHarness(TestHarness):
|
|||
self._opts = None
|
||||
self._args = None
|
||||
|
||||
|
||||
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()
|
||||
dirs = ('case-1', '../case-2', '../case-3')
|
||||
sps = ('statepoint.1.*', 'statepoint.1.*', 'statepoint.3.*')
|
||||
tallies_present = (True, True, False)
|
||||
hash_out = (False, False, True)
|
||||
for i in range(len(dirs)):
|
||||
os.chdir(dirs[i])
|
||||
self._sp_name = sps[i]
|
||||
self._tallies = tallies_present[i]
|
||||
|
||||
self._run_openmc()
|
||||
self._test_output_created()
|
||||
results = self._get_results(hash_out[i])
|
||||
self._write_results(results)
|
||||
self._compare_results()
|
||||
finally:
|
||||
os.chdir(base_dir)
|
||||
self._cleanup()
|
||||
|
||||
|
||||
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.'
|
||||
|
||||
|
||||
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 _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.encode('utf-8'))
|
||||
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)
|
||||
for i in range(len(dirs)):
|
||||
os.chdir(dirs[i])
|
||||
self._cleanup()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ from testing_harness import *
|
|||
|
||||
class FixedSourceTestHarness(TestHarness):
|
||||
def _get_results(self):
|
||||
"""Digest info in the statepoint and create a simpler ASCII file."""
|
||||
"""Digest info in the statepoint and return as a string."""
|
||||
# Read the statepoint file.
|
||||
statepoint = glob.glob(os.path.join(os.getcwd(), self._sp_name))[0]
|
||||
sp = StatePoint(statepoint)
|
||||
|
|
@ -28,9 +28,7 @@ class FixedSourceTestHarness(TestHarness):
|
|||
outstr += '\n'.join(results) + '\n'
|
||||
tally_num += 1
|
||||
|
||||
# Write results to a file.
|
||||
with open('results_test.dat','w') as fh:
|
||||
fh.write(outstr)
|
||||
return outstr
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
|||
|
|
@ -2,52 +2,7 @@
|
|||
|
||||
import sys
|
||||
sys.path.insert(0, '..')
|
||||
from testing_harness import *
|
||||
|
||||
import openmc.particle_restart as pr
|
||||
|
||||
|
||||
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 _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)
|
||||
from testing_harness import ParticleRestartTestHarness
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
|||
|
|
@ -2,52 +2,7 @@
|
|||
|
||||
import sys
|
||||
sys.path.insert(0, '..')
|
||||
from testing_harness import *
|
||||
|
||||
import openmc.particle_restart as pr
|
||||
|
||||
|
||||
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 _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)
|
||||
from testing_harness import ParticleRestartTestHarness
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
|||
|
|
@ -2,44 +2,7 @@
|
|||
|
||||
import sys
|
||||
sys.path.insert(0, '..')
|
||||
from testing_harness import *
|
||||
|
||||
|
||||
class PlotTestHarness(TestHarness):
|
||||
def execute_test(self):
|
||||
self._parse_args()
|
||||
try:
|
||||
self._run_openmc()
|
||||
self._test_output_created()
|
||||
finally:
|
||||
self._cleanup()
|
||||
|
||||
|
||||
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)
|
||||
from testing_harness import PlotTestHarness
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
|||
|
|
@ -2,44 +2,7 @@
|
|||
|
||||
import sys
|
||||
sys.path.insert(0, '..')
|
||||
from testing_harness import *
|
||||
|
||||
|
||||
class PlotTestHarness(TestHarness):
|
||||
def execute_test(self):
|
||||
self._parse_args()
|
||||
try:
|
||||
self._run_openmc()
|
||||
self._test_output_created()
|
||||
finally:
|
||||
self._cleanup()
|
||||
|
||||
|
||||
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)
|
||||
from testing_harness import PlotTestHarness
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
|||
|
|
@ -2,44 +2,7 @@
|
|||
|
||||
import sys
|
||||
sys.path.insert(0, '..')
|
||||
from testing_harness import *
|
||||
|
||||
|
||||
class PlotTestHarness(TestHarness):
|
||||
def execute_test(self):
|
||||
self._parse_args()
|
||||
try:
|
||||
self._run_openmc()
|
||||
self._test_output_created()
|
||||
finally:
|
||||
self._cleanup()
|
||||
|
||||
|
||||
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)
|
||||
from testing_harness import PlotTestHarness
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
|||
|
|
@ -2,44 +2,7 @@
|
|||
|
||||
import sys
|
||||
sys.path.insert(0, '..')
|
||||
from testing_harness import *
|
||||
|
||||
|
||||
class PlotTestHarness(TestHarness):
|
||||
def execute_test(self):
|
||||
self._parse_args()
|
||||
try:
|
||||
self._run_openmc()
|
||||
self._test_output_created()
|
||||
finally:
|
||||
self._cleanup()
|
||||
|
||||
|
||||
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)
|
||||
from testing_harness import PlotTestHarness
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -2,9 +2,9 @@
|
|||
|
||||
import sys
|
||||
sys.path.insert(0, '..')
|
||||
from testing_harness import TestHarness
|
||||
from testing_harness import HashedTestHarness
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
harness = TestHarness('statepoint.10.*', True)
|
||||
harness = HashedTestHarness('statepoint.10.*', True)
|
||||
harness.execute_test()
|
||||
|
|
|
|||
|
|
@ -1,448 +1 @@
|
|||
k-combined:
|
||||
1.093844E+00 1.626801E-02
|
||||
tally 1:
|
||||
3.403102E+01
|
||||
2.393236E+02
|
||||
1.143060E+01
|
||||
2.704386E+01
|
||||
5.691243E+01
|
||||
6.685581E+02
|
||||
2.924945E+01
|
||||
1.782032E+02
|
||||
9.965051E+00
|
||||
2.067319E+01
|
||||
4.931805E+01
|
||||
5.050490E+02
|
||||
tally 2:
|
||||
3.403102E+01
|
||||
2.393236E+02
|
||||
-3.055588E-01
|
||||
3.594044E-02
|
||||
3.171128E-01
|
||||
3.805380E-01
|
||||
-7.374877E-01
|
||||
2.391349E-01
|
||||
-1.621986E-01
|
||||
5.578051E-02
|
||||
4.710459E-01
|
||||
1.850595E-01
|
||||
-4.839599E-01
|
||||
2.440735E-01
|
||||
1.124798E-01
|
||||
8.640649E-02
|
||||
-4.976706E-01
|
||||
8.943606E-02
|
||||
1.323704E-01
|
||||
6.713903E-02
|
||||
-6.954103E-02
|
||||
7.876989E-02
|
||||
1.343675E-01
|
||||
2.569171E-02
|
||||
-5.205013E-01
|
||||
7.985579E-02
|
||||
2.037295E-01
|
||||
1.501360E-01
|
||||
-1.290735E-01
|
||||
5.069422E-02
|
||||
-2.045060E-01
|
||||
2.197889E-01
|
||||
1.307603E-01
|
||||
5.938649E-02
|
||||
-3.317004E-01
|
||||
1.359233E-01
|
||||
-4.347480E-01
|
||||
7.528253E-02
|
||||
7.685982E-02
|
||||
4.559715E-02
|
||||
-4.668783E-02
|
||||
4.065614E-02
|
||||
1.447872E-01
|
||||
5.538956E-02
|
||||
-2.027337E-01
|
||||
7.095051E-02
|
||||
-4.673353E-01
|
||||
1.235371E-01
|
||||
-3.321732E-01
|
||||
6.905624E-02
|
||||
-3.028859E-01
|
||||
3.382353E-02
|
||||
-2.320613E-01
|
||||
2.845905E-02
|
||||
8.038034E-02
|
||||
3.466746E-02
|
||||
1.766484E-01
|
||||
9.996559E-02
|
||||
3.385184E-02
|
||||
5.510769E-02
|
||||
6.952638E-02
|
||||
2.741119E-02
|
||||
3.630715E-01
|
||||
5.336447E-02
|
||||
2.876222E-01
|
||||
9.938256E-02
|
||||
-3.473240E-02
|
||||
1.031412E-01
|
||||
1.280013E-01
|
||||
2.331384E-02
|
||||
1.550774E-01
|
||||
3.881493E-02
|
||||
1.143060E+01
|
||||
2.704386E+01
|
||||
-1.955516E-01
|
||||
9.789273E-03
|
||||
4.070150E-02
|
||||
3.530892E-02
|
||||
-1.446334E-01
|
||||
3.374966E-02
|
||||
-4.072015E-02
|
||||
1.407320E-02
|
||||
1.056190E-01
|
||||
2.144988E-02
|
||||
-1.491728E-01
|
||||
1.699068E-02
|
||||
3.130539E-02
|
||||
4.945783E-03
|
||||
-1.706770E-01
|
||||
6.943395E-03
|
||||
6.278466E-02
|
||||
4.522701E-03
|
||||
-6.491915E-02
|
||||
1.218265E-02
|
||||
-6.226375E-02
|
||||
8.920919E-03
|
||||
-2.647477E-01
|
||||
2.028918E-02
|
||||
-9.179913E-03
|
||||
1.186941E-02
|
||||
-8.959288E-02
|
||||
9.826050E-03
|
||||
-4.800079E-02
|
||||
3.500548E-02
|
||||
9.919028E-02
|
||||
1.278789E-02
|
||||
-1.274511E-01
|
||||
9.357942E-03
|
||||
-9.037073E-02
|
||||
4.686665E-03
|
||||
-7.895199E-03
|
||||
8.526809E-03
|
||||
-2.071828E-02
|
||||
5.844892E-03
|
||||
-1.422877E-02
|
||||
2.008170E-03
|
||||
-7.787500E-02
|
||||
9.642363E-03
|
||||
-6.105504E-02
|
||||
7.600775E-03
|
||||
-1.249117E-01
|
||||
1.314509E-02
|
||||
-9.183605E-02
|
||||
7.513215E-03
|
||||
-9.171222E-02
|
||||
4.220465E-03
|
||||
8.798390E-02
|
||||
5.037482E-03
|
||||
4.366496E-02
|
||||
8.411743E-03
|
||||
1.605678E-02
|
||||
6.994512E-03
|
||||
-2.179875E-02
|
||||
1.352098E-03
|
||||
1.116755E-01
|
||||
7.354423E-03
|
||||
9.995739E-02
|
||||
9.710025E-03
|
||||
3.010324E-02
|
||||
1.179938E-02
|
||||
2.175816E-02
|
||||
1.281441E-03
|
||||
2.374886E-02
|
||||
6.943432E-03
|
||||
5.691243E+01
|
||||
6.685581E+02
|
||||
-7.130295E-01
|
||||
1.971869E-01
|
||||
1.138602E+00
|
||||
1.071873E+00
|
||||
-1.436194E+00
|
||||
7.200870E-01
|
||||
-2.384966E-01
|
||||
1.129688E-01
|
||||
8.003085E-01
|
||||
5.809429E-01
|
||||
-3.499868E-01
|
||||
3.310435E-01
|
||||
2.580763E-01
|
||||
2.238385E-01
|
||||
-3.576056E-01
|
||||
1.437071E-01
|
||||
2.560747E-01
|
||||
4.492224E-02
|
||||
-4.006295E-01
|
||||
2.456809E-01
|
||||
8.176054E-02
|
||||
3.924768E-01
|
||||
-8.105689E-01
|
||||
2.397175E-01
|
||||
3.777117E-01
|
||||
4.811523E-01
|
||||
-4.932440E-01
|
||||
1.789106E-01
|
||||
-3.705747E-02
|
||||
5.517840E-01
|
||||
7.049764E-01
|
||||
4.243943E-01
|
||||
-4.833188E-01
|
||||
2.014189E-01
|
||||
-5.420278E-01
|
||||
1.201572E-01
|
||||
7.606098E-02
|
||||
1.451071E-01
|
||||
2.244026E-01
|
||||
7.628680E-02
|
||||
2.495758E-01
|
||||
1.882655E-01
|
||||
-1.373888E-01
|
||||
1.958724E-01
|
||||
-3.799191E-01
|
||||
2.258678E-01
|
||||
-5.909625E-01
|
||||
2.940322E-01
|
||||
-6.336238E-01
|
||||
1.272552E-01
|
||||
-5.544697E-01
|
||||
9.027652E-02
|
||||
4.161023E-01
|
||||
1.084744E-01
|
||||
5.550548E-01
|
||||
1.838427E-01
|
||||
3.060033E-01
|
||||
8.542356E-02
|
||||
3.623817E-01
|
||||
4.245612E-02
|
||||
4.779023E-01
|
||||
8.081477E-02
|
||||
1.089872E-01
|
||||
1.402042E-01
|
||||
-1.107440E-01
|
||||
3.140479E-01
|
||||
2.333168E-01
|
||||
1.035674E-01
|
||||
-5.959476E-02
|
||||
2.482914E-01
|
||||
2.924945E+01
|
||||
1.782032E+02
|
||||
5.986907E-01
|
||||
4.163713E-01
|
||||
3.376452E-01
|
||||
1.744277E-01
|
||||
1.272993E-01
|
||||
1.526084E-01
|
||||
-2.551267E-01
|
||||
7.284601E-02
|
||||
4.755790E-02
|
||||
6.832796E-02
|
||||
-3.425133E-01
|
||||
7.756266E-02
|
||||
3.823240E-01
|
||||
1.789133E-01
|
||||
-3.767347E-01
|
||||
1.676013E-01
|
||||
1.655399E-01
|
||||
1.153056E-01
|
||||
1.432265E-01
|
||||
2.956364E-02
|
||||
-2.989439E-01
|
||||
5.066565E-02
|
||||
-3.226047E-02
|
||||
5.960686E-02
|
||||
-9.968550E-02
|
||||
4.039270E-02
|
||||
-1.235292E-02
|
||||
2.805714E-01
|
||||
-7.494860E-02
|
||||
2.838999E-02
|
||||
3.042503E-02
|
||||
7.425538E-02
|
||||
-1.849034E-01
|
||||
8.599532E-02
|
||||
-5.209242E-01
|
||||
1.174277E-01
|
||||
-2.314402E-01
|
||||
4.065974E-02
|
||||
-4.179560E-01
|
||||
1.382716E-01
|
||||
1.026654E-01
|
||||
1.611177E-02
|
||||
-2.270386E-01
|
||||
5.157513E-02
|
||||
7.884296E-02
|
||||
2.677093E-02
|
||||
7.284620E-01
|
||||
1.871262E-01
|
||||
1.360134E-01
|
||||
9.437336E-03
|
||||
-3.088199E-01
|
||||
2.292832E-02
|
||||
-2.543226E-01
|
||||
1.264440E-01
|
||||
6.256788E-02
|
||||
7.604299E-02
|
||||
-3.478518E-01
|
||||
6.632508E-02
|
||||
2.842847E-01
|
||||
4.906462E-02
|
||||
1.546241E-01
|
||||
3.362908E-02
|
||||
-2.247690E-01
|
||||
1.912574E-02
|
||||
-3.459210E-02
|
||||
1.248892E-01
|
||||
-2.204075E-01
|
||||
4.281299E-02
|
||||
2.145675E-01
|
||||
5.593188E-02
|
||||
9.965051E+00
|
||||
2.067319E+01
|
||||
2.381967E-01
|
||||
4.786935E-02
|
||||
-1.924307E-02
|
||||
4.029344E-02
|
||||
3.179175E-02
|
||||
2.098033E-02
|
||||
-1.652307E-02
|
||||
9.391525E-03
|
||||
-5.733037E-02
|
||||
1.788394E-02
|
||||
4.942155E-02
|
||||
1.206623E-03
|
||||
1.874859E-02
|
||||
1.917059E-02
|
||||
-1.179838E-01
|
||||
2.185564E-02
|
||||
-9.270518E-03
|
||||
1.659002E-02
|
||||
7.496510E-02
|
||||
6.849931E-03
|
||||
-1.004441E-01
|
||||
4.570271E-03
|
||||
-9.899603E-02
|
||||
1.027435E-02
|
||||
-9.963859E-02
|
||||
4.686519E-03
|
||||
-1.740638E-02
|
||||
3.936514E-02
|
||||
2.520348E-02
|
||||
5.900520E-03
|
||||
1.227791E-03
|
||||
6.173783E-03
|
||||
-3.068441E-02
|
||||
6.867403E-03
|
||||
-7.765653E-02
|
||||
1.399383E-02
|
||||
7.333551E-02
|
||||
4.139444E-03
|
||||
-3.508914E-02
|
||||
1.421599E-02
|
||||
4.334120E-02
|
||||
4.918888E-03
|
||||
-1.106116E-01
|
||||
1.143785E-02
|
||||
7.254492E-03
|
||||
1.337966E-03
|
||||
2.365948E-01
|
||||
2.473485E-02
|
||||
5.176646E-02
|
||||
1.514750E-03
|
||||
-8.723609E-02
|
||||
2.395099E-03
|
||||
-1.010207E-01
|
||||
1.081070E-02
|
||||
-5.113298E-02
|
||||
6.053279E-03
|
||||
-1.601115E-01
|
||||
8.304230E-03
|
||||
-5.105346E-03
|
||||
5.079654E-03
|
||||
-8.894549E-02
|
||||
2.505026E-03
|
||||
-1.023874E-01
|
||||
4.311776E-03
|
||||
7.972835E-02
|
||||
1.178305E-02
|
||||
-2.560943E-02
|
||||
4.101793E-03
|
||||
2.312203E-02
|
||||
3.036209E-03
|
||||
4.931805E+01
|
||||
5.050490E+02
|
||||
1.513494E+00
|
||||
1.676567E+00
|
||||
6.650656E-01
|
||||
1.400732E+00
|
||||
4.934620E-01
|
||||
7.673322E-01
|
||||
-2.964444E-02
|
||||
2.262500E-01
|
||||
-2.225956E-01
|
||||
4.872938E-01
|
||||
2.498269E-01
|
||||
9.442256E-02
|
||||
-1.454141E-01
|
||||
2.683171E-01
|
||||
-3.720260E-01
|
||||
2.266316E-01
|
||||
2.473591E-01
|
||||
3.624408E-01
|
||||
2.096941E-01
|
||||
6.664835E-02
|
||||
-4.700220E-01
|
||||
9.789465E-02
|
||||
-1.626165E-01
|
||||
1.315362E-01
|
||||
3.519966E-01
|
||||
1.140516E-01
|
||||
-1.185342E-01
|
||||
5.708362E-01
|
||||
-1.333083E-01
|
||||
1.352294E-01
|
||||
1.375803E-01
|
||||
1.572243E-01
|
||||
-6.099544E-02
|
||||
2.042264E-01
|
||||
-3.664336E-01
|
||||
1.762506E-01
|
||||
-1.717957E-01
|
||||
5.864778E-02
|
||||
-5.153204E-01
|
||||
2.484316E-01
|
||||
-2.258513E-01
|
||||
8.839687E-02
|
||||
-9.307566E-01
|
||||
4.802462E-01
|
||||
1.108577E-01
|
||||
4.451362E-02
|
||||
1.118965E+00
|
||||
5.173979E-01
|
||||
4.314600E-01
|
||||
5.176751E-02
|
||||
-2.864060E-01
|
||||
9.159895E-02
|
||||
-4.471918E-01
|
||||
1.743046E-01
|
||||
-7.850808E-02
|
||||
1.317732E-01
|
||||
-7.445394E-01
|
||||
1.479808E-01
|
||||
7.480873E-01
|
||||
2.696289E-01
|
||||
1.731449E-01
|
||||
5.301367E-02
|
||||
-3.663464E-01
|
||||
3.430563E-02
|
||||
3.553351E-01
|
||||
2.051544E-01
|
||||
-4.312304E-01
|
||||
2.164291E-01
|
||||
2.436515E-01
|
||||
8.025128E-02
|
||||
0683f96913bb317c6179de78ecb8fafee5aa12cf5bfc6026c25be0728d691cb9ed388280a57724a961877d4779cd3d382d759ba1c8246cc1015c42a7bc252bd9
|
||||
|
|
@ -2,9 +2,9 @@
|
|||
|
||||
import sys
|
||||
sys.path.insert(0, '..')
|
||||
from testing_harness import TestHarness
|
||||
from testing_harness import HashedTestHarness
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
harness = TestHarness('statepoint.10.*', True)
|
||||
harness = HashedTestHarness('statepoint.10.*', True)
|
||||
harness.execute_test()
|
||||
|
|
|
|||
|
|
@ -43,12 +43,12 @@ class SourceFileTestHarness(TestHarness):
|
|||
self._run_openmc()
|
||||
self._test_output_created()
|
||||
self._run_openmc_restart()
|
||||
self._get_results()
|
||||
results = self._get_results()
|
||||
self._write_results(results)
|
||||
self._compare_results()
|
||||
finally:
|
||||
self._cleanup()
|
||||
|
||||
|
||||
def _test_output_created(self):
|
||||
"""Make sure statepoint and source files have been created."""
|
||||
statepoint = glob.glob(os.path.join(os.getcwd(), self._sp_name))
|
||||
|
|
@ -64,7 +64,6 @@ class SourceFileTestHarness(TestHarness):
|
|||
or source[0].endswith('h5'), \
|
||||
'Source file is not a binary or hdf5 file.'
|
||||
|
||||
|
||||
def _run_openmc_restart(self):
|
||||
source = glob.glob(os.path.join(os.getcwd(), 'source.10.*'))
|
||||
with open('settings.xml','w') as fh:
|
||||
|
|
@ -81,7 +80,6 @@ class SourceFileTestHarness(TestHarness):
|
|||
returncode = proc.returncode
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
|
||||
def _cleanup(self):
|
||||
TestHarness._cleanup(self)
|
||||
output = glob.glob(os.path.join(os.getcwd(), 'source.*'))
|
||||
|
|
|
|||
|
|
@ -14,27 +14,23 @@ class SourcepointTestHarness(TestHarness):
|
|||
or statepoint[0].endswith('h5'), \
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
|
||||
def _get_results(self):
|
||||
"""Digest info in the statepoint and create a simpler ASCII file."""
|
||||
"""Digest info in the statepoint and return as a string."""
|
||||
# Read the statepoint file.
|
||||
statepoint = glob.glob(os.path.join(os.getcwd(), self._sp_name))[0]
|
||||
sp = StatePoint(statepoint)
|
||||
sp.read_results()
|
||||
sp.read_source()
|
||||
|
||||
# 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])
|
||||
# Get the eigenvalue information.
|
||||
outstr = TestHarness._get_results(self)
|
||||
|
||||
# Add the source information.
|
||||
xyz = sp._source[0]._xyz
|
||||
outstr += ' '.join(['{0:12.6E}'.format(x) for x in xyz])
|
||||
outstr += "\n"
|
||||
|
||||
# Write results to a file.
|
||||
with open('results_test.dat','w') as fh:
|
||||
fh.write(outstr)
|
||||
return outstr
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
|||
|
|
@ -14,27 +14,23 @@ class SourcepointTestHarness(TestHarness):
|
|||
or statepoint[0].endswith('h5'), \
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
|
||||
def _get_results(self):
|
||||
"""Digest info in the statepoint and create a simpler ASCII file."""
|
||||
"""Digest info in the statepoint and return as a string."""
|
||||
# Read the statepoint file.
|
||||
statepoint = glob.glob(os.path.join(os.getcwd(), self._sp_name))[0]
|
||||
sp = StatePoint(statepoint)
|
||||
sp.read_results()
|
||||
sp.read_source()
|
||||
|
||||
# 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])
|
||||
# Get the eigenvalue information.
|
||||
outstr = TestHarness._get_results(self)
|
||||
|
||||
# Add the source information.
|
||||
xyz = sp._source[0]._xyz
|
||||
outstr += ' '.join(['{0:12.6E}'.format(x) for x in xyz])
|
||||
outstr += "\n"
|
||||
|
||||
# Write results to a file.
|
||||
with open('results_test.dat','w') as fh:
|
||||
fh.write(outstr)
|
||||
return outstr
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
#!/usr/bin/env python
|
||||
import sys
|
||||
sys.path.insert(0, '..')
|
||||
from testing_harness import *
|
||||
|
|
@ -12,7 +11,6 @@ class StatepointTestHarness(TestHarness):
|
|||
self._opts = None
|
||||
self._args = None
|
||||
|
||||
|
||||
def _test_output_created(self):
|
||||
"""Make sure statepoint files have been created."""
|
||||
sps = ('statepoint.03.*', 'statepoint.06.*', 'statepoint.09.*')
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ class StatepointTestHarness(TestHarness):
|
|||
self._opts = None
|
||||
self._args = None
|
||||
|
||||
|
||||
def _test_output_created(self):
|
||||
"""Make sure statepoint files have been created."""
|
||||
sps = ('statepoint.02.*', 'statepoint.04.*', 'statepoint.06.*',
|
||||
|
|
|
|||
|
|
@ -11,22 +11,24 @@ class StatepointRestartTestHarness(TestHarness):
|
|||
try:
|
||||
self._run_openmc()
|
||||
self._test_output_created()
|
||||
self._get_results()
|
||||
results = self._get_results()
|
||||
self._write_results(results)
|
||||
self._compare_results()
|
||||
|
||||
self._run_openmc_restart1()
|
||||
self._test_output_created()
|
||||
self._get_results()
|
||||
results = self._get_results()
|
||||
self._write_results(results)
|
||||
self._compare_results()
|
||||
|
||||
self._run_openmc_restart2()
|
||||
self._test_output_created()
|
||||
self._get_results()
|
||||
results = self._get_results()
|
||||
self._write_results(results)
|
||||
self._compare_results()
|
||||
finally:
|
||||
self._cleanup()
|
||||
|
||||
|
||||
def _run_openmc_restart1(self):
|
||||
statepoint = glob.glob(os.path.join(os.getcwd(), self._sp_name))
|
||||
|
||||
|
|
@ -41,7 +43,6 @@ class StatepointRestartTestHarness(TestHarness):
|
|||
returncode = proc.returncode
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
|
||||
def _run_openmc_restart2(self):
|
||||
statepoint = glob.glob(os.path.join(os.getcwd(), self._sp_name))
|
||||
|
||||
|
|
|
|||
|
|
@ -18,5 +18,5 @@ class SourcepointTestHarness(TestHarness):
|
|||
|
||||
|
||||
if __name__ == '__main__':
|
||||
harness = TestHarness('statepoint.10.*')
|
||||
harness = SourcepointTestHarness('statepoint.10.*')
|
||||
harness.execute_test()
|
||||
|
|
|
|||
|
|
@ -19,18 +19,20 @@ class TrackTestHarness(TestHarness):
|
|||
assert files[0].endswith('binary') or files[0].endswith('h5'),\
|
||||
'Track files are not binary or hdf5 files'
|
||||
|
||||
|
||||
def _get_results(self):
|
||||
"""Digest info and create a simpler ASCII file."""
|
||||
"""Digest info in the statepoint and return as a string."""
|
||||
# Run the track-to-vtk conversion script.
|
||||
call(['../../scripts/openmc-track-to-vtk', '-o', 'poly'] +
|
||||
glob.glob(''.join((os.getcwd(), '/track*'))))
|
||||
|
||||
# Make sure the vtk file was created then copy it to results.
|
||||
poly = ''.join((os.getcwd(), '/poly.pvtp'))
|
||||
# Make sure the vtk file was created then return it's contents.
|
||||
poly = os.path.join(os.getcwd(), 'poly.pvtp')
|
||||
assert os.path.isfile(poly), 'poly.pvtp file not found.'
|
||||
shutil.copy('poly.pvtp', 'results_test.dat')
|
||||
|
||||
with open(poly) as fin:
|
||||
outstr = fin.read()
|
||||
|
||||
return outstr
|
||||
|
||||
def _cleanup(self):
|
||||
TestHarness._cleanup(self)
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ from __future__ import print_function
|
|||
|
||||
import filecmp
|
||||
import glob
|
||||
import hashlib
|
||||
from optparse import OptionParser
|
||||
import os
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
|
|
@ -11,27 +12,29 @@ import numpy as np
|
|||
|
||||
sys.path.insert(0, '../..')
|
||||
from openmc.statepoint import StatePoint
|
||||
import openmc.particle_restart as pr
|
||||
|
||||
|
||||
class TestHarness():
|
||||
class TestHarness(object):
|
||||
"""General class for running OpenMC regression tests."""
|
||||
def __init__(self, statepoint_name, tallies_present=False):
|
||||
self._sp_name = statepoint_name
|
||||
self._tallies = tallies_present
|
||||
self._opts = None
|
||||
self._args = None
|
||||
|
||||
|
||||
def execute_test(self):
|
||||
"""Run OpenMC with the appropriate arguments and check the outputs."""
|
||||
self._parse_args()
|
||||
try:
|
||||
self._run_openmc()
|
||||
self._test_output_created()
|
||||
self._get_results()
|
||||
results = self._get_results()
|
||||
self._write_results(results)
|
||||
self._compare_results()
|
||||
finally:
|
||||
self._cleanup()
|
||||
|
||||
|
||||
def _parse_args(self):
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
|
|
@ -42,7 +45,6 @@ class TestHarness():
|
|||
raise Exception('Must specify OpenMC executable from command line '
|
||||
'with --exe.')
|
||||
|
||||
|
||||
def _run_openmc(self):
|
||||
if self._opts.mpi_exec != '':
|
||||
proc = Popen([self._opts.mpi_exec, '-np', self._opts.mpi_np,
|
||||
|
|
@ -55,7 +57,6 @@ class TestHarness():
|
|||
returncode = proc.returncode
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
|
||||
def _test_output_created(self):
|
||||
"""Make sure statepoint.* and tallies.out have been created."""
|
||||
statepoint = glob.glob(os.path.join(os.getcwd(), self._sp_name))
|
||||
|
|
@ -68,9 +69,8 @@ class TestHarness():
|
|||
assert os.path.exists(os.path.join(os.getcwd(), 'tallies.out')), \
|
||||
'Tally output file does not exist.'
|
||||
|
||||
|
||||
def _get_results(self):
|
||||
"""Digest info in the statepoint and create a simpler ASCII file."""
|
||||
def _get_results(self, hash_output=False):
|
||||
"""Digest info in the statepoint and return as a string."""
|
||||
# Read the statepoint file.
|
||||
statepoint = glob.glob(os.path.join(os.getcwd(), self._sp_name))[0]
|
||||
sp = StatePoint(statepoint)
|
||||
|
|
@ -95,10 +95,18 @@ class TestHarness():
|
|||
outstr += '\n'.join(results) + '\n'
|
||||
tally_num += 1
|
||||
|
||||
# Write results to a file.
|
||||
with open('results_test.dat','w') as fh:
|
||||
fh.write(outstr)
|
||||
# Hash the results if necessary.
|
||||
if hash_output:
|
||||
sha512 = hashlib.sha512()
|
||||
sha512.update(outstr.encode('utf-8'))
|
||||
outstr = sha512.hexdigest()
|
||||
|
||||
return outstr
|
||||
|
||||
def _write_results(self, results_string):
|
||||
"""Write the results to an ASCII file."""
|
||||
with open('results_test.dat','w') as fh:
|
||||
fh.write(results_string)
|
||||
|
||||
def _compare_results(self):
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
|
|
@ -106,7 +114,6 @@ class TestHarness():
|
|||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
|
||||
def _cleanup(self):
|
||||
output = glob.glob(os.path.join(os.getcwd(), 'statepoint.*.*'))
|
||||
output.append(os.path.join(os.getcwd(), 'tallies.out'))
|
||||
|
|
@ -114,3 +121,121 @@ class TestHarness():
|
|||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
|
||||
class HashedTestHarness(TestHarness):
|
||||
"""Specialized TestHarness that hashes the results."""
|
||||
def _get_results(self):
|
||||
"""Digest info in the statepoint and return as a string."""
|
||||
return TestHarness._get_results(self, True)
|
||||
|
||||
|
||||
class PlotTestHarness(TestHarness):
|
||||
"""Specialized TestHarness for running OpenMC plotting tests."""
|
||||
def execute_test(self):
|
||||
"""Run OpenMC with the appropriate arguments and check the outputs."""
|
||||
self._parse_args()
|
||||
try:
|
||||
self._run_openmc()
|
||||
self._test_output_created()
|
||||
finally:
|
||||
self._cleanup()
|
||||
|
||||
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)
|
||||
|
||||
|
||||
class CMFDTestHarness(TestHarness):
|
||||
"""Specialized TestHarness for running OpenMC CMFD tests."""
|
||||
def _get_results(self):
|
||||
"""Digest info in the statepoint and return as a string."""
|
||||
# Read the statepoint file.
|
||||
statepoint = glob.glob(os.path.join(os.getcwd(), self._sp_name))[0]
|
||||
sp = StatePoint(statepoint)
|
||||
sp.read_results()
|
||||
|
||||
# Write out the eigenvalue and tallies.
|
||||
outstr = TestHarness._get_results(self)
|
||||
|
||||
# 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'
|
||||
|
||||
return outstr
|
||||
|
||||
|
||||
class ParticleRestartTestHarness(TestHarness):
|
||||
"""Specialized TestHarness for running OpenMC particle restart tests."""
|
||||
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 _get_results(self):
|
||||
"""Digest info in the statepoint and return as a string."""
|
||||
# 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])
|
||||
|
||||
return outstr
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue