Skip to content

Commit ae15186

Browse files
restored for compatibility the former api to fetch photon sources
1 parent 58e125a commit ae15186

2 files changed

Lines changed: 27 additions & 4 deletions

File tree

openmc/data/decay.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,30 @@ def sources(self):
564564
_DECAY_PARTICLE_ENERGY = {}
565565

566566

567+
def decay_photon_energy(nuclide: str) -> Univariate | None:
568+
"""Get photon energy distribution resulting from the decay of a nuclide
569+
570+
This function relies on data stored in a depletion chain. Before calling it
571+
for the first time, you need to ensure that a depletion chain has been
572+
specified in openmc.config['chain_file'].
573+
574+
.. versionadded:: 0.13.2
575+
576+
Parameters
577+
----------
578+
nuclide : str
579+
Name of nuclide, e.g., 'Co58'
580+
581+
Returns
582+
-------
583+
openmc.stats.Univariate or None
584+
Distribution of energies in [eV] of photons emitted from decay, or None
585+
if no photon source exists. Note that the probabilities represent
586+
intensities, given as [Bq/atom] (in other words, decay constants).
587+
"""
588+
return decay_particle_energy(nuclide, 'photon')
589+
590+
567591
def decay_particle_energy(nuclide: str, particle: str) -> Univariate | None:
568592
"""Get a decay particle energy distribution resulting from the decay of a nuclide
569593
@@ -651,4 +675,3 @@ def decay_energy(nuclide: str):
651675

652676
return _DECAY_ENERGY.get(nuclide, 0.0)
653677

654-

tests/unit_tests/test_data_decay.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,19 +131,19 @@ def test_decay_photon_energy():
131131
if 'chain_file' in openmc.config:
132132
del openmc.config['chain_file']
133133
with pytest.raises(DataError):
134-
openmc.data.decay_particle_energy('I135','photon')
134+
openmc.data.decay_photon_energy('I135')
135135

136136
# Set chain file to simple chain
137137
openmc.config['chain_file'] = Path(__file__).parents[1] / "chain_simple.xml"
138138

139139
# Check strength of I135 source and presence of specific spectral line
140-
src = openmc.data.decay_particle_energy('I135','photon')
140+
src = openmc.data.decay_photon_energy('I135')
141141
assert isinstance(src, openmc.stats.Discrete)
142142
assert src.integral() == pytest.approx(3.920996223799345e-05)
143143
assert 1260409. in src.x
144144

145145
# Check Xe135 source, which should be tabular
146-
src = openmc.data.decay_particle_energy('Xe135','photon')
146+
src = openmc.data.decay_photon_energy('Xe135')
147147
assert isinstance(src, openmc.stats.Tabular)
148148
assert src.integral() == pytest.approx(2.076506258964966e-05)
149149

0 commit comments

Comments
 (0)