Drop bundled MINPACK; use fortnum multiroot for quasi symplectic steps#390
Closed
krystophny wants to merge 5 commits into
Closed
Drop bundled MINPACK; use fortnum multiroot for quasi symplectic steps#390krystophny wants to merge 5 commits into
krystophny wants to merge 5 commits into
Conversation
orbit_symplectic_quasi was the sole consumer of the vendored MINPACK hybrd1. Replace each of the eight hybrd1 calls with fortnum's multiroot_hybrids (Newton step with a backtracking line search and a finite-difference Jacobian), which provides the same warm-started, Jacobian-free root solve the call sites relied on. Each f_*_quasi residual now conforms to the multiroot_fn_t interface (assumed-shape x/f, optional ctx, no iflag); state still travels through the existing module globals f, fs, si. The f_midpoint_quasi double field evaluation ordering (midpoint stage saved, then endpoint) is preserved. xtol and ftol are both set to si%rtol to track the former hybrd1 stopping behavior. Wire fortnum via CMake FetchContent (GIT_TAG a7faa3c, guarded by NOT TARGET fortnum) and link it into the simple library. Delete src/contrib/minpack.f90, minpack_interfaces.f90, and LICENSE.minpack.
fortnum a7faa3c installed its C ABI header from CMAKE_SOURCE_DIR, which resolves to the consumer tree under FetchContent and failed SIMPLE's install step. fortnum main now sources the header from PROJECT_SOURCE_DIR (9595e51); pin to the merge commit that carries the fix.
Member
Author
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.
Merge order
Merge sequence: #390, then #391 (#391 stacks its test coverage on this PR).
Both PRs are based on
mainindividually, so each diff is cumulative againstmainand the two overlap. Merge #390 first. Once it lands, the #391 diffshrinks to its increment: the
test_sympl_stellcoverage for the fortnummultiroot quasi path.
Scope
orbit_symplectic_quasiwas the only consumer of the vendored MINPACKhybrd1. This PR removes the bundled MINPACK and routes all eight root-finding call sites through fortnum'smultiroot_hybrids(Newton step with a backtracking line search and a finite-difference Jacobian), preserving the warm-started, Jacobian-free solve the call sites relied on. Eachf_*_quasiresidual now conforms to themultiroot_fn_tinterface (assumed-shapex/f, optionalctx, noiflag); residual state still travels through the existing module globalsf,fs,si, and thef_midpoint_quasimidpoint-then-endpoint double field evaluation is unchanged.xtolandftolare both set tosi%rtolto track the formerhybrd1stopping behavior. fortnum is wired via CMakeFetchContent(GIT_TAG a7faa3c, guarded byNOT TARGET fortnum) and linked into thesimplelibrary.Dependency removed: bundled MINPACK (
src/contrib/minpack.f90,src/contrib/minpack_interfaces.f90,src/contrib/LICENSE.minpack).Globalization note
hybrd1used a Powell hybrid (dogleg trust region);multiroot_hybridsuses a Newton step with an Armijo backtracking line search. Both are warm-started from the previous step and use a finite-difference Jacobian. The direct symplectic-integrator tests below pass within their existing tolerances, but the full golden-record trajectory comparison could not be run in this environment (see Unverified).Verification
Configure and build (fortnum fetched at
a7faa3c, heap-trampoline path available):orbit_symplectic_quasi.f90compiles with no warnings; the full target set links (427/427).Direct symplectic-integrator tests (these drive euler1, euler2, midpoint, and gauss4 quasi steps through the new solver with
rtol=1e-12and assert energy-drift tolerances):Full 32-particle Gauss-mode (
integmode=3,relerr=1d-13) orbit run completes and writes valid NetCDF output:51 of 75 ctest cases pass. The remaining cases fail for environment reasons unrelated to this change:
golden_record_*cases: the harness builds a second reference copy of SIMPLE that clonesfortplotover HTTPS, which fails here (fatal: fetch-pack: invalid index-pack output,Failed to clone repository: fortplot.git). The failure is in the reference sub-build, before any physics runs.orbit_netcdf_output(120s budget),test_chartmap_pipeline(60s budget): timed out only under-j8load. Run standalone they pass (simple.x84s,test_chartmap_pipeline.x82s, both exit 0).orbit_netcdf_verify,orbit_netcdf_plot: depend on the truncatedorbits.ncfrom the timed-out producer; they pass against a complete file (shown above).Unverified
The golden-record trajectory comparison (
golden_record.sh) builds a reference SIMPLE frommainand clones libneo and fortplot over HTTPS; the network is isolated in this environment, so that comparison did not run. Marked draft until it runs against the reference build.Note: fortnum pin updated to current main (92de6e9) after a fortnum history rewrite; old shas no longer resolve.