Skip to content

Fix SIP getJ for matrix-free simulations and current receiver projections - #1821

Open
manduinca wants to merge 2 commits into
simpeg:mainfrom
manduinca:codex/fix-sip-getj
Open

manduinca wants to merge 2 commits into
simpeg:mainfrom
manduinca:codex/fix-sip-getj

Conversation

@manduinca

Copy link
Copy Markdown
Contributor

Summary

Closes #1654.

getJ currently assumes the active-cell projection exists even when storeJ=False, then calls the removed receiver method projGLoc. This uses all mesh cells for the matrix-free case and obtains the receiver projection grid from the fields, consistently with receiver evaluation. Stored sensitivities keep their existing active-cell restriction.

The regression tests cover both 3D formulations, pole and dipole receivers, and default/full/subset active-cell arguments. They check matrix shape and values against the matrix-free adjoint operation, predictions, and Jacobian-vector products with an eta/taui model.

Validation

On Python 3.12, the 12 new cases reproduce the two reported AttributeErrors before the fix. With the fix, the regression tests and existing 2D/3D SIP tests pass:

pytest -q tests/em/static/test_sip_getj.py tests/em/static/test_sip_survey.py tests/em/static/test_SIP_jvecjtvecadj.py tests/em/static/test_SIP_2D_jvecjtvecadj.py
# 32 passed
black --check --target-version py312 simpeg/electromagnetics/static/spectral_induced_polarization/simulation.py tests/em/static/test_sip_getj.py
ruff check simpeg/electromagnetics/static/spectral_induced_polarization/simulation.py tests/em/static/test_sip_getj.py
flake8 simpeg/electromagnetics/static/spectral_induced_polarization/simulation.py tests/em/static/test_sip_getj.py

PR Checklist

  • Linted the modified Python files.
  • Added regression tests.
  • Ready for review and tagged the developers.

Additional information

I used Codex to help investigate and prepare the implementation and regression tests.

@codecov

codecov Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.92308% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.91%. Comparing base (4bdcf2d) to head (e411eaa).

Files with missing lines Patch % Lines
...static/spectral_induced_polarization/simulation.py 71.42% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1821      +/-   ##
==========================================
+ Coverage   86.84%   86.91%   +0.06%     
==========================================
  Files         436      437       +1     
  Lines       57952    58014      +62     
  Branches     5460     5469       +9     
==========================================
+ Hits        50330    50421      +91     
+ Misses       6186     6158      -28     
+ Partials     1436     1435       -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

Bugs in getJ for the SIP simulation

1 participant