GPEC — Generalized Perturbed Equilibrium Code
This Julia implementation of GPEC continues the legacy of the Fortran GPEC suite for magnetohydrodynamic (MHD) analysis of fusion plasmas. The Fortran suite (DCON, VACUUM, STRIDE, GPEC, PENTRC and SLAYER) has long been used to model the response of tokamak plasmas to small non-axisymmetric magnetic perturbations, from error-field correction and resonant magnetic perturbation optimization to kink and tearing stability. This implementation consolidates them into one code base of cooperating physics modules that share data in memory behind a unified, modern interface, which removes the hand-offs between separate codes and makes parameter scans, uncertainty quantification and integrated modeling practical.
One input deck runs the stages it names, in order, into one output file:
- Equilibrium — reads an EFIT or CHEASE reconstruction, an IMAS data dictionary or an analytic model, maps it to straight-field-line flux coordinates, and finds the rational surfaces q = m/n.
- Stability — ideal MHD stability by Newcomb's criterion (the DCON integration, or the STRIDE Riccati and RDCON Galerkin formulations): the force-free states ξ(ψ,θ), the free-boundary kink energies with the VACUUM response, and the tearing stability matrix Δ′.
- Perturbed equilibrium — the plasma response to external non-axisymmetric fields (RMPs, error fields, correction coils): resonant fields, island half-widths and the Chirikov overlap parameter.
- Torque, error fields and tearing — the neoclassical toroidal viscosity torque (PENTRC), coil-tolerance and locking-risk analysis, and tearing growth rates and critical resonant fields from inner-layer models (SLAYER, GGJ).
Quick Start
GPEC is configured via a gpec.toml file. To run an analysis on a directory containing that file:
./gpec path/to/directoryTo use GPEC programmatically from Julia:
using GeneralizedPerturbedEquilibrium
GeneralizedPerturbedEquilibrium.main(["path/to/directory"])See Setup for full installation instructions.
Citing
If you use GPEC, please cite it as given in CITATION.cff (GitHub's "Cite this repository" button), along with the key papers behind the modules you use, listed on the citations page.
The 3D vacuum singular correction in src/Vacuum/Kernel3D.jl is derived from BIEST and licensed under Apache-2.0 (see NOTICE and LICENSES/Apache-2.0.txt); its papers are listed with the Vacuum module citations. The rest of GPEC is MIT-licensed.
Contributing
The Git workflow, commit message conventions, and the regression-testing harness are documented in the Developer Notes.
What GPEC computes
One deck, gpec.toml, runs the stages below in order, each when its section is present, into one output file, gpec.h5. The Workflow page maps every stage to its physics, deck sections and datasets.
| Stage | Deck section | Main output |
|---|---|---|
Equilibrium — the axisymmetric equilibrium, its flux-surface coordinates and rational surfaces | [Equilibrium] | Equilibrium/ |
ForceFreeStates — ideal (or drift-kinetic) MHD stability by the Newcomb criterion, with the Vacuum response of the [Wall] (a wall case is a separate deck from a response case) | [ForceFreeStates] | ForceFreeStates/FreeBoundaryStability/, SingularSurfaces/Delta_prime_matrix |
LocalStability — Mercier, resistive-interchange and ballooning criteria | [LocalStability] | LocalStability/ |
Match — the resistive inner layer matched to the outer-region Δ′ | [Match] | SingularSurfaces/Match/ |
PerturbedEquilibrium — the plasma response to the field of [ForcingTerms]: resonant fields, islands, overlap; needs a "Forward" solve without a wall | [PerturbedEquilibrium] | PerturbedEquilibrium/SingularCoupling/ |
KineticForces — the neoclassical toroidal viscosity torque of that response | [KineticForces] | KineticForces/ |
ErrorFields — coil tolerances, locking risk and correction limits | [ErrorFields] | ErrorFields/Risk/ |
Tearing — tearing growth rates and critical resonant fields from an inner-layer model | [Tearing] | Tearing/Roots/ |
Coming from the Fortran codes
| Fortran | Here |
|---|---|
| DCON | [ForceFreeStates] with integrator = "Forward" |
| STRIDE | integrator = "Riccati", with Δ′ in SingularSurfaces/Delta_prime_matrix |
RDCON and its rmatch | integrator = "Galerkin" and [Match] |
| VACUUM | the Vacuum module, with the wall in [Wall] |
| GPEC | [ForcingTerms] and [PerturbedEquilibrium] |
| PENTRC | [KineticForces] |
| SLAYER | [Tearing] with inner_model = "SLAYER", options in [SLAYER] |
dcon.in, vac.in, gpec.in, pentrc.in, … | one gpec.toml, and one gpec.h5 for every result |
The Conventions Reference states the coordinates, signs and normalizations, including where they differ from the Fortran outputs.
Documentation
- Setup — Installation on Linux, macOS and Windows (WSL), and a first run
- Workflow — The pipeline: physics of each stage, deck sections, examples and the output file
- Scripting API — The same pipeline from Julia scripts
- Conventions Reference — Coordinates, signs, normalizations and field amplitudes
- Modules — Governing equations, deck keys, outputs and function reference per module
- Citations — Papers underpinning GPEC's algorithms
- Developer Notes — Git workflow, commit conventions and the regression-testing harness
- Introduction slides — An overview of GPEC and its physics
Contact
GPEC is developed and maintained by Nikolas Logan (ncl2128@columbia.edu) and Jong-Kyu Park (jkpark@snu.ac.kr) as lead developers.
New users and developers are warmly encouraged to reach out — whether you have questions about running GPEC, want to discuss the physics, or are interested in contributing or collaborating, please get in touch.
For bug reports and feature requests, please open an issue on the GitHub repository.