Skip to content

Equilibrium - FEATURE - Warn when a g-file's FPOL is single precision and the run computes Δ′ - #596

Merged
matt-pharr merged 4 commits into
developfrom
feature/gfile-single-precision-fpol-warning
Oct 28, 2026
Merged

matt-pharr merged 4 commits into
developfrom
feature/gfile-single-precision-fpol-warning

Conversation

@d-burg

@d-burg d-burg commented Oct 26, 2026 •

Copy link
Copy Markdown
Collaborator

Release note

  • Audience: users
  • Numerical impact: none (harness @ 6bf955b)
  • Migration: none.

GPEC splines a g-file's FPOL and differentiates it, so when FPOL was written in single precision its rounding becomes noise in Δ′: about ±2–3 on Δ′(2/1) at 257 radial nodes on DIII-D-like files. Runs with the riccati or galerkin integrator on such a file now warn and suggest regenerating it in double precision. This is the alternative to #506 agreed there.

Changes

  • Equilibrium.gfile_fpol_single_precision(filename) (in Equilibrium/Sources/GFile.jl) reads only the header and the FPOL block, and returns true when every value lies within 1e-8 (relative) of its Float32 rounding.
    • Why 1e-8. Measured on the repo's g-files, single-precision FPOL sits at ≤ 1.5e-9 from its Float32 rounding. Double-precision values printed to the format's ten digits sit at a median of 1.6e-8, and a whole column below 1e-8 does not happen by chance.
    • Test: the shipped TokaMaker example is flagged, while the double-precision g65.geqdsk and EQDSK_COCOS_02 are not.
  • main_from_inputs warns once, after the equilibrium is built, for EFIT-type equilibria whose integrator computes Δ′. The warning names the file.

Regression report

regress --cases diiid_n1_riccati,solovev_n1,efit_fixedbdy_separatrix --refs 0b4b9fbfb,6bf955b94 --force on feynman (SLURM, 8 threads, manifest pinned), after merging develop at 0b4b9fbfb: every case is unchanged. runtests_equil.jl passes (332/332).

diiid_n1_riccati
Regression Report: diiid_n1_riccati
============================================================================
Ref 1: 0b4b9fbfb  @ 0b4b9fbfb (2026-10-27)
       env: julia 1.11.9, x86_64-linux-gnu, manifest f241dbfc (pinned), 8 threads/8 BLAS, jit build
Ref 2: 6bf955b94  @ 6bf955b94 (2026-10-27)
       env: julia 1.11.9, x86_64-linux-gnu, manifest f241dbfc (pinned), 8 threads/8 BLAS, jit build
----------------------------------------------------------------------------
Quantity                       0b4b9fbfb      6bf955b94      Diff     Status
----------------------------------------------------------------------------
delta prime (BVP diagonal)     [5 elem]       [5 elem]       0.0e+00  OK
delta prime (raw side-major)   [10 elem]      [10 elem]      0.0e+00  OK
edge coil response delta_coil  [10 elem]      [10 elem]      0.0e+00  OK
total energy Re(et[1])         8.031977e-01   8.031977e-01   0.0e+00  OK
plasma energy Re(ep[1])        -1.368533e+00  -1.368533e+00  0.0e+00  OK
vacuum energy Re(ev[1])        2.171731e+00   2.171731e+00   0.0e+00  OK
total energy (all)             [35 elem]      [35 elem]      0.0e+00  OK
# singular surfaces            5              5              0.0e+00  OK
singular psi locations         [5 elem]       [5 elem]       0.0e+00  OK
singular q values              [5 elem]       [5 elem]       0.0e+00  OK
ODE steps (saved)              96             96             0.0e+00  OK
ODE steps (total)              2643           2643           0.0e+00  OK
mpert                          35             35             0.0e+00  OK
npert                          1              1              0.0e+00  OK
q0                             1.204212e+00   1.204212e+00   0.0e+00  OK
q95                            4.781723e+00   4.781723e+00   0.0e+00  OK
beta_n                         1.372511e+00   1.372511e+00   0.0e+00  OK
Runtime (s)                    240.3s         234.5s                  --
============================================================================
Summary: 17 unchanged
solovev_n1
Regression Report: solovev_n1
=================================================================================
Ref 1: 0b4b9fbfb  @ 0b4b9fbfb (2026-10-27)
       env: julia 1.11.9, x86_64-linux-gnu, manifest f241dbfc (pinned), 8 threads/8 BLAS, jit build
Ref 2: 6bf955b94  @ 6bf955b94 (2026-10-27)
       env: julia 1.11.9, x86_64-linux-gnu, manifest f241dbfc (pinned), 8 threads/8 BLAS, jit build
---------------------------------------------------------------------------------
Quantity                      0b4b9fbfb        6bf955b94        Diff       Status
---------------------------------------------------------------------------------
total energy Re(et[1])        1.090571e-02     1.090571e-02     0.0e+00    OK
total energy Im(et[1])        -3.987034e-10    -3.987034e-10    0.0e+00    OK
plasma energy Re(ep[1])       -1.041640e+01    -1.041640e+01    0.0e+00    OK
vacuum energy Re(ev[1])       1.042730e+01     1.042730e+01     0.0e+00    OK
vacuum matrix min eigenvalue  2.170703e+00     2.170703e+00     0.0e+00    OK
plasma energy (all)           [32 elem]        [32 elem]        0.0e+00    OK
vacuum energy (all)           [32 elem]        [32 elem]        0.0e+00    OK
total energy (all)            [32 elem]        [32 elem]        0.0e+00    OK
ODE steps (saved)             289              289              0.0e+00    OK
ODE steps (total)             287              287              0.0e+00    OK
q0                            1.900006e+00     1.900006e+00     0.0e+00    OK
q95                           3.147422e+00     3.147422e+00     0.0e+00    OK
beta_t                        4.621027e-02     4.621027e-02     0.0e+00    OK
beta_n                        3.217775e+00     3.217775e+00     0.0e+00    OK
# singular surfaces           2                2                0.0e+00    OK
singular psi locations        [2 elem]         [2 elem]         0.0e+00    OK
singular q values             [2 elem]         [2 elem]         0.0e+00    OK
mpert                         32               32               0.0e+00    OK
npert                         1                1                0.0e+00    OK
q profile (checksum)          260c3629d39c...  260c3629d39c...  identical  OK
pressure profile (checksum)   3dc9cd459e40...  3dc9cd459e40...  identical  OK
ca_left (checksum)            a784076f8ecc...  a784076f8ecc...  identical  OK
Runtime (s)                   226.3s           223.3s                      --
=================================================================================
Summary: 22 unchanged
efit_fixedbdy_separatrix
Regression Report: efit_fixedbdy_separatrix
=======================================================================
Ref 1: 0b4b9fbfb  @ 0b4b9fbfb (2026-10-27)
       env: julia 1.11.9, x86_64-linux-gnu, manifest f241dbfc (pinned), 8 threads/8 BLAS, jit build
Ref 2: 6bf955b94  @ 6bf955b94 (2026-10-27)
       env: julia 1.11.9, x86_64-linux-gnu, manifest f241dbfc (pinned), 8 threads/8 BLAS, jit build
-----------------------------------------------------------------------
Quantity                    0b4b9fbfb     6bf955b94     Diff     Status
-----------------------------------------------------------------------
psio (total poloidal flux)  3.344390e-01  3.344390e-01  0.0e+00  OK
q0                          1.155202e+00  1.155202e+00  0.0e+00  OK
q95                         5.741022e+00  5.741022e+00  0.0e+00  OK
beta_t                      3.945193e-05  3.945193e-05  0.0e+00  OK
beta_n                      1.009510e-01  1.009510e-01  0.0e+00  OK
Runtime (s)                 59.0s         58.6s                  --
=======================================================================
Summary: 5 unchanged

Notes for reviewers

  • The shipped examples trigger the warning. TkMkr_D3Dlike_Hmode.geqdsk, used by most DIII-D-like examples and harness cases, and the efit_fixedbdy example file are both single precision, so riccati and galerkin runs on them now warn. That is accurate. Regenerating them with OFT's double-precision writer would remove the noise, but it would move every pinned Δ′, so it belongs in its own PR.
  • Deck path only. The check sits in main, so a script that calls the solver API directly does not get it.

🤖 Generated with Claude Code

… and the run computes Δ′

GPEC splines FPOL and differentiates it, so the rounding of a single-precision FPOL column
becomes noise of order ±2–3 on Δ′ at 257 radial nodes. Runs with the riccati or galerkin
integrator on such a g-file now warn and suggest regenerating it in double precision. The
check is gfile_fpol_single_precision: every FPOL value within 1e-8 of its Float32 rounding.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@matt-pharr

Copy link
Copy Markdown
Collaborator

Merged develop and ported gfile_fpol_single_precision from the removed ReadEquilibrium.jl into Sources/GFile.jl. The helper, driver warning, and detection tests retain their original behavior.

@matt-pharr

Copy link
Copy Markdown
Collaborator

@d-burg do you want review on this now? It is marked as a draft still

@d-burg
d-burg marked this pull request as ready for review October 27, 2026 18:49
@d-burg

d-burg commented Oct 27, 2026

Copy link
Copy Markdown
Collaborator Author

@matt-pharr yes please, and thanks for porting the check into Sources/GFile.jl. I've merged develop again on top of your merge (6bf955b94) and rerun the harness: diiid_n1_riccati, solovev_n1 and efit_fixedbdy_separatrix are unchanged, and runtests_equil passes 332/332. The description is updated, and the PR is now marked ready for review.

@matt-pharr matt-pharr left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Useful change and something we should all be more aware of in Delta' world :)

@matt-pharr
matt-pharr merged commit 834cada into develop Oct 28, 2026
12 of 13 checks passed
@matt-pharr
matt-pharr deleted the feature/gfile-single-precision-fpol-warning branch October 28, 2026 11:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New capability

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants