Skip to content

Solvers: FEBio's line search in the Newton step - #11

Merged
mattjolley merged 1 commit into
mainfrom
mattjolley/line-search
Nov 28, 2026
Merged

mattjolley merged 1 commit into
mainfrom
mattjolley/line-search

Conversation

@mattjolley

Copy link
Copy Markdown
Contributor

What does this change, and why?

Adds FEBio's line search to the Newton step, as written in FELineSearch::DoLineSearch (after Bonet and Wood). It is the piece of the nonlinear strategy that the comparisons with FEBio pointed to: suite problem sh58 followed FEBio for 14 steps and left its path exactly where FEBio's line search first shortens a step, and the open mitral input stalled at leaflet closure without it. Design note: linear_solve.md (decision L6 and the settings table).

Merged by the author so the work can continue, and left here as the record for review afterwards; comments on a merged pull request are welcome.

  • The settings lstol, lsmin, lsiter and ls_check_jacobians are read from the input with FEBio's defaults (0.9, 0.01, 5, off), so the line search is on by default, as in FEBio. lstol 0 gives full Newton steps.
  • The convergence norms with a shortened step follow FENewtonSolver::CheckConvergence.
  • Nothing here differs from FEBio by design. What remains different in the nonlinear solve is BFGS (row 2 of deviations.md, updated here): inputs that ask for it are run with full Newton, so their iteration counts differ and their solutions agree to FEBio's tolerance.

Validation

  • Tests added or changed: tests/test_line_search.py (the function on scalar cases where its behavior can be stated exactly); tests/test_febio_suite.py (four more problems).
  • FEBio reference (input file, quantity compared, tolerance, FEBio version), or N/A: FEBio test suite at 986005f, the suite's stored step count, iteration count and solution norm. sh58 (shells, dynamic, automatic time stepping): FEBio's 105 steps and 435 iterations, norm to 3e-7 (before: 106 steps, 449 iterations, norm 2 percent away). sh56: FEBio's 59 iterations (before: 64). di03 and sh06: now run and agree on the norm to 3e-9 and 2e-7 (before: stopped on a negative Jacobian). All earlier comparisons are unchanged.
  • Devices the full tier ran on (CPU, and the GPU model if CUDA; say so clearly if no GPU was used): quick tier on CPU; full tier on a Quadro RTX 8000 (cuda:0). On CUDA sh58 takes 432 iterations where FEBio and the CPU take 435, a rounding effect over 105 steps of threshold decisions; the test allows a difference of 5 and says why. The full tier on CPU was not run for this change.

Checklist

  • I have read the contributing guide.
  • uvx pre-commit run --all-files passes.
  • The full tier passes: WARP_FEBIO_TEST_LEVEL=full uv run -m unittest discover -s tests, and with WARP_FEBIO_TEST_DEVICE=cuda:0 for code that runs on the device. (GPU: yes. CPU: quick tier only; the CI job runs the full tier on CPU.)
  • If this changes what a design note says, the note is updated; open design questions are in its decision points, not only in this pull request.
  • The change is focused, and every commit is signed off (git commit -s).

🤖 Generated with Claude Code

FELineSearch::DoLineSearch as written (after Bonet and Wood): a step
along the Newton increment is accepted when |du . R(u + s du)| is at
most lstol times |du . R(u)|; otherwise s is updated from a quadratic
through the two values, at most lsiter times, after which the step with
the smallest value seen is taken; a step below lsmin becomes 0.5; with
ls_check_jacobians a step whose update fails is halved. The settings
lstol, lsmin, lsiter and ls_check_jacobians are read from the input,
with FEBio's defaults (0.9, 0.01, 5, off), so the line search is on by
default as in FEBio; lstol = 0 gives full steps. The convergence norms
with a shortened step follow FENewtonSolver::CheckConvergence.

Checked against the FEBio test suite (stored step count, iteration
count and solution norm):
- sh58 (quad4 shells, dynamic, automatic time stepping): FEBio's 105
  steps and 435 iterations, norm to 3e-7. Without the line search it
  left FEBio's path at step 15 and ended 2 percent away. On CUDA the
  count is 432, a rounding effect over 105 steps of threshold
  decisions; the test allows 5.
- sh56: FEBio's 59 iterations exactly (64 before), norm to 4e-13.
- di03 and sh06 now run (a negative Jacobian before) and agree on the
  norm to 3e-9 and 2e-7.
All other comparisons are unchanged: where FEBio's line search stays
at 1 it stays at 1 here.

tests/test_line_search.py checks the function on scalar cases where
what it should do can be stated exactly.

Tested: quick tier on CPU; full tier on cuda:0 (Quadro RTX 8000).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Signed-off-by: Matthew Jolley <12954190+mattjolley@users.noreply.github.com>
@mattjolley
mattjolley merged commit 2e0171d into main Nov 28, 2026
2 checks passed
@mattjolley
mattjolley deleted the mattjolley/line-search branch November 28, 2026 15:27
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