mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 13:45:36 -04:00
added mdgxs tests
This commit is contained in:
parent
7be7c6f29b
commit
92e77eb574
19 changed files with 906 additions and 2 deletions
|
|
@ -255,12 +255,14 @@ class Library(object):
|
|||
|
||||
@mgxs_types.setter
|
||||
def mgxs_types(self, mgxs_types):
|
||||
all_mgxs_types = np.append(openmc.mgxs.MGXS_TYPES,
|
||||
openmc.mgxs.MDGXS_TYPES)
|
||||
if mgxs_types == 'all':
|
||||
self._mgxs_types = openmc.mgxs.MGXS_TYPES
|
||||
self._mgxs_types = all_mgxs_types
|
||||
else:
|
||||
cv.check_iterable_type('mgxs_types', mgxs_types, basestring)
|
||||
for mgxs_type in mgxs_types:
|
||||
cv.check_value('mgxs_type', mgxs_type, openmc.mgxs.MGXS_TYPES)
|
||||
cv.check_value('mgxs_type', mgxs_type, all_mgxs_types)
|
||||
self._mgxs_types = mgxs_types
|
||||
|
||||
@by_nuclide.setter
|
||||
|
|
|
|||
1
tests/test_mdgxs_library_condense/inputs_true.dat
Normal file
1
tests/test_mdgxs_library_condense/inputs_true.dat
Normal file
|
|
@ -0,0 +1 @@
|
|||
9e8d8b468bdd81d996956d0d43eef5779b7b7d5ca3f6a1e628f10318748086183e45cf221edf7a274ff2dc6aff34f4411e21952740cdb7652477dfa0a1ffb5f2
|
||||
63
tests/test_mdgxs_library_condense/results_true.dat
Normal file
63
tests/test_mdgxs_library_condense/results_true.dat
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
material delayedgroup group in nuclide mean std. dev.
|
||||
0 10000 1 1 total 0.000021 0.000001
|
||||
1 10000 2 1 total 0.000110 0.000008
|
||||
2 10000 3 1 total 0.000107 0.000007
|
||||
3 10000 4 1 total 0.000249 0.000017
|
||||
4 10000 5 1 total 0.000112 0.000007
|
||||
5 10000 6 1 total 0.000046 0.000003
|
||||
material delayedgroup group out nuclide mean std. dev.
|
||||
0 10000 1 1 total 0 0.000000
|
||||
1 10000 2 1 total 1 0.869128
|
||||
2 10000 3 1 total 1 1.414214
|
||||
3 10000 4 1 total 1 0.360359
|
||||
4 10000 5 1 total 0 0.000000
|
||||
5 10000 6 1 total 0 0.000000
|
||||
material delayedgroup group in nuclide mean std. dev.
|
||||
0 10000 1 1 total 0.000227 0.000020
|
||||
1 10000 2 1 total 0.001214 0.000108
|
||||
2 10000 3 1 total 0.001184 0.000104
|
||||
3 10000 4 1 total 0.002752 0.000240
|
||||
4 10000 5 1 total 0.001231 0.000105
|
||||
5 10000 6 1 total 0.000512 0.000044
|
||||
material delayedgroup group in nuclide mean std. dev.
|
||||
0 10001 1 1 total 0 0
|
||||
1 10001 2 1 total 0 0
|
||||
2 10001 3 1 total 0 0
|
||||
3 10001 4 1 total 0 0
|
||||
4 10001 5 1 total 0 0
|
||||
5 10001 6 1 total 0 0
|
||||
material delayedgroup group out nuclide mean std. dev.
|
||||
0 10001 1 1 total 0 0
|
||||
1 10001 2 1 total 0 0
|
||||
2 10001 3 1 total 0 0
|
||||
3 10001 4 1 total 0 0
|
||||
4 10001 5 1 total 0 0
|
||||
5 10001 6 1 total 0 0
|
||||
material delayedgroup group in nuclide mean std. dev.
|
||||
0 10001 1 1 total 0 0
|
||||
1 10001 2 1 total 0 0
|
||||
2 10001 3 1 total 0 0
|
||||
3 10001 4 1 total 0 0
|
||||
4 10001 5 1 total 0 0
|
||||
5 10001 6 1 total 0 0
|
||||
material delayedgroup group in nuclide mean std. dev.
|
||||
0 10002 1 1 total 0 0
|
||||
1 10002 2 1 total 0 0
|
||||
2 10002 3 1 total 0 0
|
||||
3 10002 4 1 total 0 0
|
||||
4 10002 5 1 total 0 0
|
||||
5 10002 6 1 total 0 0
|
||||
material delayedgroup group out nuclide mean std. dev.
|
||||
0 10002 1 1 total 0 0
|
||||
1 10002 2 1 total 0 0
|
||||
2 10002 3 1 total 0 0
|
||||
3 10002 4 1 total 0 0
|
||||
4 10002 5 1 total 0 0
|
||||
5 10002 6 1 total 0 0
|
||||
material delayedgroup group in nuclide mean std. dev.
|
||||
0 10002 1 1 total 0 0
|
||||
1 10002 2 1 total 0 0
|
||||
2 10002 3 1 total 0 0
|
||||
3 10002 4 1 total 0 0
|
||||
4 10002 5 1 total 0 0
|
||||
5 10002 6 1 total 0 0
|
||||
|
|
@ -0,0 +1,82 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
import sys
|
||||
import glob
|
||||
import hashlib
|
||||
sys.path.insert(0, os.pardir)
|
||||
from testing_harness import PyAPITestHarness
|
||||
from input_set import PinCellInputSet
|
||||
import openmc
|
||||
import openmc.mgxs
|
||||
|
||||
|
||||
class MDGXSTestHarness(PyAPITestHarness):
|
||||
def _build_inputs(self):
|
||||
# Set the input set to use the pincell model
|
||||
self._input_set = PinCellInputSet()
|
||||
|
||||
# Generate inputs using parent class routine
|
||||
super(MDGXSTestHarness, self)._build_inputs()
|
||||
|
||||
# Initialize a two-group structure
|
||||
energy_groups = openmc.mgxs.EnergyGroups(group_edges=[0, 0.625e-6,
|
||||
20.])
|
||||
delayed_groups = openmc.mgxs.DelayedGroups(range(1,7))
|
||||
|
||||
# Initialize MGXS Library for a few cross section types
|
||||
self.mgxs_lib = openmc.mgxs.Library(self._input_set.geometry)
|
||||
self.mgxs_lib.by_nuclide = False
|
||||
|
||||
# Test all MGXS types
|
||||
self.mgxs_lib.mgxs_types = openmc.mgxs.MDGXS_TYPES
|
||||
self.mgxs_lib.energy_groups = energy_groups
|
||||
self.mgxs_lib.delayed_groups = delayed_groups
|
||||
self.mgxs_lib.domain_type = 'material'
|
||||
self.mgxs_lib.build_library()
|
||||
|
||||
# Initialize a tallies file
|
||||
self._input_set.tallies = openmc.Tallies()
|
||||
self.mgxs_lib.add_to_tallies_file(self._input_set.tallies, merge=False)
|
||||
self._input_set.tallies.export_to_xml()
|
||||
|
||||
def _get_results(self, hash_output=False):
|
||||
"""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 = openmc.StatePoint(statepoint)
|
||||
|
||||
# Load the MGXS library from the statepoint
|
||||
self.mgxs_lib.load_from_statepoint(sp)
|
||||
|
||||
# Build a condensed 1-group MGXS Library
|
||||
one_group = openmc.mgxs.EnergyGroups([0., 20.])
|
||||
condense_lib = self.mgxs_lib.get_condensed_library(one_group)
|
||||
|
||||
# Build a string from Pandas Dataframe for each 1-group MGXS
|
||||
outstr = ''
|
||||
for domain in condense_lib.domains:
|
||||
for mgxs_type in condense_lib.mgxs_types:
|
||||
mgxs = condense_lib.get_mgxs(domain, mgxs_type)
|
||||
df = mgxs.get_pandas_dataframe()
|
||||
outstr += df.to_string() + '\n'
|
||||
|
||||
# Hash the results if necessary
|
||||
if hash_output:
|
||||
sha512 = hashlib.sha512()
|
||||
sha512.update(outstr.encode('utf-8'))
|
||||
outstr = sha512.hexdigest()
|
||||
|
||||
return outstr
|
||||
|
||||
|
||||
def _cleanup(self):
|
||||
super(MDGXSTestHarness, self)._cleanup()
|
||||
f = os.path.join(os.getcwd(), 'tallies.xml')
|
||||
if os.path.exists(f): os.remove(f)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
harness = MDGXSTestHarness('statepoint.10.*', True)
|
||||
harness.main()
|
||||
1
tests/test_mdgxs_library_distribcell/inputs_true.dat
Normal file
1
tests/test_mdgxs_library_distribcell/inputs_true.dat
Normal file
|
|
@ -0,0 +1 @@
|
|||
2d7ef183881fb47ba66ac4ff60a4e510f7b85361aca6dbbe6df2dc89b8492ad3bacbde747803532670bf207ec586dab910448fc1e49f2e57a3bf93256d24442c
|
||||
21
tests/test_mdgxs_library_distribcell/results_true.dat
Normal file
21
tests/test_mdgxs_library_distribcell/results_true.dat
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
avg(distribcell) delayedgroup group in nuclide mean std. dev.
|
||||
0 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,... 1 1 total 0 0
|
||||
1 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,... 2 1 total 0 0
|
||||
2 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,... 3 1 total 0 0
|
||||
3 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,... 4 1 total 0 0
|
||||
4 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,... 5 1 total 0 0
|
||||
5 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,... 6 1 total 0 0
|
||||
avg(distribcell) delayedgroup group out nuclide mean std. dev.
|
||||
0 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,... 1 1 total 0 0
|
||||
1 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,... 2 1 total 0 0
|
||||
2 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,... 3 1 total 0 0
|
||||
3 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,... 4 1 total 0 0
|
||||
4 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,... 5 1 total 0 0
|
||||
5 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,... 6 1 total 0 0
|
||||
avg(distribcell) delayedgroup group in nuclide mean std. dev.
|
||||
0 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,... 1 1 total 0 0
|
||||
1 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,... 2 1 total 0 0
|
||||
2 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,... 3 1 total 0 0
|
||||
3 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,... 4 1 total 0 0
|
||||
4 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,... 5 1 total 0 0
|
||||
5 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,... 6 1 total 0 0
|
||||
|
|
@ -0,0 +1,80 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
import sys
|
||||
import glob
|
||||
import hashlib
|
||||
sys.path.insert(0, os.pardir)
|
||||
from testing_harness import PyAPITestHarness
|
||||
import openmc
|
||||
import openmc.mgxs
|
||||
|
||||
|
||||
class MDGXSTestHarness(PyAPITestHarness):
|
||||
def _build_inputs(self):
|
||||
# Generate inputs using parent class routine
|
||||
super(MDGXSTestHarness, self)._build_inputs()
|
||||
|
||||
# Initialize a one-group structure
|
||||
energy_groups = openmc.mgxs.EnergyGroups(group_edges=[0, 20.])
|
||||
|
||||
# Initialize a six-group structure
|
||||
delayed_groups = openmc.mgxs.DelayedGroups(range(1,7))
|
||||
|
||||
# Initialize MGXS Library for a few cross section types
|
||||
# for one material-filled cell in the geometry
|
||||
self.mgxs_lib = openmc.mgxs.Library(self._input_set.geometry)
|
||||
self.mgxs_lib.by_nuclide = False
|
||||
|
||||
# Test all MDGXS types
|
||||
self.mgxs_lib.mgxs_types = openmc.mgxs.MDGXS_TYPES
|
||||
self.mgxs_lib.energy_groups = energy_groups
|
||||
self.mgxs_lib.delayed_groups = delayed_groups
|
||||
self.mgxs_lib.domain_type = 'distribcell'
|
||||
material_cells = self.mgxs_lib.openmc_geometry.get_all_material_cells()
|
||||
self.mgxs_lib.domains = [material_cells[-1]]
|
||||
self.mgxs_lib.build_library()
|
||||
|
||||
# Initialize a tallies file
|
||||
self._input_set.tallies = openmc.Tallies()
|
||||
self.mgxs_lib.add_to_tallies_file(self._input_set.tallies, merge=False)
|
||||
self._input_set.tallies.export_to_xml()
|
||||
|
||||
def _get_results(self, hash_output=False):
|
||||
"""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 = openmc.StatePoint(statepoint)
|
||||
|
||||
# Load the MGXS library from the statepoint
|
||||
self.mgxs_lib.load_from_statepoint(sp)
|
||||
|
||||
# Average the MGXS across distribcell subdomains
|
||||
avg_lib = self.mgxs_lib.get_subdomain_avg_library()
|
||||
|
||||
# Build a string from Pandas Dataframe for each 1-group MGXS
|
||||
outstr = ''
|
||||
for domain in avg_lib.domains:
|
||||
for mgxs_type in avg_lib.mgxs_types:
|
||||
mgxs = avg_lib.get_mgxs(domain, mgxs_type)
|
||||
df = mgxs.get_pandas_dataframe()
|
||||
outstr += df.to_string() + '\n'
|
||||
|
||||
# Hash the results if necessary
|
||||
if hash_output:
|
||||
sha512 = hashlib.sha512()
|
||||
sha512.update(outstr.encode('utf-8'))
|
||||
outstr = sha512.hexdigest()
|
||||
|
||||
return outstr
|
||||
|
||||
def _cleanup(self):
|
||||
super(MDGXSTestHarness, self)._cleanup()
|
||||
f = os.path.join(os.getcwd(), 'tallies.xml')
|
||||
if os.path.exists(f): os.remove(f)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
harness = MDGXSTestHarness('statepoint.10.*', True)
|
||||
harness.main()
|
||||
1
tests/test_mdgxs_library_hdf5/inputs_true.dat
Normal file
1
tests/test_mdgxs_library_hdf5/inputs_true.dat
Normal file
|
|
@ -0,0 +1 @@
|
|||
9e8d8b468bdd81d996956d0d43eef5779b7b7d5ca3f6a1e628f10318748086183e45cf221edf7a274ff2dc6aff34f4411e21952740cdb7652477dfa0a1ffb5f2
|
||||
117
tests/test_mdgxs_library_hdf5/results_true.dat
Normal file
117
tests/test_mdgxs_library_hdf5/results_true.dat
Normal file
|
|
@ -0,0 +1,117 @@
|
|||
domain=10000 type=delayed-nu-fission
|
||||
[[ 2.29808234e-05 1.06974158e-04]
|
||||
[ 1.43606337e-04 5.52167907e-04]
|
||||
[ 1.51382216e-04 5.27147681e-04]
|
||||
[ 7.42603178e-05 2.22018043e-04]
|
||||
[ 4.14908454e-05 9.10244403e-05]
|
||||
[ 1.70016000e-05 3.81298119e-05]]
|
||||
[[ 1.66363133e-06 9.49156242e-06]
|
||||
[ 1.05907806e-05 4.89925426e-05]
|
||||
[ 1.12671238e-05 4.67725567e-05]
|
||||
[ 5.22610273e-06 1.87563195e-05]
|
||||
[ 2.99830766e-06 7.68984041e-06]
|
||||
[ 1.22654684e-06 3.22124663e-06]]
|
||||
domain=10000 type=chi-delayed
|
||||
[[ 0. 0.]
|
||||
[ 1. 0.]
|
||||
[ 1. 0.]
|
||||
[ 1. 0.]
|
||||
[ 0. 0.]
|
||||
[ 0. 0.]]
|
||||
[[ 0. 0. ]
|
||||
[ 0.86912776 0. ]
|
||||
[ 1.41421356 0. ]
|
||||
[ 0.36035904 0. ]
|
||||
[ 0. 0. ]
|
||||
[ 0. 0. ]]
|
||||
domain=10000 type=beta
|
||||
[[ 4.89188107e-05 2.27713711e-04]
|
||||
[ 3.05691886e-04 1.17538858e-03]
|
||||
[ 3.22244241e-04 1.12212853e-03]
|
||||
[ 3.82159891e-03 1.14255357e-02]
|
||||
[ 2.13520995e-03 4.68431744e-03]
|
||||
[ 8.74939644e-04 1.96224379e-03]]
|
||||
[[ 4.67388620e-06 2.46946810e-05]
|
||||
[ 2.95223877e-05 1.27466393e-04]
|
||||
[ 3.12885004e-05 1.21690543e-04]
|
||||
[ 3.21434855e-04 1.09939816e-03]
|
||||
[ 1.82980497e-04 4.50738567e-04]
|
||||
[ 7.48899920e-05 1.88812772e-04]]
|
||||
domain=10001 type=delayed-nu-fission
|
||||
[[ 0. 0.]
|
||||
[ 0. 0.]
|
||||
[ 0. 0.]
|
||||
[ 0. 0.]
|
||||
[ 0. 0.]
|
||||
[ 0. 0.]]
|
||||
[[ 0. 0.]
|
||||
[ 0. 0.]
|
||||
[ 0. 0.]
|
||||
[ 0. 0.]
|
||||
[ 0. 0.]
|
||||
[ 0. 0.]]
|
||||
domain=10001 type=chi-delayed
|
||||
[[ 0. 0.]
|
||||
[ 0. 0.]
|
||||
[ 0. 0.]
|
||||
[ 0. 0.]
|
||||
[ 0. 0.]
|
||||
[ 0. 0.]]
|
||||
[[ 0. 0.]
|
||||
[ 0. 0.]
|
||||
[ 0. 0.]
|
||||
[ 0. 0.]
|
||||
[ 0. 0.]
|
||||
[ 0. 0.]]
|
||||
domain=10001 type=beta
|
||||
[[ 0. 0.]
|
||||
[ 0. 0.]
|
||||
[ 0. 0.]
|
||||
[ 0. 0.]
|
||||
[ 0. 0.]
|
||||
[ 0. 0.]]
|
||||
[[ 0. 0.]
|
||||
[ 0. 0.]
|
||||
[ 0. 0.]
|
||||
[ 0. 0.]
|
||||
[ 0. 0.]
|
||||
[ 0. 0.]]
|
||||
domain=10002 type=delayed-nu-fission
|
||||
[[ 0. 0.]
|
||||
[ 0. 0.]
|
||||
[ 0. 0.]
|
||||
[ 0. 0.]
|
||||
[ 0. 0.]
|
||||
[ 0. 0.]]
|
||||
[[ 0. 0.]
|
||||
[ 0. 0.]
|
||||
[ 0. 0.]
|
||||
[ 0. 0.]
|
||||
[ 0. 0.]
|
||||
[ 0. 0.]]
|
||||
domain=10002 type=chi-delayed
|
||||
[[ 0. 0.]
|
||||
[ 0. 0.]
|
||||
[ 0. 0.]
|
||||
[ 0. 0.]
|
||||
[ 0. 0.]
|
||||
[ 0. 0.]]
|
||||
[[ 0. 0.]
|
||||
[ 0. 0.]
|
||||
[ 0. 0.]
|
||||
[ 0. 0.]
|
||||
[ 0. 0.]
|
||||
[ 0. 0.]]
|
||||
domain=10002 type=beta
|
||||
[[ 0. 0.]
|
||||
[ 0. 0.]
|
||||
[ 0. 0.]
|
||||
[ 0. 0.]
|
||||
[ 0. 0.]
|
||||
[ 0. 0.]]
|
||||
[[ 0. 0.]
|
||||
[ 0. 0.]
|
||||
[ 0. 0.]
|
||||
[ 0. 0.]
|
||||
[ 0. 0.]
|
||||
[ 0. 0.]]
|
||||
93
tests/test_mdgxs_library_hdf5/test_mdgxs_library_hdf5.py
Normal file
93
tests/test_mdgxs_library_hdf5/test_mdgxs_library_hdf5.py
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
import sys
|
||||
import glob
|
||||
import hashlib
|
||||
import h5py
|
||||
sys.path.insert(0, os.pardir)
|
||||
from testing_harness import PyAPITestHarness
|
||||
from input_set import PinCellInputSet
|
||||
import openmc
|
||||
import openmc.mgxs
|
||||
|
||||
|
||||
class MDGXSTestHarness(PyAPITestHarness):
|
||||
def _build_inputs(self):
|
||||
# Set the input set to use the pincell model
|
||||
self._input_set = PinCellInputSet()
|
||||
|
||||
# Generate inputs using parent class routine
|
||||
super(MDGXSTestHarness, self)._build_inputs()
|
||||
|
||||
# Initialize a two-group structure
|
||||
energy_groups = openmc.mgxs.EnergyGroups(group_edges=[0, 0.625e-6,
|
||||
20.])
|
||||
|
||||
# Initialize a six-group structure
|
||||
delayed_groups = openmc.mgxs.DelayedGroups(range(1,7))
|
||||
|
||||
# Initialize MGXS Library for a few cross section types
|
||||
self.mgxs_lib = openmc.mgxs.Library(self._input_set.geometry)
|
||||
self.mgxs_lib.by_nuclide = False
|
||||
|
||||
# Test all MDGXS types
|
||||
self.mgxs_lib.mgxs_types = openmc.mgxs.MDGXS_TYPES
|
||||
self.mgxs_lib.energy_groups = energy_groups
|
||||
self.mgxs_lib.delayed_groups = delayed_groups
|
||||
self.mgxs_lib.domain_type = 'material'
|
||||
self.mgxs_lib.build_library()
|
||||
|
||||
# Initialize a tallies file
|
||||
self._input_set.tallies = openmc.Tallies()
|
||||
self.mgxs_lib.add_to_tallies_file(self._input_set.tallies, merge=False)
|
||||
self._input_set.tallies.export_to_xml()
|
||||
|
||||
def _get_results(self, hash_output=False):
|
||||
"""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 = openmc.StatePoint(statepoint)
|
||||
|
||||
# Load the MGXS library from the statepoint
|
||||
self.mgxs_lib.load_from_statepoint(sp)
|
||||
|
||||
# Export the MGXS Library to an HDF5 file
|
||||
self.mgxs_lib.build_hdf5_store(directory='.')
|
||||
|
||||
# Open the MGXS HDF5 file
|
||||
f = h5py.File('mgxs.h5', 'r')
|
||||
|
||||
# Build a string from the datasets in the HDF5 file
|
||||
outstr = ''
|
||||
for domain in self.mgxs_lib.domains:
|
||||
for mgxs_type in self.mgxs_lib.mgxs_types:
|
||||
outstr += 'domain={0} type={1}\n'.format(domain.id, mgxs_type)
|
||||
key = 'material/{0}/{1}/average'.format(domain.id, mgxs_type)
|
||||
outstr += str(f[key][...]) + '\n'
|
||||
key = 'material/{0}/{1}/std. dev.'.format(domain.id, mgxs_type)
|
||||
outstr += str(f[key][...]) + '\n'
|
||||
|
||||
# Close the MGXS HDF5 file
|
||||
f.close()
|
||||
|
||||
# Hash the results if necessary
|
||||
if hash_output:
|
||||
sha512 = hashlib.sha512()
|
||||
sha512.update(outstr.encode('utf-8'))
|
||||
outstr = sha512.hexdigest()
|
||||
|
||||
return outstr
|
||||
|
||||
def _cleanup(self):
|
||||
super(MDGXSTestHarness, self)._cleanup()
|
||||
f = os.path.join(os.getcwd(), 'tallies.xml')
|
||||
if os.path.exists(f): os.remove(f)
|
||||
f = os.path.join(os.getcwd(), 'mgxs.h5')
|
||||
if os.path.exists(f): os.remove(f)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
harness = MDGXSTestHarness('statepoint.10.*', True)
|
||||
harness.main()
|
||||
1
tests/test_mdgxs_library_mesh/inputs_true.dat
Normal file
1
tests/test_mdgxs_library_mesh/inputs_true.dat
Normal file
|
|
@ -0,0 +1 @@
|
|||
f76b5d0cc2dbadd48d51918d8c82e4457e9ce3eafb191cd51394e420ba3ae80eccdff03098b276f7d3eb87f6a4616f1dd0e39e1892244a29d0f486ff2bf4ddbb
|
||||
78
tests/test_mdgxs_library_mesh/results_true.dat
Normal file
78
tests/test_mdgxs_library_mesh/results_true.dat
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
mesh 1 delayedgroup group in nuclide mean std. dev.
|
||||
x y z
|
||||
0 1 1 1 1 1 total 0.000004 4.432287e-07
|
||||
1 1 1 1 2 1 total 0.000026 2.652890e-06
|
||||
2 1 1 1 3 1 total 0.000024 2.402024e-06
|
||||
3 1 1 1 4 1 total 0.000054 5.463683e-06
|
||||
4 1 1 1 5 1 total 0.000026 2.662762e-06
|
||||
5 1 1 1 6 1 total 0.000010 1.037947e-06
|
||||
6 1 2 1 1 1 total 0.000005 1.099501e-06
|
||||
7 1 2 1 2 1 total 0.000029 6.440339e-06
|
||||
8 1 2 1 3 1 total 0.000027 5.929275e-06
|
||||
9 1 2 1 4 1 total 0.000061 1.359998e-05
|
||||
10 1 2 1 5 1 total 0.000029 6.491514e-06
|
||||
11 1 2 1 6 1 total 0.000011 2.575232e-06
|
||||
12 2 1 1 1 1 total 0.000004 6.988358e-07
|
||||
13 2 1 1 2 1 total 0.000023 4.116310e-06
|
||||
14 2 1 1 3 1 total 0.000021 3.817611e-06
|
||||
15 2 1 1 4 1 total 0.000049 8.889347e-06
|
||||
16 2 1 1 5 1 total 0.000024 4.380665e-06
|
||||
17 2 1 1 6 1 total 0.000009 1.746558e-06
|
||||
18 2 2 1 1 1 total 0.000004 1.661116e-06
|
||||
19 2 2 1 2 1 total 0.000025 9.704053e-06
|
||||
20 2 2 1 3 1 total 0.000023 9.007295e-06
|
||||
21 2 2 1 4 1 total 0.000054 2.084505e-05
|
||||
22 2 2 1 5 1 total 0.000026 9.981347e-06
|
||||
23 2 2 1 6 1 total 0.000010 3.988280e-06
|
||||
mesh 1 delayedgroup group out nuclide mean std. dev.
|
||||
x y z
|
||||
0 1 1 1 1 1 total 0 0.000000
|
||||
1 1 1 1 2 1 total 0 0.000000
|
||||
2 1 1 1 3 1 total 0 0.000000
|
||||
3 1 1 1 4 1 total 1 1.414214
|
||||
4 1 1 1 5 1 total 0 0.000000
|
||||
5 1 1 1 6 1 total 0 0.000000
|
||||
6 1 2 1 1 1 total 0 0.000000
|
||||
7 1 2 1 2 1 total 0 0.000000
|
||||
8 1 2 1 3 1 total 0 0.000000
|
||||
9 1 2 1 4 1 total 0 0.000000
|
||||
10 1 2 1 5 1 total 0 0.000000
|
||||
11 1 2 1 6 1 total 0 0.000000
|
||||
12 2 1 1 1 1 total 0 0.000000
|
||||
13 2 1 1 2 1 total 0 0.000000
|
||||
14 2 1 1 3 1 total 0 0.000000
|
||||
15 2 1 1 4 1 total 0 0.000000
|
||||
16 2 1 1 5 1 total 0 0.000000
|
||||
17 2 1 1 6 1 total 0 0.000000
|
||||
18 2 2 1 1 1 total 0 0.000000
|
||||
19 2 2 1 2 1 total 0 0.000000
|
||||
20 2 2 1 3 1 total 0 0.000000
|
||||
21 2 2 1 4 1 total 0 0.000000
|
||||
22 2 2 1 5 1 total 0 0.000000
|
||||
23 2 2 1 6 1 total 0 0.000000
|
||||
mesh 1 delayedgroup group in nuclide mean std. dev.
|
||||
x y z
|
||||
0 1 1 1 1 1 total 0.000166 0.000023
|
||||
1 1 1 1 2 1 total 0.000990 0.000136
|
||||
2 1 1 1 3 1 total 0.000907 0.000123
|
||||
3 1 1 1 4 1 total 0.002088 0.000282
|
||||
4 1 1 1 5 1 total 0.001014 0.000137
|
||||
5 1 1 1 6 1 total 0.000400 0.000054
|
||||
6 1 2 1 1 1 total 0.000171 0.000039
|
||||
7 1 2 1 2 1 total 0.001003 0.000226
|
||||
8 1 2 1 3 1 total 0.000919 0.000208
|
||||
9 1 2 1 4 1 total 0.002101 0.000478
|
||||
10 1 2 1 5 1 total 0.000997 0.000228
|
||||
11 1 2 1 6 1 total 0.000395 0.000090
|
||||
12 2 1 1 1 1 total 0.000168 0.000030
|
||||
13 2 1 1 2 1 total 0.001003 0.000178
|
||||
14 2 1 1 3 1 total 0.000927 0.000165
|
||||
15 2 1 1 4 1 total 0.002150 0.000385
|
||||
16 2 1 1 5 1 total 0.001057 0.000190
|
||||
17 2 1 1 6 1 total 0.000418 0.000076
|
||||
18 2 2 1 1 1 total 0.000171 0.000082
|
||||
19 2 2 1 2 1 total 0.001010 0.000481
|
||||
20 2 2 1 3 1 total 0.000932 0.000445
|
||||
21 2 2 1 4 1 total 0.002151 0.001030
|
||||
22 2 2 1 5 1 total 0.001030 0.000493
|
||||
23 2 2 1 6 1 total 0.000410 0.000197
|
||||
84
tests/test_mdgxs_library_mesh/test_mdgxs_library_mesh.py
Normal file
84
tests/test_mdgxs_library_mesh/test_mdgxs_library_mesh.py
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
import sys
|
||||
import glob
|
||||
import hashlib
|
||||
sys.path.insert(0, os.pardir)
|
||||
from testing_harness import PyAPITestHarness
|
||||
import openmc
|
||||
import openmc.mgxs
|
||||
|
||||
|
||||
class MDGXSTestHarness(PyAPITestHarness):
|
||||
def _build_inputs(self):
|
||||
# Generate inputs using parent class routine
|
||||
super(MDGXSTestHarness, self)._build_inputs()
|
||||
|
||||
# Initialize a one-group structure
|
||||
energy_groups = openmc.mgxs.EnergyGroups(group_edges=[0, 20.])
|
||||
|
||||
# Initialize a six-group structure
|
||||
delayed_groups = openmc.mgxs.DelayedGroups(range(1,7))
|
||||
|
||||
# Initialize MGXS Library for a few cross section types
|
||||
# for one material-filled cell in the geometry
|
||||
self.mgxs_lib = openmc.mgxs.Library(self._input_set.geometry)
|
||||
self.mgxs_lib.by_nuclide = False
|
||||
|
||||
# Test all MDGXS types
|
||||
self.mgxs_lib.mgxs_types = openmc.mgxs.MDGXS_TYPES
|
||||
self.mgxs_lib.energy_groups = energy_groups
|
||||
self.mgxs_lib.delayed_groups = delayed_groups
|
||||
self.mgxs_lib.domain_type = 'mesh'
|
||||
|
||||
# Instantiate a tally mesh
|
||||
mesh = openmc.Mesh(mesh_id=1)
|
||||
mesh.type = 'regular'
|
||||
mesh.dimension = [2, 2]
|
||||
mesh.lower_left = [-100., -100.]
|
||||
mesh.width = [100., 100.]
|
||||
|
||||
self.mgxs_lib.domains = [mesh]
|
||||
self.mgxs_lib.build_library()
|
||||
|
||||
# Initialize a tallies file
|
||||
self._input_set.tallies = openmc.Tallies()
|
||||
self.mgxs_lib.add_to_tallies_file(self._input_set.tallies, merge=False)
|
||||
self._input_set.tallies.export_to_xml()
|
||||
|
||||
def _get_results(self, hash_output=False):
|
||||
"""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 = openmc.StatePoint(statepoint)
|
||||
|
||||
# Load the MGXS library from the statepoint
|
||||
self.mgxs_lib.load_from_statepoint(sp)
|
||||
|
||||
# Build a string from Pandas Dataframe for each 1-group MGXS
|
||||
outstr = ''
|
||||
for domain in self.mgxs_lib.domains:
|
||||
for mgxs_type in self.mgxs_lib.mgxs_types:
|
||||
mgxs = self.mgxs_lib.get_mgxs(domain, mgxs_type)
|
||||
df = mgxs.get_pandas_dataframe()
|
||||
outstr += df.to_string() + '\n'
|
||||
|
||||
# Hash the results if necessary
|
||||
if hash_output:
|
||||
sha512 = hashlib.sha512()
|
||||
sha512.update(outstr.encode('utf-8'))
|
||||
outstr = sha512.hexdigest()
|
||||
|
||||
return outstr
|
||||
|
||||
def _cleanup(self):
|
||||
super(MDGXSTestHarness, self)._cleanup()
|
||||
f = os.path.join(os.getcwd(), 'tallies.xml')
|
||||
if os.path.exists(f): os.remove(f)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
harness = MDGXSTestHarness('statepoint.10.*', True)
|
||||
harness.main()
|
||||
1
tests/test_mdgxs_library_no_nuclides/inputs_true.dat
Normal file
1
tests/test_mdgxs_library_no_nuclides/inputs_true.dat
Normal file
|
|
@ -0,0 +1 @@
|
|||
9e8d8b468bdd81d996956d0d43eef5779b7b7d5ca3f6a1e628f10318748086183e45cf221edf7a274ff2dc6aff34f4411e21952740cdb7652477dfa0a1ffb5f2
|
||||
117
tests/test_mdgxs_library_no_nuclides/results_true.dat
Normal file
117
tests/test_mdgxs_library_no_nuclides/results_true.dat
Normal file
|
|
@ -0,0 +1,117 @@
|
|||
material delayedgroup group in nuclide mean std. dev.
|
||||
1 10000 1 1 total 0.000023 0.000002
|
||||
3 10000 2 1 total 0.000144 0.000011
|
||||
5 10000 3 1 total 0.000151 0.000011
|
||||
7 10000 4 1 total 0.000074 0.000005
|
||||
9 10000 5 1 total 0.000041 0.000003
|
||||
11 10000 6 1 total 0.000017 0.000001
|
||||
0 10000 1 2 total 0.000107 0.000009
|
||||
2 10000 2 2 total 0.000552 0.000049
|
||||
4 10000 3 2 total 0.000527 0.000047
|
||||
6 10000 4 2 total 0.000222 0.000019
|
||||
8 10000 5 2 total 0.000091 0.000008
|
||||
10 10000 6 2 total 0.000038 0.000003
|
||||
material delayedgroup group out nuclide mean std. dev.
|
||||
1 10000 1 1 total 0 0.000000
|
||||
3 10000 2 1 total 1 0.869128
|
||||
5 10000 3 1 total 1 1.414214
|
||||
7 10000 4 1 total 1 0.360359
|
||||
9 10000 5 1 total 0 0.000000
|
||||
11 10000 6 1 total 0 0.000000
|
||||
0 10000 1 2 total 0 0.000000
|
||||
2 10000 2 2 total 0 0.000000
|
||||
4 10000 3 2 total 0 0.000000
|
||||
6 10000 4 2 total 0 0.000000
|
||||
8 10000 5 2 total 0 0.000000
|
||||
10 10000 6 2 total 0 0.000000
|
||||
material delayedgroup group in nuclide mean std. dev.
|
||||
1 10000 1 1 total 0.000049 0.000005
|
||||
3 10000 2 1 total 0.000306 0.000030
|
||||
5 10000 3 1 total 0.000322 0.000031
|
||||
7 10000 4 1 total 0.003822 0.000321
|
||||
9 10000 5 1 total 0.002135 0.000183
|
||||
11 10000 6 1 total 0.000875 0.000075
|
||||
0 10000 1 2 total 0.000228 0.000025
|
||||
2 10000 2 2 total 0.001175 0.000127
|
||||
4 10000 3 2 total 0.001122 0.000122
|
||||
6 10000 4 2 total 0.011426 0.001099
|
||||
8 10000 5 2 total 0.004684 0.000451
|
||||
10 10000 6 2 total 0.001962 0.000189
|
||||
material delayedgroup group in nuclide mean std. dev.
|
||||
1 10001 1 1 total 0 0
|
||||
3 10001 2 1 total 0 0
|
||||
5 10001 3 1 total 0 0
|
||||
7 10001 4 1 total 0 0
|
||||
9 10001 5 1 total 0 0
|
||||
11 10001 6 1 total 0 0
|
||||
0 10001 1 2 total 0 0
|
||||
2 10001 2 2 total 0 0
|
||||
4 10001 3 2 total 0 0
|
||||
6 10001 4 2 total 0 0
|
||||
8 10001 5 2 total 0 0
|
||||
10 10001 6 2 total 0 0
|
||||
material delayedgroup group out nuclide mean std. dev.
|
||||
1 10001 1 1 total 0 0
|
||||
3 10001 2 1 total 0 0
|
||||
5 10001 3 1 total 0 0
|
||||
7 10001 4 1 total 0 0
|
||||
9 10001 5 1 total 0 0
|
||||
11 10001 6 1 total 0 0
|
||||
0 10001 1 2 total 0 0
|
||||
2 10001 2 2 total 0 0
|
||||
4 10001 3 2 total 0 0
|
||||
6 10001 4 2 total 0 0
|
||||
8 10001 5 2 total 0 0
|
||||
10 10001 6 2 total 0 0
|
||||
material delayedgroup group in nuclide mean std. dev.
|
||||
1 10001 1 1 total 0 0
|
||||
3 10001 2 1 total 0 0
|
||||
5 10001 3 1 total 0 0
|
||||
7 10001 4 1 total 0 0
|
||||
9 10001 5 1 total 0 0
|
||||
11 10001 6 1 total 0 0
|
||||
0 10001 1 2 total 0 0
|
||||
2 10001 2 2 total 0 0
|
||||
4 10001 3 2 total 0 0
|
||||
6 10001 4 2 total 0 0
|
||||
8 10001 5 2 total 0 0
|
||||
10 10001 6 2 total 0 0
|
||||
material delayedgroup group in nuclide mean std. dev.
|
||||
1 10002 1 1 total 0 0
|
||||
3 10002 2 1 total 0 0
|
||||
5 10002 3 1 total 0 0
|
||||
7 10002 4 1 total 0 0
|
||||
9 10002 5 1 total 0 0
|
||||
11 10002 6 1 total 0 0
|
||||
0 10002 1 2 total 0 0
|
||||
2 10002 2 2 total 0 0
|
||||
4 10002 3 2 total 0 0
|
||||
6 10002 4 2 total 0 0
|
||||
8 10002 5 2 total 0 0
|
||||
10 10002 6 2 total 0 0
|
||||
material delayedgroup group out nuclide mean std. dev.
|
||||
1 10002 1 1 total 0 0
|
||||
3 10002 2 1 total 0 0
|
||||
5 10002 3 1 total 0 0
|
||||
7 10002 4 1 total 0 0
|
||||
9 10002 5 1 total 0 0
|
||||
11 10002 6 1 total 0 0
|
||||
0 10002 1 2 total 0 0
|
||||
2 10002 2 2 total 0 0
|
||||
4 10002 3 2 total 0 0
|
||||
6 10002 4 2 total 0 0
|
||||
8 10002 5 2 total 0 0
|
||||
10 10002 6 2 total 0 0
|
||||
material delayedgroup group in nuclide mean std. dev.
|
||||
1 10002 1 1 total 0 0
|
||||
3 10002 2 1 total 0 0
|
||||
5 10002 3 1 total 0 0
|
||||
7 10002 4 1 total 0 0
|
||||
9 10002 5 1 total 0 0
|
||||
11 10002 6 1 total 0 0
|
||||
0 10002 1 2 total 0 0
|
||||
2 10002 2 2 total 0 0
|
||||
4 10002 3 2 total 0 0
|
||||
6 10002 4 2 total 0 0
|
||||
8 10002 5 2 total 0 0
|
||||
10 10002 6 2 total 0 0
|
||||
|
|
@ -0,0 +1,80 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
import sys
|
||||
import glob
|
||||
import hashlib
|
||||
sys.path.insert(0, os.pardir)
|
||||
from testing_harness import PyAPITestHarness
|
||||
from input_set import PinCellInputSet
|
||||
import openmc
|
||||
import openmc.mgxs
|
||||
|
||||
|
||||
class MDGXSTestHarness(PyAPITestHarness):
|
||||
def _build_inputs(self):
|
||||
# Set the input set to use the pincell model
|
||||
self._input_set = PinCellInputSet()
|
||||
|
||||
# Generate inputs using parent class routine
|
||||
super(MDGXSTestHarness, self)._build_inputs()
|
||||
|
||||
# Initialize a two-group structure
|
||||
energy_groups = openmc.mgxs.EnergyGroups(group_edges=[0, 0.625e-6,
|
||||
20.])
|
||||
|
||||
# Initialize a six-group structure
|
||||
delayed_groups = openmc.mgxs.DelayedGroups(range(1,7))
|
||||
|
||||
# Initialize MGXS Library for a few cross section types
|
||||
self.mgxs_lib = openmc.mgxs.Library(self._input_set.geometry)
|
||||
self.mgxs_lib.by_nuclide = False
|
||||
|
||||
# Test all MDGXS types
|
||||
self.mgxs_lib.mgxs_types = openmc.mgxs.MDGXS_TYPES
|
||||
self.mgxs_lib.energy_groups = energy_groups
|
||||
self.mgxs_lib.delayed_groups = delayed_groups
|
||||
self.mgxs_lib.domain_type = 'material'
|
||||
self.mgxs_lib.build_library()
|
||||
|
||||
# Initialize a tallies file
|
||||
self._input_set.tallies = openmc.Tallies()
|
||||
self.mgxs_lib.add_to_tallies_file(self._input_set.tallies, merge=False)
|
||||
self._input_set.tallies.export_to_xml()
|
||||
|
||||
def _get_results(self, hash_output=False):
|
||||
"""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 = openmc.StatePoint(statepoint)
|
||||
|
||||
# Load the MGXS library from the statepoint
|
||||
self.mgxs_lib.load_from_statepoint(sp)
|
||||
|
||||
# Build a string from Pandas Dataframe for each MGXS
|
||||
outstr = ''
|
||||
for domain in self.mgxs_lib.domains:
|
||||
for mgxs_type in self.mgxs_lib.mgxs_types:
|
||||
mgxs = self.mgxs_lib.get_mgxs(domain, mgxs_type)
|
||||
df = mgxs.get_pandas_dataframe()
|
||||
outstr += df.to_string() + '\n'
|
||||
|
||||
# Hash the results if necessary
|
||||
if hash_output:
|
||||
sha512 = hashlib.sha512()
|
||||
sha512.update(outstr.encode('utf-8'))
|
||||
outstr = sha512.hexdigest()
|
||||
|
||||
return outstr
|
||||
|
||||
|
||||
def _cleanup(self):
|
||||
super(MDGXSTestHarness, self)._cleanup()
|
||||
f = os.path.join(os.getcwd(), 'tallies.xml')
|
||||
if os.path.exists(f): os.remove(f)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
harness = MDGXSTestHarness('statepoint.10.*', True)
|
||||
harness.main()
|
||||
1
tests/test_mdgxs_library_nuclides/inputs_true.dat
Normal file
1
tests/test_mdgxs_library_nuclides/inputs_true.dat
Normal file
|
|
@ -0,0 +1 @@
|
|||
1cf1a4e8f46f3a5e4bb2824b8b3e4f4af5b43f12e0025ef98f7f54e3212305d8ec4334b3dffeab0e0df94de2eedae2d4aa4d0f15649129264a1cc3e3f9d08b58
|
||||
1
tests/test_mdgxs_library_nuclides/results_true.dat
Normal file
1
tests/test_mdgxs_library_nuclides/results_true.dat
Normal file
|
|
@ -0,0 +1 @@
|
|||
7a6b9ba8f6289f1dac2d474f88003561a0179b45db58eedd671583eced3952f9ed708c1e35248351e469d511a6d99d33e02a9ba5135a0123f7f9c474c4e55a68
|
||||
|
|
@ -0,0 +1,80 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
import sys
|
||||
import glob
|
||||
import hashlib
|
||||
sys.path.insert(0, os.pardir)
|
||||
from testing_harness import PyAPITestHarness
|
||||
from input_set import PinCellInputSet
|
||||
import openmc
|
||||
import openmc.mgxs
|
||||
|
||||
|
||||
class MDGXSTestHarness(PyAPITestHarness):
|
||||
def _build_inputs(self):
|
||||
# Set the input set to use the pincell model
|
||||
self._input_set = PinCellInputSet()
|
||||
|
||||
# Generate inputs using parent class routine
|
||||
super(MDGXSTestHarness, self)._build_inputs()
|
||||
|
||||
# Initialize a two-group structure
|
||||
energy_groups = openmc.mgxs.EnergyGroups(group_edges=[0, 0.625e-6,
|
||||
20.])
|
||||
|
||||
# Initialize a six-group structure
|
||||
delayed_groups = openmc.mgxs.DelayedGroups(range(1,7))
|
||||
|
||||
# Initialize MGXS Library for a few cross section types
|
||||
self.mgxs_lib = openmc.mgxs.Library(self._input_set.geometry)
|
||||
self.mgxs_lib.by_nuclide = True
|
||||
|
||||
# Test all MDGXS types
|
||||
self.mgxs_lib.mgxs_types = openmc.mgxs.MDGXS_TYPES
|
||||
self.mgxs_lib.energy_groups = energy_groups
|
||||
self.mgxs_lib.delayed_groups = delayed_groups
|
||||
self.mgxs_lib.domain_type = 'material'
|
||||
self.mgxs_lib.build_library()
|
||||
|
||||
# Initialize a tallies file
|
||||
self._input_set.tallies = openmc.Tallies()
|
||||
self.mgxs_lib.add_to_tallies_file(self._input_set.tallies, merge=False)
|
||||
self._input_set.tallies.export_to_xml()
|
||||
|
||||
def _get_results(self, hash_output=True):
|
||||
"""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 = openmc.StatePoint(statepoint)
|
||||
|
||||
# Load the MGXS library from the statepoint
|
||||
self.mgxs_lib.load_from_statepoint(sp)
|
||||
|
||||
# Build a string from Pandas Dataframe for each MGXS
|
||||
outstr = ''
|
||||
for domain in self.mgxs_lib.domains:
|
||||
for mgxs_type in self.mgxs_lib.mgxs_types:
|
||||
mgxs = self.mgxs_lib.get_mgxs(domain, mgxs_type)
|
||||
df = mgxs.get_pandas_dataframe()
|
||||
outstr += df.to_string() + '\n'
|
||||
|
||||
# Hash the results if necessary
|
||||
if hash_output:
|
||||
sha512 = hashlib.sha512()
|
||||
sha512.update(outstr.encode('utf-8'))
|
||||
outstr = sha512.hexdigest()
|
||||
|
||||
return outstr
|
||||
|
||||
|
||||
def _cleanup(self):
|
||||
super(MDGXSTestHarness, self)._cleanup()
|
||||
f = os.path.join(os.getcwd(), 'tallies.xml')
|
||||
if os.path.exists(f): os.remove(f)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
harness = MDGXSTestHarness('statepoint.10.*', True)
|
||||
harness.main()
|
||||
Loading…
Add table
Add a link
Reference in a new issue