Skip to main content

FAX

Tests Docs License: MIT

FAX is a lean JAX code for shear-Alfvén physics in stellarators: the continuum, AE3D-form global modes and a perturbative fast-ion drive, with first-order derivatives with respect to profiles and, through VMEX, the VMEC boundary.

CTOK continuum and global modes Könies TAE drive

Left: the n = 2 CTOK continuum with the six global modes nearest 384 kHz (red). Right: the passing-only drive of the Könies et al. (2018) TAE.

Scope

Supported Not supported
Low-β continuum on each Boozer surface (STELLGAP form) Sound coupling in the global modes, so no BAE or BAAE eigenmodes (the continuum has it, opt-in)
AE3D-form reduced ideal-MHD global modes, signed $\omega^2$ Continuum damping and electron damping
finite_beta=True: restricted $J_\parallel$ and pressure terms (experimental) A full-MHD or compressional model
Drive of a fixed mode: zero orbit width, passing ions only Trapped particles, finite orbit width, finite Larmor radius

The drive is perturbative and valid up to about 200 keV in the Könies case ($\gamma/\omega \le 4%$). It is about 0.6 of the CAS3D-K zero-orbit-width curve; the ratio is unexplained (see the validation page). Derivatives are first order and are NaN unless the eigensolve converged and its selection is not a tie.

Install

Python 3.10 or newer, JAX 0.4.38 or newer, solvax>=0.36.0. FAX is on PyPI as alfvex; the code is imported as fax. FAX will soon be renamed ALFVEX everywhere (repository, import and command line). Do not pip install fax: that is an unrelated package.

pip install alfvex            # core
pip install "alfvex[vmex]"    # VMEC solves and boundary gradients (Python >= 3.11)
pip install "alfvex[plot]"    # matplotlib, for the figure examples

From a clone, pip install . (with the same extras) installs the development version.

Quickstart

This runs from an installed wheel with no data files: a continuum, a global TAE and one gradient on the analytic Könies et al. (2018) torus.

import jax, jax.numpy as jnp, fax

s = (jnp.arange(200) + 0.5) / 200
geo = fax.circular_torus(s=s, major_radius=10.0, minor_radius=1.0, B0=3.0, iota=1 / (1.71 + 0.16 * s), epsilon_B=0.1)
harmonics, rho = fax.mode_family(6, 16, 5), fax.mass_density(2e19, 1.00727647)
f_hz = fax.continuum(geo, harmonics, rho)  # (surfaces, harmonics)
modes = fax.eigenmodes(geo, harmonics, rho, target_hz=6.46e4, count=3, ntheta=32, nzeta=4)
print(modes.frequencies_hz[-1], modes.status.converged)  # the TAE, 64.63 kHz
f = lambda r: fax.frequency_hz(geo, harmonics, r, 2, 3, target_hz=6.46e4, count=3, ntheta=32, nzeta=4)
print(jax.grad(f)(rho))  # equals -f / (2 rho)

The command line runs the continuum and global-mode tasks from a TOML case; the drive, objectives and boundary gradients are Python only.

Examples (checkout only)

These read files in the repository or need an extra; each is a plain script with its settings at the top and no command-line parsing.

File Needs Shows
examples/quickstart.py nothing the quickstart above, plus gaps, a dense solve and the smooth objectives
examples/ctok_boozmn.py, ctok_continuum.toml, ctok_eigenmodes.toml tests/data CTOK from a boozmn file: the TOML cases, the Python API and fax run <case> --plot
examples/qa_vmex.py, qa_continuum.toml vmex VMEC solve, Boozer transform, continuum and the gradient with respect to boundary coefficients
examples/koenies_tae_drive.py plot fast-ion drive against temperature, slowing-down ions and Landau damping
examples/optimize_alfven.py vmex, plot QS plus Paul's continuum cost (QH) or a classified gap-mode window (QA)
examples/knyazev_qa.py tests/data, plot the STELLGAP and AE3D comparison; RESEARCH and an archive rebuild the fixture
examples/benchmark.py tests/data equal-accuracy timings of the eigensolvers

Every script has a RESEARCH = False switch at the top: the default is a fast run, True selects the finer settings and extra analysis.

Evidence

Check Result
STELLGAP CTOK continuum (97 surfaces), outer Boozer half surface restored 4.2e-3 mean, 7.0e-3 maximum relative
AE3D v31 CTOK, six global modes within 0.19–1.35% in frequency; two of them (738.2, 741.2 kHz) in frequency only (inertia-norm cosine 0.37, 0.08)
AE3D CTOK TAE, 337.9 kHz not reproduced. On identical input three $\iota'$ terms of AE3D's bending blocks differ from the energy (pinned block comparison; real-space quadrature FAX 0.1–0.3%, AE3D 2–37%). The $J_\parallel$ blocks still disagree, cause open. Not reported upstream
Knyazev et al. (2026) precise QA continuum 3.0e-3 mean from STELLGAP. The AE3D global mode (30.31 kHz) is not a FAX eigenmode (overlap 0.18, 5.1% below); cause unresolved
Könies et al. (2018) TAE (n = 6) 4.061e5 rad/s (CAS3D 4.01e5, GYGLES 4.13e5), converged to 1e-4
Drive, 100/200/300/400 keV 4.29/16.39/32.72/64.48 ×10³ s⁻¹; 0.58–0.60 of CAS3D-K ZOW at 82–191 keV (content unmatched, not a validation)
Gradients fixed-geometry AD vs finite differences to about 1e-9 at best; LP-QA gap-mode shift of 4 kHz predicted to 0.05 kHz, resolution budget 0.13 kHz; the $m = 1$ gauge leaves a 1e-2 floor on zs11, not closed

The validation page has every gate, its test and what is not done.

Ecosystem

SOLVAX provides the generalized eigensolver and its implicit derivatives; VMEX the equilibrium and its implicit derivative; booz_xform_jax the Boozer transform. ESSOS orbit transport of FAX modes is planned, not implemented.

Documentation and testing

fax.readthedocs.io: getting started and TOML reference, tutorials, theory, validation, API with its derivative contract.

pip install -e ".[dev,vmex]"
python -m pytest -q -m 'not scheduled'
ruff check . && ruff format --check . && sphinx-build -W -b html docs docs/_build/html

Citing and license

Cite the repository through CITATION.cff and the papers whose models FAX implements (references). MIT license.

Metadata

Release files for alfvex 1.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for alfvex 1.2.1
File Size Uploaded Provenance Actions
alfvex-1.2.1.tar.gz 2.0 MB With provenance Details for alfvex-1.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for alfvex 1.2.1
File Interpreter ABI Platform Actions
alfvex-1.2.1-py3-none-any.whl Python 3 none any Details for alfvex-1.2.1-py3-none-any.whl

Total release size: 2.0 MB

Release files / alfvex-1.2.1.tar.gz

Download URL alfvex-1.2.1.tar.gz
Size 2.0 MB
Tags Source
SHA-256 checksum
How to use checksums
5d865913a42ab9e179fda906a399a0a4a04fa8fedb0dc48054d315e5e7d1a670
BLAKE2b-256 checksum
How to use checksums
e85153b557d7ab98ebea298448bd32e257c6f6787c450d14efc173b970c9ed74
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.

Transparency log

Release files / alfvex-1.2.1-py3-none-any.whl

Download URL alfvex-1.2.1-py3-none-any.whl
Size 49.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b6a82070aa769eed1a535fa6d8ca92d85f0485158d68b54add21b76dd9d0242f
BLAKE2b-256 checksum
How to use checksums
5043aa7084e2f93186c4aba254756bae4fbd2595352cea9eaed28d92a3b982c3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.

Transparency log

Security for alfvex 1.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for alfvex-1.2.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page