Skip to content

Optimize depletion chain loading and material activity calculations#4025

Open
paulromano wants to merge 3 commits into
openmc-dev:developfrom
paulromano:chain-optimizations
Open

Optimize depletion chain loading and material activity calculations#4025
paulromano wants to merge 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)

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.

1 participant