Commit b2ec04c
COILS - BUGFIX - Default the coil control surface to psihigh, not psi_N=1 (Fortran parity)
sample_boundary_grid (and the two pass-throughs compute_coil_forcing_modes! /
convert_forcing_normalization!) defaulted to psi_N=1, which extrapolates the
geometry splines past their last knot. Fortran GPEC does not do this:
gpec/gpec.f:431 CALL field_bs_psi(psilim, coilmn(:,j), ...)
coil/field.F:167-183 field_bs_psi = this function's analog, same splines,
same rfac = SQRT(crzphi_f(1))
coil/field.F:133 Fortran's own name for the mesh: "control surface mesh"
dcon/sing.f:170 psilim = psihigh, moved only inward by sas_flag/qhigh/psiedge
equil/inverse.f:142 psihigh is the last knot -> Fortran never extrapolates
docs/index.rst:60 external field is on the boundary "defined by the psihigh
variable in equil.in"
Both Fortran-comparison benchmarks already pass Fortran's own psilim explicitly
(benchmark_against_fortran_run.jl:548, benchmark_coil_ForcingTerms_against_fortran.jl:236),
so the psi_N=1 default was never exercised on a Fortran-validated path.
Numerically, on the DIII-D-like example (psihigh=0.995) rzphi_rsquared is +0.29
at psi_N=0.995 but -22.6 at psi_N=1 (negative on 15/96 theta), so sqrt threw a
DomainError. The extrapolated distance is fixed at 1-psihigh while the final
spline interval shrinks with edge packing, so refining the pass-1 auto grid in
this PR exposed it: runtests_coils passes 8/8 at PASS1_INTERVALS=128 and errors
at 512/1024. Fixing the root cause keeps PASS1_INTERVALS=1024 and leaves the
Delta' convergence untouched (dpm[1,1] = 9.246/9.291/9.239 at 256/512/1024).
Impact: coupling surface moves inward by (1-psihigh) — 0.05% of flux at the
default psihigh=0.9995. Callers passing psi explicitly are unaffected.
Known gap: strictly faithful is psilim (integration limit), not psihigh
(spline limit); they differ when dmlim/qhigh/psiedge fire. psihigh is all a bare
PlasmaEquilibrium knows — callers with an FFS solve should pass intr.psilim.
Full test suite passes locally.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>1 parent 8f5254e commit b2ec04c
1 file changed
Lines changed: 43 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
50 | | - | |
| 50 | + | |
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
55 | | - | |
56 | | - | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
57 | 94 | | |
58 | 95 | | |
59 | 96 | | |
| |||
64 | 101 | | |
65 | 102 | | |
66 | 103 | | |
67 | | - | |
| 104 | + | |
68 | 105 | | |
69 | 106 | | |
70 | 107 | | |
| |||
226 | 263 | | |
227 | 264 | | |
228 | 265 | | |
229 | | - | |
| 266 | + | |
230 | 267 | | |
231 | 268 | | |
232 | 269 | | |
| |||
307 | 344 | | |
308 | 345 | | |
309 | 346 | | |
310 | | - | |
| 347 | + | |
311 | 348 | | |
312 | 349 | | |
313 | 350 | | |
| |||
0 commit comments