Skip to content

Adding chain.get_daughter_products#3904

Open
shimwell wants to merge 2 commits intoopenmc-dev:developfrom
shimwell:adding-chain-get-daughter-products
Open

Adding chain.get_daughter_products#3904
shimwell wants to merge 2 commits intoopenmc-dev:developfrom
shimwell:adding-chain-get-daughter-products

Conversation

@shimwell
Copy link
Copy Markdown
Member

@shimwell shimwell commented Mar 27, 2026

Summary

Add Chain.get_decay_daughters() method that returns all radioactive nuclides reachable via decay from a given parent nuclide.

Details

Unlike Chain.reduce(), this method follows only decay paths (not reactions like neutron capture) and returns a set of nuclide names rather than a new Chain.
Stable nuclides are excluded from the result. Cyclic decay chains are handled without infinite loops.

chain = openmc.deplete.Chain.from_xml('chain.xml')
chain.get_decay_daughters('I135')  # {'Xe135'}                                                                                                                          
chain.get_decay_daughters('Xe135')  # set() (Cs135 is stable)                                                                                                           

Fixes # (issue)

Checklist

  • I have performed a self-review of my own code
    - [ ] I have run clang-format (version 18) on any C++ source files (if applicable)
  • I have followed the style guidelines for Python source files (if applicable)
  • I have made corresponding changes to the documentation (if applicable)
  • I have added tests that prove my fix is effective or that my feature works (if applicable)

@shimwell shimwell requested a review from paulromano as a code owner March 27, 2026 15:01
Comment on lines +610 to +612
# Nuclide not in chain returns empty set
daughters = gnd_simple_chain.get_decay_daughters("Xx999")
assert daughters == set()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps it would be better to raise a ValueError if a nuclide is passed that is not in the chain. Do you agree?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants