mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 05:35:49 -04:00
Added new test in test suite to check for <nuclides>all</nuclides> with void
material.
This commit is contained in:
parent
891ad670b7
commit
028a271e86
7 changed files with 162 additions and 0 deletions
10
tests/test_tally_nuclides/geometry.xml
Normal file
10
tests/test_tally_nuclides/geometry.xml
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0"?>
|
||||
<geometry>
|
||||
|
||||
<surface id="1" type="sphere" coeffs="0. 0. 0. 1.4" />
|
||||
<surface id="2" type="sphere" coeffs="0. 0. 0. 5.35" boundary="vacuum" />
|
||||
|
||||
<cell id="1" material="void" surfaces="-1" /> <!-- cavity -->
|
||||
<cell id="2" material="1" surfaces=" 1 -2" /> <!-- Pu Core -->
|
||||
|
||||
</geometry>
|
||||
13
tests/test_tally_nuclides/materials.xml
Normal file
13
tests/test_tally_nuclides/materials.xml
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0"?>
|
||||
<materials>
|
||||
|
||||
<default_xs>71c</default_xs>
|
||||
|
||||
<!-- Plutonium -->
|
||||
<material id="1">
|
||||
<density value="18.4757" units="g/cm3" />
|
||||
<nuclide name="Pu-239" ao="1.0" />
|
||||
</material>
|
||||
|
||||
|
||||
</materials>
|
||||
37
tests/test_tally_nuclides/results.py
Normal file
37
tests/test_tally_nuclides/results.py
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
import numpy as np
|
||||
|
||||
# import statepoint
|
||||
sys.path.append('../../src/utils')
|
||||
import statepoint
|
||||
|
||||
# read in statepoint file
|
||||
if len(sys.argv) > 1:
|
||||
sp = statepoint.StatePoint(sys.argv[1])
|
||||
else:
|
||||
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:12.6E} {1:12.6E}\n".format(sp.k_combined[0], sp.k_combined[1])
|
||||
|
||||
# write out tally results
|
||||
outstr += 'tallies:\n'
|
||||
for item in results:
|
||||
outstr += "{0:12.6E}\n".format(item)
|
||||
|
||||
# write results to file
|
||||
with open('results_test.dat','w') as fh:
|
||||
fh.write(outstr)
|
||||
19
tests/test_tally_nuclides/results_true.dat
Normal file
19
tests/test_tally_nuclides/results_true.dat
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
k-combined:
|
||||
9.914201E-01 3.310472E-02
|
||||
tallies:
|
||||
7.251620E+00
|
||||
1.056750E+01
|
||||
1.649542E+00
|
||||
5.462124E-01
|
||||
1.598276E+00
|
||||
5.127366E-01
|
||||
5.602079E+00
|
||||
6.310407E+00
|
||||
7.251620E+00
|
||||
1.056750E+01
|
||||
1.649542E+00
|
||||
5.462124E-01
|
||||
1.598276E+00
|
||||
5.127366E-01
|
||||
5.602079E+00
|
||||
6.310407E+00
|
||||
17
tests/test_tally_nuclides/settings.xml
Normal file
17
tests/test_tally_nuclides/settings.xml
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0"?>
|
||||
<settings>
|
||||
|
||||
<eigenvalue>
|
||||
<batches>10</batches>
|
||||
<inactive>5</inactive>
|
||||
<particles>100</particles>
|
||||
</eigenvalue>
|
||||
|
||||
<source>
|
||||
<space>
|
||||
<type>point</type>
|
||||
<parameters>0.0 0.0 0.0</parameters>
|
||||
</space>
|
||||
</source>
|
||||
|
||||
</settings>
|
||||
9
tests/test_tally_nuclides/tallies.xml
Normal file
9
tests/test_tally_nuclides/tallies.xml
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0"?>
|
||||
<tallies>
|
||||
|
||||
<tally id="1">
|
||||
<nuclides>all</nuclides>
|
||||
<scores>total absorption fission scatter</scores>
|
||||
</tally>
|
||||
|
||||
</tallies>
|
||||
57
tests/test_tally_nuclides/test_tally_nuclides.py
Normal file
57
tests/test_tally_nuclides/test_tally_nuclides.py
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
from subprocess import Popen, STDOUT, PIPE, call
|
||||
import filecmp
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
|
||||
parser = OptionParser()
|
||||
parser.add_option('--mpi_exec', dest='mpi_exec', default='')
|
||||
parser.add_option('--mpi_np', dest='mpi_np', default='3')
|
||||
parser.add_option('--exe', dest='exe')
|
||||
(opts, args) = parser.parse_args()
|
||||
cwd = os.getcwd()
|
||||
|
||||
def test_run():
|
||||
if opts.mpi_exec != '':
|
||||
proc = Popen([opts.mpi_exec, '-np', opts.mpi_np, opts.exe, cwd],
|
||||
stderr=STDOUT, stdout=PIPE)
|
||||
else:
|
||||
proc = Popen([opts.exe, cwd], stderr=STDOUT, stdout=PIPE)
|
||||
print(proc.communicate()[0])
|
||||
returncode = proc.returncode
|
||||
assert returncode == 0, 'OpenMC did not exit successfully.'
|
||||
|
||||
def test_created_statepoint():
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
assert len(statepoint) == 1, 'Either multiple or no statepoint files exist.'
|
||||
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5'),\
|
||||
'Statepoint file is not a binary or hdf5 file.'
|
||||
|
||||
def test_results():
|
||||
statepoint = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
call(['python', 'results.py', statepoint[0]])
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.rename('results_test.dat', 'results_error.dat')
|
||||
assert compare, 'Results do not agree.'
|
||||
|
||||
def teardown():
|
||||
output = glob.glob(os.path.join(cwd, 'statepoint.10.*'))
|
||||
output.append(os.path.join(cwd, 'results_test.dat'))
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# test for openmc executable
|
||||
if opts.exe is None:
|
||||
raise Exception('Must specify OpenMC executable from command line with --exe.')
|
||||
|
||||
# run tests
|
||||
test_run()
|
||||
test_created_statepoint()
|
||||
test_results()
|
||||
teardown()
|
||||
Loading…
Add table
Add a link
Reference in a new issue