Skip to content

Migrate KIM Fokker-Planck QUADPACK to fortnum (2/8)#141

Draft
krystophny wants to merge 1 commit into
fortnum/k1-kim-special-funcsfrom
fortnum/k2-kim-quadpack
Draft

Migrate KIM Fokker-Planck QUADPACK to fortnum (2/8)#141
krystophny wants to merge 1 commit into
fortnum/k1-kim-special-funcsfrom
fortnum/k2-kim-quadpack

Conversation

@krystophny

@krystophny krystophny commented Jun 14, 2026

Copy link
Copy Markdown
Member

Migrate the KIM Fokker-Planck QUADPACK calls (vendored Netlib dqag/dqags) onto the fortnum adaptive integrator, and pin fortnum to the main commit that makes its QAGS/QAGP/QAGIU path reproduce QUADPACK.

The fortnum adaptive driver previously used a clean-room extrapolation control that drifted on singular and semi-infinite integrands and used 5-11x more panels than QUADPACK at the same tolerance, which is what timed out this golden. fortnum main 974dcf1 reimplements the extrapolation path to follow QUADPACK dqagse/dqagpe (faithful dqelg Wynn-epsilon table, incremental dqpsrt ordering, depth-keyed level/levmax extrapolation gate, break-adjacent ndin error inflation). int_0^1 ln x and int_0^1 x^-1/2 now reach machine precision in 6 subintervals (231 GK21 evals), bit-matching Netlib dqagse.

Verification

Built against fortnum main 974dcf1 and ran the golden under a uv venv (pytest numpy scipy h5py f90nml matplotlib), Python 3.13.

Before (CI, this branch on the old fortnum): ql-balance_golden_record exceeded the 600 s timeout (the slow over-subdividing QAGS/QAGIU path).

After:

2/2 Test #19: ql-balance_golden_record .........   Passed  241.06 sec
100% tests passed, 0 tests failed out of 2

Per-quantity pytest run (golden bar rtol=1e-8, atol=1e-15, unchanged):

============================= 115 passed in 49.07s =============================

All LinearProfiles/KinProfiles quantities including Br_Re/Br_Im/Br_abs, dqle*/dqli*, T_EM_phi_e/i pass; no quantity exceeds rtol=1e-8.


Stack reconciliation (update)

The migration stack was rebuilt as a strictly linear cumulative chain on main 428a708:

k1 (+ golden CI fix) -> k2 -> k3 -> k4 -> k5 -> k6 -> k7 -> k8 -> z1 -> z2 -> z3

Every branch now pins fortnum to main 974dcf1 (all kernel fixes plus both new integrators). This branch's standalone golden result above stands. The cumulative tip (#150 z3) does not pass: the KiLCA background equilibrium ODE on #143 k4 cannot reproduce the GSL rk8pd golden with DOP853 at the unchanged 1e-8 bar. See #143 and #150. Tolerances were not weakened and the stored golden was not regenerated.

Merge order: #140 -> #141 -> #142 -> #143 -> #144 -> #145 -> #146 -> #147 -> #148 -> #149 -> #150.

Note: fortnum pin updated to current main (92de6e9) after a fortnum history rewrite; old shas no longer resolve.

@krystophny krystophny force-pushed the fortnum/k2-kim-quadpack branch from 5fcc8d9 to b091cad Compare June 15, 2026 19:27
@krystophny krystophny changed the base branch from main to fortnum/k1-kim-special-funcs June 15, 2026 19:28
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