Skip to content

EQUIL - BUGFIX - Sample every direct-equilibrium surface at the common straight-fieldline angles - #329

Merged
matt-pharr merged 2 commits into
developfrom
bugfix/direct-sample-sfl-angles
Oct 23, 2026
Merged

matt-pharr merged 2 commits into
developfrom
bugfix/direct-sample-sfl-angles

Conversation

@StuartBenjamin

Copy link
Copy Markdown
Collaborator

direct_run traces each flux surface with lsode, splines the surface on that trace's own steps, and resamples the spline onto the common θ grid. The resample error is therefore different on each surface, and the ψ derivatives in the stability coefficients amplify it. This PR runs the same trace a second time and samples it exactly at the common straight-fieldline angles: each target angle is found by Newton iteration on lsode's own interpolant (dintdy), and the solution is taken there. The Julia version made the same change in OpenFUSIONToolkit/GPEC#398.

solovev_ideal_example (DCON, mpsi 128), least stable total energy against the equilibrium tolerance etol:

etol develop this PR
1e-7 0.01013 0.00593
1e-9 0.00592 0.00595
1e-11 0.00593 0.00595

Develop only reaches the converged value as etol tightens; with this PR it no longer depends on etol.

Other examples (this PR against develop):

  • DIIID_ideal_example: least stable energy 0.77366 → 0.77364 (DCON); STRIDE Re Δ′ moves ≤ 0.9 % (q = 4: −17.38 → −17.23).
  • DIIID_resistive_example (RDCON): Δ′ unchanged to 4 digits.
  • solovev_resistive_example (RDCON): Δ′ 4.763e9 → 4.761e9.

At a tight tolerance (etol 1e-10, on DIII-D g-files at mpsi 256–2048) RDCON's Δ′ moves ≤ 2e-7 and STRIDE's ≤ 0.02 %. The cost is a second trace per surface, which is small next to the stability solve.


🤖 Generated with Claude Code

StuartBenjamin and others added 2 commits October 17, 2026 17:51
…n straight-fieldline angles

direct_run splined each traced surface on its own lsode steps and resampled it onto the theta grid, so the resample error was uncorrelated between surfaces and the psi derivatives amplified it. A second pass of the same trace now finds each target angle on lsode's interpolant (dintdy) and samples the solution there, as OpenFUSIONToolkit/GPEC#398 does in Julia GPEC.

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

Same results bit for bit; direct_fl_int keeps only the call.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
StuartBenjamin added a commit to StuartBenjamin/GPEC-1 that referenced this pull request Oct 18, 2026
…on straight-fieldline angles) into PSFC_dev
@logan-nc logan-nc mentioned this pull request Oct 21, 2026
27 tasks done
@StuartBenjamin
StuartBenjamin marked this pull request as ready for review October 23, 2026 02:14

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

I ran this myself, improvements check out. Thanks Stuart

@matt-pharr
matt-pharr merged commit 20b1139 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