mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-26 21:25:36 -04:00
Change EnergyHelper -> NormalizationHelper
This commit is contained in:
parent
c9120bafbc
commit
bf8405f6cc
4 changed files with 38 additions and 40 deletions
|
|
@ -207,7 +207,7 @@ OpenMC simulations back on to the :class:`abc.TransportOperator`
|
|||
:nosignatures:
|
||||
:template: myclass.rst
|
||||
|
||||
abc.EnergyHelper
|
||||
abc.NormalizationHelper
|
||||
abc.FissionYieldHelper
|
||||
abc.ReactionRateHelper
|
||||
abc.TalliedFissionYieldHelper
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ from .pool import deplete
|
|||
|
||||
__all__ = [
|
||||
"OperatorResult", "TransportOperator", "ReactionRateHelper",
|
||||
"EnergyHelper", "FissionYieldHelper", "TalliedFissionYieldHelper",
|
||||
"NormalizationHelper", "FissionYieldHelper", "TalliedFissionYieldHelper",
|
||||
"Integrator", "SIIntegrator", "DepSystemSolver"]
|
||||
|
||||
|
||||
|
|
@ -302,14 +302,14 @@ class ReactionRateHelper(ABC):
|
|||
return results
|
||||
|
||||
|
||||
class EnergyHelper(ABC):
|
||||
"""Abstract class for obtaining energy produced
|
||||
class NormalizationHelper(ABC):
|
||||
"""Abstract class for obtaining normalization factor on tallies
|
||||
|
||||
The ultimate goal of this helper is to provide instances of
|
||||
:class:`openmc.deplete.Operator` with the total energy produced
|
||||
in a transport simulation. This information, provided with the
|
||||
power requested by the user and reaction rates from a
|
||||
:class:`ReactionRateHelper` will scale reaction rates to the
|
||||
This helper class determines how reaction rates calculated by an instance of
|
||||
:class:`openmc.deplete.Operator` should be normalized for the purpose of
|
||||
constructing a burnup matrix. Based on the method chosen, the power or
|
||||
source rate provided by the user, and reaction rates from a
|
||||
:class:`ReactionRateHelper`, this class will scale reaction rates to the
|
||||
correct values.
|
||||
|
||||
Attributes
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ from openmc.checkvalue import check_type, check_greater_than
|
|||
from openmc.lib import (
|
||||
Tally, MaterialFilter, EnergyFilter, EnergyFunctionFilter)
|
||||
from .abc import (
|
||||
ReactionRateHelper, EnergyHelper, FissionYieldHelper,
|
||||
ReactionRateHelper, NormalizationHelper, FissionYieldHelper,
|
||||
TalliedFissionYieldHelper)
|
||||
|
||||
__all__ = (
|
||||
|
|
@ -91,13 +91,13 @@ class DirectReactionRateHelper(ReactionRateHelper):
|
|||
return self._results_cache
|
||||
|
||||
|
||||
# ----------------------------
|
||||
# Helpers for obtaining energy
|
||||
# ----------------------------
|
||||
# ------------------------------------------
|
||||
# Helpers for obtaining normalization factor
|
||||
# ------------------------------------------
|
||||
|
||||
|
||||
class ChainFissionHelper(EnergyHelper):
|
||||
"""Computes energy using fission Q values from depletion chain
|
||||
class ChainFissionHelper(NormalizationHelper):
|
||||
"""Computes normalization using fission Q values from depletion chain
|
||||
|
||||
Attributes
|
||||
----------
|
||||
|
|
@ -159,7 +159,7 @@ class ChainFissionHelper(EnergyHelper):
|
|||
self._energy += dot(fission_rates, self._fission_q_vector)
|
||||
|
||||
|
||||
class EnergyScoreHelper(EnergyHelper):
|
||||
class EnergyScoreHelper(NormalizationHelper):
|
||||
"""Class responsible for obtaining system energy via a tally score
|
||||
|
||||
Parameters
|
||||
|
|
@ -172,7 +172,7 @@ class EnergyScoreHelper(EnergyHelper):
|
|||
----------
|
||||
nuclides : list of str
|
||||
List of nuclides with reaction rates. Not needed, but provided
|
||||
for a consistent API across other :class:`EnergyHelper`
|
||||
for a consistent API across other :class:`NormalizationHelper`
|
||||
energy : float
|
||||
System energy [eV] computed from the tally. Will be zero for
|
||||
all MPI processes that are not the "master" process to avoid
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ import numpy as np
|
|||
from uncertainties import ufloat
|
||||
|
||||
import openmc
|
||||
from openmc.checkvalue import check_value
|
||||
import openmc.lib
|
||||
from . import comm
|
||||
from .abc import TransportOperator, OperatorResult
|
||||
|
|
@ -81,7 +82,7 @@ class Operator(TransportOperator):
|
|||
Whether to differentiate burnable materials with multiple instances.
|
||||
Volumes are divided equally from the original material volume.
|
||||
Default: False.
|
||||
energy_mode : {"energy-deposition", "fission-q"}
|
||||
normalization_mode : {"energy-deposition", "fission-q", "source-rate"}
|
||||
Indicator for computing system energy. ``"energy-deposition"`` will
|
||||
compute with a single energy deposition tally, taking fission energy
|
||||
release data and heating into consideration. ``"fission-q"`` will
|
||||
|
|
@ -89,7 +90,7 @@ class Operator(TransportOperator):
|
|||
fission_q : dict, optional
|
||||
Dictionary of nuclides and their fission Q values [eV]. If not given,
|
||||
values will be pulled from the ``chain_file``. Only applicable
|
||||
if ``"energy_mode" == "fission-q"``
|
||||
if ``"normalization_mode" == "fission-q"``
|
||||
dilute_initial : float, optional
|
||||
Initial atom density [atoms/cm^3] to add for nuclides that are zero
|
||||
in initial condition to ensure they exist in the decay chain.
|
||||
|
|
@ -164,23 +165,18 @@ class Operator(TransportOperator):
|
|||
}
|
||||
|
||||
def __init__(self, geometry, settings, chain_file=None, prev_results=None,
|
||||
diff_burnable_mats=False, energy_mode="fission-q",
|
||||
diff_burnable_mats=False, normalization_mode="fission-q",
|
||||
fission_q=None, dilute_initial=1.0e3,
|
||||
fission_yield_mode="constant", fission_yield_opts=None,
|
||||
reduce_chain=False, reduce_chain_level=None):
|
||||
if fission_yield_mode not in self._fission_helpers:
|
||||
raise KeyError(
|
||||
"fission_yield_mode must be one of {}, not {}".format(
|
||||
", ".join(self._fission_helpers), fission_yield_mode))
|
||||
if energy_mode == "energy-deposition":
|
||||
check_value('fission yield mode', fission_yield_mode,
|
||||
self._fission_helpers.keys())
|
||||
check_value('normalization mode', normalization_mode,
|
||||
('energy-deposition', 'fission-q', 'source-rate'))
|
||||
if normalization_mode != "fission-q":
|
||||
if fission_q is not None:
|
||||
warn("Fission Q dictionary not used if energy deposition "
|
||||
"is used")
|
||||
warn("Fission Q dictionary will not be used")
|
||||
fission_q = None
|
||||
elif energy_mode != "fission-q":
|
||||
raise ValueError(
|
||||
"energy_mode {} not supported. Must be energy-deposition "
|
||||
"or fission-q".format(energy_mode))
|
||||
super().__init__(chain_file, fission_q, dilute_initial, prev_results)
|
||||
self.round_number = False
|
||||
self.settings = settings
|
||||
|
|
@ -243,11 +239,13 @@ class Operator(TransportOperator):
|
|||
# Get classes to assist working with tallies
|
||||
self._rate_helper = DirectReactionRateHelper(
|
||||
self.reaction_rates.n_nuc, self.reaction_rates.n_react)
|
||||
if energy_mode == "fission-q":
|
||||
self._energy_helper = ChainFissionHelper()
|
||||
else:
|
||||
if normalization_mode == "fission-q":
|
||||
self._normalization_helper = ChainFissionHelper()
|
||||
elif normalization_mode == "energy-deposition":
|
||||
score = "heating" if settings.photon_transport else "heating-local"
|
||||
self._energy_helper = EnergyScoreHelper(score)
|
||||
self._normalization_helper = EnergyScoreHelper(score)
|
||||
else:
|
||||
self._normalization_helper = ...
|
||||
|
||||
# Select and create fission yield helper
|
||||
fission_helper = self._fission_helpers[fission_yield_mode]
|
||||
|
|
@ -286,7 +284,7 @@ class Operator(TransportOperator):
|
|||
self._update_materials()
|
||||
nuclides = self._get_tally_nuclides()
|
||||
self._rate_helper.nuclides = nuclides
|
||||
self._energy_helper.nuclides = nuclides
|
||||
self._normalization_helper.nuclides = nuclides
|
||||
self._yield_helper.update_tally_nuclides(nuclides)
|
||||
|
||||
# Run OpenMC
|
||||
|
|
@ -493,7 +491,7 @@ class Operator(TransportOperator):
|
|||
materials = [openmc.lib.materials[int(i)]
|
||||
for i in self.burnable_mats]
|
||||
self._rate_helper.generate_tallies(materials, self.chain.reactions)
|
||||
self._energy_helper.prepare(
|
||||
self._normalization_helper.prepare(
|
||||
self.chain.nuclides, self.reaction_rates.index_nuc, materials)
|
||||
# Tell fission yield helper what materials this process is
|
||||
# responsible for
|
||||
|
|
@ -643,7 +641,7 @@ class Operator(TransportOperator):
|
|||
|
||||
# Keep track of energy produced from all reactions in eV per source
|
||||
# particle
|
||||
self._energy_helper.reset()
|
||||
self._normalization_helper.reset()
|
||||
self._yield_helper.unpack()
|
||||
|
||||
# Store fission yield dictionaries
|
||||
|
|
@ -674,14 +672,14 @@ class Operator(TransportOperator):
|
|||
fission_yields.append(self._yield_helper.weighted_yields(i))
|
||||
|
||||
# Accumulate energy from fission
|
||||
self._energy_helper.update(tally_rates[:, fission_ind], mat_index)
|
||||
self._normalization_helper.update(tally_rates[:, fission_ind], mat_index)
|
||||
|
||||
# Divide by total number and store
|
||||
rates[i] = self._rate_helper.divide_by_adens(number)
|
||||
|
||||
# Reduce energy produced from all processes
|
||||
# J / s / source neutron
|
||||
energy = comm.allreduce(self._energy_helper.energy)
|
||||
energy = comm.allreduce(self._normalization_helper.energy)
|
||||
|
||||
# Guard against divide by zero
|
||||
if energy == 0:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue