Skip to content

FFS - NEW FEATURE - Certified adaptive psi grid for the calculated kinetic matrices - #410

Draft
logan-nc wants to merge 2 commits into
performance/decoupled-el-matrix-gridfrom
performance/certified-kinetic-grid
Draft

FFS - NEW FEATURE - Certified adaptive psi grid for the calculated kinetic matrices#410
logan-nc wants to merge 2 commits into
performance/decoupled-el-matrix-gridfrom
performance/certified-kinetic-grid

Conversation

@logan-nc

@logan-nc logan-nc commented Aug 19, 2026

Copy link
Copy Markdown
Collaborator

Stacked on #408 (base branch performance/decoupled-el-matrix-grid; a force-push trimming that branch back to the cap commits is pending, until then this diff shows only the seed-rework commit).

What

Adds kinetic_grid_tol ([ForceFreeStates], default 0 = off, bit-identical to today when off): when kinetic_source = "calculated", the expensive bounce-average kernel is driven over a certified adaptive ψ grid instead of every equilibrium knot.

  • Certificate on the total matrices the EL solver consumes (ideal + kinetic, max-element residual vs tol · max|T|), including the adjoint combination kw₃ − kt₃ — never the kinetic increments in isolation.
  • Physics-skeleton seed: the same structure the NTV ψ quadrature panels at — rational windows, located kinetic-resonance surfaces (kinetic_resonance_psi_nodes, one source of truth with the torque quadrature), and four interior points per inter-rational span (log-spaced in the axis span, matching the core Frobenius structure).
  • Batched certify-or-refine rounds: every round evaluates all uncertified midpoints as one threaded batch (bulk-synchronous — the existing Threads.@threads kernel pattern is untouched). Spacing floors: the Frobenius cap in the core, RATIONAL_RES_SPACING outside, ÷4 inside rational windows (anti-aliasing where layers are expected). Certification exhaustion warns loudly with the first uncertified location.
  • Kernel takes an arbitrary ψ list (psis kwarg through the KineticForces callback); everything else sizes from it.

Why

The shipped calculated-kinetic decks run mpsi = 16 and carry percent-level interpolation error on the B/C total matrices (ε 6.8e-2 → 5.8e-4 across a 16/64/256 ladder — mostly unresolved real structure, not noise). At production grids the kernel costs ~1.3 s/surface: minutes of matrix formation spent on knots the totals don't need, while coarse decks are silently under-resolved. Certification fixes both directions: it adds knots where the deck is starved and skips them where the equilibrium grid over-packs.

Evidence

  • Knob-off bit-identity, re-verified on this branch's actual head (bef73a6, i.e. including the seed rework): regress --cases solovev_kinetic_calculated,solovev_kinetic_ntv,solovev_kinetic_nuzero,diiid_n1 --refs performance/decoupled-el-matrix-grid,local81/81 tracked quantities unchanged.
  • Solovev smoke (m16 deck, tol=1e-3): 15 seed → 74 knots, 133 kernel evaluations, fully certified — the certifier correctly refuses the deck's under-resolution (more evals than the deck's 17 knots, because the deck was wrong).
  • DIII-D survival test: FAILED its pre-registered physics gate — this PR stays draft until the root cause is decided. Full record in handoff/issue376/RESULTS.md §28. Summary: the DIII-D kinetic-calculated configuration (never run before) is pathological on the full grid too — 223k EL steps (94% at ψ<0.01) and 17.5 GB solution dumps. A discriminator run (kernel tolerance ×10 tighter) reproduces the full-grid et[1] to 2.7e-7 with steps unchanged, so the pathology is real near-axis structure, not kernel noise: the calculated kinetic increments diverge toward the axis (~ψ^−0.7; the kernel has no near-axis validity clamp). The certified grid smooths that structure (et[1] off by 17→14% across the tol ladder, converging toward the full-grid value with cost exceeding the full grid). Two design consequences recorded for the fix: certify the post-Schur matrices the ODE consumes (f0/K/G amplify the raw-increment certificate ~20×), and the Frobenius core floor is unjustified for kinetic increments. A denser-equilibrium-grid check confirms the full-grid reference is converged (1.6e-4), so the certified deviation is unambiguously certification error; the identified design flaw is the certificate's GLOBAL max|T| scale, which is blind to the small-amplitude but dynamically dominant near-axis structure (1.6e-4 of the G scale, yet 94% of the ODE work). The blocking question is physics: should the drift-kinetic contribution be tapered/cut near the axis where the model degenerates? If yes, both the step pathology and the certification failure disappear together.

⚠️ REQUIRES THIRD-PARTY HUMAN REVIEW BEFORE MERGING — NON-NEGOTIABLE. DO NOT MERGE WITHOUT AN APPROVING HUMAN REVIEW.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LzbLFQKyuRE5DYZmLokKmk

logan-nc and others added 2 commits August 19, 2026 08:35
…e-panel physics skeleton

Replace the arbitrary constant-size decimation seed with the same structure the
NTV psi quadrature panels at: rational windows, located kinetic-resonance
surfaces (Omega_l = 0 via KineticForces.kinetic_resonance_psi_nodes -- one
source of truth with the torque quadrature), and four interior points per
inter-rational span (log-spaced in the axis span to match the core Frobenius
structure). Warn loudly when certification exhausts max_rounds instead of
returning silently.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LzbLFQKyuRE5DYZmLokKmk
DIII-D auto-grid runs exhaust 6 rounds in the core spans (warned as designed);
10 rounds lets the certificate reach the spacing floors. Docstring now describes
the physics-skeleton seed instead of the removed decimation seed.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LzbLFQKyuRE5DYZmLokKmk
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