Repository navigation
Equilibrium - BUGFIX! - Build F and P of g-file and IMAS equilibria from the tabulated FF′ and p′ - #506
Equilibrium - BUGFIX! - Build F and P of g-file and IMAS equilibria from the tabulated FF′ and p′#506d-burg wants to merge 1 commit into
Conversation
…rom the tabulated FF′ and p′ The g-file and IMAS readers took F and P from the tabulated profiles and left their derivatives to the cubic spline. F varies by only a few percent across the plasma, so rounding in the table (single precision in TokaMaker and classic EFIT output) leaves F′ nearly right in value but wrong in slope at the node scale, and Δ′ responds to that slope. `profile_source = "derivatives"` (the new default) integrates the file's FF′ and p′ inward from the boundary values of F and P, always for both profiles together. `profile_source = "values"` keeps the previous behaviour, and the reader falls back to it with a warning when the derivative arrays are absent or unusable. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
This pull request is missing a reviewer. If you are not ready to name them, mark this pull request as a draft. |
1 similar comment
|
This pull request is missing a reviewer. If you are not ready to name them, mark this pull request as a draft. |
|
Parking this PR. OpenFUSIONToolkit/OpenFUSIONToolkit#358 fixes the noise at the writer, and with double-precision g-files develop gives clean Δ′ without this change. Integrating FF′ and p′ also moves surfaces near pedestal kinks by more than the noise it removes (cubic, trapezoid and Akima rules disagree there by several units). Results and the open points are in #504. The one CI failure is the Δ′(2/1) pin of the in-repo example, which this change moves by design; it is left as is while the PR is parked. |
|
@d-burg do we want to close this and just have a loud warning if a user tries to use a single-precision equilibrium with an integrator that calculates Delta'? @StuartBenjamin has a PR stacked on this one, I am going to unstack it and rebase on develop because the i-file compatibility improvement is useful. |
|
@matt-pharr Agreed, let’s close this. The Δ′ noise it targets comes from the input file, not from GPEC. OFT’s double-precision g-file writer (OFT PR 358) removes it for every new file with GPEC unchanged. Rebuilding F and P from FF′ and p′ also moves the edge surfaces through its quadrature, which is more change than the problem warrants. I’d warn when a geqdsk's FPOL looks single precision (every value round trips through Float32 exactly) and the integrator computes Δ′: probably should say that Δ′ can carry noise of order +/- 2-3 at 257 radial nodes, and suggest the user regenerates the file in double precision. I can open that as a small PR unless you'd like to? |
|
@d-burg good idea, you are free to open that PR and add me as a reviewer |
|
Per the thread this is agreed closed: the Δ′ noise comes from single-precision g-files, which OFT's double-precision writer fixes, and #596 (draft) carries the loud warning Matt asked for. Suggest closing and dropping the milestone so the 2.0 list reflects what is still moving. |
|
Closing this, as @logan-nc suggested, and removing it from the 2.0 milestone. #596 takes the alternative agreed here: GPEC's quadrature stays as it is, and a run on a g-file with single-precision FPOL warns, since that is where the Δ′ noise comes from. New files written by OFT's double-precision writer don't have the problem. The quadrature change here also moved the edge surfaces, which is the reason not to merge it as it stands. |
Release note
efit,efit_arclength,efit_by_inversion) and IMAS result moves. On the DIII-D-like example: Δ′ diagonal up to 15 %, free-boundary energy 0.6 %, SLAYER γ 6 %, NTV torque 2.8 %. Solovev is unchanged. (harness @ b3f412f)profile_source = "values"in[Equilibrium]to reproduce earlier results exactly.F and P of a g-file or IMAS equilibrium are now the integrals of the file's FF′ and p′, anchored at the boundary values, instead of the tabulated F and P. Differentiating a tabulated F amplified its rounding error into the current gradient, which put noise of several units on Δ′ for 257-node files written in single precision. Closes #504.
What changed
read_efitandread_imasfill the F and P columns of the 1D table through one helper (integrate_profile_derivatives), always for both profiles together. Everything downstream is untouched and still differentiates one spline.[Equilibrium]keyprofile_source:"derivatives"(default) or"values"(previous behaviour, bit-identical to develop).1e-4of F or 5 % of the peak pressure. It falls back to"values"with a warning when the derivative arrays are absent, all zero, non-finite, or opposite in sign for only one of the two profiles.Regression report
regress --cases diiid_n1,diiid_n1_riccati,diiid_slayer_n1,diiid_error_field,diiid_multi_n,efit_fixedbdy_separatrix,gal_resistive_diiid,gal_resistive_pe,solovev_n1 --refs 0e68a0553,b3f412f35 --force(julia 1.11.9, x86_64, pinned manifest, 8 threads).Unit tests on the same commit: equilibrium 305/305, IMAS 32/32, rerun-from-h5 40/40.
Validation beyond the harness
profile_source = "values"gives develop's Δ′(2/1) to every digit on two files.ldp,mpsi = 256) it is 0.027 rms.TkMkr_D3Dlike_Hmode.geqdskwith F rebuilt from FF′, Julia and Fortran STRIDE give Δ′(2/1) of 7.27 and 7.28. Fortran GPEC has the same defect and will need the same fix.Notes for reviewers
diiid_n1PE toroidal torque changes sign (+0.0509 → −0.0506). The same flip is recorded under grid refinement in PE toroidal torque changes sign under grid refinement while its magnitude stays stable to ~1% #370; I have not investigated it here.diiid_error_fieldrotation-scan quantities move 50–66 %. The scan shifts themselves change, which suggests a discrete choice moved; not investigated.read_imastoo; the overlap is the block that builds the 1D table.profile_source = "values", so the previous numbers stay tracked. Not added here.🤖 Generated with Claude Code