Skip to content

KineticForces - BUGFIX! - Start the torque quadrature where the perturbation data starts - #661

Merged
matt-pharr merged 3 commits into
developfrom
bugfix/kf-torque-psilow
Nov 12, 2026
Merged

matt-pharr merged 3 commits into
developfrom
bugfix/kf-torque-psilow

Conversation

@logan-nc

@logan-nc logan-nc commented Nov 7, 2026 •

Copy link
Copy Markdown
Collaborator

Release note

  • Audience: users
  • Numerical impact: the post-PE torque now starts at the plasma response's first ψ. Runs whose response starts off axis (qlow above q₀) no longer include the region below it; elsewhere the response's first saved ψ lies one step above psilow (1.0515e-4 against 1e-4 in the DIII-D-like deck), which moves only torques without the near-axis validity cut: the diiid_error_field NTV couplings, at ~1e-8 absolute (harness @ 938668a)
  • Migration: a run whose plasma response starts off axis (qlow above q₀) gets a smaller post-PE torque on rerun, without the region below the response; no input changes

When qlow is above q₀, ForceFreeStates raises psilow and the plasma response starts off axis. The KineticForces torque quadrature still started at the equilibrium's psilow, so it integrated extrapolated perturbation data below the response. It now starts where that data starts, as it already stopped at psilim.

Regression report

Full fan-out on ITER's SDCC cluster (regress_fanout.sh --refs 052978b42,938668a77, all 27 cases, Julia 1.12.6, pinned manifest), branch 938668a77 against develop 052978b42. 382 of 385 tracked quantities unchanged; 3 changed, all diiid_error_field NTV coupling torques, by 1.8e-8, 1.7e-8 and 6.6e-8 absolute (below 0.005 %). In that run the equilibrium and ForceFreeStates start at ψ = 1e-4 but pe.psi_grid[1] = 1.0515e-4, so the couplings' torque, which has no near-axis validity cut, loses that sliver; the KineticForces diagnostics start at ψ_c = 0.04 and are unchanged. None of the cases starts the response off axis. The new solve-API test runs the TJ NTV deck with qlow = 1.9 (q₀ = 1.6) and checks that the torque ψ grid starts at or above the response's first ψ.

Case: diiid_error_field — DIII-D-like error-field assessment, n=1: ErrorFields stage with the NTV-limited correction couplings

Regression Report: diiid_error_field
Ref 1: 052978b42  @ 052978b42 (2026-11-12)
       env: julia 1.12.6, x86_64-linux-gnu, manifest 4c9d54fa (pinned), 2 threads/1 BLAS, jit build, warm
Ref 2: 938668a77  @ 938668a77 (2026-11-12)
       env: julia 1.12.6, x86_64-linux-gnu, manifest 4c9d54fa (pinned), 2 threads/1 BLAS, jit build, warm
-------------------------------------------------------------------------------------------------------------
Quantity                                         052978b42     938668a77     Diff               Status
-------------------------------------------------------------------------------------------------------------
EFC overlap per kAt                              [1 elem]      [1 elem]      0.0e+00            OK
EFC whole-field NTV torque per kAt² [N·m]        [1 elem]      [1 elem]      1.792e-08 (0.00%)  ** CHANGED **
EFC residual-field NTV torque per kAt² [N·m]     [1 elem]      [1 elem]      1.675e-08 (0.00%)  ** CHANGED **
EFC reference rotation ω_ref [rad/s]             [1 elem]      [1 elem]      0.0e+00            OK
EFC rotation-scan shifts [rad/s]                 [9 elem]      [9 elem]      0.0e+00            OK
EFC residual torque against rotation [N·m/kAt²]  [9 elem]      [9 elem]      6.590e-08 (0.00%)  ** CHANGED **
dominant-coupling singular values                [3 elem]      [3 elem]      0.0e+00            OK
|delta_nominal| of coil set 1                    1.414981e-06  1.414981e-06  0.0e+00            OK
|Σ δ_as_designed| of the error-field coils       1.289590e-18  1.289590e-18  0.0e+00            OK
Monte Carlo mean |δ| of the error-field coils    4.701440e-05  4.701440e-05  0.0e+00            OK
Runtime (s)                                      188.9s        189.1s                           --
Summary: 3 changed, 7 unchanged

Case: diiid_kinetic_multi_n — DIII-D-like equilibrium, n = 1, 2, KineticForces kinetic matrices, kinetic_factor=1.0, stability only, truncation at psihigh.

Regression Report: diiid_kinetic_multi_n
Ref 1: 052978b42  @ 052978b42 (2026-11-12)
       env: julia 1.12.6, x86_64-linux-gnu, manifest 4c9d54fa (pinned), 8 threads/4 BLAS, jit build, warm
Ref 2: 938668a77  @ 938668a77 (2026-11-12)
       env: julia 1.12.6, x86_64-linux-gnu, manifest 4c9d54fa (pinned), 8 threads/4 BLAS, jit build, warm
-----------------------------------------------------------------------------
Quantity                        052978b42      938668a77      Diff     Status
-----------------------------------------------------------------------------
total energy Re(et[1])          5.186142e-01   5.186142e-01   0.0e+00  OK
total energy Im(et[1])          -1.543101e-01  -1.543101e-01  0.0e+00  OK
total energy (all)              [82 elem]      [82 elem]      0.0e+00  OK
# kinetic singular surfaces     0              0              0.0e+00  OK
kinetic singular psi locations  [0 elem]       [0 elem]       0.0e+00  OK
ODE steps (saved)               836            836            0.0e+00  OK
mpert                           41             41             0.0e+00  OK
npert                           2              2              0.0e+00  OK
Runtime (s)                     470.6s         477.4s                  --
Summary: 8 unchanged

Case: solovev_kinetic_nuzero — Solovev, n=1, kinetic = 'KineticForces', nutype=zero (collisionless energy integral), 50/50 D-T multi-ion kinetic matrices, mode-converged band (delta_m=8, mpert=32). Reuses the nuzero test fixture via override; pressure-consistent kinetic.dat.

Regression Report: solovev_kinetic_nuzero
Ref 1: 052978b42  @ 052978b42 (2026-11-12)
       env: julia 1.12.6, x86_64-linux-gnu, manifest 4c9d54fa (pinned), 2 threads/1 BLAS, jit build, warm
Ref 2: 938668a77  @ 938668a77 (2026-11-12)
       env: julia 1.12.6, x86_64-linux-gnu, manifest 4c9d54fa (pinned), 2 threads/1 BLAS, jit build, warm
----------------------------------------------------------------------
Quantity                 052978b42      938668a77      Diff     Status
----------------------------------------------------------------------
vacuum energy Re(ev[1])  1.054354e+01   1.054354e+01   0.0e+00  OK
q0                       1.900003e+00   1.900003e+00   0.0e+00  OK
total energy Re(et[1])   2.316509e+00   2.316509e+00   0.0e+00  OK
total energy Im(et[1])   -1.555306e+00  -1.555306e+00  0.0e+00  OK
plasma energy Re(ep[1])  -8.227027e+00  -8.227027e+00  0.0e+00  OK
ODE steps (saved)        617            617            0.0e+00  OK
# singular surfaces      2              2              0.0e+00  OK
singular psi locations   [2 elem]       [2 elem]       0.0e+00  OK
total energy (all)       [32 elem]      [32 elem]      0.0e+00  OK
ODE steps (total)        616            616            0.0e+00  OK
mpert                    32             32             0.0e+00  OK
q95                      3.147422e+00   3.147422e+00   0.0e+00  OK
Runtime (s)              28.7s          24.6s                   --
singular q values        [2 elem]       [2 elem]       0.0e+00  OK
npert                    1              1              0.0e+00  OK
Summary: 14 unchanged

Case: tj_kinetic_multiion — TJ-analytic n=1, no wall, ideal + PE + multi-ion NTV (D + T + electron summed)

Regression Report: tj_kinetic_multiion
Ref 1: 052978b42  @ 052978b42 (2026-11-12)
       env: julia 1.12.6, x86_64-linux-gnu, manifest 4c9d54fa (pinned), 2 threads/1 BLAS, jit build, warm
Ref 2: 938668a77  @ 938668a77 (2026-11-12)
       env: julia 1.12.6, x86_64-linux-gnu, manifest 4c9d54fa (pinned), 2 threads/1 BLAS, jit build, warm
------------------------------------------------------------------------
Quantity                     052978b42     938668a77     Diff     Status
------------------------------------------------------------------------
NTV total (D+T+imp+e) [N·m]  8.956218e-04  8.956218e-04  0.0e+00  OK
NTV Deuterium [N·m]          4.759094e-04  4.759094e-04  0.0e+00  OK
NTV Tritium [N·m]            4.133763e-04  4.133763e-04  0.0e+00  OK
NTV electron [N·m]           6.336120e-06  6.336120e-06  0.0e+00  OK
total energy Re(et[1])       4.350277e-01  4.350277e-01  0.0e+00  OK
# singular surfaces          2             2             0.0e+00  OK
Runtime (s)                  6.5s          5.2s                   --
Summary: 6 unchanged

Case: tj_kinetic_ntv — TJ-analytic equilibrium, n=1, no wall, ideal + PE + NTV torque quadrature

Regression Report: tj_kinetic_ntv
Ref 1: 052978b42  @ 052978b42 (2026-11-12)
       env: julia 1.12.6, x86_64-linux-gnu, manifest 4c9d54fa (pinned), 2 threads/1 BLAS, jit build, warm
Ref 2: 938668a77  @ 938668a77 (2026-11-12)
       env: julia 1.12.6, x86_64-linux-gnu, manifest 4c9d54fa (pinned), 2 threads/1 BLAS, jit build, warm
--------------------------------------------------------------------------------------
Quantity                                   052978b42     938668a77     Diff     Status
--------------------------------------------------------------------------------------
NTV torque fgar [Re, Im]                   [1 elem]      [1 elem]      0.0e+00  OK
NTV ψ quadrature evaluations               75            75            0.0e+00  OK
fluid CGL energy fcgl [J]                  5.446364e-04  5.446364e-04  0.0e+00  OK
root-area-weighted total energy Re(et[1])  4.350277e-01  4.350277e-01  0.0e+00  OK
# singular surfaces                        2             2             0.0e+00  OK
singular psi locations                     [2 elem]      [2 elem]      0.0e+00  OK
q0                                         1.599966e+00  1.599966e+00  0.0e+00  OK
Runtime (s)                                3.5s          2.5s                   --
Summary: 7 unchanged

Case: tj_kinetic_ntv_rates — TJ-analytic equilibrium, n=1, no wall, NTV torque with supplied rates-v1 collision rates (reuses the TJ NTV deck via overrides)

Regression Report: tj_kinetic_ntv_rates
Ref 1: 052978b42  @ 052978b42 (2026-11-12)
       env: julia 1.12.6, x86_64-linux-gnu, manifest 4c9d54fa (pinned), 2 threads/1 BLAS, jit build, warm
Ref 2: 938668a77  @ 938668a77 (2026-11-12)
       env: julia 1.12.6, x86_64-linux-gnu, manifest 4c9d54fa (pinned), 2 threads/1 BLAS, jit build, warm
-----------------------------------------------------------------------------------
Quantity                                      052978b42  938668a77  Diff     Status
-----------------------------------------------------------------------------------
NTV torque fgar with supplied rates [Re, Im]  [1 elem]   [1 elem]   0.0e+00  OK
NTV ψ quadrature evaluations                  75         75         0.0e+00  OK
Runtime (s)                                   2.8s       2.8s                --
Summary: 2 unchanged

All cases:
  diiid_error_field: 3 changed, 7 unchanged
  diiid_kinetic_multi_n: 8 unchanged
  diiid_multi_n: 19 unchanged
  diiid_n1: 53 unchanged
  diiid_n1_riccati: 17 unchanged
  diiid_n1_riccati_precompiled: 17 unchanged
  diiid_slayer_n1: 22 unchanged
  diiid_slayer_n1_chi_perp_e: 22 unchanged
  diiid_slayer_n1_coupled: 7 unchanged
  diiid_slayer_n1_toroidal: 5 unchanged
  diiid_slayer_n1_winding: 22 unchanged
  diiid_truncation_n1: 12 unchanged
  efit_fixedbdy_separatrix: 5 unchanged
  gal_resistive_diiid: 11 unchanged
  gal_resistive_diiid_galinner: 11 unchanged
  ggj_ray_q500i: 4 unchanged
  ggj_reference: 4 unchanged
  lar_ggj_tearing_n1: 3 unchanged
  lar_reversed_shear_n1: 22 unchanged
  solovev_kinetic_nuzero: 14 unchanged
  solovev_multi_n: 15 unchanged
  solovev_n1: 22 unchanged
  tj_kinetic_calculated: 20 unchanged
  tj_kinetic_multiion: 6 unchanged
  tj_kinetic_ntv: 7 unchanged
  tj_kinetic_ntv_rates: 2 unchanged
  tj_n1: 25 unchanged

Notes for reviewers

  • Found on an equilibrium with q₀ below the default qlow = 1.02: the response started off axis, but the torque was integrated from 1e-4, so it included extrapolated perturbation data below the response.
  • KineticForcesInternal gains psilow, set from the first ψ of the perturbed-equilibrium grid in set_perturbation_data!.
  • Not addressed here: methods that read the perturbation along an orbit (the orbit-averaged path on feature/ntv-orbit) can still sample just below psilow, as they can just above psilim.
  • Develop merged in at 938668a77 (ErrorFields - BUGFIX! - Sum the NTV couplings over the resolved kinetic species #580's ErrorFields NTV species sum); no conflicts.

https://claude.ai/code/session_01BgNxCFidkS5NEJM3EvSoBs

…rbation data starts

With qlow above q0, ForceFreeStates raises psilow and the plasma response starts off axis, but the
post-PE torque quadrature still started at the equilibrium's psilow and integrated extrapolated
perturbation data below the response. It now starts at the first psi of that data, as it already
stopped at psilim.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BgNxCFidkS5NEJM3EvSoBs
@logan-nc logan-nc self-assigned this Nov 7, 2026
@github-actions github-actions Bot added bugfix Something was wrong and now is not changed-results Results move or an interface breaks - read before upgrading labels Nov 7, 2026
@logan-nc
logan-nc requested a review from matt-pharr November 7, 2026 03:57
@logan-nc
logan-nc marked this pull request as ready for review November 7, 2026 13:15
@matt-pharr
matt-pharr enabled auto-merge November 12, 2026 20:21

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

simple change that makes sense

@matt-pharr
matt-pharr added this pull request to the merge queue Nov 12, 2026
Merged via the queue into develop with commit f11d75a Nov 12, 2026
18 of 20 checks passed
@matt-pharr
matt-pharr deleted the bugfix/kf-torque-psilow branch November 12, 2026 20:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Something was wrong and now is not changed-results Results move or an interface breaks - read before upgrading

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants