Skip to content

PENTRC - BUG FIX - Conjugate the bounce-averaged W vectors so the kinetic EL matrices see the physical perturbation - #357

Merged
logan-nc merged 1 commit into
developfrom
bugfix/pentrc-wmat-conjugation
Oct 24, 2026
Merged

logan-nc merged 1 commit into
developfrom
bugfix/pentrc-wmat-conjugation

Conversation

@matt-pharr

@matt-pharr matt-pharr commented Oct 24, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

The kinetic Euler-Lagrange matrices built in torque.F90 (the op_wmats path that DCON uses for kin_flag runs) 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-averaged wmmt/wemt (two lines), so W^T Ξ is exactly the projection the scalar route computes.

What was wrong

In tpsi, the scalar route forms bj = ∫ conj(jvtheta)·(pl + (1−σ)/pl), where jvtheta = Σ_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)·pl and 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:

build GPEC ∫T_φ [N·m] PENTRC fgar [N·m] fgar ÷ GPEC
develop 0.15447 0.1537 0.995
this PR 0.15046 0.1507 1.0016

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 mpsi 128 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.

image image image

Notes for review

  • Unchanged convention: both routes still use 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.
  • Downstream impact: kinetic DCON / GPEC results on asymmetric equilibria (DIII-D, ITER, …) will move. Results on symmetric (Solovev) equilibria do not.

🤖 Generated with Claude Code

@matt-pharr matt-pharr self-assigned this Oct 24, 2026
@matt-pharr
matt-pharr requested a review from logan-nc October 24, 2026 20:06

@logan-nc logan-nc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very convincing tests. Thanks for the catch!

@logan-nc
logan-nc merged commit e695e59 into develop Oct 24, 2026
6 checks passed
@logan-nc logan-nc mentioned this pull request Oct 24, 2026
27 tasks done
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.

2 participants