Uh oh!
There was an error while loading. Please reload this page.
EQUIL - BUG FIX - Integrate equilibrium 0D flux integrals out to the boundary - #292
Conversation
36b8cda to
ebe92a2Compareebe92a2 to
f899c68Compare…boundary The 0D flux-surface integrals (betat, betap*, betaj, li1/2/3, volume) stopped at the last grid point (psihigh) and dropped the edge slice out to the plasma boundary psi=1. On the Fortran-matched DIII-D grid (psihigh=0.993) this made volume/li2/li3 ~1.5-1.8% low and betat/betan ~1.5% high vs Fortran equil_out_global. Switch the four trapezoidal sums to the native FastInterpolations cubic integral over [psilow, 1]; ExtendExtrap carries the integral past psihigh to the boundary, matching what Fortran adds. After the fix, the matched-grid run agrees with dcon.out to <=0.5% (volume 0.05%, betat 0.01%, li1 0.12%); the remaining residual is a separate pre-existing ~0.3% crnt edge-geometry difference. Track the previously-untracked 0D params (li1/2/3, betap1/2/3, betaj, volume, crnt, bt0, bwall, aratio, kappa) in the diiid_n1 regression case. Harness: only the flux-integration params move (<=0.12% on the shipped example, psihigh=0.9995); all energies, q/pressure checksums, singular surfaces, and PE outputs bit-identical. Add a "Minimal-change discipline" note to CLAUDE.md (reuse native ops/existing utilities, size the change to the problem, no throwaway artifacts for minor fixes). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
f899c68 to
a378e2cComparelogan-nc
commented
Jun 20, 2026
@parkjk who found funny li values? I was only able to see ~1% differences with fortran and here I fix them to be <1%. I don't see any way the minor differences would have made "crazy" li unless the psilow or psihigh was 0.5 or something unusual like that. If your group is still or is ever finding odd results - be sure to post an issue so we can fix them! |
Uh oh!
There was an error while loading. Please reload this page.
@logan-nc |
Bug
The 0D flux-surface integrals behind
betat,betap*,betaj,li1/2/3, andvolumeintegrated only up to the last grid point (psihigh) and dropped the edge slice out to the plasma boundary ψ=1 that Fortranequil_out_globalincludes. On the Fortran-matched DIII-D grid (psihigh=0.993) this madevolume/li2/li3~1.5–1.8% low andbetat/betan~1.5% high.Fix (minimal)
Replace the four trapezoidal sums with the native FastInterpolations cubic integral (already used elsewhere in this file) plus Fortran's linear edge slice to ψ=1 — a small local
fsiclosure, no new module-level machinery:Verified against the Fortran DIII-D KEFIT
dcon.out(matched hamada/ldp grid, psilow=1e-4, psihigh=0.993, mpsi=128, mtheta=256):volume0.02%,betat0.015%,li10.09%,li2/li3~0.5%,betan0.34%. All remaining residual is a separate, pre-existing ~0.3%crntedge-geometry difference (every leftover is a crnt/bwall-dependent quantity), out of scope.Regression
Tracks the previously-untracked 0D params (
li1/2/3,betap1/2/3,betaj,volume,crnt,bt0,bwall,aratio,kappa) indiiid_n1.regress --cases diiid_n1 --refs develop,local: 10 changed, 36 unchanged — only the flux-integration params move (≤0.12% on the shipped example, whosepsihigh=0.9995shrinks the edge slice); all energies, q/pressure checksums, singular surfaces, Δ', and PE outputs are bit-identical.Also
Adds a short "Minimal-change discipline" note to
CLAUDE.md(reuse native ops/existing utilities before writing new ones; size the change to the problem; no throwaway benchmark/agent-memory artifacts for minor fixes).🤖 Generated with Claude Code