Skip to content

Continue symplectic integrators after finite Newton maxiter#486

Closed
krystophny wants to merge 3 commits into
mainfrom
fix/symplectic-euler-warning-mode
Closed

Continue symplectic integrators after finite Newton maxiter#486
krystophny wants to merge 3 commits into
mainfrom
fix/symplectic-euler-warning-mode

Conversation

@krystophny

@krystophny krystophny commented Jul 13, 2026

Copy link
Copy Markdown
Member

Risk tier

  • T0: docs, comments, small build metadata
  • T1: pure refactor, no behavior change intended
  • T2: local numerical logic
  • T3: physics, output behavior, coordinate convention
  • T4: parallelism or GPU; dependency, CI, or security-sensitive build logic

Correctness contract

Intended behavior change

All symplectic integrators accept the final Newton iterate after the configured
iteration limit if every state component is finite. This restores the warning
and continue behavior used before #457 for Euler 1, Euler 2, midpoint, Gauss
orders 1 through 4, and Lobatto 3. symplectic_newton_warning_mode = .false.
restores strict termination.

Each accepted maximum-iteration step increments its integrator-specific
diagnostic counter. Midpoint now has a separate midpoint_maxit counter.

Behavior that must not change

Converged steps use the same discrete maps, timestep, nonlinear equations,
tolerances, iteration limits, and update order. LCFS, wall, outside-domain,
singular-linear-system, non-finite, and unresolved-boundary-event failures
remain terminal. Strict mode rolls back the integrator and field to the last
accepted step.

The canonical state remains (s, theta, phi, p_phi), with normalized toroidal
flux s and angles in radians. Field, time, energy, and momentum units are
unchanged. This change does not alter the Hamiltonian, source distribution,
field, wall, boundary conditions, or symmetry.

Numerical limitation

The accepted maximum-iteration state has not met the configured nonlinear
tolerance, so that step only approximately satisfies its discrete symplectic
map. The unchanged counters expose every such step.

CPU and GPU behavior

The CPU implementation covers every symplectic integrator. The GPU path uses
the same warning-mode rule for its Euler solver. NaN and infinity rejection
uses IEEE-754 exponent bits because the fast-math build can optimize
ieee_is_finite incorrectly. The finite-state check runs only after Newton
reaches its iteration limit; the converged hot path is unchanged.

Tests added

  • warning and strict behavior for Euler 1, Euler 2, midpoint, Gauss 1 through
    4, and Lobatto 3
  • strict rollback to the accepted state
  • rejection of a non-finite final iterate under the production compiler flags
  • CPU/GPU Euler equivalence

Golden-record impact

  • unchanged
  • changed

Verification

The non-finite regression failed before the bit-pattern check: warning mode
accepted a NaN under fast-math. It passes with this commit.

$ fo test test_newton_solver_status test_gpu_orbit_bench
test_newton_solver_status                  PASS       0.06s
test_gpu_orbit_bench                       PASS       5.78s

$ fo
Static: OK (175 modules, 175 changed, 175 affected)
Build: OK
CTest: 83 passed, 0 failed, 1 skipped

The skipped chartmap test records the existing libneo issue #179 condition.

@krystophny krystophny changed the title Continue symplectic Euler after finite Newton maxiter Continue symplectic integrators after finite Newton maxiter Jul 14, 2026
@krystophny

Copy link
Copy Markdown
Member Author

Superseded by #487, which preserves bounded continuation while rejecting excessive or non-finite corrections and keeps numerical failures distinct from physical losses.

@krystophny krystophny closed this Jul 14, 2026
@krystophny krystophny deleted the fix/symplectic-euler-warning-mode branch July 14, 2026 10:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant