Skip to content

Commit 2d8e006

Browse files
yrrepypaulromano
andauthored
Enable nuclide filters with get_decay_photon_energy (#3614)
Co-authored-by: Paul Romano <paul.k.romano@gmail.com>
1 parent fd964bc commit 2d8e006

File tree

1 file changed

+25
-9
lines changed

1 file changed

+25
-9
lines changed

openmc/material.py

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -290,34 +290,45 @@ def decay_photon_energy(self) -> Univariate | None:
290290
return self.get_decay_photon_energy(0.0)
291291

292292
def get_decay_photon_energy(
293-
self,
294-
clip_tolerance: float = 1e-6,
295-
units: str = 'Bq',
296-
volume: float | None = None
297-
) -> Univariate | None:
293+
self,
294+
clip_tolerance: float = 1e-6,
295+
units: str = 'Bq',
296+
volume: float | None = None,
297+
exclude_nuclides: list[str] | None = None,
298+
include_nuclides: list[str] | None = None
299+
) -> Univariate | None:
298300
r"""Return energy distribution of decay photons from unstable nuclides.
299301
300302
.. versionadded:: 0.14.0
301303
302304
Parameters
303305
----------
304306
clip_tolerance : float
305-
Maximum fraction of :math:`\sum_i x_i p_i` for discrete
306-
distributions that will be discarded.
307+
Maximum fraction of :math:`\sum_i x_i p_i` for discrete distributions
308+
that will be discarded.
307309
units : {'Bq', 'Bq/g', 'Bq/kg', 'Bq/cm3'}
308310
Specifies the units on the integral of the distribution.
309311
volume : float, optional
310312
Volume of the material. If not passed, defaults to using the
311313
:attr:`Material.volume` attribute.
314+
exclude_nuclides : list of str, optional
315+
Nuclides to exclude from the photon source calculation.
316+
include_nuclides : list of str, optional
317+
Nuclides to include in the photon source calculation. If specified,
318+
only these nuclides are used.
312319
313320
Returns
314321
-------
315322
Univariate or None
316-
Decay photon energy distribution. The integral of this distribution
317-
is the total intensity of the photon source in the requested units.
323+
Decay photon energy distribution. The integral of this distribution is
324+
the total intensity of the photon source in the requested units.
318325
319326
"""
320327
cv.check_value('units', units, {'Bq', 'Bq/g', 'Bq/kg', 'Bq/cm3'})
328+
329+
if exclude_nuclides is not None and include_nuclides is not None:
330+
raise ValueError("Cannot specify both exclude_nuclides and include_nuclides")
331+
321332
if units == 'Bq':
322333
multiplier = volume if volume is not None else self.volume
323334
if multiplier is None:
@@ -332,6 +343,11 @@ def get_decay_photon_energy(
332343
dists = []
333344
probs = []
334345
for nuc, atoms_per_bcm in self.get_nuclide_atom_densities().items():
346+
if exclude_nuclides is not None and nuc in exclude_nuclides:
347+
continue
348+
if include_nuclides is not None and nuc not in include_nuclides:
349+
continue
350+
335351
source_per_atom = openmc.data.decay_photon_energy(nuc)
336352
if source_per_atom is not None and atoms_per_bcm > 0.0:
337353
dists.append(source_per_atom)

0 commit comments

Comments
 (0)