Fourier–Hermite and DG solvers for multispecies Gyrokinetic equation with JAX.
Project description
SPECTRAX-GK
SPECTRAX-GK is a modern, differentiable solver for the multispecies Vlasov–Poisson system in 1D–1V, implemented with JAX. It supports both Fourier–Hermite and Discontinuous Galerkin (DG) discretizations, runs on CPUs/GPUs/TPUs, and is designed for plasma physics research, reproducibility, and education.
🚀 Features
- Two discretizations
- Fourier–Hermite pseudo-spectral solver
- DG-in-x + Hermite-in-v solver
- Linear and nonlinear physics
- Multi-species support (electrons, ions, arbitrary charge & mass)
- Units-aware input
- time in plasma periods
- length in Debye lengths
- temperature in eV
- drift velocity in fractions of
- time in plasma periods
- Differentiable & JIT-able: compatible with JAX AD for optimization and ML workflows
- Built-in diagnostics: field & kinetic energy, electric field evolution, distribution functions
- Publication-quality plots and animations
- Modern dev workflow: Ruff (lint/format), MyPy (types), pytest (tests), pre-commit hooks, CI/CD
📖 Background
We solve the Vlasov–Poisson equations in one spatial and one velocity dimension (1D1V):
with self-consistent electrostatics:
where
: distribution function of species s
,
: species charge and mass
: electric field
Key plasma scales
Plasma frequency:
Debye length:
Discretizations
- Fourier–Hermite: expand in Fourier (x) and Hermite (v); efficient for Landau damping, two-stream, bump-on-tail instabilities.
- DG–Hermite: discontinuous Galerkin in x + Hermite in v; more robust for nonlinear dynamics.
📦 Installation
From PyPI (recommended)
pip install spectraxgk
From source
git clone https://github.com/uwplasma/SPECTRAX-GK.git
cd SPECTRAX-GK
pip install -e ".[dev]"
The dev extras include pytest, ruff, and mypy.
⚡ Quick Start
Run a simulation from an example .toml config:
spectraxgk --input examples/two_stream.toml
This produces:
- Energy traces (kinetic + field)
- Electric field evolution
- Distribution function snapshots/animations
⚙️ Input Configuration
Inputs are given in .toml files. Example: Two-stream instability
[sim]
mode = "dg" # "fourier" or "dg"
backend = "diffrax" # "eig" or "diffrax"
tmax = 10.0 # simulation length in units of 1/ω_p
nt = 200
nonlinear = true
[grid]
L_lambdaD = 64 # box length in multiples of Debye length
Nx = 32
[hermite]
N = 24
[bc]
kind = "periodic"
[[species]]
name = "e_plus"
q = -1.0
n0 = 0.5*1e19
mass_base = "electron"
temperature_eV = 1.0
drift_c = +0.1
[[species]]
name = "e_minus"
q = -1.0
n0 = 0.5*1e19
mass_base = "electron"
temperature_eV = 1.0
drift_c = -0.1
[[species]]
name = "ions"
q = +1.0
n0 = 1.0*1e19
mass_base = "proton"
temperature_eV = 1.0
drift_c = 0.0
Notes
-
Units:
tmax: multiples ofL_lambdaD: multiples oftemperature_eV: in eVdrift_c: fraction of
-
Species:
mass_base = "electron"or"proton"(scaled bymass_multiple)- densities given in SI (m⁻³)
📊 Output & Diagnostics
Diagnostics automatically produced:
-
Energies: kinetic + field energy
-
Electric field evolution in space & time
-
Distribution functions per species
Plots are configurable under [plot] in the .toml file:
[plot]
nv = 257
vmin_c = -0.3
vmax_c = 0.3
fig_width = 10.0
fig_row_height = 2.2
fps = 30
dpi = 150
🧪 Development Workflow
Code style
We use Ruff as formatter and linter:
ruff check .
ruff format .
Type checking
We use MyPy:
mypy .
Tests
Run unit and regression tests with pytest:
pytest -v
Tests cover:
- Fourier/DG solver shapes
- Poisson operator assembly
- Unit conversions (Debye length, plasma frequency)
- Example configs (smoke tests)
Pre-commit hooks
Install pre-commit once:
pre-commit install
Then checks (ruff, mypy, pytest) run automatically on commit.
🤖 Continuous Integration
-
GitHub Actions run on every push/PR:
ruff check+ruff format --checkmypypytest
-
PyPI release: pushing a git tag (
vX.Y.Z) triggers an automatic build + upload.
📚 References
- Landau, L. D. On the vibration of the electronic plasma. J. Phys. USSR, 1946.
- Klimontovich, Y. L., Silin, V. P. The Spectra of Systems of Interacting Particles. JETP, 1960.
- Cheng, C. Z., Knorr, G. The Integration of the Vlasov Equation in Configuration Space. J. Comput. Phys., 1976.
- Boyd, J. P. Chebyshev and Fourier Spectral Methods. Dover, 2001.
- Shu, C.-W. Discontinuous Galerkin Methods. Springer, 2016.
🧑💻 Contributing
We welcome issues and pull requests! Please:
- Fork the repo
- Install dev deps:
pip install -e ".[dev]" - Run checks:
ruff check . && pytest && mypy . - Submit a PR
📜 License
MIT License © 2025 UWPlasma
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file spectraxgk-0.0.1.tar.gz.
File metadata
- Download URL: spectraxgk-0.0.1.tar.gz
- Upload date:
- Size: 56.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eef77097e59c3453a37a8db8fc10c85f6a80e0c5b26f5e1183903549f464175c
|
|
| MD5 |
3bed4003c62aa9cb9dd42cc38c09671c
|
|
| BLAKE2b-256 |
6070b60269faf5273684af71a7df947f835051ae50e551dab2b992c7e62b8d2b
|
Provenance
The following attestation bundles were made for spectraxgk-0.0.1.tar.gz:
Publisher:
release.yml on uwplasma/SPECTRAX-GK
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
spectraxgk-0.0.1.tar.gz -
Subject digest:
eef77097e59c3453a37a8db8fc10c85f6a80e0c5b26f5e1183903549f464175c - Sigstore transparency entry: 541677434
- Sigstore integration time:
-
Permalink:
uwplasma/SPECTRAX-GK@95d5c5fcb2564fdeb76f7090a0853418c7f45597 -
Branch / Tag:
refs/tags/v0.0.1 - Owner: https://github.com/uwplasma
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@95d5c5fcb2564fdeb76f7090a0853418c7f45597 -
Trigger Event:
push
-
Statement type:
File details
Details for the file spectraxgk-0.0.1-py3-none-any.whl.
File metadata
- Download URL: spectraxgk-0.0.1-py3-none-any.whl
- Upload date:
- Size: 32.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
64073315dcaf3edf656f92ba071f26af9f6f9a9824347cf9c9b4272553af1c84
|
|
| MD5 |
09cc17e576cb2cb7f215edaba17c86b5
|
|
| BLAKE2b-256 |
c5726d62bebb4a9b88e97a91814fd316c5c5dd1a52144dadcbfa3344798675c3
|
Provenance
The following attestation bundles were made for spectraxgk-0.0.1-py3-none-any.whl:
Publisher:
release.yml on uwplasma/SPECTRAX-GK
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
spectraxgk-0.0.1-py3-none-any.whl -
Subject digest:
64073315dcaf3edf656f92ba071f26af9f6f9a9824347cf9c9b4272553af1c84 - Sigstore transparency entry: 541677458
- Sigstore integration time:
-
Permalink:
uwplasma/SPECTRAX-GK@95d5c5fcb2564fdeb76f7090a0853418c7f45597 -
Branch / Tag:
refs/tags/v0.0.1 - Owner: https://github.com/uwplasma
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@95d5c5fcb2564fdeb76f7090a0853418c7f45597 -
Trigger Event:
push
-
Statement type: