TORAX: A Fast and Differentiable Tokamak Transport Simulator in JAX
This paper introduces TORAX, an open-source, differentiable tokamak transport simulator built in JAX that leverages automatic differentiation and JIT compilation to enable fast, gradient-based optimization for plasma scenario modeling, pulse design, and control.
Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer
Imagine you're trying to bake the perfect loaf of bread, but instead of flour and water, your ingredients are super-hot plasma, magnetic fields, and fusion energy. The goal? To build a machine (a tokamak) that can power the world. The problem is, predicting how that plasma behaves inside the machine is like trying to forecast the weather in a hurricane while the storm is happening. It's messy, it's fast, and it involves a dizzying mix of physics rules that change every millisecond.
Enter TORAX, a new, open-source computer program created by researchers at Google DeepMind. Think of TORAX as a "smart, super-fast flight simulator" for these fusion reactors. But here's the twist: unlike old simulators that are like clunky, slow-moving trucks, TORAX is built with a special engine called JAX. This engine allows the simulator to not only run incredibly fast but also to "learn" from its mistakes instantly by calculating gradients (basically, figuring out exactly which knob to turn to get a better result).
The Old Way vs. The New Way
For years, scientists have used other simulators (like RAPTOR, JETTO, or ASTRA) to model these reactors. These tools are like reliable, heavy-duty calculators. They work well, but they are often written in older languages (like Fortran) that make it hard to plug in modern Artificial Intelligence (AI) models or to quickly tweak the math to find the perfect settings. They are also slow; running a simulation for a few seconds of reactor time could take hours or even days on a standard computer.
The authors of this paper argue that this slowness and lack of flexibility are holding fusion research back. They explicitly rule out the idea that we should stick with these old, rigid codes if we want to use modern machine learning or do complex optimization. They show that while old codes are good, they can't easily handle the "what-if" scenarios needed to design future reactors or control them in real-time.
How TORAX Works: The Magic of the "Flight Simulator"
TORAX simulates the core of the plasma by solving a set of four main equations. You can think of these as the rules governing:
- Ion Heat: How hot the heavy particles get.
- Electron Heat: How hot the light particles get.
- Particle Transport: How the density of the plasma changes.
- Current Diffusion: How the electric current flows through the plasma.
Instead of solving these one by one in a slow, step-by-step march, TORAX uses a technique called Finite Volume Method. Imagine slicing the plasma into a stack of thin, invisible pancakes (or cells). The program calculates how heat and particles flow from one pancake to the next. It uses a clever math trick called the "power-law scheme" to decide whether to look at the flow from the left or the right, depending on how fast the plasma is moving. This ensures the simulation doesn't get "wobbly" or inaccurate.
The real magic happens because TORAX is written in Python using JAX. This means:
- Speed: It compiles the code into a super-efficient version that runs on CPUs, GPUs, or even TPUs. In tests, it ran a simulation of an 80-second reactor startup in just 22 seconds on a standard computer. That's faster than real-time!
- Differentiability: This is the big deal. TORAX can calculate exactly how a tiny change in the input (like turning up the heating power by 1%) affects the final result. This is crucial for using AI to automatically design the perfect "pulse" (the sequence of events) for a reactor.
The "Surrogate" Trick: AI as a Shortcut
One of the most exciting features is how TORAX handles turbulence. Turbulence in plasma is incredibly complex, like trying to predict every swirl in a river. Usually, simulating this takes forever. TORAX can use Machine Learning (ML) surrogates instead.
Think of an ML surrogate as a "crystal ball" trained on millions of complex physics simulations. Instead of doing the heavy lifting of calculating every swirl, the crystal ball (the AI model) instantly predicts the result. TORAX is built to plug these AI models in seamlessly. For example, it uses a model called QLKNN, which is trained on data from a more complex code called QuaLiKiz. This allows TORAX to run simulations with high-fidelity turbulence models in a fraction of the time it used to take.
Did It Work? The Proof is in the Pudding
The authors didn't just build it; they tested it. They ran TORAX side-by-side with RAPTOR, a well-established and trusted simulator. They simulated an "ITER-like" scenario (ITER is the massive international fusion experiment being built in France).
The results were impressive:
- Agreement: The temperature, density, and magnetic profiles generated by TORAX matched RAPTOR almost perfectly. The difference was tiny—less than 1% for steady states and around 2.5% during fast changes.
- Speed: While RAPTOR is fast, TORAX was able to run the same scenarios even faster, especially when using the AI surrogates.
- Verification: The paper explicitly states that TORAX is "verified" against RAPTOR, meaning the results are trustworthy within the tested scenarios.
What's Next? (And What's Not There Yet)
The paper is careful not to overhype. It admits that TORAX is a "new" tool and that some things are still on the roadmap.
- What's missing: It doesn't yet handle complex 3D shapes of the magnetic field dynamically (it uses pre-calculated shapes), nor does it include all types of radiation losses or heavy impurity transport yet.
- What's coming: The authors plan to add more physics models, like those for "sawteeth" (a type of magnetic instability) and better ways to handle the edge of the plasma (the "pedestal").
The Bottom Line
TORAX isn't a magic wand that solves fusion overnight. It's a powerful, flexible, and incredibly fast tool that makes the job of designing fusion reactors much easier. By combining the speed of modern computing with the smarts of machine learning, it allows scientists to run thousands of "what-if" scenarios in the time it used to take to run just one. It's like upgrading from a hand-cranked calculator to a supercomputer that can also teach itself how to solve the problem better.
The paper concludes that this tool is ready to help accelerate research in tokamak scenario modeling, pulse design, and control, but it emphasizes that it is a step forward in the journey, not the final destination. The future of fusion is bright, and tools like TORAX are helping to light the way.
Drowning in papers in your field?
Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.