Skip to content

GPEC - BUG FIX - Use each surface's own R for |grad psi| in xbnormal - #356

Merged
logan-nc merged 1 commit into
developfrom
bugfix/xbnormal-surface-r
Oct 24, 2026
Merged

logan-nc merged 1 commit into
developfrom
bugfix/xbnormal-surface-r

Conversation

@logan-nc

Copy link
Copy Markdown
Contributor

gpout_xbnormal builds |∇ψ| (delpsi, which normalizes xno, bno and bwp) from the shared surface array r(:) but never sets it. Each surface therefore used whatever surface the previous caller left in r. Inside the loop that is usually the previous surface, because gpeq_bcoords resets r when it transforms coordinates. On the first surface it was whatever gpout_singfld had left, which is the symptom @krystophny found in #353, where switching singfld_flag changed the xbnormal output.

This adds one line that sets r(itheta) from the surface's own rs(istep,itheta) before it is used, the same way the gpeq_* routines set r themselves. It is the only routine in gpec/ that read r without setting it. This supersedes #353, which saved and restored r around gpout_singfld. That made the output independent of the flag, but it still used the wrong surface's R.

Checks (gfortran -O3, develop vs this branch):

singfld_flag t vs f, develop singfld_flag t vs f, this PR develop vs this PR (max |Δ|/max over xno, bno, bwp)
regression_solovev_ideal (jac_out=pest) differ, 2e-5 identical 3.7e-3, at ψ≈0.99
DIIID_ideal (jac_out=hamada) identical identical 7.0e-4, at ψ≈0.99

All runs terminate normally. The xbnormal outputs of every run move slightly, so this needs a line in the 1.6.0 release notes.

Closes #353.

🤖 Generated with Claude Code

https://claude.ai/code/session_01VMDGyfQKRZQMdk3NJXsKQE

gpout_xbnormal formed |grad psi| from the shared r(:) without setting
it, so each surface used whatever surface the previous caller left
there: usually one surface behind, and on the first surface whatever
gpout_singfld left. Set r(itheta) from the surface's own rs, as the
gpeq_* routines do. xno, bno and bwp move by up to 0.4% near the edge
and no longer depend on singfld_flag.

Supersedes #353.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VMDGyfQKRZQMdk3NJXsKQE
@logan-nc logan-nc added this to the v1.6.0 milestone Oct 24, 2026
@logan-nc logan-nc self-assigned this Oct 24, 2026
@logan-nc
logan-nc merged commit 28af32f into develop Oct 24, 2026
5 checks passed
@logan-nc logan-nc mentioned this pull request Oct 24, 2026
27 tasks done
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.

1 participant