Merge remote-tracking branch 'upstream/develop' into mg

This commit is contained in:
Adam Nelson 2016-02-23 19:42:54 -05:00
commit e9324fc32a
4 changed files with 1479 additions and 1472 deletions

View file

@ -25,6 +25,7 @@ MGXS_TYPES = ['total',
'capture',
'fission',
'nu-fission',
'kappa-fission',
'scatter',
'nu-scatter',
'scatter matrix',
@ -315,7 +316,7 @@ class MGXS(object):
Parameters
----------
mgxs_type : {'total', 'transport', 'absorption', 'capture', 'fission', 'nu-fission', 'scatter', 'nu-scatter', 'scatter matrix', 'nu-scatter matrix', 'chi'}
mgxs_type : {'total', 'transport', 'absorption', 'capture', 'fission', 'nu-fission', 'kappa-fission', 'scatter', 'nu-scatter', 'scatter matrix', 'nu-scatter matrix', 'chi'}
The type of multi-group cross section object to return
domain : Material or Cell or Universe
The domain for spatial homogenization
@ -352,6 +353,8 @@ class MGXS(object):
mgxs = FissionXS(domain, domain_type, energy_groups)
elif mgxs_type == 'nu-fission':
mgxs = NuFissionXS(domain, domain_type, energy_groups)
elif mgxs_type == 'kappa-fission':
mgxs = KappaFissionXS(domain, domain_type, energy_groups)
elif mgxs_type == 'scatter':
mgxs = ScatterXS(domain, domain_type, energy_groups)
elif mgxs_type == 'nu-scatter':
@ -1484,96 +1487,80 @@ class CaptureXS(MGXS):
self._rxn_rate_tally.sparse = self.sparse
return self._rxn_rate_tally
class FissionXSBase(MGXS):
"""A fission production multi-group cross section base class
for NuFission and KappaFission
"""
class FissionXS(MGXS):
# This is an abstract class which cannot be instantiated
__metaclass__ = abc.ABCMeta
def __init__(self, rxn_type, domain=None, domain_type=None,
groups=None, by_nuclide=False, name=''):
super(FissionXSBase, self).__init__(domain, domain_type,
groups, by_nuclide, name)
self._rxn_type = rxn_type
@property
def tallies(self):
"""Construct the OpenMC tallies needed to compute this cross section.
This method constructs two tracklength tallies to compute the 'flux'
and 'rxn_type' reaction rates in the spatial domain and energy
groups of interest.
"""
# Instantiate tallies if they do not exist
if self._tallies is None:
# Create a list of scores for each Tally to be created
scores = ['flux', self._rxn_type]
estimator = 'tracklength'
keys = scores
# Create the non-domain specific Filters for the Tallies
group_edges = self.energy_groups.group_edges
energy_filter = openmc.Filter('energy', group_edges)
filters = [[energy_filter], [energy_filter]]
# Initialize the Tallies
self._create_tallies(scores, filters, keys, estimator)
return self._tallies
@property
def rxn_rate_tally(self):
if self._rxn_rate_tally is None:
self._rxn_rate_tally = self.tallies[self._rxn_type]
self._rxn_rate_tally.sparse = self.sparse
return self._rxn_rate_tally
class FissionXS(FissionXSBase):
"""A fission multi-group cross section."""
def __init__(self, domain=None, domain_type=None,
groups=None, by_nuclide=False, name=''):
super(FissionXS, self).__init__(domain, domain_type,
super(FissionXS, self).__init__('fission', domain, domain_type,
groups, by_nuclide, name)
self._rxn_type = 'fission'
@property
def tallies(self):
"""Construct the OpenMC tallies needed to compute this cross section.
This method constructs two tracklength tallies to compute the 'flux'
and 'fission' reaction rates in the spatial domain and energy
groups of interest.
"""
# Instantiate tallies if they do not exist
if self._tallies is None:
# Create a list of scores for each Tally to be created
scores = ['flux', 'fission']
estimator = 'tracklength'
keys = scores
# Create the non-domain specific Filters for the Tallies
group_edges = self.energy_groups.group_edges
energy_filter = openmc.Filter('energy', group_edges)
filters = [[energy_filter], [energy_filter]]
# Initialize the Tallies
self._create_tallies(scores, filters, keys, estimator)
return self._tallies
@property
def rxn_rate_tally(self):
if self._rxn_rate_tally is None:
self._rxn_rate_tally = self.tallies['fission']
self._rxn_rate_tally.sparse = self.sparse
return self._rxn_rate_tally
class NuFissionXS(MGXS):
class NuFissionXS(FissionXSBase):
"""A fission production multi-group cross section."""
def __init__(self, domain=None, domain_type=None,
groups=None, by_nuclide=False, name=''):
super(NuFissionXS, self).__init__(domain, domain_type,
super(NuFissionXS, self).__init__('nu-fission', domain, domain_type,
groups, by_nuclide, name)
self._rxn_type = 'nu-fission'
@property
def tallies(self):
"""Construct the OpenMC tallies needed to compute this cross section.
This method constructs two tracklength tallies to compute the 'flux'
and 'nu-fission' reaction rates in the spatial domain and energy
groups of interest.
"""
# Instantiate tallies if they do not exist
if self._tallies is None:
# Create a list of scores for each Tally to be created
scores = ['flux', 'nu-fission']
estimator = 'tracklength'
keys = scores
# Create the non-domain specific Filters for the Tallies
group_edges = self.energy_groups.group_edges
energy_filter = openmc.Filter('energy', group_edges)
filters = [[energy_filter], [energy_filter]]
# Initialize the Tallies
self._create_tallies(scores, filters, keys, estimator)
return self._tallies
@property
def rxn_rate_tally(self):
if self._rxn_rate_tally is None:
self._rxn_rate_tally = self.tallies['nu-fission']
self._rxn_rate_tally.sparse = self.sparse
return self._rxn_rate_tally
class KappaFissionXS(FissionXSBase):
"""A recoverable fission energy production rate multi-group cross section."""
def __init__(self, domain=None, domain_type=None,
groups=None, by_nuclide=False, name=''):
super(KappaFissionXS, self).__init__('kappa-fission', domain, domain_type,
groups, by_nuclide, name)
class ScatterXS(MGXS):
"""A scatter multi-group cross section."""

View file

@ -664,7 +664,10 @@ contains
file_id = file_open(path_state_point, 'r', parallel=.true.)
! Read filetype
call read_dataset(file_id, "filetype", int_array(1))
call read_dataset(file_id, "filetype", word)
if (word /= 'statepoint') then
call fatal_error("OpenMC tried to restart from a non-statepoint file.")
end if
! Read revision number for state point file and make sure it matches with
! current version
@ -761,8 +764,13 @@ contains
&file")
end if
! Read tallies to master
! Read tallies to master. If we are using Parallel HDF5, all processes
! need to be included in the HDF5 calls.
#ifdef PHDF5
if (.true.) then
#else
if (master) then
#endif
! Read number of realizations for global tallies
call read_dataset(file_id, "n_realizations", n_realizations, indep=.true.)
@ -772,7 +780,8 @@ contains
! Check if tally results are present
tallies_group = open_group(file_id, "tallies")
call read_dataset(file_id, "tallies_present", int_array(1), indep=.true.)
call read_dataset(tallies_group, "tallies_present", int_array(1), &
indep=.true.)
! Read in sum and sum squared
if (int_array(1) == 1) then
@ -780,10 +789,12 @@ contains
! Set pointer to tally
tally => tallies(i)
! Read sum and sum_sq for each bin
! Read sum, sum_sq, and N for each bin
tally_group = open_group(tallies_group, "tally " // &
trim(to_str(tally%id)))
call read_dataset(tally_group, "results", tally%results)
trim(to_str(tally % id)))
call read_dataset(tally_group, "results", tally % results)
call read_dataset(tally_group, "n_realizations", &
tally % n_realizations)
call close_group(tally_group)
end do TALLY_RESULTS
end if

File diff suppressed because it is too large Load diff

View file

@ -10,6 +10,11 @@ from openmc.executor import Executor
class StatepointRestartTestHarness(TestHarness):
def __init__(self, final_sp, restart_sp, tallies_present=False):
super(StatepointRestartTestHarness, self).__init__(final_sp,
tallies_present)
self._restart_sp = restart_sp
def execute_test(self):
"""Run OpenMC with the appropriate arguments and check the outputs."""
try:
@ -40,7 +45,9 @@ class StatepointRestartTestHarness(TestHarness):
def _run_openmc_restart(self):
# Get the name of the statepoint file.
statepoint = glob.glob(os.path.join(os.getcwd(), self._sp_name))
statepoint = glob.glob(os.path.join(os.getcwd(), self._restart_sp))
assert len(statepoint) == 1
statepoint = statepoint[0]
# Run OpenMC
executor = Executor()
@ -52,11 +59,13 @@ class StatepointRestartTestHarness(TestHarness):
mpi_exec=self._opts.mpi_exec)
else:
returncode = executor.run_simulation(openmc_exec=self._opts.exe)
returncode = executor.run_simulation(openmc_exec=self._opts.exe,
restart_file=statepoint)
assert returncode == 0, 'OpenMC did not exit successfully.'
if __name__ == '__main__':
harness = StatepointRestartTestHarness('statepoint.07.*', True)
harness = StatepointRestartTestHarness('statepoint.10.h5',
'statepoint.07.h5', True)
harness.main()