TORAX
TORAX is a differentiable 1D tokamak core plasma transport simulator written in Python and JAX for fast forward modelling, pulse design, trajectory optimization, and controller design. Key design principles include:
- Modular and extensible: easy to register custom models for transport, sources, neoclassical effects, etc.
- Fast and auto-differentiable: End-to-end
jax.jitcompilation on CPU and GPU, gradient-based nonlinear PDE solvers without hand-derived Jacobians, andjax.grad/jax.vmapsupport for sensitivity analysis and parameter optimization. - ML-surrogate native: Seamless JAX coupling to neural-network physics
surrogates, including turbulent transport models from
fusion_surrogates.
Full documentation and physics details are available at torax.readthedocs.io. Upgrading from TORAX v1? See the v1-to-v2 Migration Guide.
Physics and numerics
-
Coupled 1D transport PDEs
- Finite-volume discretization of ion heat transport, electron heat transport, electron particle transport, and poloidal flux diffusion with a variety of boundary conditions.
- Support for uniform or non-uniform grids.
- Multiple solver options, including predictor-corrector, Newton-Raphson, and JAX-based optimizers.
-
Turbulent and neoclassical transport
- Multi-component core and pedestal transport supporting ML surrogates (QLKNN, TGLFNN), empirical models (Bohm/gyro-Bohm), and high-fidelity quasilinear models (QuaLiKiz, TGLF).
- Fast analytic models for bootstrap current, conductivity, neoclassical transport, and poloidal velocity.
-
Pedestal, edge, and MHD
- Modular pedestal structure, with formation triggered by L-H power-threshold scalings and supporting both enforcing as a boundary condition or evolving via transport.
- Built-in coupling to the Extended Lengyel 1D SOL/divertor model.
- Simple sawtooth crash model.
-
Sources, sinks, and equilibria
- Analytical models for core physics, including fusion, impurity radiation, and Bremsstrahlung.
- Basic models for actuators such as pellets, ion- and electron-cyclotron heating and current drive. Feedback controllers available for particle sources to match experimental density profiles.
- Static and time-dependent equilibria from CHEASE, MEQ, EQDSK, IMAS and TokaMaker.
Installation
TORAX requires Python 3.12 or newer. Install the latest release from PyPI in a virtual environment:
python3 -m venv toraxvenv
source toraxvenv/bin/activate
pip install torax
For development (editable install with testing and linting dependencies):
git clone https://github.com/google-deepmind/torax.git
cd torax
pip install -e ".[dev]"
See the Installation Guide for GPU setup and optional
QLKNN10D or tglf2py extensions.
Quickstart
Command line
Run an example configuration from the terminal:
run_torax --config=examples/iterhybrid_rampup.py --output_dir=/tmp/torax_results
View one or more saved runs with interactive Plotly plots:
plot_torax --outfile /tmp/torax_results/state_history_<timestamp>.nc
Python API
import torax
torax_config = torax.build_torax_config_from_file(
'examples/iterhybrid_rampup.py'
) # or torax.ToraxConfig.from_dict(config_dict)
state_history = torax.run_simulation(torax_config)
data_tree = state_history.simulation_output_to_xr()
data_tree.to_netcdf('state_history.nc')
Plot results directly in Python with torax.plot_run_from_data_tree (in-memory)
or torax.plot_run (from .nc files).
See Running Programmatically for more details.
JAX cache, debugging, and tests
To enable persistent JAX compilation caching, run
export JAX_COMPILATION_CACHE_DIR=~/jax_cache
export JAX_PERSISTENT_CACHE_MIN_ENTRY_SIZE_BYTES=-1
export JAX_PERSISTENT_CACHE_MIN_COMPILE_TIME_SECS=0.0
For debugging, set JAX_DISABLE_JIT=True to disable JIT compilation or
TORAX_ERRORS_ENABLED=True to enable internal runtime checks. Run the unit
test suite from a source checkout with:
TORAX_JAXTYPING=True TORAX_ERRORS_ENABLED=True pytest -n auto
Citing TORAX
If you use TORAX in your research, please cite the TORAX paper on arXiv:
@article{torax2024arxiv,
title={{TORAX: A Fast and Differentiable Tokamak Transport Simulator in JAX}},
author={Citrin, Jonathan and Goodfellow, Ian and Raju, Akhil and Chen, Jeremy
and Degrave, Jonas and Donner, Craig and Felici, Federico and Hamel, Philippe
and Huber, Andrea and Nikulin, Dmitry and Pfau, David and Tracey, Brendan and
Riedmiller, Martin and Kohli, Pushmeet},
journal={arXiv preprint arXiv:2406.06718},
year={2024}
}
Interested in contributing? See the Contributing docs.
This is not an officially supported Google product.
Metadata
Release files for torax 2.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| torax-2.0.0.tar.gz | 20.6 MB | Without provenance | Details for torax-2.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| torax-2.0.0-py3-none-any.whl | Python 3 | none | any | Details for torax-2.0.0-py3-none-any.whl |
Total release size: 41.5 MB
Release files / torax-2.0.0.tar.gz
| Download URL | torax-2.0.0.tar.gz |
|---|---|
| Size | 20.6 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e5b6d90c6f043be4dad96b90ff3eba95934c36422fa117485cb1e02d256efbf8
|
|
BLAKE2b-256 checksum How to use checksums |
8e3fd1f8265c8bb2a816481bce4a3c5cb5f3a44a6e9440a52ebd13159fba4e74
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.15
|
Release files / torax-2.0.0-py3-none-any.whl
| Download URL | torax-2.0.0-py3-none-any.whl |
|---|---|
| Size | 20.9 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
60842bfbdef22729dd38d414d52fec05fcd6fe9154153a32971fcd8335161e13
|
|
BLAKE2b-256 checksum How to use checksums |
2d1fe8f20e593f3079680f44b58333baaa42be2bf832970f4a98b5966a9c5839
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.15
|
Security for torax 2.0.0
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.