Skip to content

PERTURBED EQUILIBRIUM - BUG FIX - Use Λ† in reluctance to match Fortran gpresp_reluct - #297

Merged
github-actions[bot] merged 1 commit into
developfrom
bugfix/reluctance-plasma-inductance-adjoint
Jun 22, 2026
Merged

PERTURBED EQUILIBRIUM - BUG FIX - Use Λ† in reluctance to match Fortran gpresp_reluct#297
github-actions[bot] merged 1 commit into
developfrom
bugfix/reluctance-plasma-inductance-adjoint

Conversation

@logan-nc

Copy link
Copy Markdown
Collaborator

Summary

The flux-space reluctance matrix in src/PerturbedEquilibrium/Response.jl was computed with the plasma inductance Λ where the Fortran GPEC reference (gpresp_reluct) uses its adjoint Λ†:

formula
Julia (before) ϱ = L⁻¹·(Λ − L)·L⁻¹
Fortran gpresp_reluct ϱ = L⁻¹·(Λ† − L)·L⁻¹
Julia (after) ϱ = L⁻¹·(Λ† − L)·L⁻¹

Λ (plasma inductance) is not Hermitian — its anti-Hermitian part carries the dissipative/torque response — so dropping the adjoint introduces a small but real error in the reported reluctance. For a perfectly Hermitian Λ the two forms coincide, which is why it went unnoticed.

This was surfaced by a fortran-physics-reviewer audit of the coordinate-invariant field-space work (merged in #277). It is a pre-existing inconsistency — it predates #277 and was only flagged during that review — hence this separate bugfix branched from develop.

The fix

# Reluctance ϱ = L⁻¹·(Λ† − L)·L⁻¹ (Fortran gpresp_reluct: diff_indmats = CONJG(TRANSPOSE(plas_indmats)) − surf_indmats).
# Λ (plasma inductance) is not Hermitian — its anti-Hermitian part is the dissipative/torque response — so the adjoint matters.
L_inv = inv(surface_inductance)
reluctance = L_inv * (plasma_inductance' - surface_inductance) * L_inv

(' is the Julia adjoint = conjugate transpose, i.e. CONJG(TRANSPOSE(...)).)

Scope / blast radius

reluctance is an output-only quantity: it is stored in PerturbedEquilibriumState, conformed to field space by field_space_response_matrices, and written to HDF5 — nothing downstream consumes it (permeability is built directly from Λ and L, not from ϱ). The fix therefore only changes the reluctance dataset itself.

Verification

  • using GeneralizedPerturbedEquilibrium loads cleanly.
  • test/runtests_coordinate_invariant.jl: 15/15 + energy net-zero still green (those tests exercise the congruence conform on synthetic inputs, not this production formula).
  • Regression harness diiid_n1, develop vs this branch: 46 quantities unchanged, 0 moved — confirms the change is isolated (no pinned quantity moves; reluctance is not pinned).

Fortran reference (for convenience — exact lines, no need to pull up the source)

~/Code/gpec/gpec/gpresp.f, SUBROUTINE gpresp_reluct (lines 423–461). temp1 is set to the identity then zhetrf/zhetrs solve surf_indmats·X = I, so temp1 = L⁻¹:

         temp1=0
         DO i=1,mpert
            temp1(i,i)=1
         ENDDO
         temp2=surf_indmats
         CALL zhetrf('L',mpert,temp2,mpert,ipiv,work2,mpert*mpert,info)
         CALL zhetrs('L',mpert,mpert,temp2,mpert,ipiv,temp1,mpert,info)
         diff_indmats(j,:,:)=CONJG(TRANSPOSE(plas_indmats(j,:,:)))
     $        -surf_indmats
         reluctmats(j,:,:)=MATMUL(temp1,
     $        MATMUL(diff_indmats(j,:,:),temp1))

Key lines:

  • L449–450: diff_indmats = CONJG(TRANSPOSE(plas_indmats)) − surf_indmatsΛ† − L
  • L451–452: reluctmats = MATMUL(temp1, MATMUL(diff_indmats, temp1))L⁻¹·(Λ† − L)·L⁻¹

🤖 Generated with Claude Code

…an gpresp_reluct

The flux-space reluctance was computed as ϱ = L⁻¹·(Λ − L)·L⁻¹, but the
Fortran GPEC reference (gpresp_reluct) uses the adjoint of the plasma
inductance: ϱ = L⁻¹·(Λ† − L)·L⁻¹. Λ is not Hermitian — its anti-Hermitian
part carries the dissipative/torque response — so dropping the adjoint
introduced a small error in the reported reluctance.

reluctance is an output-only quantity (stored and written to HDF5; not
consumed by any downstream calculation), so the fix is isolated to the
reluctance dataset and its field-space conform.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@logan-nc logan-nc self-assigned this Jun 22, 2026
@logan-nc logan-nc added bug Something isn't working auto-merge labels Jun 22, 2026
@github-actions
github-actions Bot merged commit c80d94f into develop Jun 22, 2026
8 checks passed
@github-actions
github-actions Bot deleted the bugfix/reluctance-plasma-inductance-adjoint branch June 22, 2026 01:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant