Repository navigation
ENH: trace_s_curve: sparse corrector Jacobian for large clusters - #345
Merged
Merged
Conversation
… not a fold The start is relaxed only to max|F| < ftol at fixed k, so on large clusters it can sit further off the curve than the first step is long, and the first corrected point can then lie below it in k. crackcell's driver (the same algorithm) counted that as a fold on 110_110 at 18816 atoms (0.8 -> 0.790 -> 0.794, "fold" at 0.750). Port of crackcell 655901b: `_k_turns` ignores a sign change of dk whose first point is the start. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
TraceSettings(surrogate="sparse") (default "dense", unchanged) holds the corrector Jacobian as B = S + U V^T (LowRankJacobian): S the surrogate Jacobian at the last refresh as a scipy.sparse matrix, U V^T the limited-memory good-Broyden correction (one column pair per force call, compressed by truncated SVD to max_rank = 120 at each refresh). The refresh rules are the dense ones (projected adds -(Sn - S) Q Q^T to the low-rank part). Bordered solves use block elimination on one splu of S's free-free block per refresh plus Woodbury for U V^T (S_u^-1 U cached), one step of iterative refinement, and are reused by the tangent, every corrector iteration and the Krylov preconditioner. Port of crackcell continuation/sparse.py. HessianSurrogate.hessian_sparse / jac_sparse keep the calculator's sparse Hessian sparse (X-H cap springs as sparse blocks); jac is unchanged, calibrate uses the sparse Jacobian. A surrogate's jac may return dense or scipy.sparse in either mode. If the problem provides hvp(x, v) (exact dF/dx v), KrylovCorrector uses it instead of finite differences. SW, unpassivated 110_110, start k 0.8, ftol 2e-3, k_window (0.3, 3), max_calls_per_point 60, start_max_iter 300, stopped just after K- (Apple M3 Pro): atoms B points K+ / K- calls/pt rejected wall peak RSS 864 dense 164 1.575250 / 0.601770 1.45 3 80 s 0.57 GB 864 sparse 164 1.575250 / 0.601770 1.45 3 64 s 0.33 GB 1536 dense 192 1.574234 / 0.590595 1.35 2 236 s 1.36 GB 1536 sparse 192 1.574234 / 0.590595 1.35 2 134 s 0.48 GB 3456 sparse 239 1.575392 / 0.580519 1.29 3 456 s 0.90 GB Dense and sparse folds agree to 5e-8 with identical points and force calls. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d fracture docs Co-Authored-By: Claude Opus 5.5 <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.
Stacked on #344 (base
26_continuation_tangent, so the diff shows only this PR's commits); it retargets to master when #344 merges.What
trace_s_curvecan now keep its corrector Jacobian sparse, so clamped clusters of several thousand atoms trace with modest memory.TraceSettings(surrogate="sparse")is opt-in; the default stays"dense".LowRankJacobian: B = S + U Vᵀ.scipy.sparsematrix.max_rank(default 120).refreshkeeps the three rules from BUG: trace_s_curve: tangent predictor and projected surrogate refresh (large-cluster stall) #344 (projected/carry/reset). The projected form adds −(Sn − S) Q Qᵀ to the low-rank part.spluof S per refresh, Woodbury for the low-rank part (S⁻¹U cached) and one step of iterative refinement.bordered_solve,BroydenCorrector(update,refresh,tangent) and theKrylovCorrectorpreconditioner accept either a dense B or aLowRankJacobian.HessianSurrogate.jac_sparse/hessian_sparse: these keep the calculator's sparsehessianproperty sparse and add the X-H cap springs as sparse blocks. The densejacandhessianare unchanged.calibratenow uses the sparse Jacobian in both modes, so its scale changes only at round-off.hvp(x, v), an exact dF/dx·v, the Krylov corrector uses it instead of finite differences. The module stays calculator-agnostic; the hook is a seam for application code.docs/applications/fracture_mechanics.rst.Validation
SW, unpassivated 110_110
clamped_cluster, start k 0.8, ftol 2e-3, dr_cap 0.05, alpha 2, run to just past K−. M3 Pro laptop, single process.Dense and sparse give the same points, force calls and rejected steps. The same design in the crackcell driver traced 9600 and 18816 atoms.
Tests
Nine new tests in
tests/test_clamped_crack.py, each written to fail first:hvphook.Results:
test_clamped_crack.py38 passed,test_cubic_crystal_crack.py6,test_rectilinear_anisotropic_crack.py3,test_build_3D_crack.py2.test_crack.pyneeds atomistica, which is not installed locally, so CI covers it.Not included: ASE's
Exppreconditioner was tried as the Jacobian and is too stiff on the soft in-plane modes (cos 0.08 with the exact tangent at 864 atoms). Faster sparse Hessian assembly in matscipy's calculators is a separate follow-up: it dominates the run time at ~10k atoms.🤖 Generated with Claude Code