From d66556a6375add6c855bae66af6f8a170482fe36 Mon Sep 17 00:00:00 2001 From: "wbinventor@gmail.com" Date: Fri, 26 Feb 2016 19:44:03 -0500 Subject: [PATCH] Addressed comments by @samuelshaner --- openmc/arithmetic.py | 5 ----- openmc/filter.py | 2 ++ openmc/geometry.py | 10 +++++----- openmc/mgxs/mgxs.py | 30 ++++++++++++++++++------------ openmc/tallies.py | 4 ++-- 5 files changed, 27 insertions(+), 24 deletions(-) diff --git a/openmc/arithmetic.py b/openmc/arithmetic.py index 521d33e9f..5271e49a6 100644 --- a/openmc/arithmetic.py +++ b/openmc/arithmetic.py @@ -927,11 +927,6 @@ class AggregateFilter(object): if bin in other.bins: return False - # None of the bins in the other filter should match in this filter - for bin in other.bins: - if bin in self.bins: - return False - # If all conditional checks passed then filters are mergeable return True diff --git a/openmc/filter.py b/openmc/filter.py index 0c45d67d9..67e15605b 100644 --- a/openmc/filter.py +++ b/openmc/filter.py @@ -86,6 +86,8 @@ class Filter(object): else: return False else: + # Compare largest/smallest energy bin edges in energy filters + # This logic is used when merging tallies with energy filters if 'energy' in self.type and 'energy' in other.type: return self.bins[0] >= other.bins[-1] else: diff --git a/openmc/geometry.py b/openmc/geometry.py index 807dcf7c6..ab3af872f 100644 --- a/openmc/geometry.py +++ b/openmc/geometry.py @@ -253,7 +253,7 @@ class Geometry(object): """ - if case_sensitive: + if not case_sensitive: name = name.lower() all_materials = self.get_all_materials() @@ -293,7 +293,7 @@ class Geometry(object): """ - if case_sensitive: + if not case_sensitive: name = name.lower() all_cells = self.get_all_cells() @@ -333,7 +333,7 @@ class Geometry(object): """ - if case_sensitive: + if not case_sensitive: name = name.lower() all_cells = self.get_all_cells() @@ -373,7 +373,7 @@ class Geometry(object): """ - if case_sensitive: + if not case_sensitive: name = name.lower() all_universes = self.get_all_universes() @@ -413,7 +413,7 @@ class Geometry(object): """ - if case_sensitive: + if not case_sensitive: name = name.lower() all_lattices = self.get_all_lattices() diff --git a/openmc/mgxs/mgxs.py b/openmc/mgxs/mgxs.py index 022acef5f..ce02a4393 100644 --- a/openmc/mgxs/mgxs.py +++ b/openmc/mgxs/mgxs.py @@ -241,8 +241,7 @@ class MGXS(object): @property def num_subdomains(self): - tally = list(self.tallies.values())[0] - domain_filter = tally.find_filter(self.domain_type) + domain_filter = self.xs_tally.find_filter(self.domain_type) return domain_filter.num_bins @property @@ -877,14 +876,19 @@ class MGXS(object): # Clone this MGXS to initialize the subdomain-averaged version avg_xs = copy.deepcopy(self) - avg_xs._rxn_rate_tally = None - avg_xs._xs_tally = None - # Average each of the tallies across subdomains - for tally_type, tally in avg_xs.tallies.items(): - tally_avg = tally.average(filter_type=self.domain_type, - filter_bins=subdomains) - avg_xs.tallies[tally_type] = tally_avg + if self.derived: + avg_xs._rxn_rate_tally = avg_xs.rxn_rate_tally.average( + filter_type=self.domain_type, filter_bins=subdomains) + else: + avg_xs._rxn_rate_tally = None + avg_xs._xs_tally = None + + # Average each of the tallies across subdomains + for tally_type, tally in avg_xs.tallies.items(): + tally_avg = tally.average(filter_type=self.domain_type, + filter_bins=subdomains) + avg_xs.tallies[tally_type] = tally_avg avg_xs._domain_type = 'avg({0})'.format(self.domain_type) avg_xs.sparse = self.sparse @@ -1002,8 +1006,10 @@ class MGXS(object): def merge(self, other): """Merge another MGXS with this one - If results have been loaded from a statepoint, then MGXS are only - mergeable along one and only one of energy groups or nuclides. + MGXS are only mergeable if their energy groups and nuclides are either + identical or mutually exclusive. If results have been loaded from a + statepoint, then MGXS are only mergeable along one and only one of + energy groups or nuclides. Parameters ---------- @@ -1510,7 +1516,7 @@ class TotalXS(MGXS): @property def rxn_rate_tally(self): - if self._rxn_rate_tally is None: + if self._rxn_rate_tally is None : self._rxn_rate_tally = self.tallies['total'] self._rxn_rate_tally.sparse = self.sparse return self._rxn_rate_tally diff --git a/openmc/tallies.py b/openmc/tallies.py index 60200a201..cba7ff927 100644 --- a/openmc/tallies.py +++ b/openmc/tallies.py @@ -881,7 +881,7 @@ class Tally(object): # Differentiate Tally with a new auto-generated Tally ID merged_tally.id = None - # If the two tallies are equal, simpy return copy + # If the two tallies are equal, simply return copy if self == other: return merged_tally @@ -936,7 +936,7 @@ class Tally(object): # If results have not been read, then return tally for input generation if self._results_read is None: return merged_tally - #Otherwise, this is a derived tally which needs merged results arrays + # Otherwise, this is a derived tally which needs merged results arrays else: self._derived = True