Repository navigation
Equilibrium - g-file reader differentiates FPOL and PRES and discards FFPRIM and PPRIME, putting rounding noise on Δ′ #504
Description
Activity
Correction to the first caveat above. The large 4/1 changes (13 as written, 35 or 50 rebuilt) came from rebuilding F alone, which leaves it inconsistent with the as-written P near the edge. With F and P both rebuilt from
FFPRIMandPPRIME:- the same-state gap stays closed on all three surfaces (rms B − A: 2/1 0.16, 3/1 0.17, 4/1 0.22; as written 3.70, 0.67, 1.20);
- 4/1 returns to or near its as-written value in three of five pairs (for example −16.7 → −16.6) and is 4–7 away in the others.
So a fix should take F and P together from
FFPRIMandPPRIME, never one alone. The end-node features remain an open but smaller question. Rebuilding P alone moves Δ′(2/1) by ≤ 0.27 on eight of the ten files; the kinetic EFIT 257 file moves by 2.1, cause not yet identified.Update: the writer fix is enough for new files; the GPEC-side change (#506) is parked
OpenFUSIONToolkit/OpenFUSIONToolkit#358 (merged 2026-10-07) makes TokaMaker's
gs_save_eqdskwrite doubles instead of single precision. I tested it with GPEC unchanged.Test. bouquet's public D3D-like H-mode example: four equilibria, each written by the old and the new writer from the same solver state (one OFT build with only that change added). develop
0e68a0553, n = 1, Riccati, settings as in the issue.Same state, two g-files whose inputs differ only in the last digits. rms gap in Δ′ over three states:
grid writer 2/1 3/1 4/1 ldp 256 single 0.29 0.83 1.08 ldp 256 double 0.014 0.021 0.088 ldp 512 single 1.28 1.98 1.26 ldp 512 double 0.07 0.08 0.13 auto single 1.76 2.25 1.59 auto double 0.42 0.14 0.41 - On fixed grids the gap falls by about a factor of 20.
- The auto-grid residual is the grid's own response to small input changes (one state at −0.72 on 2/1, two near 0.1). That is a separate matter from this issue.
- develop on double-precision files agrees with Equilibrium - BUGFIX! - Build F and P of g-file and IMAS equilibria from the tabulated FF′ and p′ #506 to 0.04 on 2/1, 3/1 and 4/1 (ldp 256).
Why #506 is parked. Integrating FF′ and p′ needs an assumed shape between nodes, and near profile kinks that assumption moves Δ′ by more than the noise it removes.
- Public example, 6/1 surface, ldp 256: −20.5 (single) and −20.3 (double) on develop, −11.2 with Equilibrium - BUGFIX! - Build F and P of g-file and IMAS equilibria from the tabulated FF′ and p′ #506.
- On the five same-state pairs in the issue, Δ′(4/1) differs from the value given by the file's own F and P by 5.1 rms with the cubic rule of Equilibrium - BUGFIX! - Build F and P of g-file and IMAS equilibria from the tabulated FF′ and p′ #506, 4.9 with trapezoid and 1.5 with Akima. Δ′(2/1) is the same for all three rules to within 0.1.
- No rule suits every writer. EFIT and kinetic-EFIT files tabulate
FPOLandPRESas the trapezoid integral ofFFPRIMandPPRIME(trapezoid reproduces them to rounding); TokaMaker files with piecewise-linear profiles do not follow that rule. - This corrects a caveat in the issue: the end nodes of
FFPRIMare not what moves the edge surface. Changing the axis node has no effect on Δ′, and the boundary node moves 4/1 by at most 0.4. The kinks in the pedestal foot are the cause.
Still open.
- g-files already written in single precision (older TokaMaker output, some EFIT output) keep the noise. A reader warning when
FPOLis exactly single precision would at least make it visible. PSIRZmatters too: single-precision ψ(R,Z) alone puts about 0.03 on Δ′(2/1) per file on a fixed grid. Only the writer can fix that, and VAC - REFACTOR - Give the Vacuum module its own output struct #358 does.- Nine printed digits leave rounding of about 1e-9. I have not tested g-files finer than 257 nodes, where the amplification is larger.
- Fortran GPEC behaves the same way; see the comment on Equilibrium - BUGFIX - Build F and P values in sq spline from FF′ and p′ information PrincetonUniversity/GPEC#297.
Summary
For
eq_type = "efit",read_efitparsesFFPRIMandPPRIMEand discards them. F′ and p′ then come from cubic splines ofFPOLandPRES. F′ enters the Euler-Lagrange matrices directly (jtheta = -F′), and Δ′ depends on how F′ varies across each rational surface. F changes by only a few percent across the plasma, so rounding noise inFPOLleaves F′ nearly right in value (0.04 % rms) but wrong in slope at the node scale: the error in dF′/dψ grows as roughly 1/(h²δ) (h = node spacing, δ = fractional variation of F). On 257-node g-files written in single precision this puts noise of a few units on Δ′(2/1).Evidence
Static, in-repo file.
examples/DIIID-like_ideal_example/TkMkr_D3Dlike_Hmode.geqdsk(257 nodes; everyFPOLvalue is exactly a single-precision number). The spline F′ matchesFFPRIM/F to 0.04 % rms, but its slope scatters about theFFPRIM-derived slope by up to 37 % near q = 2. No F″ is formed explicitly; the slope enters through the ψ-variation of the splined coefficient matrices:Same state, two g-files. Five pairs of g-files of one equilibrium state (inputs agree to 1e-5) gave Δ′(2/1) differing by up to 6.2 (rms 3.7). The gap is unchanged on develop, on an identical fixed ψ grid, and with #398, #480 and #491 applied. Swapping only the
FPOLblock between the two files moves 82–101 % of the gap with it. RebuildingFPOLas the integral of the file's ownFFPRIMcloses it (rms 0.17).Noise ladder. Seeded relative noise on
FPOLshifts Δ′(2/1) linearly, about 9e7 × noise: 0.15 at 1e-9, 2.1 at single precision (2.4e-8). The same experiment onFFPRIMis about 900 times less sensitive.Ten g-files of different provenance. Δ′(2/1), n = 1, Riccati, auto grid:
FPOLFFPRIMFFPRIM,PPRIMEThe effect grows with g-file resolution and with single precision: negligible at 65 nodes, about ±0.2 at 129, units at 257 single precision. Rebuilding P as well changes 2/1 by ≤ 0.14 on eight of ten files.
Caveats for a fix
FFPRIMis not clean at the end nodes of TokaMaker files (axis-node spike, last-node drop). The 2/1 result is insensitive to how these are integrated (12.35 spline quadrature, 12.50 trapezoid), but an edge 4/1 entry is not (13 as written, 35 or 50 rebuilt). A fix needs an explicit end-node treatment.PRESandPPRIMEdisagree the result moves (kinetic EFIT 257 above, and outer surfaces), and these tests do not say which array is right.efit-type result will move, including the regression cases built on the in-repo example.Notes
gs_save_eqdskwrites every array asREAL(x,4). Writing doubles would reduce the noise to the 9-digit print limit (about ±0.1 here), but would not help existing files or single-precision EFIT output.1b385a504;read_efitis unchanged on develop57ec7e16a. Settings:psilow = 0.01,psihigh = 0.998,mtheta = 512,delta_mlow = delta_mhigh = 8,qlow = 1.02,dmlim = 0.2,sing_order = 6.