Skip to content

Symmetrize STRIDE Δ matrices - #191

Closed
d-burg wants to merge 7 commits into
developfrom
stride_sym
Closed

d-burg wants to merge 7 commits into
developfrom
stride_sym

Conversation

@d-burg

@d-burg d-burg commented Feb 4, 2025

Copy link
Copy Markdown
Collaborator

The procedure outlined in sym.f follows the procedure written by Fitzpatrick through equation (16) (see: Benchmark.pdf). On this first pass and as far as I can tell, I've implemented all GPEC equilibrium quantities, integrals, and matrix multiplies correctly – however, the resulting matrices do not yet follow the desired symmetry properties.

One question for now: does this look like I'm calculating the J(psi_N) contour integral correctly? I'm also not totally sure about the need for jac in this case.

GPEC/stride/sym.f

Lines 148 to 165 in 4568a5c

! Calculate J(psi_N) contour integral
dtheta = twopi / real(mthsurf)
DO itheta=0,mthsurf
CALL bicube_eval(rzphi,psilim,theta(itheta),1)
rfac=SQRT(rzphi%f(1))
angle=twopi*(theta(itheta)+rzphi%f(2))
r(itheta)=ro+rfac*COS(angle)
z(itheta)=zo+rfac*SIN(angle)
jac=rzphi%f(4)
w(1,1)=(1+rzphi%fy(2))*twopi**2*rfac*r(itheta)/jac
w(1,2)=-rzphi%fy(1)*pi*r(itheta)/(rfac*jac)
delpsi=SQRT(w(1,1)**2+w(1,2)**2)
J(ising)=J(ising)+
$ (1.0/(delpsi**2))*(dtheta/twopi)!/jac !DB !!
ENDDO

And in the meantime, I'll continue checking through the rest of the algebra (f_S, f_L, etc) for any issues.

@d-burg d-burg changed the title WIP: symmetrize STRIDE Δ matrices Symmetrize STRIDE Δ matrices Feb 4, 2025
@logan-nc

logan-nc commented Feb 6, 2025

Copy link
Copy Markdown
Contributor

Your J does indeed look to be the theta integral of 1/(delpsi)^2, which is what Richard defines it as here,
image

What do you think @parkjk ?

@logan-nc

Copy link
Copy Markdown
Contributor

Any progress here @d-burg?

@d-burg

d-burg commented Jun 24, 2025

Copy link
Copy Markdown
Collaborator Author

Any progress here @d-burg?

I think I have a shot if I can set up the psi_tor spline correctly! I'll return to it this week @logan-nc

@logan-nc

Copy link
Copy Markdown
Contributor

Status @d-burg?

@logan-nc

Copy link
Copy Markdown
Contributor

@d-burg this seems to have gone stale. Let's get it merged or closed as part of your current PR push

@d-burg

d-burg commented Feb 24, 2026

Copy link
Copy Markdown
Collaborator Author

@logan-nc should we keep this on the backburner? With my latest changes to this branch (and without TJ's Fitzpatrick-specific flux coordinate "r") I still haven't been able to get the outputs looking correct. However, given how well the STRIDE and TJ Δ' values align, and how close the growth rates are on circular equilibria, I'm not sure if we need this symmetrization? This might be a good question for a future meeting with Dylan or Richard, if we can catch him at MHDW.

@logan-nc

Copy link
Copy Markdown
Contributor

Sounds good @d-burg. change the pr status from "open" to "draft" please. if/when you come back to it you can change it back

@d-burg
d-burg marked this pull request as draft February 25, 2026 02:19
@logan-nc

logan-nc commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

@d-burg is this so stale it should be closed?
Please wrap up any fortran feature dev this month so we can release a "final" v1.6 before releasing Julia GPEC 2.0

@d-burg

d-burg commented Oct 23, 2026 •

Copy link
Copy Markdown
Collaborator Author

Closing this without merging. As part of wrapping up #173 I checked whether STRIDE's Δ' still needs symmetrizing. It doesn't: on current develop, STRIDE's Δ' is already Hermitian up to a per-surface scale, and symmetrizing could not change any growth rate SLAYER computes.

STRIDE's Δ' is already symmetric up to a per-surface scale. Fitzpatrick's normalization differs from STRIDE's only by a separate scale on each surface's large and small solutions. That changes the matrix to B⁻¹ Δ' A with A and B diagonal. Such a rescaling can make a matrix Hermitian only if certain products of its entries, which the rescaling leaves unchanged, are already Hermitian-consistent. On the DIII-D-like example (n = 1, five surfaces, q = 2–6, develop at a362835), STRIDE's Δ' passes every such test:

  • Every pair product Δ'_ij·Δ'_ji is real and positive. The largest phase is 5e-4°.
  • Every three-surface product Δ'_ij·Δ'_jk·Δ'_ki equals the complex conjugate of the reverse cycle to within 3e-5 (relative).
  • The diagonal is real: the largest Im/|Δ'_kk| is 6e-5.
  • With one real positive weight per surface, the whole matrix becomes Hermitian to a relative residual of 4e-5. Unweighted, the off-diagonal residual is 1.22.

The raw matrix therefore looks non-symmetric only because the surfaces are normalized differently. The coupling information is consistent.

Symmetrizing cannot change the roots. A rescaling with A = B is a similarity transform, and det(Δ' − D) is unchanged by a similarity transform for any diagonal D. That determinant is the one SLAYER's coupled dispersion relation uses. What remains when A ≠ B is a scaling of each row by a_i/b_i. In the dispersion relation that is the same as scaling each surface's layer response, so it amounts to choosing the reference length on each surface. #173 now handles that explicitly: it converts Δ' from STRIDE's ψ_N reference to the r_s reference of the layer, Δ'_ij → K_i^(1/2+α_i) Δ'_ij K_j^(α_j−1/2) with K = r_s dψ_N/dr and α = √(−D_I), following the Julia implementation.

Note on earlier develop. Before the equilibrium and grid fixes merged today (#325, #329, #335; most likely #329, which samples every direct-equilibrium surface at the common straight-fieldline angles), the same test found the off-diagonal entries Hermitian only to 4e-4. It also found sizable imaginary parts on the diagonal (Im/|Δ'_kk| of 0.42 for the 4/1, and close to 1 on the near-edge 5/1 and 6/1), which no rescaling can remove. Those fixes removed both, so they were an equilibrium-sampling artifact, not something symmetrization was missing.

If we later want a symmetric Δ' as a diagnostic, for example to compare entry by entry with TJ, the per-surface weights above take about ten lines to compute from the pair products. That can be added when someone needs it.

🤖 Generated with Claude Code

@d-burg d-burg closed this Oct 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants