mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 14:15:42 -04:00
updated score_scatter_n test
This commit is contained in:
parent
1422811e0b
commit
0ee864b077
3 changed files with 77 additions and 1 deletions
34
tests/test_score_scatter_n/results.py
Normal file
34
tests/test_score_scatter_n/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)
|
||||
33
tests/test_score_scatter_n/results_true.dat
Normal file
33
tests/test_score_scatter_n/results_true.dat
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
k-combined:
|
||||
1.63626998 0.13749537
|
||||
tallies:
|
||||
12.52000000
|
||||
31.63760000
|
||||
0.98756223
|
||||
0.21542730
|
||||
0.45047247
|
||||
0.04228472
|
||||
0.31795301
|
||||
0.03892891
|
||||
0.05365941
|
||||
0.01062510
|
||||
3.53000000
|
||||
2.51970000
|
||||
0.39957808
|
||||
0.03853015
|
||||
0.11242633
|
||||
0.00644611
|
||||
0.05649785
|
||||
0.01272789
|
||||
0.06730127
|
||||
0.00232340
|
||||
43.38000000
|
||||
380.96820000
|
||||
22.36892729
|
||||
102.01729343
|
||||
8.35400999
|
||||
14.46115375
|
||||
0.49890639
|
||||
0.18335238
|
||||
-1.46199676
|
||||
0.45033259
|
||||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
import os
|
||||
from subprocess import Popen, STDOUT, PIPE
|
||||
import filecmp
|
||||
|
||||
pwd = os.path.dirname(__file__)
|
||||
|
||||
|
|
@ -21,8 +22,16 @@ def test_statepoint_exists():
|
|||
def test_output_exists():
|
||||
assert os.path.exists(pwd + '/tallies.out')
|
||||
|
||||
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 = [pwd + '/statepoint.10.binary', pwd + '/tallies.out']
|
||||
output = [pwd + '/statepoint.10.binary', pwd + '/tallies.out',
|
||||
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