From fe7ba998169d3dba1dc3e435aff003a5e19629cf Mon Sep 17 00:00:00 2001 From: Will Boyd Date: Sun, 31 May 2015 13:26:10 -0700 Subject: [PATCH] Added tally arithmetic cross-scores --- src/utils/openmc/tallies.py | 76 +++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) diff --git a/src/utils/openmc/tallies.py b/src/utils/openmc/tallies.py index e5473ca03e..eb3d5046c3 100644 --- a/src/utils/openmc/tallies.py +++ b/src/utils/openmc/tallies.py @@ -145,6 +145,22 @@ class Tally(object): if self.num_realizations == other.num_realizations: new_tally.num_realizations = self.num_realizations + # Generate "cross" scores + # NOTE: This only needs to cross the scores if the + if self.scores != other.scores: + + for self_score in self.scores: + for other_score in other.scores: + new_score = '({0} + {1})'.format(self_score, other_score) + new_tally.add_score(new_score) + + else: + + for score in self.scores: + new_score = '({0} + {1})'.format(score, score) + new_tally.add_score(new_score) + + elif is_integer(other) or is_float(other): new_tally._mean = self._mean + other @@ -206,6 +222,21 @@ class Tally(object): if self.num_realizations == other.num_realizations: new_tally.num_realizations = self.num_realizations + # Generate "cross" scores + # NOTE: This only needs to cross the scores if the + if self.scores != other.scores: + + for self_score in self.scores: + for other_score in other.scores: + new_score = '({0} - {1})'.format(self_score, other_score) + new_tally.add_score(new_score) + + else: + + for score in self.scores: + new_score = '({0} - {1})'.format(score, score) + new_tally.add_score(new_score) + elif is_integer(other) or is_float(other): new_tally._mean = self._mean - other @@ -270,6 +301,21 @@ class Tally(object): if self.num_realizations == other.num_realizations: new_tally.num_realizations = self.num_realizations + # Generate "cross" scores + # NOTE: This only needs to cross the scores if the + if self.scores != other.scores: + + for self_score in self.scores: + for other_score in other.scores: + new_score = '({0} * {1})'.format(self_score, other_score) + new_tally.add_score(new_score) + + else: + + for score in self.scores: + new_score = '({0} * {1})'.format(score, score) + new_tally.add_score(new_score) + elif is_integer(other) or is_float(other): new_tally._mean = self._mean * other @@ -334,6 +380,21 @@ class Tally(object): if self.num_realizations == other.num_realizations: new_tally.num_realizations = self.num_realizations + # Generate "cross" scores + # NOTE: This only needs to cross the scores if the + if self.scores != other.scores: + + for self_score in self.scores: + for other_score in other.scores: + new_score = '({0} / {1})'.format(self_score, other_score) + new_tally.add_score(new_score) + + else: + + for score in self.scores: + new_score = '({0} / {1})'.format(score, score) + new_tally.add_score(new_score) + elif is_integer(other) or is_float(other): new_tally._mean = self._mean / other @@ -399,6 +460,21 @@ class Tally(object): if self.num_realizations == power.num_realizations: new_tally.num_realizations = self.num_realizations + # Generate "cross" scores + # NOTE: This only needs to cross the scores if the + if self.scores != power.scores: + + for self_score in self.scores: + for power_score in power.scores: + new_score = '({0} ^ {1})'.format(self_score, power_score) + new_tally.add_score(new_score) + + else: + + for score in self.scores: + new_score = '({0} ^ {1})'.format(score, score) + new_tally.add_score(new_score) + elif is_integer(power) or is_float(power): new_tally._mean = self._mean ** power