Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Chain.form_matrix to work with scipy 1.12 #2922

Merged
merged 1 commit into from
Mar 23, 2024

Conversation

paulromano
Copy link
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
18 checks passed
@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
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