From f72eda7f282f2d79de8466090a6d1bb342a99105 Mon Sep 17 00:00:00 2001 From: Will Boyd Date: Mon, 19 Oct 2015 10:25:45 -0400 Subject: [PATCH] The ScatterMatrixXS now optionally creates tallies for P0 transport correction --- openmc/mgxs/library.py | 4 ++++ openmc/mgxs/mgxs.py | 52 ++++++++++++++++++++++++++++++++++-------- 2 files changed, 46 insertions(+), 10 deletions(-) diff --git a/openmc/mgxs/library.py b/openmc/mgxs/library.py index 8680e726ac..85cfaad3b0 100644 --- a/openmc/mgxs/library.py +++ b/openmc/mgxs/library.py @@ -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 diff --git a/openmc/mgxs/mgxs.py b/openmc/mgxs/mgxs.py index d4e368af5d..aa2abb0de5 100644 --- a/openmc/mgxs/mgxs.py +++ b/openmc/mgxs/mgxs.py @@ -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,