openmc icon indicating copy to clipboard operation
openmc copied to clipboard

Migrate to SciPy sparse arrays

Open paulromano opened this issue 2 months ago • 2 comments

Description

In recent versions of scipy, they have introduced sparse arrays (e.g., csc_array) that generalize the existing sparse matrix classes to N dimensions. The scipy documentation recommends migrating to using sparse arrays rather than sparse matrices. This PR completes that migration for OpenMC, preferentially using sparse arrays for scipy 1.15+ (when they became fully supported) and falling back to sparse matrices for earlier versions.

Checklist

  • [x] I have performed a self-review of my own code
  • [x] I have run clang-format (version 15) on any C++ source files (if applicable)
  • [x] I have followed the style guidelines for Python source files (if applicable)
  • [x] I have made corresponding changes to the documentation (if applicable)
  • [x] I have added tests that prove my fix is effective or that my feature works (if applicable)

paulromano avatar Oct 22 '25 21:10 paulromano

I guess another option is to change the pyproject.toml to ensure scipy 1.115.0 or newer is installed.

shimwell avatar Oct 23 '25 08:10 shimwell

@shimwell We follow SPEC 0 with respect to minimum versions required, which currently says we should support scipy 1.12+

paulromano avatar Oct 23 '25 12:10 paulromano

@eepeterson Correct, at the appropriate point we'll drop the compatibility module and just use the sparse array classes directly from scipy. Also thanks for pointing out those ones I missed in cmfd.py and tallies.py! Those have been updated now.

paulromano avatar Dec 18 '25 05:12 paulromano

Changes in cmfd.py look good to me 👍🏾

shikhar413 avatar Dec 18 '25 06:12 shikhar413