Skip to content

Fix Chain.form_matrix to work with scipy 1.12 - #2922

Merged
drewejohnson merged 1 commit into
openmc-dev:developfrom
paulromano:scipy-1.12-fix
Mar 23, 2024
Merged

drewejohnson merged 1 commit into
openmc-dev:developfrom
paulromano:scipy-1.12-fix

Conversation

@paulromano

Copy link
Copy Markdown
Contributor

Description

The release of scipy 1.12 apparently broke OpenMC's depletion solver, which we deployed a temporary workaround for in #2854 by forcing CI to use an older version. This PR fixes the underlying issue so that the depletion solver works with scipy 1.12.

The problem was this line:

dict.update(matrix_dok, matrix)

In this line, matrix_dok is a scipy.sparse.dok_matrix object, which prior to scipy 1.12 directly subclassed the dict class. However, in scipy 1.12 the design was changed so that a dictionary was stored as an attribute rather than the class subclassing dict directly (see scipy/scipy#18929), which breaks the implicit assumption of the line above that it can be treated like a dictionary. The reason this was originally done in OpenMC was because the performance of building a dictionary of (i, j) to matrix element values and then using that to update the DOK matrix all at once was found to be faster than incrementally updating a dok_matrix, but with the updates in scipy 1.12, the performance for this operation directly on the dok_matrix is supposed to be improved. So, my solution in this PR is to get rid of the temporary dict used to map (i, j) to matrix elements and instead update the dok_matrix directly.

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)

@drewejohnson
drewejohnson merged commit ce7efa4 into openmc-dev:develop Mar 23, 2024
@paulromano
paulromano deleted the scipy-1.12-fix branch March 26, 2024 14:44
church89 pushed a commit to openmsr/openmc that referenced this pull request Jul 18, 2024
@paulromano paulromano mentioned this pull request Mar 7, 2025
3 of 5 tasks
apingegno pushed a commit to apingegno/openmc that referenced this pull request May 7, 2026
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