Uh oh!
There was an error while loading. Please reload this page.
KineticForces: single METHOD_REGISTRY for NTV method flags, docs, and dispatch - #284
Merged
Merged
Conversation
…s, docs, and dispatch Closes#248. Replaces three position-coupled enumerations of the 18 NTV methods (KineticForcesInternal.methods/.docs vectors, the Compute.jl flags array, and the Torque.jl dispatch membership list) with a single const METHOD_REGISTRY of (name, flag, kind, doc) NamedTuples. Compute.jl iterates the registry and reads each flag via getfield; Torque.jl routes on the kind tag via method_kind. The 18 *_flag struct fields stay (the TOML kwargs splat and direct ctrl.*_flag accesses need them). The length-guard test is replaced with a structural test asserting every registry flag is a real KineticForcesControl field with a valid dispatch kind — no fixed count, so adding a method needs no magic-number edit. Verified: 190/190 kinetic unit tests pass; regression harness solovev_kinetic_calculated local vs develop is 15/15 identical (numerically inert). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
logan-nc
disabled auto-merge
June 15, 2026 00:59
Uh oh!
There was an error while loading. Please reload this page.
Merged
This was referenced Jul 30, 2026
logan-nc added a commit
that referenced
this pull request
Sep 4, 2026
The bounce-point spline samples 1-(lmda/bo)*B(theta), which is periodic on the closed poloidal interval, but was fitted with non-periodic endpoint conditions while the adjacent equilibrium B spline (tspl) was already periodic. The resulting fit is only C0 at the theta=0/1 seam, so it can manufacture false near-seam extrema and bounce-root pairs. On a synthetic shaped field the seam derivative mismatch drops ~5x (1.4e-4 -> 2.6e-5) when the fit is made periodic. Fixed at both construction sites (the tpsi! quadrature path and the _setup_surface_state kinetic-matrix path). Renamed B_extrap -> B_vpar and _vpar_from_extrap -> _vpar_from_spline, since after this change the old names describe a fit that no longer exists. Julia analog of Fortran GPEC PR #284, which fixed the same spline_fit(vspl, "extrap") -> "periodic" defect in pentrc/torque.F90 after it produced non-finite omega_b/omega_D and an LSODE failure on an ITER case. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes#248.
Problem
src/KineticForces/enumerated the same 18 NTV methods, in the same order, in three (really four) position-coupled places that had to be hand-kept in lockstep:KineticForcesInternal.methods(names) +.docs(doc strings) vectorsflags = [...]array inCompute.jl, indexedflags[m]againstintr.methods[m]/intr.docs[m]elseif method in ["fgar", …, "prmm"]dispatch list inTorque.jlThe positional coupling in (2) was the real hazard: a single transposed or omitted entry silently paired the wrong boolean/doc with the wrong method and would produce wrong-but-plausible NTV output. The old guard test only checked
length == 18, which would pass even with two flags swapped.Change
A single
const METHOD_REGISTRYinKineticForcesStructs.jlof(name, flag, kind, doc)NamedTuples is now the one place the methods are enumerated:Compute.jliterates the registry and reads each flag viagetfield(ctrl, entry.flag)— theflagsarray andmethods/docsvectors are gone.Torque.jlroutes on thekindtag (:gar/:fcgl/:rlar/:clar) via a newmethod_kindhelper, replacing the hardcoded membership list andelse error(...).*_flagstruct fields onKineticForcesControlstay — the TOML kwargs splat (KineticForcesControl(; (Symbol(k) => v …)...)) and directctrl.fgar_flagaccesses require them.The length-guard test is replaced with a structural test asserting every registry
flagis a realKineticForcesControlfield with a recognizedkindand round-trips throughmethod_kind— no fixed count, so adding a method needs no magic-number edit.Drift surfaces drop from 3+ to 1.
Verification
runtests_kinetic.jl), including the newMETHOD_REGISTRYtestset.solovev_kinetic_calculated, local vs develop): 15/15 quantities identical (0.0e+00 / OK). The case exercises the NTV dispatch (nonzero kineticIm(et[1])), confirming the refactor is numerically inert.🤖 Generated with Claude Code