Skip to content

Conversation

yrrepy
Copy link
Contributor

@yrrepy yrrepy commented Sep 25, 2025

Issue

Chain Reduce fails with a vanilla jeff-3.3 chain:

Traceback (most recent call last):
  File "~/OMC-mR2S_v5.py", line 798, in <module>
    chain_reduce(model_n)
  File "~/OMC-mR2S_v5.py", line 84, in chain_reduce
    reduced_chain = chain.reduce(initial_nuclides, level=3)    # reduced to only the isotopes initially present in depletable materials and their possible progeny
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "xxx/site-packages/openmc/deplete/chain.py", line 1177, in reduce
    previous.yield_data.restrict_products(name_sort))
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'restrict_products'

Description

In the reduce method, when processing fission reactions, the code tries to call restrict_products() on previous.yield_data without checking if it's None first.

The issue is that some nuclides in your chain don't have fission yield data (yield_data is None), but the code assumes all fissionable nuclides have this data.

Solution:
Add a null check before calling restrict_products().

Alternative

elif rx.type == "fission":
    try:
        new_yields = new_nuclide.yield_data = (
            previous.yield_data.restrict_products(name_sort))
        if new_yields is not None:
            new_nuclide.add_reaction(*rx)
    except AttributeError:
        # Skip fission reactions with no yield data
        pass

Checklist

  • I have performed a self-review of my own code
  • I have run clang-format (version 15) 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)

Add a null check before calling restrict_products().
@yrrepy yrrepy requested a review from paulromano as a code owner September 25, 2025 19:11
Copy link
Contributor

@paulromano paulromano left a comment

Choose a reason for hiding this comment

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

@yrrepy What is the set of initial isotopes you are feeding it that is leading to that exception? I tried a few random choices but wasn't able to reproduce the behavior yet.

@paulromano
Copy link
Contributor

Also, where are you getting your JEFF 3.3 chain from? I just generated one myself but it took a bit of work to get the neutron fission yield data in there because the file is not properly formatted. Wouldn't be surprised if your chain is indeed just missing fission yields altogether.

@yrrepy
Copy link
Contributor Author

yrrepy commented Oct 8, 2025

Hmm, I'm running down a rabbit hole of what I did.

I used Jon's
https://github.com/openmc-data-storage/openmc_data/blob/main/src/openmc_data/depletion/generate_jeff_chain.py

But looking at it there are not nearly enough <neutron_fission_yields parent="etc.
I guess it's not right or a problem during chain production..
Maybe I should close and re-produce the chain (or use one of the many other ones) and re-visit if it re-occurs.

Separately, when I chain reduce
https://anl.box.com/shared/static/x3kp739hr5upmeqpbwx9zk9ep04fnmtg.xml
I get:
ValueError: Fission product yields for U239 borrow from Pu241, but Pu241 is not present in the chain file or has no yields.

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.

2 participants