Skip to content

Optimize depletion chain loading and material activity calculations#4025

Merged
GuySten merged 3 commits into
openmc-dev:developfrom
paulromano:chain-optimizations
Jul 24, 2026
Merged

Optimize depletion chain loading and material activity calculations#4025
GuySten merged 3 commits into
openmc-dev:developfrom
paulromano:chain-optimizations

Conversation

@paulromano

Copy link
Copy Markdown
Contributor

Description

I recently found while profiling a script that analyzed activated material compositions from an R2S calculation that substantial time was being spent repeatedly resolving depletion-chain paths and parsing decay source distributions. This PR fixes this by loading the depletion chain once per Material.get_activity() call, utilizing Path.absolute() instead of Path.resolve(), and simplifying how the chain cache works. It also accelerates chain XML loading by parsing distribution data directly into NumPy arrays, which enables a fast-path when doing type checks.

One other issue I identified along the way: some ENDF decay evaluations indicate an emitted radiation type but provide no corresponding discrete energies or continuous spectrum. These metadata-only records previously produced zero-length distributions and empty <parameters> elements in generated depletion chains. They are now omitted as sources, while existing chain files containing these empty elements remain readable.

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)

@GuySten GuySten left a comment

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.

Looks good to me.

@shimwell shimwell added the Merging Soon PR will be merged in < 24 hrs if no further comments are made. label Jul 23, 2026
@GuySten
GuySten merged commit 0179059 into openmc-dev:develop Jul 24, 2026
18 checks passed
@paulromano
paulromano deleted the chain-optimizations branch July 24, 2026 16:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Merging Soon PR will be merged in < 24 hrs if no further comments are made.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants