The ScatterMatrixXS now optionally creates tallies for P0 transport correction

This commit is contained in:
Will Boyd 2015-10-19 10:25:45 -04:00
parent 5b8c683c49
commit f72eda7f28
2 changed files with 46 additions and 10 deletions

View file

@ -244,6 +244,10 @@ class Library(object):
if self.tally_trigger:
mgxs.tally_trigger = self.tally_trigger
# Specify whether to use a transport ('P0') correction
if isinstance(mgxs, openmc.mgxs.ScatterMatrixXS):
mgxs.correction = self.correction
mgxs.create_tallies()
self.all_mgxs[domain.id][mgxs_type] = mgxs

View file

@ -1603,13 +1603,35 @@ class NuScatterXS(MGXS):
class ScatterMatrixXS(MGXS):
"""A scattering matrix multi-group cross section."""
"""A scattering matrix multi-group cross section.
Attributes
----------
correction : 'P0' or None
Apply the P0 correction to scattering matrices if set to 'P0'
"""
def __init__(self, domain=None, domain_type=None,
groups=None, by_nuclide=False, name=''):
super(ScatterMatrixXS, self).__init__(domain, domain_type,
groups, by_nuclide, name)
self._rxn_type = 'scatter matrix'
self._correction = 'P0'
def __deepcopy__(self, memo):
clone = super(ScatterMatrixXS, self).__deepcopy__(memo)
clone._correction = self.correction
return clone
@property
def correction(self):
return self._correction
@correction.setter
def correction(self, correction):
cv.check_value('correction', correction, ('P0', None))
self._correction = correction
def create_tallies(self):
"""Construct the OpenMC tallies needed to compute this cross section.
@ -1625,8 +1647,12 @@ class ScatterMatrixXS(MGXS):
energyout = openmc.Filter('energyout', group_edges)
# Create a list of scores for each Tally to be created
scores = ['flux', 'scatter', 'scatter-P1']
filters = [[energy], [energy, energyout], [energyout]]
if self.correction == 'P0':
scores = ['flux', 'scatter', 'scatter-P1']
filters = [[energy], [energy, energyout], [energyout]]
else:
scores = ['flux', 'scatter']
filters = [[energy], [energy, energyout]]
estimator = 'analog'
keys = scores
@ -1648,7 +1674,7 @@ class ScatterMatrixXS(MGXS):
"""
# If using P0 correction subtract scatter-P1 from the diagonal
if correction == 'P0':
if self.correction == 'P0':
scatter_p1 = self.tallies['scatter-P1']
scatter_p1 = scatter_p1.get_slice(scores=['scatter-P1'])
energy_filter = openmc.Filter(type='energy')
@ -1924,16 +1950,22 @@ class NuScatterMatrixXS(ScatterMatrixXS):
"""
# Create a list of scores for each Tally to be created
scores = ['flux', 'nu-scatter', 'scatter-P1']
estimator = 'analog'
keys = ['flux', 'scatter', 'scatter-P1']
# Create the non-domain specific Filters for the Tallies
group_edges = self.energy_groups.group_edges
energy = openmc.Filter('energy', group_edges)
energyout = openmc.Filter('energyout', group_edges)
filters = [[energy], [energy, energyout], [energyout]]
# Create a list of scores for each Tally to be created
if self.correction == 'P0':
scores = ['flux', 'nu-scatter', 'scatter-P1']
estimator = 'analog'
keys = ['flux', 'scatter', 'scatter-P1']
filters = [[energy], [energy, energyout], [energyout]]
else:
scores = ['flux', 'nu-scatter']
estimator = 'analog'
keys = ['flux', 'scatter']
filters = [[energy], [energy, energyout]]
# Intialize the Tallies
super(ScatterMatrixXS, self).create_tallies(scores, filters,