diff --git a/docs/source/pythonapi/deplete.rst b/docs/source/pythonapi/deplete.rst index e9cd6d305..d4a0f128f 100644 --- a/docs/source/pythonapi/deplete.rst +++ b/docs/source/pythonapi/deplete.rst @@ -181,7 +181,7 @@ total system energy. helpers.DirectReactionRateHelper helpers.EnergyScoreHelper helpers.FissionYieldCutoffHelper - + helpers.FluxCollapseHelper Abstract Base Classes --------------------- diff --git a/openmc/deplete/helpers.py b/openmc/deplete/helpers.py index 11692e1a7..ec51c211c 100644 --- a/openmc/deplete/helpers.py +++ b/openmc/deplete/helpers.py @@ -109,107 +109,6 @@ class FluxCollapseHelper(ReactionRateHelper): .. versionadded:: 0.12.1 - Parameters - ---------- - n_nucs : int - Number of burnable nuclides tracked by :class:`openmc.deplete.Operator` - n_react : int - Number of reactions tracked by :class:`openmc.deplete.Operator` - energies : iterable of float - Energy group boundaries for flux spectrum in [eV] - - Attributes - ---------- - nuclides : list of str - All nuclides with desired reaction rates. - """ - def __init__(self, n_nucs, n_reacts, energies): - super().__init__(n_nucs, n_reacts) - self._energies = asarray(energies) - - def generate_tallies(self, materials, scores): - """Produce multigroup flux spectrum tally - - Uses the :mod:`openmc.lib` module to generate a multigroup flux tally - for each burnable material. - - Parameters - ---------- - materials : iterable of :class:`openmc.Material` - Burnable materials in the problem. Used to construct a - :class:`openmc.MaterialFilter` - scores : iterable of str - Reaction identifiers, e.g. ``"(n, fission)"``, ``"(n, gamma)"``, - needed for the reaction rate tally. - """ - self._materials = materials - - # Convert reactions to MT values (needed when collapsing) - mt_values = {v: k for k, v in REACTION_NAME.items()} - mt_values['fission'] = 18 - self._mts = [mt_values[x] for x in scores] - - # Create flux tally with material and energy filters - self._flux_tally = Tally() - self._flux_tally.writable = False - self._flux_tally.filters = [ - MaterialFilter(materials), - EnergyFilter(self._energies) - ] - self._flux_tally.scores = ['flux'] - - def get_material_rates(self, mat_index, nuc_index, react_index): - """Return an array of reaction rates for a material - - Parameters - ---------- - mat_index : int - Index for material - nuc_index : iterable of int - Index for each nuclide in :attr:`nuclides` in the - desired reaction rate matrix - react_index : iterable of int - Index for each reaction scored in the tally - - Returns - ------- - rates : numpy.ndarray - Array with shape ``(n_nuclides, n_rxns)`` with the reaction rates in - this material - - """ - self._results_cache.fill(0.0) - - # Get flux for specified material - shape = (len(self._materials), len(self._energies) - 1) - mean_value = self._flux_tally.mean.reshape(shape) - flux = mean_value[mat_index] - - mat = self._materials[mat_index] - - # Build nucname: density mapping to enable O(1) lookup in loop below - densities = dict(zip(mat.nuclides, mat.densities)) - - for name, i_nuc in zip(self.nuclides, nuc_index): - # Determine density of nuclide - density = densities[name] - - for mt, i_react in zip(self._mts, react_index): - # Use flux to collapse reaction rate (per N) - nuc = openmc.lib.nuclides[name] - rate_per_nuc = nuc.collapse_rate(mt, mat.temperature, self._energies, flux) - - # Multiply by density to get absolute reaction rate - self._results_cache[i_nuc, i_react] = rate_per_nuc * density - - return self._results_cache - - -class HybridReactionHelper(ReactionRateHelper): - """Class that generates tallies for one-group rates - - .. versionadded:: 0.12.1 - Parameters ---------- n_nucs : int diff --git a/openmc/deplete/operator.py b/openmc/deplete/operator.py index bc106278b..1f99abe95 100644 --- a/openmc/deplete/operator.py +++ b/openmc/deplete/operator.py @@ -27,7 +27,7 @@ from .results_list import ResultsList from .helpers import ( DirectReactionRateHelper, ChainFissionHelper, ConstantFissionYieldHelper, FissionYieldCutoffHelper, AveragedFissionYieldHelper, EnergyScoreHelper, - SourceRateHelper, FluxCollapseHelper, HybridReactionHelper) + SourceRateHelper, FluxCollapseHelper) __all__ = ["Operator", "OperatorResult"] @@ -113,16 +113,20 @@ class Operator(TransportOperator): ``fission_yield_mode``. Will be passed directly on to the helper. Passing a value of None will use the defaults for the associated helper. - reaction_rate_mode : {"direct", "flux"} + reaction_rate_mode : {"direct", "flux"}, optional Indicate how one-group reaction rates should be calculated. The "direct" method tallies transmutation reaction rates directly. The "flux" method tallies a multigroup flux spectrum and then collapses one-group reaction - rates after a transport solve. + rates after a transport solve (with an option to tally some reaction + rates directly). .. versionadded:: 0.12.1 - reaction_rate_opts : iterable of float - Energy group boundaries that are to be used for calculating a multigroup - flux spectrum when the "flux" based ``reaction_rate_mode`` is being used. + reaction_rate_opts : dict, optional + Keyword arguments that are passed to the reaction rate helper class. + When ``reaction_rate_mode`` is set to "flux", energy group boundaries + can be set using the "energies" key. See the + :class:`~openmc.deplete.helpers.FluxCollapseHelper` class for all + options. .. versionadded:: 0.12.1 reduce_chain : bool, optional @@ -255,7 +259,7 @@ class Operator(TransportOperator): if reaction_rate_mode == "direct": self._rate_helper = DirectReactionRateHelper( self.reaction_rates.n_nuc, self.reaction_rates.n_react) - elif reaction_rate_mode in ("flux", "hybrid"): + elif reaction_rate_mode == "flux": if reaction_rate_opts is None: reaction_rate_opts = {} @@ -264,15 +268,9 @@ class Operator(TransportOperator): raise ValueError( "Energy group boundaries must be specified in the " "reaction_rate_opts argument when reaction_rate_mode is" - "set to 'flux' or 'hybrid'.") + "set to 'flux'.") - if reaction_rate_mode == "flux": - cls = FluxCollapseHelper - else: - cls = HybridReactionHelper - - - self._rate_helper = cls( + self._rate_helper = FluxCollapseHelper( self.reaction_rates.n_nuc, self.reaction_rates.n_react, **reaction_rate_opts