Repository navigation
DCON/RDCON/STRIDE: put the vacuum matrix and norm in the plasma's Fourier frame - #295
jhalpern30 wants to merge 3 commits into
Conversation
…r frame VACUUM runs on a theta-reversed boundary, so wv comes back complex-conjugated relative to wp; conjugate it after mscvac (free_run and free_wvmats). The eigenvector norm used jmat(jpert-ipert), the transpose of the plasma-matrix index order; use jmat(ipert-jpert). Up-down symmetric cases are unchanged; asymmetric ones no longer depend on the theta origin.
…er frame Same change as DCON: conjugate wv after mscvac (free_run and free_get_wvac, used by the Galerkin solve) and transpose the norm.
…ier frame STRIDE called mscvac with complex_flag false, keeping only Re(wv), which is itself origin-dependent. Keep the full matrix, conjugate it as in DCON, and transpose the norm.
|
@logan-nc the Fortran equivalent of the Julia fix - probably easiest to review them together |
|
@jhalpern30 FYI any delta W numbers you are getting from RDCON are actually just an old fork of regular DCON, there is no path in RDCON fortran from the galerkin solution to delta W. The delta W it gives comes from the regular forward integration solve happening in RDCON. |
|
@matt-pharr Yeah agreed, it was more so I wanted the free.f files between the branches to all reflect the fix, even if the paths are actually stale |
|
@claude review this pr |
|
Claude finished @logan-nc's task in 24s —— View job Review of PR #295The fix looks correct to me, and it matches the described mechanism: VACUUM runs on a θ-reversed grid, so Checked
Minor points (non-blocking)
Verdict: LGTM. This is a small, well-targeted fix with strong evidence in the PR description. Logan has already approved it. |
|
@jhalpern30 let me know if you want to address claude points 1 and 2 before merging. You can ignore 3. |
DCON's free-boundary energy depends on where θ = 0 sits on an up-down asymmetric equilibrium. Moving θ = 0 only relabels the coordinates, so it can't change δW. This PR fixes that by putting the vacuum matrix
wvand the eigenvector norm in the same Fourier frame as the plasma matrixwp. The change is a few lines each indcon/free.f,rdcon/free.fandstride/free.f. It is the Fortran counterpart of OpenFUSIONToolkit/GPEC#503.Same result, different mechanism. The Julia PR removes the θ reversal, so its vacuum runs in GPEC's own frame. This PR keeps VACUUM's reversed θ and conjugates
wvafterwards. In JPEC both routes give the samewvandI_vto ≤ 4e‑14 (PEST, Hamada, no wall and conformal wall). I chose different routes because the Julia change is more extensive but has longer term benefits of clarity, whereas this is the most direct fix to obtain a correct result.The bug
free.fpasses VACUUM a θ-reversed boundary. Reversing θ complex-conjugates every harmonic, sowvcomes back in the conjugate frame ofwp.gpvacuum.falready conjugates the surface current for this reason;wvwas never conjugated.jmat(jpert-ipert)*wt(ipert)*CONJG(wt(jpert)), the transpose of ∮J|ξ|²:amatputs that coefficient onCONJG(ξ_i)*ξ_j.The fix
wv=CONJG(wv)aftermscvacinfree_runand infree_wvmats(thepsiedgescan);jmat(jpert-ipert)→jmat(ipert-jpert)in both normalizations.free_runandfree_get_wvac(Galerkin).complex_flag=.TRUE.for itsmscvaccall. STRIDE kept only Re(wv), which is itself origin-dependent, so the conjugation alone does nothing there.Evidence, all from Fortran DCON (PEST, n = 1, no wall); least-stable δW over 16 θ origins:
psiedgescan is now independent of the origin too: the end point is 0.1995 at both origins tested (develop 0.2003 and 0.3607).solovev_idealanda10_idealare unchanged (δW to 1e‑10).DIIID_idealmoves 0.772038 → 0.771843; the vacuum and plasma parts each move about 1.5 %.wt0from DCON, so the default energy route for Λ and P picks up the fix with no patch of its own. The surface-current route was already in the right frame.RDCON and STRIDE, same asymmetric / symmetric decks, 5 origins:
STRIDE with the conjugation and norm only (Re(wv) kept) still spans 0.2008 – 0.2982. Stock examples: STRIDE
a10_idealandsolovev_idealunchanged,DIIID_resistive0.7798 → 0.7795. RDCONsolovev_resistiveunchanged,DIIID_resistive0.7644 → 0.7653, and its Galerkin Δ′ output is byte-identical.Reviewer page (figures): https://claude.ai/artifact/2SA9fP18tmWWQ4WgqwvmoB