Enable nuclide filters with get_decay_photon_energy (#3614)

Co-authored-by: Paul Romano <paul.k.romano@gmail.com>
This commit is contained in:
Perry 2025-11-03 09:10:30 -08:00 committed by GitHub
parent fd964bc9b0
commit 2d8e006c3d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -290,11 +290,13 @@ class Material(IDManagerMixin):
return self.get_decay_photon_energy(0.0)
def get_decay_photon_energy(
self,
clip_tolerance: float = 1e-6,
units: str = 'Bq',
volume: float | None = None
) -> Univariate | None:
self,
clip_tolerance: float = 1e-6,
units: str = 'Bq',
volume: float | None = None,
exclude_nuclides: list[str] | None = None,
include_nuclides: list[str] | None = None
) -> Univariate | None:
r"""Return energy distribution of decay photons from unstable nuclides.
.. versionadded:: 0.14.0
@ -302,22 +304,31 @@ class Material(IDManagerMixin):
Parameters
----------
clip_tolerance : float
Maximum fraction of :math:`\sum_i x_i p_i` for discrete
distributions that will be discarded.
Maximum fraction of :math:`\sum_i x_i p_i` for discrete distributions
that will be discarded.
units : {'Bq', 'Bq/g', 'Bq/kg', 'Bq/cm3'}
Specifies the units on the integral of the distribution.
volume : float, optional
Volume of the material. If not passed, defaults to using the
:attr:`Material.volume` attribute.
exclude_nuclides : list of str, optional
Nuclides to exclude from the photon source calculation.
include_nuclides : list of str, optional
Nuclides to include in the photon source calculation. If specified,
only these nuclides are used.
Returns
-------
Univariate or None
Decay photon energy distribution. The integral of this distribution
is the total intensity of the photon source in the requested units.
Decay photon energy distribution. The integral of this distribution is
the total intensity of the photon source in the requested units.
"""
cv.check_value('units', units, {'Bq', 'Bq/g', 'Bq/kg', 'Bq/cm3'})
if exclude_nuclides is not None and include_nuclides is not None:
raise ValueError("Cannot specify both exclude_nuclides and include_nuclides")
if units == 'Bq':
multiplier = volume if volume is not None else self.volume
if multiplier is None:
@ -332,6 +343,11 @@ class Material(IDManagerMixin):
dists = []
probs = []
for nuc, atoms_per_bcm in self.get_nuclide_atom_densities().items():
if exclude_nuclides is not None and nuc in exclude_nuclides:
continue
if include_nuclides is not None and nuc not in include_nuclides:
continue
source_per_atom = openmc.data.decay_photon_energy(nuc)
if source_per_atom is not None and atoms_per_bcm > 0.0:
dists.append(source_per_atom)