Skip to content

RDCON - BUGFIX - Galerkin F built from the factored spline used by the asymptotics - #303

Merged
matt-pharr merged 2 commits into
developfrom
pr_rdcon_galerkin_spline
Oct 15, 2026
Merged

matt-pharr merged 2 commits into
developfrom
pr_rdcon_galerkin_spline

Conversation

@StuartBenjamin

@StuartBenjamin StuartBenjamin commented Oct 13, 2026 •

Copy link
Copy Markdown
Collaborator

RDCON's Galerkin solve and the asymptotic series at each rational surface used two different splines of F. gal_get_fkg built F from fmats_gal, a spline of F. sing_mmat/sing1_mmat use fmats, a spline of its Cholesky factor L (F = L Lᴴ). Between grid points these differ, so the big asymptotic solution does not exactly solve the Galerkin operator. The residual is singular at the surface, and Δ′ picks up an error that jumps with purely numerical settings (nx, dx1/dx2, gal_tol). 3/1 is hit hardest because its Δ′ is a large cancellation.

Fix

gal_get_fkg builds F = (QL)(QL)ᴴ from fmats, with Q = diag(m − nq), so both parts use the same F. fmats_gal is now used only for the bin_fmat diagnostic. Side effect: with delta_mband > 0, the F entries outside the band were left undefined; they are now zero. (K and G outside the band are still unset, a separate older issue.)

Results

D3D-like TokaMaker i-file (mpsi 257, n = 1, sing_order 8, LU), one numerical setting changed at a time:

Δ′(3/1) develop this PR
nx 128 / 256 / 512 / 1024 −3.78 / −3.90 / −5.45 / −4.45 −3.812 / −3.811 / −3.815 / −3.830
gal_tol 1e-9 / 1e-11 / 1e-12 −3.88 / −3.72 / −3.83 −3.814 / −3.817 / −3.809
spread over all 10 runs (also dx1/dx2 ×½, ×2 and psihigh + 1e-6) 45 % 0.8 %

Shipped examples, Δ′ range over nx 128–1024:

develop this PR
a5_tearing 2/1 13.04 to 13.43 13.16 to 13.22
DIIID_resistive 2/1 3.71 to 4.05 3.81 to 3.84
DIIID_resistive 3/1 −9.63 to −10.07 −10.138 to −10.142

Not improved: DIIID 4/1 (−23.3 to −24.1 on develop, −24.0 to −25.2 here) and the edge surfaces. DIIID 5/1 spreads more here (−3767 to −4570, develop −3383 to −3415), and 6/1 is unconverged in both. All runs still have the sing_mmat slot typo that #304 fixes.

Scripts: rdcon_galerkin_spline_scripts.zip (python with numpy, xarray, netCDF4, matplotlib):

PY_DP=python3 ./sweep.sh DEV/bin/rdcon out_dev
PY_DP=python3 ./sweep.sh PR/bin/rdcon out_fix
python3 plot_dp.py out_dev/dp.txt out_fix/dp.txt dp_galerkin.png
dp_galerkin

run_examples.sh and plot_examples.py do the same for the shipped examples.

No dependencies; merges cleanly with #301.


🤖 Generated with Claude Code

…e asymptotics

gal_get_fkg took F from fmats_gal (cubic spline of Fbar) while the
singular-surface series (sing_mmat/sing1_mmat) and the resonant lsode
integrals use fmats (cubic spline of its Cholesky factor L). Between
knots spline(L L^H) /= spline(L) spline(L)^H, so the big solution is not
a solution of the Galerkin operator; the residual is singular at the
surface and Delta' depended on nx, dx, cutoff, sing_order and gal_tol.
Build F = (Q L)(Q L)^H from fmats instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@StuartBenjamin
StuartBenjamin marked this pull request as ready for review October 13, 2026 09:27
@StuartBenjamin
StuartBenjamin marked this pull request as ready for review October 13, 2026 09:27

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

Nice clean tweak!

@matt-pharr
matt-pharr merged commit 312ec17 into develop Oct 15, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants