diff --git a/openmc/deplete/abc.py b/openmc/deplete/abc.py index 3e1dbde59..7f6de6d62 100644 --- a/openmc/deplete/abc.py +++ b/openmc/deplete/abc.py @@ -480,13 +480,14 @@ class TalliedFissionYieldHelper(FissionYieldHelper): chain_nuclides : iterable of openmc.deplete.Nuclide Nuclides tracked in the depletion chain. Not necessary that all have yield data. - n_bmats : int + n_bmats : int, optional Number of burnable materials tracked in the problem. Attributes ---------- n_bmats : int - Number of burnable materials tracked in the problem + Number of burnable materials tracked in the problem. + Must be set prior to generating tallies constant_yields : dict of str to :class:`openmc.deplete.FissionYield` Fission yields for all nuclides that only have one set of fission yield data. Can be accessed as ``{parent: {product: yield}}`` @@ -494,13 +495,26 @@ class TalliedFissionYieldHelper(FissionYieldHelper): _upper_energy = 20.0e6 # upper energy for tallies - def __init__(self, chain_nuclides, n_bmats): + def __init__(self, chain_nuclides, n_bmats=None): super().__init__(chain_nuclides) self.n_bmats = n_bmats self._local_indexes = None self._fission_rate_tally = None self._tally_index = {} + @property + def n_bmats(self): + return self._n_bmats + + @n_bmats.setter + def n_bmats(self, value): + if value is None: + self._n_bmats = None + return + check_type("n_bmats", value, Integral) + check_greater_than("n_bmats", value, 0) + sef._n_bmats = value + def generate_tallies(self, materials, mat_indexes): """Construct the fission rate tally @@ -512,6 +526,8 @@ class TalliedFissionYieldHelper(FissionYieldHelper): Indexes for materials in ``materials`` tracked on this process """ + if self._n_bmat is None: + raise AttributeError("Number of burnable materials is not set") self._local_indexes = asarray(mat_indexes) # Tally group-wise fission reaction rates diff --git a/openmc/deplete/helpers.py b/openmc/deplete/helpers.py index 37d7359e8..2dae7c036 100644 --- a/openmc/deplete/helpers.py +++ b/openmc/deplete/helpers.py @@ -238,7 +238,7 @@ class FissionYieldCutoffHelper(TalliedFissionYieldHelper): chain_nuclides : iterable of openmc.deplete.Nuclide Nuclides tracked in the depletion chain. Not necessary that all have yield data. - n_bmats : int + n_bmats : int, optional Number of burnable materials tracked in the problem cutoff : float, optional Cutoff energy in [eV] below which all fissions will be @@ -254,7 +254,8 @@ class FissionYieldCutoffHelper(TalliedFissionYieldHelper): Attributes ---------- n_bmats : int - Number of burnable materials tracked in the problem + Number of burnable materials tracked in the problem. + Must be set prior to generating tallies thermal_yields : dict Dictionary of the form ``{parent: {product: yield}}`` with thermal yields