merged cmake into ctests branch

This commit is contained in:
Bryan Herman 2014-03-11 18:25:58 -04:00
commit 433b579004
60 changed files with 5821 additions and 795 deletions

10
tests/cleanup Executable file
View file

@ -0,0 +1,10 @@
#!/bin/bash
# This simple script ensures that all binary
# output files have been deleted in all the
# folders. This can occur if a previous error
# occurred and the test suite was rerun without
# deleting left over binary files. This will
# cause an assertion error in some of the
# tests.
find . \( -name "*.binary" -o -name "*.h5" \) -exec rm -f {} \;

View file

@ -138,7 +138,6 @@ if len(sys.argv) > 1:
try:
tests__.index(j)
except ValueError:
tests__.append(j)
# Test name specified on command line
else:

View file

@ -0,0 +1,8 @@
<?xml version="1.0"?>
<geometry>
<!-- Sphere with radius 10 -->
<surface id="1" type="sphere" coeffs="0 0 0 10" boundary="vacuum"/>
<cell id="1" material="1" surfaces="-1" />
</geometry>

View file

@ -0,0 +1,9 @@
<?xml version="1.0"?>
<materials>
<material id="1">
<density value="4.5" units="g/cc" />
<nuclide name="U-235" xs="70c" ao="1.0" />
</material>
</materials>

View file

@ -0,0 +1,25 @@
#!/usr/bin/env python
import sys
# 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()
# 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 results to file
with open('results_test.dat','w') as fh:
fh.write(outstr)

View file

@ -0,0 +1,2 @@
k-combined:
2.977307E-01 2.848670E-03

View file

@ -0,0 +1,19 @@
<?xml version="1.0"?>
<settings>
<state_point batches="10" />
<source_point separate="true" />
<eigenvalue>
<batches>10</batches>
<inactive>5</inactive>
<particles>1000</particles>
</eigenvalue>
<source>
<space type="box">
<parameters>-4 -4 -4 4 4 4</parameters>
</space>
</source>
</settings>

View file

@ -0,0 +1,101 @@
#!/usr/bin/env python
import os
from subprocess import Popen, STDOUT, PIPE, call
import filecmp
from nose_mpi import NoseMPI
import glob
pwd = os.path.dirname(__file__)
settings1="""<?xml version="1.0"?>
<settings>
<state_point batches="10" />
<source_point separate="true" />
<eigenvalue>
<batches>10</batches>
<inactive>5</inactive>
<particles>1000</particles>
</eigenvalue>
<source>
<space type="box">
<parameters>-4 -4 -4 4 4 4</parameters>
</space>
</source>
</settings>
"""
settings2 = """<?xml version="1.0"?>
<settings>
<eigenvalue>
<batches>10</batches>
<inactive>5</inactive>
<particles>1000</particles>
</eigenvalue>
<source>
<file> source.10.{0} </file>
</source>
</settings>
"""
def setup():
os.putenv('PWD', pwd)
os.chdir(pwd)
def test_run1():
openmc_path = pwd + '/../../src/openmc'
if int(NoseMPI.mpi_np) > 0:
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path],
stderr=STDOUT, stdout=PIPE)
else:
proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE)
print(proc.communicate()[0])
returncode = proc.returncode
assert returncode == 0
def test_statepoint_exists():
statepoint = glob.glob(pwd + '/statepoint.10.*')
assert len(statepoint) == 1
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
source = glob.glob(pwd + '/source.10.*')
assert len(statepoint) == 1
assert source[0].endswith('binary') or source[0].endswith('h5')
def test_run2():
openmc_path = pwd + '/../../src/openmc'
source = glob.glob(pwd + '/source.10.*')
with open('settings.xml','w') as fh:
fh.write(settings2.format(source[0].split('.')[2]))
if int(NoseMPI.mpi_np) > 0:
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path],
stderr=STDOUT, stdout=PIPE)
else:
proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE)
print(proc.communicate()[0])
returncode = proc.returncode
assert returncode == 0
def test_results():
statepoint = glob.glob(pwd + '/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
def teardown():
with open('settings.xml','w') as fh:
fh.write(settings1)
output = glob.glob(pwd + '/statepoint.10.*')
output += glob.glob(pwd + '/source.10.*')
output.append(pwd + '/results_test.dat')
for f in output:
if os.path.exists(f):
os.remove(f)

View file

@ -0,0 +1,8 @@
<?xml version="1.0"?>
<geometry>
<!-- Sphere with radius 10 -->
<surface id="1" type="sphere" coeffs="0 0 0 10" boundary="vacuum"/>
<cell id="1" material="1" surfaces="-1" />
</geometry>

View file

@ -0,0 +1,9 @@
<?xml version="1.0"?>
<materials>
<material id="1">
<density value="4.5" units="g/cc" />
<nuclide name="U-235" xs="70c" ao="1.0" />
</material>
</materials>

View file

@ -0,0 +1,32 @@
#!/usr/bin/env python
import sys
# 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.8.binary')
sp.read_results()
sp.read_source()
# 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 xyz
xyz = sp.source[0].xyz
for i in xyz:
outstr += "{0:12.6E} ".format(i)
outstr += "\n"
# write results to file
with open('results_test.dat','w') as fh:
fh.write(outstr)

View file

@ -0,0 +1,3 @@
k-combined:
0.000000E+00 0.000000E+00
-9.438655E-02 -4.436810E+00 -2.416825E+00

View file

@ -0,0 +1,19 @@
<?xml version="1.0"?>
<settings>
<state_point batches="2 3 4 5 8"/>
<source_point batches="2 5 8"/>
<eigenvalue>
<batches>10</batches>
<inactive>5</inactive>
<particles>1000</particles>
</eigenvalue>
<source>
<space type="box">
<parameters>-4 -4 -4 4 4 4</parameters>
</space>
</source>
</settings>

View file

@ -0,0 +1,44 @@
#!/usr/bin/env python
import os
from subprocess import Popen, STDOUT, PIPE, call
import filecmp
from nose_mpi import NoseMPI
import glob
pwd = os.path.dirname(__file__)
def setup():
os.putenv('PWD', pwd)
os.chdir(pwd)
def test_run():
openmc_path = pwd + '/../../src/openmc'
if int(NoseMPI.mpi_np) > 0:
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path],
stderr=STDOUT, stdout=PIPE)
else:
proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE)
print(proc.communicate()[0])
returncode = proc.returncode
assert returncode == 0
def test_statepoint_exists():
statepoint = glob.glob(pwd + '/statepoint.*')
assert len(statepoint) == 5
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
def test_results():
statepoint = glob.glob(pwd + '/statepoint.8.*')
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
def teardown():
output = glob.glob(pwd + '/statepoint.*')
output.append(pwd + '/results_test.dat')
for f in output:
if os.path.exists(f):
os.remove(f)

View file

@ -0,0 +1,8 @@
<?xml version="1.0"?>
<geometry>
<!-- Sphere with radius 10 -->
<surface id="1" type="sphere" coeffs="0 0 0 10" boundary="vacuum"/>
<cell id="1" material="1" surfaces="-1" />
</geometry>

View file

@ -0,0 +1,9 @@
<?xml version="1.0"?>
<materials>
<material id="1">
<density value="4.5" units="g/cc" />
<nuclide name="U-235" xs="70c" ao="1.0" />
</material>
</materials>

View file

@ -0,0 +1,32 @@
#!/usr/bin/env python
import sys
# 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.8.binary')
sp.read_results()
sp.read_source()
# 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 xyz
xyz = sp.source[0].xyz
for i in xyz:
outstr += "{0:12.6E} ".format(i)
outstr += "\n"
# write results to file
with open('results_test.dat','w') as fh:
fh.write(outstr)

View file

@ -0,0 +1,3 @@
k-combined:
0.000000E+00 0.000000E+00
-9.438655E-02 -4.436810E+00 -2.416825E+00

View file

@ -0,0 +1,19 @@
<?xml version="1.0"?>
<settings>
<state_point interval="2"/>
<source_point interval="4"/>
<eigenvalue>
<batches>10</batches>
<inactive>5</inactive>
<particles>1000</particles>
</eigenvalue>
<source>
<space type="box">
<parameters>-4 -4 -4 4 4 4</parameters>
</space>
</source>
</settings>

View file

@ -0,0 +1,44 @@
#!/usr/bin/env python
import os
from subprocess import Popen, STDOUT, PIPE, call
import filecmp
from nose_mpi import NoseMPI
import glob
pwd = os.path.dirname(__file__)
def setup():
os.putenv('PWD', pwd)
os.chdir(pwd)
def test_run():
openmc_path = pwd + '/../../src/openmc'
if int(NoseMPI.mpi_np) > 0:
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path],
stderr=STDOUT, stdout=PIPE)
else:
proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE)
print(proc.communicate()[0])
returncode = proc.returncode
assert returncode == 0
def test_statepoint_exists():
statepoint = glob.glob(pwd + '/statepoint.*')
assert len(statepoint) == 5
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
def test_results():
statepoint = glob.glob(pwd + '/statepoint.8.*')
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
def teardown():
output = glob.glob(pwd + '/statepoint.*')
output.append(pwd + '/results_test.dat')
for f in output:
if os.path.exists(f):
os.remove(f)

View file

@ -0,0 +1,8 @@
<?xml version="1.0"?>
<geometry>
<!-- Sphere with radius 10 -->
<surface id="1" type="sphere" coeffs="0 0 0 10" boundary="vacuum"/>
<cell id="1" material="1" surfaces="-1" />
</geometry>

View file

@ -0,0 +1,9 @@
<?xml version="1.0"?>
<materials>
<material id="1">
<density value="4.5" units="g/cc" />
<nuclide name="U-235" xs="70c" ao="1.0" />
</material>
</materials>

View file

@ -0,0 +1,25 @@
#!/usr/bin/env python
import sys
# 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()
# 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 results to file
with open('results_test.dat','w') as fh:
fh.write(outstr)

View file

@ -0,0 +1,2 @@
k-combined:
3.011353E-01 2.854556E-03

View file

@ -0,0 +1,18 @@
<?xml version="1.0"?>
<settings>
<source_point batches="0" separate="true" overwrite_latest="true"/>
<eigenvalue>
<batches>10</batches>
<inactive>5</inactive>
<particles>1000</particles>
</eigenvalue>
<source>
<space type="box">
<parameters>-4 -4 -4 4 4 4</parameters>
</space>
</source>
</settings>

View file

@ -0,0 +1,48 @@
#!/usr/bin/env python
import os
from subprocess import Popen, STDOUT, PIPE, call
import filecmp
from nose_mpi import NoseMPI
import glob
pwd = os.path.dirname(__file__)
def setup():
os.putenv('PWD', pwd)
os.chdir(pwd)
def test_run():
openmc_path = pwd + '/../../src/openmc'
if int(NoseMPI.mpi_np) > 0:
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path],
stderr=STDOUT, stdout=PIPE)
else:
proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE)
print(proc.communicate()[0])
returncode = proc.returncode
assert returncode == 0
def test_statepoint_exists():
statepoint = glob.glob(pwd + '/statepoint.10.*')
assert len(statepoint) == 1
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
source = glob.glob(pwd + '/source.*')
assert len(source) == 1
assert source[0].endswith('binary') or source[0].endswith('h5')
def test_results():
statepoint = glob.glob(pwd + '/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
def teardown():
output = glob.glob(pwd + '/statepoint.10.*')
output += glob.glob(pwd + '/source.*')
output.append(pwd + '/results_test.dat')
for f in output:
if os.path.exists(f):
os.remove(f)

View file

@ -0,0 +1,8 @@
<?xml version="1.0"?>
<geometry>
<!-- Sphere with radius 10 -->
<surface id="1" type="sphere" coeffs="0 0 0 10" boundary="vacuum"/>
<cell id="1" material="1" surfaces="-1" />
</geometry>

View file

@ -0,0 +1,9 @@
<?xml version="1.0"?>
<materials>
<material id="1">
<density value="4.5" units="g/cc" />
<nuclide name="U-235" xs="70c" ao="1.0" />
</material>
</materials>

View file

@ -0,0 +1,44 @@
#!/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
results1 = sp.tallies[0].results
shape1 = results1.shape
size1 = (np.product(shape1))
results1 = np.reshape(results1, size1)
results2 = sp.tallies[1].results
shape2 = results2.shape
size2 = (np.product(shape2))
results2 = np.reshape(results2, size2)
# 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 += 'tally 1:\n'
for item in results1:
outstr += "{0:12.6E}\n".format(item)
outstr += 'tally 2:\n'
for item in results2:
outstr += "{0:12.6E}\n".format(item)
# write results to file
with open('results_test.dat','w') as fh:
fh.write(outstr)

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,19 @@
<?xml version="1.0"?>
<settings>
<state_point batches="7 10" />
<source_point batches="7" separate="true" />
<eigenvalue>
<batches>10</batches>
<inactive>5</inactive>
<particles>1000</particles>
</eigenvalue>
<source>
<space type="box">
<parameters>-4 -4 -4 4 4 4</parameters>
</space>
</source>
</settings>

View file

@ -0,0 +1,23 @@
<?xml version="1.0"?>
<tallies>
<mesh id="1">
<type>rectangular</type>
<dimension>5 3 4</dimension>
<lower_left>-10. -5. 0.</lower_left>
<upper_right>10. 4. 9.</upper_right>
</mesh>
<tally id="10">
<filter type="mesh" bins="1" />
<filter type="energy" bins="0.0 5.0 10.0" />
<filter type="energyout" bins="0.0 5.0 10.0" />
<scores>scatter-P3 nu-fission</scores>
</tally>
<tally id="5">
<filter type="cell" bins="1" />
<scores>fission absorption total flux</scores>
</tally>
</tallies>

View file

@ -0,0 +1,129 @@
#!/usr/bin/env python
import os
from subprocess import Popen, STDOUT, PIPE, call
import filecmp
from nose_mpi import NoseMPI
import glob
pwd = os.path.dirname(__file__)
def setup():
os.putenv('PWD', pwd)
os.chdir(pwd)
def test_run():
openmc_path = pwd + '/../../src/openmc'
if int(NoseMPI.mpi_np) > 0:
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path],
stderr=STDOUT, stdout=PIPE)
else:
proc = Popen([openmc_path], stderr=STDOUT, stdout=PIPE)
print(proc.communicate()[0])
returncode = proc.returncode
assert returncode == 0
def test_created_statepoint():
statepoint = glob.glob(pwd + '/statepoint.*')
assert len(statepoint) == 2
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
sourcepoint = glob.glob(pwd + '/source.7.*')
assert len(sourcepoint) == 1
assert sourcepoint[0].endswith('binary') or sourcepoint[0].endswith('h5')
def test_results():
statepoint = glob.glob(pwd + '/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
os.remove(statepoint[0])
def test_restart_form1():
statepoint = glob.glob(pwd + '/statepoint.7.*')
sourcepoint = glob.glob(pwd + '/source.7.*')
openmc_path = pwd + '/../../src/openmc'
if int(NoseMPI.mpi_np) > 0:
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path,
'-r', statepoint[0], sourcepoint[0]],
stderr=STDOUT, stdout=PIPE)
else:
proc = Popen([openmc_path, '-r', statepoint[0], sourcepoint[0]], stderr=STDOUT, stdout=PIPE)
print(proc.communicate()[0])
returncode = proc.returncode
assert returncode == 0
def test_created_statepoint_form1():
statepoint = glob.glob(pwd + '/statepoint.10.*')
assert len(statepoint) == 1
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
def test_results_form1():
statepoint = glob.glob(pwd + '/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
os.remove(statepoint[0])
def test_restart_form2():
statepoint = glob.glob(pwd + '/statepoint.7.*')
sourcepoint = glob.glob(pwd + '/source.7.*')
openmc_path = pwd + '/../../src/openmc'
if int(NoseMPI.mpi_np) > 0:
proc = Popen([NoseMPI.mpi_exec, '-np', NoseMPI.mpi_np, openmc_path,
'--restart', statepoint[0], sourcepoint[0]],
stderr=STDOUT, stdout=PIPE)
else:
proc = Popen([openmc_path, '--restart', statepoint[0], sourcepoint[0]],
stderr=STDOUT, stdout=PIPE)
print(proc.communicate()[0])
returncode = proc.returncode
assert returncode == 0
def test_created_statepoint_form2():
statepoint = glob.glob(pwd + '/statepoint.10.*')
assert len(statepoint) == 1
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
def test_results_form2():
statepoint = glob.glob(pwd + '/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
os.remove(statepoint[0])
def test_restart_serial():
statepoint = glob.glob(pwd + '/statepoint.7.*')
sourcepoint = glob.glob(pwd + '/source.7.*')
openmc_path = pwd + '/../../src/openmc'
proc = Popen([openmc_path, '--restart', statepoint[0], sourcepoint[0]],
stderr=STDOUT, stdout=PIPE)
print(proc.communicate()[0])
returncode = proc.returncode
assert returncode == 0
def test_created_statepoint_serial():
statepoint = glob.glob(pwd + '/statepoint.10.*')
assert len(statepoint) == 1
assert statepoint[0].endswith('binary') or statepoint[0].endswith('h5')
def test_results_serial():
statepoint = glob.glob(pwd + '/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
def teardown():
output = glob.glob(pwd + '/statepoint.*')
output += glob.glob(pwd + '/source.*')
output.append(pwd + '/results_test.dat')
for f in output:
if os.path.exists(f):
os.remove(f)

View file

@ -1,7 +1,8 @@
<?xml version="1.0"?>
<settings>
<state_point batches="10" source_separate="true" />
<state_point batches="10" />
<source_point separate="true" />
<eigenvalue>
<batches>10</batches>