Repository navigation
PENTRC - BUG FIX - Conjugate the bounce-averaged W vectors so the kinetic EL matrices see the physical perturbation - #357
Merged
Conversation
…se of up-down-asymmetric equilibria
logan-nc
approved these changes
Oct 24, 2026
logan-nc
left a comment
Contributor
There was a problem hiding this comment.
Very convincing tests. Thanks for the catch!
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.
Summary
The kinetic Euler-Lagrange matrices built in
torque.F90(theop_wmatspath that DCON uses forkin_flagruns) bounce-average the W vectors with the opposite complex pairing from PENTRC's scalar torque. As a result the self-consistent kinetic matrices encode the drift-kinetic action of the up-down-mirrored perturbation rather than the actual one. This PR conjugates the bounce-averagedwmmt/wemt(two lines), soW^T Ξis exactly the projection the scalar route computes.What was wrong
In
tpsi, the scalar route formsbj = ∫ conj(jvtheta)·(pl + (1−σ)/pl), wherejvtheta = Σ_m D_m e^{+2πi(m−nq)θ}is the perturbation along the field line. Its magnitude is|∫ jvtheta·conj(pl)|: the real perturbation projected onto the orbit phase.The matrix route bounce-averaged
conjg(wmu_mt)·pland then contracted with the unconjugated D_m. That givesΣ_m D_m ∫ e^{−2πi(m−nq)θ}·pl, which pairs D_m with conjugated phases. It is neither the perturbation nor its conjugate; it is the mirrored perturbation. Conjugating the bounce integrals givesΣ_m D_m ∫ e^{+2πi(m−nq)θ}·conj(pl) = ∫ jvtheta·conj(pl), identical to the scalar route's δJ as a complex number.On up-down-symmetric equilibria the mirrored and actual perturbations coincide, so nothing changes. On asymmetric ones, the self-consistent kinetic matrices, and everything built on them (kinetic DCON eigenfunctions, the GPEC response, the self-consistent torque
gpec_dw_profile), were affected. PENTRC's scalar methods (fgar etc.) evaluated on a given perturbation were already correct.Evidence
Logan's thesis (ch. 7, App. C) requires the self-consistent torque from DCON's boundary term and PENTRC's fgar to agree pointwise in ψ. Before this fix they don't on asymmetric equilibria; after it they do.
Fortran, DIII-D-like
docs/examples/run_kinetic_example(up-down asymmetric),mpsi = 256:Pointwise at
mpsi = 128, away from resonances, PENTRC's and GPEC's torque densities disagree by 15–20% on develop and agree to 0.1–0.5% with this PR. On develop the total torques happen to agree (0.07%) only because those regional errors cancel.Fortran,
docs/examples/solovev_kinetic_example(up-down symmetric): develop and this PR give identical output to every printed digit (DCON energies, ∫T_φ = 3.93793e−6, fgar = 3.954e−6), as expected for a symmetric equilibrium.Julia GPEC (a faithful port with the same pairing), TokaMaker up-down-asymmetry family: 11 fixed-boundary shapes, R₀ = 1.7 m, a = 0.6 m, κ = 1.7, mean δ = 0.35, with Δδ = δ_upper − δ_lower from 0 to 0.5 at fixed q₀ = 1.13, q_edge = 5.0 and β_N = 1.5%. Each was run on 26 radial grids from
mpsi128 to 1024, with and without the fix. In the converged-grid figure (mpsi ≥ 576), the unpatched gap between the two torque routes grows with asymmetry (up to −0.57% and +1.09%), while with the fix it stays at the discretization floor (+0.01–0.05%) for every shape. At Δδ = 0 the builds agree with each other.Notes for review
conj(pl)as the orbit weight. That matters only for passing particles and predates this PR. A mirror-symmetry test that checks it independently is planned as a follow-up.🤖 Generated with Claude Code