Architecture
Core modules
gkx.core.velocity: Hermite/Laguerre basis functions, gyroaverage coefficients, and polarization helpers.gkx.geometry: analytic s-alpha flux-tube geometry.gkx.terms: term-wise RHS kernels (streaming, mirror, drifts, drive, collisions, fields).gkx.operators.linear: cache construction, linked-boundary maps, Hermite/Laguerre moment operators, linear parameter pytrees, and cached RHS assembly entry points.gkx.solvers.linear: matrix-free eigensolver policy, linear fixed-step/diagnostic integration policy, implicit GMRES/preconditioner policy, and gated velocity-parallel linear RHS dispatch.gkx.solvers.nonlinear: explicit RK/SSP/K10 and IMEX fixed-point, GMRES, and stage-composition policy.gkx.operators.nonlinear.diagnostics: sampling, resolved-diagnostic packing, andSimulationDiagnosticsconstruction shared by nonlinear diagnostic scans.gkx.operators.nonlinear.projection: Hermitian and fixed-mode state projections used by compressed-real-FFT nonlinear scans and fixed-mode diagnostics.gkx.operators.nonlinear.collisions: diagonal collision and hypercollision split policies shared by explicit and IMEX nonlinear scans.gkx.operators.nonlinear.policies: diagnostic cache/weight/projection setup, adaptive time-step policy, fixed-mode omega masks used by comparison parity audits, reusable nonlinear IMEX operator construction, and public facades for the focused projection/collision owners.gkx.runtime/gkx.workflows.runtime.config: user-facing runtime entrypoints and configuration schema.gkx.workflows.runtime.policies: pure runtime selection policies for solver names, scan modes, nonlinear monitored modes, external fields, and step-count inference.gkx.workflows.runtime.orchestration_scan,gkx.workflows.runtime.chunks, andgkx.workflows.runtime.orchestration_artifacts: runtime scan batching, progress/ETA formatting, and nonlinear restart/checkpoint artifact handoff behind injectable seams.gkx.benchmarking.shared: reviewed reference tables, normalization constants, and comparison-only branch policies.gkx.diagnostics.growth_rates: reusable growth/frequency fitting.gkx.artifacts.plotting: reusable, publication-ready plotting utilities.
Term-level source mapping
streaming, mirror, curvature, grad-B, diamagnetic, collisions, hypercollisions, hyperdiffusion, end damping:
src/gkx/terms/linear_terms.pyfield solves:
src/gkx/terms/fields.pynonlinear E×B, flutter, and Bessel-grid transforms:
src/gkx/terms/nonlinear.pyassembled RHS:
src/gkx/terms/assembly.py
For the full operator equations, see Operators And Terms.
Data flow
The linear solve is structured as:
build the spectral grid and geometry
compute gyroaverage coefficients
convert
LinearTermsinto one canonicalTermConfigsolve the field equations for \((\\phi, B_\\parallel, A_\\parallel)\)
build the gyrokinetic variable
Hassemble RHS by summing per-term kernels from
gkx.termsadvance in time using
integrate_linear/diffrax/Krylov with the same RHS
This structure is intentionally modular so that nonlinear terms, collisions, geometry adapters, and electromagnetic extensions can be inserted with minimal refactoring.