Skip to content

Extract shared GC Gauss implicit-RK core (orbit_rk_core); drop CPP and symplectic FO#429

Merged
krystophny merged 1 commit into
mainfrom
refactor/shared-gc-core
Jun 25, 2026
Merged

Extract shared GC Gauss implicit-RK core (orbit_rk_core); drop CPP and symplectic FO#429
krystophny merged 1 commit into
mainfrom
refactor/shared-gc-core

Conversation

@krystophny

Copy link
Copy Markdown
Member

Summary

Rebase-and-strip of the shelved shared-symplectic-core work (PR #407) onto
current main. Keeps only the keep-worthy nucleus: the guiding-centre (GC)
Gauss implicit-RK / Newton core, extracted into a new device-callable module
orbit_rk_core. Everything CPP and symplectic-full-orbit is dropped.

What lands

  • New src/orbit_rk_core.f90: the GC Gauss-collocation residual, analytic
    Jacobian, a device-portable dense LU solve (rk_solve), and a device-callable
    Newton shell (rk_gauss_newton). Reduced to a single GC kernel; the former
    MODEL_CPP / MODEL_FO_SYMPL codes and their dispatch shells are gone.
  • src/orbit_symplectic.f90: f_rk_gauss / jac_rk_gauss become thin wrappers
    over the shared core (MODEL_GC). The arithmetic is moved byte-identically,
    so GC numerics do not change.
  • src/CMakeLists.txt: compile orbit_rk_core.f90 before orbit_symplectic.f90.

What is dropped (not merged)

  • The CPP pusher (orbit_cpp.f90, MODEL_CPP) and its tests
    (test_cpp_equals_gc_largestep, test_cpp_invariants).
  • The shelved symplectic / mocked-Boris full-orbit prototype (orbit_full.f90,
    MODEL_FO_SYMPL), its provider seam (orbit_full_provider.f90) and the two
    mocks, and their tests (test_fo_symplectic, test_full_orbit,
    test_orbit_model_dispatch).
  • The branch's params.f90 / simple_main.f90 orbit_model hunks: main
    already owns orbit_model (ORBIT_GC=0, ORBIT_FULL_ORBIT=7) and the
    validated explicit Boris full-orbit pusher (PR Add full-orbit (FO) Boris pusher (orbit_model=7) #426), which this PR leaves
    untouched.

Why

orbit_rk_core is the single home for the GC Gauss step shared by the CPU
integrator and (later) the OpenACC GPU kernel; it is written !$acc routine seq-ready with its own device-portable LU. CPP is retired; the full-orbit path
is the explicit Cartesian Boris (orbit_model=7), not the shelved symplectic
prototype.

Verification

make CONFIG=Fast: build OK. make test: 100% tests passed, 0 failed out of
77
(total 677.80 s). All 14 golden-record regression cases (albert,
albert_coils, boozer, boozer_ncsx, canonical, classifier, classifier_combined,
classifier_fast, collision, meiss, meiss_coils, and the tokamak variants)
pass, confirming the GC numerics are byte-identical after the extraction.

Before (on main): the same 14 golden-record cases pass with the inlined GC
residual/Jacobian. After (this branch): identical results with the arithmetic
moved into orbit_rk_core -- a pure refactor, no numeric change.

Follow-ups (separate PRs)

  • Wire rk_gauss_newton / rk_solve onto the fortnum multiroot core in place of
    dgesv for the CPU GC Newton; must preserve the verified GC numerics.
  • The device (OpenACC) GC solver path uses fortnum's reverse-communication
    multiroot_step (fortnum PR for the device-capable solver), keeping
    orbit_rk_core as the shared CPU+GPU home.

Lift the Gauss-collocation residual, Jacobian, dense LU solve, and Newton
shell out of orbit_symplectic into a new device-callable module
orbit_rk_core. f_rk_gauss and jac_rk_gauss become thin wrappers that call
rk_gauss_residual/rk_gauss_jacobian with MODEL_GC; the arithmetic is moved
byte-identically, so GC numerics are unchanged (all golden-record
regressions pass).

rk_gauss_newton and rk_solve are retained for the deferred fortnum
multiroot wiring; the CPU GC path still uses dgesv.

This is the keep-worthy nucleus of the shelved shared-symplectic-core work.
The CPP pusher and the symplectic full-orbit prototype, their mock field/
metric providers, and the associated tests are not brought over.
@krystophny krystophny added tier/T1 pure refactor size/L review size up to 1000 changed lines labels Jun 24, 2026
@krystophny krystophny merged commit 123d26a into main Jun 25, 2026
7 checks passed
@krystophny krystophny deleted the refactor/shared-gc-core branch June 25, 2026 08:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/L review size up to 1000 changed lines tier/T1 pure refactor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant