From 73a3ad3e5ee26386259dbeb66f17f2a9f6445e61 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Fri, 16 Aug 2019 16:13:33 -0500 Subject: [PATCH] Guard against using FPY tally results if not needed If there are no nuclides with multiple sets of yields, then the tallies needed for fission yields may or or may not exist. Regardless, this means that using constant_yields is absolutely appropriate and there is no need for unpacking on FissionYieldCutoffHelper nor AveragedFissionYieldHelper. The weighted_yields methods for these two classes simply return the set of constant yields if this is the case. --- openmc/deplete/abc.py | 5 ++++- openmc/deplete/helpers.py | 12 +++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/openmc/deplete/abc.py b/openmc/deplete/abc.py index 56914367e2..4406614eb4 100644 --- a/openmc/deplete/abc.py +++ b/openmc/deplete/abc.py @@ -556,8 +556,11 @@ class TalliedFissionYieldHelper(FissionYieldHelper): """ overlap = set(self._chain_nuclides).intersection(set(nuclides)) if len(overlap) == 0: + if self._fission_rate_tally is None: + # No tally to update + return tuple() # tally no nuclides, but keep the Tally alive - self._fission_rate_tally.nuclides = None + self._fission_rate_tally.nuclides = [] self._tally_nucs = [] return tuple() nuclides = tuple(sorted(overlap)) diff --git a/openmc/deplete/helpers.py b/openmc/deplete/helpers.py index 3303dd4e40..1336af7e69 100644 --- a/openmc/deplete/helpers.py +++ b/openmc/deplete/helpers.py @@ -390,6 +390,9 @@ class FissionYieldCutoffHelper(TalliedFissionYieldHelper): def unpack(self): """Obtain fast and thermal fission fractions from tally""" + if not self._tally_nucs: + self.results = None + return fission_rates = self._fission_rate_tally.results[..., 1].reshape( self.n_bmats, 2, len(self._tally_nucs)) self.results = fission_rates[self._local_indexes] @@ -424,8 +427,10 @@ class FissionYieldCutoffHelper(TalliedFissionYieldHelper): library : dict Dictionary of ``{parent: {product: fyield}}`` """ - rates = self.results[local_mat_index] yields = self.constant_yields + if not self._tally_nucs: + return yields + rates = self.results[local_mat_index] # iterate over thermal then fast yields, prefer __mul__ to __rmul__ for therm_frac, nuc in zip(rates[0], self._tally_nucs): yields[nuc.name] = self._thermal_yields[nuc.name] * therm_frac @@ -528,6 +533,9 @@ class AveragedFissionYieldHelper(TalliedFissionYieldHelper): def unpack(self): """Unpack tallies and populate :attr:`results` with average energies""" + if not self._tally_nucs: + self.results = None + return fission_results = ( self._fission_rate_tally.results[self._local_indexes, :, 1]) self.results = ( @@ -556,6 +564,8 @@ class AveragedFissionYieldHelper(TalliedFissionYieldHelper): library : dict Dictionary of ``{parent: {product: fyield}}`` """ + if not self._tally_nucs: + return self.constant_yields mat_yields = {} average_energies = self.results[local_mat_index] for avg_e, nuc in zip(average_energies, self._tally_nucs):