mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 21:55:41 -04:00
updated fixed_source test and added simple flux tally for comparison
This commit is contained in:
parent
fa217cc6d0
commit
bfbc929e66
4 changed files with 55 additions and 2 deletions
30
tests/test_fixed_source/results.py
Normal file
30
tests/test_fixed_source/results.py
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
#!/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 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)
|
||||
3
tests/test_fixed_source/results_true.dat
Normal file
3
tests/test_fixed_source/results_true.dat
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
tallies:
|
||||
471.58945263
|
||||
22414.09099170
|
||||
8
tests/test_fixed_source/tallies.xml
Normal file
8
tests/test_fixed_source/tallies.xml
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0"?>
|
||||
<tallies>
|
||||
|
||||
<tally id="1">
|
||||
<scores>flux</scores>
|
||||
</tally>
|
||||
|
||||
</tallies>
|
||||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
import os
|
||||
from subprocess import Popen, STDOUT, PIPE
|
||||
import filecmp
|
||||
|
||||
pwd = os.path.dirname(__file__)
|
||||
|
||||
|
|
@ -15,11 +16,22 @@ def test_run():
|
|||
print(proc.communicate()[0])
|
||||
assert returncode == 0
|
||||
|
||||
def test_created_statepoint():
|
||||
def test_statepoint_exists():
|
||||
assert os.path.exists(pwd + '/statepoint.10.binary')
|
||||
|
||||
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']
|
||||
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