Skip to content

Commit 83ff416

Browse files
logan-ncclaude
andcommitted
PE - EXPERIMENT - Kinetic runs regularize the stored xi_s (Fortran gpeq.f kin_flag analog)
The Clebsch xi_alpha fed to the NTV kernel was re-solved from the IDEAL A,B,C even in kinetic runs, inconsistent with the self-consistent kinetic tangential response exactly where resonant layers live. Mirror Fortran: scale the stored xi_s by the singfac regularization factor and invert nothing (analog of the #407 fix, adapted to the FourFitVars API; kinetic-ness detected via populated kwmats pending proper flag threading). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LzbLFQKyuRE5DYZmLokKmk
1 parent b3d7ab9 commit 83ff416

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

src/PerturbedEquilibrium/FieldReconstruction.jl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,25 @@ function compute_clebsch_displacements(
365365
return clebsch_psi, clebsch_psi1, clebsch_alpha
366366
end
367367

368+
# Kinetic runs: mirror Fortran gpeq.f kin_flag — regularize the STORED self-consistent ξ_s
369+
# by the same singfac factor and never re-solve from matrices. The ideal-matrix resolve is
370+
# inconsistent with the kinetic solution's tangential response (the resonant layers live in
371+
# exactly that dynamics), and the kinetic A is non-Hermitian and must not be re-inverted
372+
# here. Kinetic-ness detected by populated kwmats splines (sentinel has 5 knots).
373+
if length(ffit.kwmats[1].cache.x) > 8
374+
for ipsi in 1:npsi
375+
q = equil.profiles.q_spline(psi_grid[ipsi])
376+
for ipert in 1:mpert
377+
m = mlow + ipert - 1
378+
singfac = m - nn * q
379+
reg_factor = singfac^2 / (singfac^2 + reg_spot^2)
380+
clebsch_psi1[ipsi, ipert] = xi_psi1_modes[ipsi, ipert] * reg_factor
381+
clebsch_alpha[ipsi, ipert] = xi_s_modes[ipsi, ipert] * reg_factor / chi1
382+
end
383+
end
384+
return clebsch_psi, clebsch_psi1, clebsch_alpha
385+
end
386+
368387
# Per-thread workspaces: matrix ops and spline hints are not safe to share across threads.
369388
# Size by maxthreadid() and index by threadid() under :static scheduling (GPEC convention).
370389
nt = Threads.maxthreadid()

0 commit comments

Comments
 (0)