Skip to content

EQUIL - BUGFIX - Bound grid_type original by psilow and psihigh - #335

Merged
matt-pharr merged 3 commits into
developfrom
bugfix/original-grid-psi-limits
Oct 23, 2026
Merged

matt-pharr merged 3 commits into
developfrom
bugfix/original-grid-psi-limits

Conversation

@StuartBenjamin

@StuartBenjamin StuartBenjamin commented Oct 19, 2026 •

Copy link
Copy Markdown
Collaborator

grid_type = "original" is meant to put the equilibrium on the input file's own ψ surfaces, but it took every one of them and ignored psilow and psihigh:

  • Inverse files (inverse_run, inverse_chease4_run): the grid ran from the axis to the last file surface. On TokaMaker i-files RDCON and STRIDE then never return, because the top/bottom search in equil_out_sep_find does not converge on that surface and has no iteration limit. The sas_flag reform to psilim could not move the edge either.
  • Direct files (direct_run): sq%xs=sq_in%xs(1:mpsi) assigns mpsi values to an array of mpsi+1, so sq%xs is reallocated with the wrong size and bounds. The shipped DIIID_ideal_example with grid_type="original" stops with "Took too many steps to find flux surf.".

This PR makes the original grid psilow, then the file's surfaces strictly between psilow and psihigh, then psihigh: the same end points as every other grid type. A small new grid_mod function, clipspace, does this for both readers. The other grid types are unchanged.

grid_type="original" develop this PR
DIIID_ideal_example (g-file 257×257), DCON and STRIDE stops: "Took too many steps to find flux surf." runs; psilim 0.995, as with ldp (DCON energy: see below)
DIII-D TokaMaker i-file 129×257, RDCON and STRIDE does not return (killed after 180 s) runs (STRIDE 4 s); psilim 0.9962, as with ldp
DIII-D TokaMaker g-file 257×257, STRIDE does not return runs

STRIDE Re Δ′ (n = 1, mtheta 128) with this PR, as the change against ldp with mpsi 4096 on the 513×1025 i-file of the same equilibrium (DIII-D 174956 at 1490 ms):

input and grid q = 2 q = 3 q = 4 q = 5 q = 6
i-file 257×513, original −1.6 % −0.2 % +0.8 % +2.3 % +8.2 %
i-file 513×1025, original −0.5 % +0.2 % 0.0 % +0.9 % −12 %
g-file 1025×1025, original +1.1 % +0.5 % +0.4 % 0.0 % +38 %
g-file 1025×1025, ldp mpsi 4096 +1.0 % +6.9 % −3.1 % −4.1 % +1.3 %

The original grid now converges with file size on the interior surfaces. q = 6 sits just inside psilim, where the file's own surfaces are sparser than a packed ldp grid.

Running is not the same as being accurate. The original grid is only as fine as the file's grid, and a g-file's grid is uniform in ψ, so it is coarse at the edge. On DIIID_ideal_example, DCON's least stable total energy with this PR is:

grid mpsi least stable energy
original 256 (file) −1.516 (reported unstable)
ldp 128 / 256 / 512 0.772 / 0.798 / 0.803
pow1 256 0.801
rho 256 / 512 / 1024 / 2048 3.12 / 1.34 / 1.01 / 0.846

rho, also coarse at the edge, approaches the ldp value only slowly as mpsi grows, so this is edge resolution rather than a bug in the new grid. dcon/README and the input/equil.in comment now say this and recommend ldp unless the input grid is packed toward the edge. The README also corrects "psilow is used only for ldp": every grid type except rho uses it.

The scripts and inputs used are in the attached zip.


🤖 Generated with Claude Code

grid_type = "original" took every node of the input file and ignored
psilow and psihigh. On inverse files the grid ran from the axis to the
file edge, where the separatrix search in equil_out_sep_find never
converges (RDCON and STRIDE hang), and the psilim reform could not move
the edge. On direct files sq%xs was assigned mpsi nodes for its mpsi+1
(reallocating it), so the radial spline was corrupt. The grid is now
psilow, the file's nodes strictly between psilow and psihigh, and
psihigh (new grid_mod function clipspace).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ow and psihigh

grid_type 'original' builds the radial grid as psilow, the input nodes strictly inside, psihigh. An i-file node
at psilow + 1e-16 (OFT's axis_pack puts its first node at psi_N = 1e-5 = psilow, and round-off can land it on
either side) survived as a ~1e-16-wide first interval; RDCON and STRIDE then never left the axis (ODE steps of
1e-16, then garbage psi), hanging on every recomputed DIII-D i-file tested. Points within 1e-10 of the range of
an end are now dropped. Files without such a node give bitwise-identical output.

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

Copy link
Copy Markdown
Collaborator Author

Added a second commit: clipspace now also drops input nodes within round-off (1e-10 of the range) of psilow or psihigh. TokaMaker i-files put their first packed node at psi_N = 1e-5, and round-off can land it just above psilow = 1e-5. That left a ~1e-16-wide first interval on which RDCON and STRIDE never left the axis. Grids without such a node are unchanged.

…tion limit

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

@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.

This is good. I appended a minor docs update on this for reference

@matt-pharr
matt-pharr merged commit a362835 into develop Oct 23, 2026
6 checks passed
StuartBenjamin pushed a commit to StuartBenjamin/GPEC-1 that referenced this pull request Oct 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants