Replace NLsolve.jl with NonlinearSolve.jl TrustRegion#261
Conversation
…e solving
NLsolve.jl's trust region dogleg solver is replaced by NonlinearSolve.jl's
TrustRegion() in both KPS3 and KPS4 find_steady_state! functions. This
removes NLsolve and NLSolversBase as direct dependencies while NonlinearSolve
was already a transitive dependency via OrdinaryDiffEqNonlinearSolve.
The custom finite-difference Jacobian (make_jac) is retained because the
model's MVector{3, Float64} internals cannot hold ForwardDiff.Dual numbers.
NLsolve's autoscale=true is not needed — TrustRegion works without it and
actually produces slightly better results on the l=392 test case.
All 452 tests pass (441 pass + 11 pre-existing broken).
Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
|
This branch is not passing the tests: |
|
v1.12 is fine but v1.11 is not. Peculiar. |
|
now that the linear solve issue is fixed we should rerun tests |
|
Retested locally on Julia 1.11.9 with LinearSolve.jl v3.59.1 (which includes the fix from LinearSolve.jl#888). All tests pass: The root cause on 1.11 was LinearSolve.jl#887: The fix in LinearSolve.jl#888 stores a backup of the original matrix and restores it before the QR fallback. With LinearSolve v3.59.1 this PR's KPS4 steady-state tests all converge correctly on Julia 1.11. |
Summary
NLsolve.jltrust region dogleg withNonlinearSolve.jlTrustRegion()in bothKPS3andKPS4find_steady_state!functionsNLsolveandNLSolversBaseas direct dependencies (NonlinearSolve was already a transitive dependency via OrdinaryDiffEqNonlinearSolve)make_jac) since the model'sMVector{3, Float64}internals cannot holdForwardDiff.DualnumbersMotivation
NLsolve.jl has known issues with subnormal Jacobian entries from NLSolversBase >= 7.10 (see PR #259). Rather than pinning NLSolversBase or maintaining workarounds, this PR switches to NonlinearSolve.jl which:
TrustRegion()passes all 452 tests (441 pass + 11 pre-existing broken)autoscale=true(Moré/MINPACK diagonal scaling) is unnecessary with NonlinearSolve's TrustRegionChanges
src/KPS4.jlnlsolve()call withNonlinearProblem+solve(prob, TrustRegion())src/KPS3.jlsrc/KiteModels.jlNLsolvefromusing, addimport SciMLBasesrc/init.jlmake_jacdocstringProject.tomltest/Project.tomlexamples_3d/Project.tomltest/create_sys_image.jlTest plan
Pkg.test()passes: 441 pass + 11 pre-existing broken, 0 failuresRelated
🤖 Generated with Claude Code