2013-02-01 15:22:32 -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
|
|
|
import numpy as np
|
|
|
|
|
sys.path.insert(0, os.pardir)
|
|
|
|
|
from testing_harness import TestHarness
|
2017-04-07 10:25:24 -05:00
|
|
|
from openmc import StatePoint
|
2015-06-25 00:10:07 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class FixedSourceTestHarness(TestHarness):
|
|
|
|
|
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]
|
|
|
|
|
outstr = ''
|
2017-04-07 10:25:24 -05:00
|
|
|
with StatePoint(statepoint) as sp:
|
|
|
|
|
# Write out tally data.
|
|
|
|
|
for i, tally_ind in enumerate(sp.tallies):
|
2015-09-16 16:19:12 +07:00
|
|
|
tally = sp.tallies[tally_ind]
|
|
|
|
|
results = np.zeros((tally.sum.size*2, ))
|
|
|
|
|
results[0::2] = tally.sum.ravel()
|
|
|
|
|
results[1::2] = tally.sum_sq.ravel()
|
2015-06-25 00:10:07 -06:00
|
|
|
results = ['{0:12.6E}'.format(x) for x in results]
|
|
|
|
|
|
2017-04-07 10:25:24 -05:00
|
|
|
outstr += 'tally ' + str(i + 1) + ':\n'
|
2015-06-25 00:10:07 -06:00
|
|
|
outstr += '\n'.join(results) + '\n'
|
|
|
|
|
|
2017-04-07 10:25:24 -05:00
|
|
|
gt = sp.global_tallies
|
|
|
|
|
outstr += 'leakage:\n'
|
|
|
|
|
outstr += '{0:12.6E}'.format(gt[gt['name'] == b'leakage'][0]['sum']) + '\n'
|
|
|
|
|
outstr += '{0:12.6E}'.format(gt[gt['name'] == b'leakage'][0]['sum_sq']) + '\n'
|
2015-08-13 23:01:02 -07:00
|
|
|
|
2015-06-28 00:06:33 -06:00
|
|
|
return outstr
|
2013-02-01 15:22:32 -05:00
|
|
|
|
2014-02-25 11:18:51 -05:00
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2017-04-07 10:25:24 -05:00
|
|
|
harness = FixedSourceTestHarness('statepoint.10.h5')
|
2015-06-29 18:50:53 -06:00
|
|
|
harness.main()
|