FFS - NEW FEATURE - Certified adaptive psi grid for the calculated kinetic matrices - #410
Draft
logan-nc wants to merge 5 commits into
Draft
Conversation
…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
…ordering fails near the axis Physics ruling (issue #376 DIII-D kinetic pathology): the drift-kinetic model loses validity where thermal ion orbit widths reach the local minor radius. psi_c = outermost crossing of <r> by max(potato width (q^2 rho^2 R0)^(1/3), banana width q rho/sqrt(eps), poloidal gyroradius q rho/eps), computed from the equilibrium and kinetic profiles at runtime -- no user tuning parameters (the Fortran ktanh_flag precedent needed four). A C2 quintic envelope zeroes the calculated kinetic increments below psi_c (kernel evaluation skipped) and rises to 1 at 2 psi_c; the same boundary and envelope apply to the NTV torque psi quadrature (one source of truth). One Bool (axis_validity_suppression, default true) to disable for debugging. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LzbLFQKyuRE5DYZmLokKmk
…icForces/Validity Whenever kinetic profiles are used (self-consistent matrices or NTV post-processing), write the thermal orbit-width scales (rho_i, rho_banana, rho_theta, w_potato), the local geometry (r_minor, d_separatrix), the profile gradient lengths (L_p, L_q), the near-axis boundary psi_c with its applied envelope, and an is_valid array (orbit width < r, rho_banana < L_p and L_q, orbit width < distance to separatrix). Validity outside the near-axis envelope is flagged, never suppressed -- the far edge can dominate the physical NTV. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LzbLFQKyuRE5DYZmLokKmk
…n-or-create the KineticForces group The envelope has structure on the psi_c scale; coarse kinetic decks (m16) cannot represent env*(increment) and the spline overshoot can land on a rational surface inside the transition band, corrupting the eigenvalues. Augment the kernel grid with knots across [psi_c, 2 psi_c] (band ends pinned -- the smoothstep is only C2 there) on the full-grid path and seed them on the certified path. Also open-or-create KineticForces in the NTV writer, which collided with the Validity group. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LzbLFQKyuRE5DYZmLokKmk
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.
Stacked on #408 → #414 (near-axis kinetic validity suppression). This branch currently duplicates #414's commits and will be rebased onto
feature/kinetic-axis-validityonce #414 lands; the certified-grid work is the only content that belongs here. (The #408 base-branch force-push trimming its remote copy back to the cap commits is still pending.)What
Adds
kinetic_grid_tol([ForceFreeStates], default 0 = off, bit-identical to today when off): whenkinetic_source = "calculated", the expensive bounce-average kernel is driven over a certified adaptive ψ grid instead of every equilibrium knot.tol · max|T|), including the adjoint combinationkw₃ − kt₃— never the kinetic increments in isolation.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).Threads.@threadskernel pattern is untouched). Spacing floors: the Frobenius cap in the core,RATIONAL_RES_SPACINGoutside, ÷4 inside rational windows (anti-aliasing where layers are expected). Certification exhaustion warns loudly with the first uncertified location.psiskwarg through the KineticForces callback); everything else sizes from it.Why
The shipped calculated-kinetic decks run
mpsi = 16and 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
regress --cases solovev_kinetic_calculated,solovev_kinetic_ntv,solovev_kinetic_nuzero,diiid_n1 --refs performance/decoupled-el-matrix-grid,local→ 81/81 tracked quantities unchanged.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.🤖 Generated with Claude Code
https://claude.ai/code/session_01LzbLFQKyuRE5DYZmLokKmk