OpenMC/tests/test_sourcepoint_batch/test_sourcepoint_batch.py

39 lines
1.1 KiB
Python
Raw Normal View History

2014-01-06 09:57:45 -05:00
#!/usr/bin/env python
2015-09-14 21:42:25 -04:00
import glob
import os
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
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.'
def _get_results(self):
2015-06-28 00:06:33 -06:00
"""Digest info in the statepoint and return as a string."""
# 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-28 00:06:33 -06:00
# Add the source information.
xyz = sp.source[0]['xyz']
outstr += ' '.join(['{0:12.6E}'.format(x) for x in xyz])
outstr += "\n"
2015-06-28 00:06:33 -06:00
return outstr
if __name__ == '__main__':
harness = SourcepointTestHarness('statepoint.08.*')
harness.main()