2014-01-06 09:57:45 -05:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
2015-09-14 21:42:25 -04:00
|
|
|
import glob
|
|
|
|
|
import os
|
2015-06-04 13:53:42 +07:00
|
|
|
import sys
|
2015-10-02 23:19:00 -04:00
|
|
|
sys.path.insert(0, os.pardir)
|
|
|
|
|
from testing_harness import TestHarness
|
|
|
|
|
from openmc.statepoint import StatePoint
|
2014-03-11 18:59:37 -04:00
|
|
|
|
|
|
|
|
|
2015-06-25 00:10:07 -06:00
|
|
|
class SourcepointTestHarness(TestHarness):
|
|
|
|
|
def _test_output_created(self):
|
|
|
|
|
"""Make sure statepoint.* files have been created."""
|
|
|
|
|
statepoint = glob.glob(os.path.join(os.getcwd(), 'statepoint.*'))
|
2015-09-04 12:50:19 +07:00
|
|
|
assert len(statepoint) == 5, '5 statepoint files must exist.'
|
|
|
|
|
assert statepoint[0].endswith('h5'), \
|
|
|
|
|
'Statepoint file is not a HDF5 file.'
|
2015-06-25 00:10:07 -06:00
|
|
|
|
|
|
|
|
def _get_results(self):
|
2015-06-28 00:06:33 -06:00
|
|
|
"""Digest info in the statepoint and return as a string."""
|
2015-06-25 00:10:07 -06:00
|
|
|
# Read the statepoint file.
|
|
|
|
|
statepoint = glob.glob(os.path.join(os.getcwd(), self._sp_name))[0]
|
|
|
|
|
sp = StatePoint(statepoint)
|
|
|
|
|
|
2015-06-28 00:06:33 -06:00
|
|
|
# Get the eigenvalue information.
|
|
|
|
|
outstr = TestHarness._get_results(self)
|
2015-06-25 00:10:07 -06:00
|
|
|
|
2015-06-28 00:06:33 -06:00
|
|
|
# Add the source information.
|
2015-09-16 16:50:11 +07:00
|
|
|
xyz = sp.source[0]['xyz']
|
2015-06-25 00:10:07 -06:00
|
|
|
outstr += ' '.join(['{0:12.6E}'.format(x) for x in xyz])
|
|
|
|
|
outstr += "\n"
|
|
|
|
|
|
2015-06-28 00:06:33 -06:00
|
|
|
return outstr
|
2015-06-25 00:10:07 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
|
harness = SourcepointTestHarness('statepoint.08.*')
|
2015-06-29 18:50:53 -06:00
|
|
|
harness.main()
|