From 4bf7fe5104b34af559fbd465ae0ef51c176462c1 Mon Sep 17 00:00:00 2001 From: Will Boyd Date: Sat, 26 Sep 2015 12:18:03 -0400 Subject: [PATCH] Fixed issue in Filter.is_subset(...) routine for energy filter types --- openmc/filter.py | 2 ++ openmc/mgxs/mgxs.py | 15 +++++++++------ openmc/statepoint.py | 11 +++++------ 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/openmc/filter.py b/openmc/filter.py index fdeebaf8ae..5c97fb9e35 100644 --- a/openmc/filter.py +++ b/openmc/filter.py @@ -322,6 +322,8 @@ class Filter(object): return False elif self.type != other.type: return False + elif self.type in ['energy', 'energyout']: + return np.all(self.bins == other.bins) for bin in other.bins: if bin not in self.bins: diff --git a/openmc/mgxs/mgxs.py b/openmc/mgxs/mgxs.py index 332eb7190a..98248dc871 100644 --- a/openmc/mgxs/mgxs.py +++ b/openmc/mgxs/mgxs.py @@ -840,6 +840,7 @@ class TransportXS(MultiGroupXS): super(TransportXS, self).load_from_statepoint(statepoint) scatter_p1 = self.tallies['scatter-P1'] self.tallies['scatter-P1'] = scatter_p1.get_slice(scores=['scatter-P1']) + self.tallies['scatter-P1'].filters[-1].type = 'energy' def compute_xs(self): """Computes the multi-group transport cross-sections using OpenMC @@ -1061,7 +1062,7 @@ class ScatterMatrixXS(MultiGroupXS): # Initialize the Tallies super(ScatterMatrixXS, self).create_tallies(scores, filters, keys, estimator) - def compute_xs(self, correction='None'): + def compute_xs(self, correction='P0'): """Computes the multi-group scattering matrix using OpenMC tally arithmetic. @@ -1075,7 +1076,7 @@ class ScatterMatrixXS(MultiGroupXS): # If using P0 correction subtract scatter-P1 from the diagonal if correction == 'P0': - scatter_p1 = self.tallies['scatter-1'] + scatter_p1 = self.tallies['scatter-P1'] scatter_p1 = scatter_p1.get_slice(scores=['scatter-P1']) energy_filter = openmc.Filter(type='energy') energy_filter.bins = self.energy_groups.group_edges @@ -1245,7 +1246,7 @@ class NuScatterMatrixXS(ScatterMatrixXS): # Intialize the Tallies super(ScatterMatrixXS, self).create_tallies(scores, filters, keys, estimator) - def compute_xs(self, correction='None'): + def compute_xs(self, correction='P0'): """Computes the multi-group nu-scattering matrix using OpenMC tally arithmetic. @@ -1259,7 +1260,7 @@ class NuScatterMatrixXS(ScatterMatrixXS): # If using P0 correction subtract scatter-P1 from the diagonal if correction == 'P0': - scatter_p1 = self.tallies['scatter-1'] + scatter_p1 = self.tallies['scatter-P1'] scatter_p1 = scatter_p1.get_slice(scores=['scatter-P1']) energy_filter = openmc.Filter(type='energy') energy_filter.bins = self.energy_groups.group_edges @@ -1288,8 +1289,9 @@ class Chi(MultiGroupXS): # Create the non-domain specific Filters for the Tallies group_edges = self.energy_groups.group_edges - energyout_filter = openmc.Filter('energyout', group_edges) - filters = [[], [energyout_filter]] + energyout_filter1 = openmc.Filter('energyout', group_edges) + energyout_filter2 = openmc.Filter('energyout', [group_edges[0], group_edges[-1]]) + filters = [[energyout_filter2], [energyout_filter1]] # Intialize the Tallies super(Chi, self).create_tallies(scores, filters, keys, estimator) @@ -1299,6 +1301,7 @@ class Chi(MultiGroupXS): nu_fission_in = self.tallies['nu-fission-in'] nu_fission_out = self.tallies['nu-fission-out'] + nu_fission_in.remove_filter(nu_fission_in.filters[-1]) self._xs_tally = nu_fission_out / nu_fission_in self._xs_tally._mean = np.nan_to_num(self.xs_tally.mean) self._xs_tally._std_dev = np.nan_to_num(self.xs_tally.std_dev) diff --git a/openmc/statepoint.py b/openmc/statepoint.py index 34ed09ad42..f90e429cc0 100644 --- a/openmc/statepoint.py +++ b/openmc/statepoint.py @@ -466,7 +466,7 @@ class StatePoint(object): """Finds and returns a Tally object with certain properties. This routine searches the list of Tallies and returns the first Tally - found it finds which satisfies all of the input parameters. + found which satisfies all of the input parameters. NOTE: The input parameters do not need to match the complete Tally specification and may only represent a subset of the Tally's properties. @@ -534,15 +534,14 @@ class StatePoint(object): # Iterate over the Filters requested by the user for filter in filters: - contains_filter = False + contains_filters = False for test_filter in test_tally.filters: - if test_filter.is_subset(filter): - contains_filter = True + if filter.is_subset(test_filter): + contains_filters = True break - if not contains_filter: - contains_filters = False + if not contains_filters: break if not contains_filters: