Skip to content

BUG: BroydenCorrector.refresh with no B or no previous surrogate - #346

Merged
jameskermode merged 1 commit into
masterfrom
26_refresh_fixes
Oct 26, 2026
Merged

jameskermode merged 1 commit into
masterfrom
26_refresh_fixes

Conversation

@jameskermode

Copy link
Copy Markdown
Member

Two edge cases in BroydenCorrector.refresh (matscipy.fracture_mechanics.continuation), found when a downstream driver (crackcell) switched to the matscipy continuation API and had to guard around them.

  • First refresh with a sparse Jacobian. With no B yet, a sparse surrogate Jacobian Jn was stored as a bare scipy.sparse matrix, which bordered_solve and tangent cannot use. It now starts a LowRankJacobian(Jn, max_rank=self.max_rank). BroydenCorrector takes a new max_rank argument (default 120, as LowRankJacobian), and trace_s_curve passes TraceSettings.max_rank.
  • No previous surrogate Jacobian. refresh(Jn, None, "projected"|"carry") on a dense B failed on Jn - Js. B now stays as it is, since there is no surrogate change to merge, and only the update span restarts. "reset" still sets B = Jn.

trace_s_curve itself never hit either case, because it seeds B before the first refresh. The behaviour of existing traces is unchanged.

Tests

tests/test_clamped_crack.py:

  • test_first_refresh_with_a_sparse_jacobian_gives_a_low_rank_b: the SW sparse Jacobian gives a LowRankJacobian with the corrector's max_rank, and the bordered solve and tangent work on it.
  • test_refresh_without_a_previous_surrogate_keeps_b[projected, carry].

All three failed before the fix. test_clamped_crack.py, test_cubic_crystal_crack.py, test_rectilinear_anisotropic_crack.py and test_build_3D_crack.py give 52 passed locally.

🤖 Generated with Claude Code

A first refresh with a sparse surrogate Jacobian now starts a
LowRankJacobian (new BroydenCorrector max_rank, passed from
TraceSettings.max_rank by trace_s_curve) instead of storing a bare
sparse matrix the bordered solves cannot use. A refresh with Js=None
keeps a dense B rather than failing on Jn - Js.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jameskermode
jameskermode merged commit d8ba558 into master Oct 26, 2026
47 checks passed
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.

1 participant