Repository navigation
fix(solver): boundary-consistent projection, reproject_every option, divergence test - #7
Merged
Merged
Conversation
…on and divergence test * project_vector_field / project_vector_field_jax now zero the one-voxel boundary layer *before* taking the divergence. Taking the divergence first and masking afterwards left a residual f_boundary/(2h) in the layer next to the domain edge whenever the input force was non-zero on the box faces (7.7 m^-1 relative divergence on the halle_dacc ARF, now at float32 roundoff). * shear_fdtd gains opts["reproject_every"] = N (default 0, off): re-apply the Helmholtz projection to u_curr and u_prev every N steps. The zero-Dirichlet box wall is not solenoidal-preserving and is excited from step one because the projected force is non-local, so it injects divergence that travels inward at the shear speed; this option removes it at the cost of two CG solves per event. The JAX solver raises NotImplementedError if it is passed. * tests/test_divergence_free.py asserts RMS(div u)/RMS(|curl u|) < 1e-4 for a homogeneous point-force run until the wall signal arrives, documents the wall mechanism, and checks that reproject_every bounds the ratio afterwards. The pre-July-2026 projection gives ~0.3 on this setup from the first step. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…able in ruff 0.16 CI installs the latest ruff, which now enables PLR0917 and flags 28 pre-existing numeric-API signatures across src/, examples/ and tests/. The sibling rule PLR0913 is already ignored for the same reason. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to the 12 July projection fix (bc9429b), prompted by a residual-divergence diagnosis on the halle_dacc transcranial run in
acoustoelastic_ultrasound_neurons.project_vector_field/project_vector_field_jaxnow zero the one-voxel boundary layer before taking the divergence. Taking the divergence first and masking afterwards left a residualf_boundary/(2h)in the layer next to the domain edge whenever the force is non-zero on the box faces (7.7 m⁻¹ relative divergence on the halle_dacc ARF; now at float32 roundoff). No effect on the existing tests (tapered fields) and a negligible effect on the focal field of the transcranial run.opts["reproject_every"] = Ninshear_fdtd(default 0 = off, NumPy solver only; the JAX solver raisesNotImplementedError). Re-applies the Helmholtz projection tou_currandu_prevevery N steps. The zero-Dirichlet box wall is not solenoidal-preserving and is excited from step one because the projected force is non-local, so it injects divergence that travels inward at the shear speed. The option removes it at the cost of two CG solves per event.tests/test_divergence_free.pyassertsRMS(div u)/RMS(|curl u|) < 1e-4for a homogeneous point-force run until the wall signal arrives (observed 1–4e-6; the pre-July projection gives ≈0.3 from step one), documents the wall mechanism, and checks thatreproject_everybounds the ratio afterwards.Test plan
pytest -q tests: 18 passed, 3 skipped (JAX not installed locally)ruff check src testsandruff format --checkcleanreproject_every=60: identical focal field (peak von Mises 2.3134e-5 vs 2.3126e-5), interior divergence ratio 1.6e-5 vs 6.9e-4🤖 Generated with Claude Code