diff --git a/openmc/deplete/chain.py b/openmc/deplete/chain.py index 60716895548..76b842fc90d 100644 --- a/openmc/deplete/chain.py +++ b/openmc/deplete/chain.py @@ -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 @@ -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 diff --git a/tests/unit_tests/test_deplete_chain.py b/tests/unit_tests/test_deplete_chain.py index e4e0231355f..77c7dd03d50 100644 --- a/tests/unit_tests/test_deplete_chain.py +++ b/tests/unit_tests/test_deplete_chain.py @@ -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 @@ -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()