mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 22:26:08 -04:00
updated statepoint_interval test
This commit is contained in:
parent
5845209acc
commit
8e387c6e90
3 changed files with 33 additions and 0 deletions
22
tests/test_statepoint_interval/results.py
Normal file
22
tests/test_statepoint_interval/results.py
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
|
||||
# import statepoint
|
||||
sys.path.append('../../src/utils')
|
||||
import statepoint
|
||||
|
||||
# read in statepoint file
|
||||
sp = statepoint.StatePoint('statepoint.10.binary')
|
||||
sp.read_results()
|
||||
|
||||
# set up output string
|
||||
outstr = ''
|
||||
|
||||
# write out k-combined
|
||||
outstr += 'k-combined:\n'
|
||||
outstr += "{0:10.8f} {1:10.8f}".format(sp.k_combined[0], sp.k_combined[1])
|
||||
|
||||
# write results to file
|
||||
with open('results_test.dat','w') as fh:
|
||||
fh.write(outstr)
|
||||
2
tests/test_statepoint_interval/results_true.dat
Normal file
2
tests/test_statepoint_interval/results_true.dat
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
k-combined:
|
||||
0.30078030 0.00343315
|
||||
|
|
@ -3,6 +3,7 @@
|
|||
import os
|
||||
import glob
|
||||
from subprocess import Popen, STDOUT, PIPE
|
||||
import filecmp
|
||||
|
||||
pwd = os.path.dirname(__file__)
|
||||
|
||||
|
|
@ -23,8 +24,16 @@ def test_statepoints_exist():
|
|||
assert os.path.exists(pwd + '/statepoint.8.binary')
|
||||
assert os.path.exists(pwd + '/statepoint.10.binary')
|
||||
|
||||
def test_results():
|
||||
os.system('python results.py')
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.system('cp results_test.dat results_error.dat')
|
||||
assert compare
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(pwd + '/statepoint.*.binary')
|
||||
output.append(pwd + '/results_test.dat')
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue