mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 21:55:41 -04:00
updated confidence interval testing for k combined and tally results
This commit is contained in:
parent
5d00dfa638
commit
947b8576d6
4 changed files with 44 additions and 2 deletions
34
tests/test_confidence_intervals/results.py
Normal file
34
tests/test_confidence_intervals/results.py
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
import numpy as np
|
||||
|
||||
# import statepoint
|
||||
sys.path.append('../../src/utils')
|
||||
import statepoint
|
||||
|
||||
# read in statepoint file
|
||||
sp = statepoint.StatePoint('statepoint.10.binary')
|
||||
sp.read_results()
|
||||
|
||||
# extract tally results and convert to vector
|
||||
results = sp.tallies[0].results
|
||||
shape = results.shape
|
||||
size = (np.product(shape))
|
||||
results = np.reshape(results, size)
|
||||
|
||||
# set up output string
|
||||
outstr = ''
|
||||
|
||||
# write out k-combined
|
||||
outstr += 'k-combined:\n'
|
||||
outstr += "{0:10.8f} {1:10.8f}\n".format(sp.k_combined[0], sp.k_combined[1])
|
||||
|
||||
# write out tally results
|
||||
outstr += 'tallies:\n'
|
||||
for item in results:
|
||||
outstr += "{0:10.8f}\n".format(item)
|
||||
|
||||
# write results to file
|
||||
with open('results_test.dat','w') as fh:
|
||||
fh.write(outstr)
|
||||
5
tests/test_confidence_intervals/results_true.dat
Normal file
5
tests/test_confidence_intervals/results_true.dat
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
k-combined:
|
||||
0.29618376 0.01254762
|
||||
tallies:
|
||||
63.10626773
|
||||
503.50685224
|
||||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
import os
|
||||
from subprocess import Popen, STDOUT, PIPE
|
||||
import filecmp
|
||||
|
||||
pwd = os.path.dirname(__file__)
|
||||
|
||||
|
|
@ -21,6 +22,10 @@ def test_created_statepoint():
|
|||
def test_created_output():
|
||||
assert os.path.exists(pwd + '/tallies.out')
|
||||
|
||||
def test_results():
|
||||
os.system('python results.py')
|
||||
assert filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
|
||||
def teardown():
|
||||
output = [pwd + '/statepoint.10.binary', pwd + '/tallies.out']
|
||||
for f in output:
|
||||
|
|
|
|||
|
|
@ -27,5 +27,3 @@ for root, dirs, files in os.walk('.'):
|
|||
|
||||
# Go back a directory
|
||||
os.chdir('..')
|
||||
|
||||
exit()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue