mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 21:55:41 -04:00
updated survival_biasing test
This commit is contained in:
parent
aba065867d
commit
a507d6802f
3 changed files with 33 additions and 9 deletions
22
tests/test_survival_biasing/results.py
Normal file
22
tests/test_survival_biasing/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_survival_biasing/results_true.dat
Normal file
2
tests/test_survival_biasing/results_true.dat
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
k-combined:
|
||||
0.30212453 0.00814702
|
||||
|
|
@ -2,32 +2,32 @@
|
|||
|
||||
import os
|
||||
from subprocess import Popen, STDOUT, PIPE
|
||||
import filecmp
|
||||
|
||||
pwd = os.path.dirname(__file__)
|
||||
|
||||
def setup():
|
||||
# Change directory
|
||||
os.putenv('PWD', pwd)
|
||||
os.chdir(pwd)
|
||||
|
||||
def test_run():
|
||||
# Run the simulation
|
||||
proc = Popen([pwd + '/../../src/openmc'], stderr=STDOUT, stdout=PIPE)
|
||||
returncode = proc.wait()
|
||||
|
||||
# Display stdout
|
||||
print(proc.communicate()[0])
|
||||
|
||||
# Make sure simulation ran to completion
|
||||
assert returncode == 0
|
||||
|
||||
def test_created_statepoint():
|
||||
# Make sure that statepoint file was created
|
||||
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():
|
||||
# Remove output files
|
||||
output = [pwd + '/statepoint.10.binary']
|
||||
output = [pwd + '/statepoint.10.binary', 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