2015-09-14 21:42:25 -04:00
|
|
|
import glob
|
|
|
|
|
import os
|
2018-01-29 10:53:46 -06:00
|
|
|
|
2017-04-07 10:25:24 -05:00
|
|
|
from openmc import StatePoint
|
2014-02-25 10:40:08 -05:00
|
|
|
|
2018-01-29 10:53:46 -06:00
|
|
|
from tests.testing_harness import TestHarness
|
|
|
|
|
|
2014-02-25 10:40:08 -05:00
|
|
|
|
2015-06-25 00:10:07 -06:00
|
|
|
class EntropyTestHarness(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]
|
2017-04-07 10:25:24 -05:00
|
|
|
with StatePoint(statepoint) as sp:
|
|
|
|
|
# Write out k-combined.
|
|
|
|
|
outstr = 'k-combined:\n'
|
2022-04-28 15:43:42 -05:00
|
|
|
outstr += '{:12.6E} {:12.6E}\n'.format(sp.keff.n, sp.keff.s)
|
2015-06-25 00:10:07 -06:00
|
|
|
|
2017-04-07 10:25:24 -05:00
|
|
|
# Write out entropy data.
|
|
|
|
|
outstr += 'entropy:\n'
|
2018-03-02 16:19:10 -06:00
|
|
|
results = ['{:12.6E}'.format(x) for x in sp.entropy]
|
2017-04-07 10:25:24 -05:00
|
|
|
outstr += '\n'.join(results) + '\n'
|
2015-06-25 00:10:07 -06:00
|
|
|
|
2015-06-28 00:06:33 -06:00
|
|
|
return outstr
|
2015-06-25 00:10:07 -06:00
|
|
|
|
|
|
|
|
|
2018-01-29 12:10:24 -06:00
|
|
|
def test_entropy():
|
2017-04-07 10:25:24 -05:00
|
|
|
harness = EntropyTestHarness('statepoint.10.h5')
|
2015-06-29 18:50:53 -06:00
|
|
|
harness.main()
|