Repository navigation
ErrorFields - BUGFIX! - Sum the NTV couplings over the resolved kinetic species - #580
Merged
Merged
Conversation
…ic species The error-field NTV couplings computed every correction array's torque for the deck's main ion alone, while the KineticForces diagnostics of the same run summed over the resolved species. The run's species list now reaches efc_couplings, whose torque at every rotation shift is the same species sum with each species' own profiles shifted, and the per-species control construction is shared by both paths. Single-ion decks are unchanged; the reference rotation stays the full-composition main ion's. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0186CLfjeJeSusNTva5RMfGU
…faults with isequal Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0186CLfjeJeSusNTva5RMfGU
…ings into ntv_torque_state The species sum at one rotation shift becomes a module-level function the couplings call, so the test can check it on the run's own perturbation instead of re-solving the plasma response. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0186CLfjeJeSusNTva5RMfGU
logan-nc
marked this pull request as ready for review
October 24, 2026 19:25
Resolve against the kinetic profiles now living on the equilibrium: efc_couplings derives the resolved species from the control and the equilibrium instead of taking a species argument, so run_error_fields keeps develop's signature. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0186CLfjeJeSusNTva5RMfGU
Port the species sum onto develop's layout: efc_couplings now lives in ErrorFields/NTVLimits.jl and the species identity is passed to compute_torque_all_methods! as z/m/electron, so species_control and its test are dropped and the error-fields test resolves species from the equilibrium's kinetic data.
matt-pharr
approved these changes
Nov 12, 2026
matt-pharr
left a comment
Collaborator
There was a problem hiding this comment.
Good fix that aligns the code with expected behavior. Approve
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 free
to 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.
Release note
ErrorFields/NTV/*moves for runs whose kinetic data resolve more than one NTV species (severalion_specieson the equilibrium, a partial or explicit main-ion density, or[KineticForces] electron = true); single-ion runs are unchanged (harness @ 2323fbd)[ErrorFields.NTV]gets species-summed correction-coil torques, rotation scans and NTV current limits on rerun; no input changesThe ErrorFields (EF) NTV couplings evaluated every correction array's torque for the main ion alone, while the KineticForces diagnostics of the same run summed over the resolved species. The couplings now resolve the same species set from the kinetic profiles attached to the equilibrium, so their torque at every rotation shift is the same species sum.
Regression report
Full fan-out on ITER's SDCC cluster (
regress_fanout.sh --refs a1149c5c2,2323fbdf6, all 27 cases, Julia 1.12.6, pinned manifest), branch2323fbdf6against developa1149c5c2. 385 tracked quantities, all unchanged; no stale-baseline banner — as predicted, since no case runs the error-field NTV couplings with more than one species.Notes for reviewers
efc_couplingscalledcompute_torque_all_methods!once, with the equilibrium's main ion on the full-composition NTV profiles. A D-T or electron run therefore wrote NTV diagnostics summed over species but NTV couplings for the main ion only, silently.efc_couplings(src/ErrorFields/NTVLimits.jl) resolves the species set withKineticForces.ntv_species(kf_ctrl, equil), as it already builds its profile view withntv_profiles. The torque of each perturbation at each rotation shift is the newErrorFields.ntv_torque_state, which with a species set loops the species exactly asKineticForces.kinetic_torquedoes: each species' own profiles shifted, its identity passed asz/m/electron, thencombine_species_states. Without a set nothing changes: the Δ = 0 short-circuit on the unshifted profiles is kept, so the single-ion path is the same code on the same inputs.kinetic_torquepasses the near-axis validity boundaryaxis_psi_cto the torque;efc_couplingsnever has (suppression off). Folding it in would move the single-iondiiid_error_fieldrows, so it is flagged here rather than changed.runtests_error_fields.jlchecksntv_torque_stateon the fixture run's own perturbation (no extra plasma-response solves): the main ion resolved on its own reproduces the single-ion torque (rtol 1e-6, the agreement between the resolved view and the NTV view of the same attached profiles), and a D-T set's torque equals the sum of its members' own torques (rtol 1e-12).2323fbdf6). Since the last stamp develop movedefc_couplingsout of the driver intoErrorFields/NTVLimits.jl, took the species composition offKineticForcesControlonto the equilibrium's kinetic data, and passes the species identity tocompute_torque_all_methods!as keywords. The fix was ported onto that layout:species_control(a per-species copy of the control) and itsruntests_multiion.jltest are gone, since nothing builds a per-species control any more, and the error-fields test now takes its species fromffs.equil.kineticandKineticForces.main_ion.ErrorFields/NTV/*row must be unchanged;tj_kinetic_multiionexercises the species sum on the diagnostics path. A multi-species error-field case could be added if those numbers should be tracked.No review package: a small bug fix, below the threshold for one.
🤖 Generated with Claude Code
https://claude.ai/code/session_0186CLfjeJeSusNTva5RMfGU