Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 31 additions & 1 deletion openmc/deplete/chain.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import scipy.sparse as sp

from openmc.checkvalue import check_type, check_greater_than
from openmc.data import gnds_name, zam
from openmc.data import gnds_name, zam, DADZ
from .nuclide import FissionYieldDistribution, Nuclide
import openmc.data

Expand Down Expand Up @@ -742,6 +742,36 @@ def form_rr_term(self, tr_rates, mats):
dict.update(matrix_dok, matrix)
return matrix_dok.tocsc()

def get_reaction_pathways_to_target(self):
"""Return a dictionary with reaction pathways to targets.

Returns
-------
pathways : dict
dict of targets nuclide as keys with a list of reactions and nuclides
as the dictionary value. For example the reaction pathways for Gold

chain.get_reaction_pathways_to_target()["Au197"]
[('Hg197', '(n,p)'), ('Hg197_m1', '(n,p)'),
('Hg198', '(n,np)'), ('Hg198', '(n,d)')]
"""

reaction_pathways = {}
for nuclide in self.nuclides:
for reaction in nuclide.reactions:
# if the reaction changes the A or Z number.
if reaction.type in DADZ.keys():
secondaries = openmc.deplete.REACTIONS[reaction.type].secondaries
# includes secondary such as H1, H2, H3, He3 and He4
for secondary in secondaries:
reaction_pathways.setdefault(
secondary, []
).append((nuclide.name, reaction.type))
reaction_pathways.setdefault(
reaction.target, []
).append((nuclide.name, reaction.type))
return reaction_pathways

def get_branch_ratios(self, reaction="(n,gamma)"):
"""Return a dictionary with reaction branching ratios

Expand Down
13 changes: 13 additions & 0 deletions tests/unit_tests/test_deplete_chain.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import numpy as np
from openmc.mpi import comm
from openmc.deplete import Chain, reaction_rates, nuclide, cram, pool
from openmc.data import zam, REACTION_MT
from openmc.stats import Discrete
import pytest

Expand Down Expand Up @@ -580,3 +581,15 @@ def test_reduce(gnd_simple_chain, endf_chain):
reduced_chain = endf_chain.reduce(['U235'])
assert 'H1' in reduced_chain
assert 'H2' in reduced_chain

def test_chain_sources(gnd_simple_chain):
pathways = gnd_simple_chain.get_reaction_pathways_to_target()
assert isinstance(pathways, dict)
assert isinstance(pathways['Xe136'], list)
assert isinstance(pathways['Xe136'][0], tuple)
assert isinstance(pathways['Xe136'][0][0], str)
assert isinstance(pathways['Xe136'][0][1], str)
for nuc, reaction in pathways['Xe136']:
# checks nuclide is acceptable ZAM
_ = zam(nuc)
assert reaction in REACTION_MT.keys()