Vignesh Gopakumar
  • Home
  • Research
  • Talks
  • Blog
  • Tokamak Toolkit

On this page

  • Where the plasma sits
  • How heat and particles move
  • Why these pieces have to be solved together
  • What a surrogate is, and why it can’t simply be trusted
  • What “guarantees” means here
  • Open and gated codes
  • Why JAX

Primer

The setting, in plain words. Log entries refer back to this page.

This page introduces the physics and the checks used throughout the log. For a specific term, use the glossary; for equations and interfaces, start with the technical reading guide. The action plan records the accepted scope and remaining limitations.

Where the plasma sits

A tokamak holds a gas of charged particles, hotter than the centre of the Sun, inside a doughnut-shaped magnetic cage. The field lines wind around the doughnut and form nested surfaces, like the layers of an onion wrapped into a ring. Particles and heat move easily along a surface and only slowly across them, which is the basis of magnetic confinement.

Because the plasma is nearly the same everywhere on one surface, most of the physics can be described by how things change from the centre (the core) to the edge. The log uses one number for “how far out”: ρ (rho), which is 0 at the centre and 1 at the edge.

The magnetic cage is shaped by coils outside the plasma, and by currents flowing in the plasma itself. Working out the shape the plasma settles into is the equilibrium problem. The machines named in this log are ITER, the large international device under construction in France, whose published scenarios are used as a benchmark, and MAST-U, a compact spherical tokamak in the UK, shaped more like a cored apple than a doughnut.

How heat and particles move

Heating systems pour power into the core. It leaks out across the surfaces, mostly through small-scale turbulence. How fast it leaks decides how hot the core gets, and that decides how much fusion power the plasma makes.

Transport is the name for that leakage. It is stiff: below a critical temperature gradient the turbulence is quiet, above it the turbulence switches on hard and the leak jumps. The plasma tends to sit right at that threshold, which makes it numerically awkward: small changes in the profile cause large changes in the leak, which change the profile, and so on.

Why these pieces have to be solved together

Integrated modelling couples the separate pieces of physics:

piece what it answers example code used here
equilibrium what shape is the plasma, given the coil currents? FreeGSNKE
transport how fast do heat and particles leak across the surfaces? TORAX with QLKNN
sources where does the heating power go? Gaussian deposition, EC surrogates and prescribed ASCOT5 results, depending on the run
events sudden internal collapses (“sawteeth”) and edge transitions TORAX’s models

These pieces exchange information: temperature gradients affect transport, transport changes temperature, and temperature changes heating and fusion. The coupling loop must find profiles consistent with the models it uses. Some inputs can remain prescribed; a coupled simulation does not necessarily recompute every physics code at every step.

#| fig-cap: "Conceptual coupling: the new profiles must be consistent with the transport and sources evaluated from them. Geometry and boundary inputs depend on the chosen scenario."
#| fig-alt: "Prescribed geometry and boundary inputs feed a profile solve. Trial profiles feed transport and heating models, whose coefficients and sources return to the solve. Accepted profiles become the starting state for the next time step."
%%{init: {"flowchart": {"useMaxWidth": false}}}%%
flowchart TD
  inputs["Scenario geometry and boundaries"] --> solve["Solve the profile equations"]
  old["Previous accepted state"] --> solve
  solve --> trial["Trial temperature and density profiles"]
  trial --> models["Evaluate transport and heating"]
  models -->|"Coefficients and sources"| solve
  solve -->|"Acceptance checks pass"| next["Next accepted state"]

The machine explorer distinguishes these routes. ITER uses prescribed equilibrium geometry. The MAST-U equilibrium calculations and the offline JOREK stability studies have their own scopes; neither should be read as demonstrated feedback from every module into TORAX.

What a surrogate is, and why it can’t simply be trusted

A surrogate is a neural network trained to reproduce a physics code at lower evaluation cost. Actual savings depend on the complete simulation, including fallback and solver costs. The catch is that a network will return a confident-looking number for any input, including plasma conditions it never saw in training, where its answer can be arbitrarily wrong.

In this project every surrogate sits behind a guard. Transport decisions apply at radial faces; EC source and pedestal decisions apply to a returned profile or boundary response. The checks depend on the model route:

  1. Is the input inside the region the network was trained on? (its domain)
  2. Do several independently trained copies of the network agree? (an ensemble; disagreement can trigger rejection, but agreement alone does not establish accuracy)
  3. Is the output physically possible? (finite, positive where it must be, within bounds)

In the original binary guard, any failed check selects the fallback, the declared alternative physics model, at that point. Ensemble-spread checks apply only to ensemble routes. The current ITER research baseline also blends coefficients continuously near accepted-domain boundaries; rejected inputs still receive fallback. See the guard and continuous-closure method for the distinction.

Fallback use and guard rejection diagnose where a surrogate is usable. A decision recomputed on an accepted state is a snapshot, not a record of every nonlinear trial during that step. Fallback also has modelling limits: switching to it does not by itself validate the physics.

What “guarantees” means here

Three kinds, each covering what the others can’t:

  • Formal: proved mathematically for a whole box of inputs, e.g. “the predicted heat flux never decreases when the temperature gradient increases”. Proofs cover the network itself, not the physics it imitates.
  • Statistical: calibrated error bars (conformal prediction) evaluated against reference labels. Their coverage depends on the calibration assumptions; a marginal interval does not guarantee a whole trajectory or accuracy against experiment.
  • Closed-loop: a whole simulation run with the surrogate compared with the same run using the physics model, because small errors at each step can grow or cancel over thousands of steps. A time-step refinement check separately asks whether the numerical result changes acceptably as the time step is reduced.

#| fig-cap: "Different checks support different claims. None of these checks alone establishes experimental predictive accuracy."
#| fig-alt: "Network properties are checked over a declared input box. Statistical intervals are checked against reference labels. Coupled behaviour is checked along trajectories, and numerical convergence under refinement. Each leads to a separate, limited conclusion."
%%{init: {"flowchart": {"useMaxWidth": false}}}%%
flowchart TD
  proof["Proof over an input box"] --> property["Specified network property"]
  labels["Calibration and evaluation labels"] --> coverage["Statistical interval coverage"]
  loop["Matched coupled runs"] --> response["Trajectory agreement in that scenario"]
  refine["Time-step refinement"] --> numerical["Numerical convergence under that protocol"]

Open and gated codes

The toolkit is built so that everything it ships depends only on open-source codes that anyone can download (called Tier A in this log). Some of the most accurate fusion codes are available only through the UK Atomic Energy Authority (Tier B). Those may be used to generate training data or reference runs, but never as something the finished toolkit needs in order to run. The test suite is run a second time with every gated code switched off to prove it.

Why JAX

The transport calculation uses JAX, a numerical library that compiles array calculations and applies automatic differentiation. This supports fast repeated evaluation and derivatives for sensitivity analysis. Those derivatives still need checks: nonsmooth model switches, invalid intermediate values and unconverged implicit solves can make them unusable. The fixed-step paths and the adaptive research driver have different differentiation limits, described in the coupling loop and research solver.

© Copyright 2026 Vignesh Gopakumar

 
 
Code and first draft by Claude (Anthropic) and Codex, working to a brief by Vignesh Gopakumar, who reviewed and approved this page. How this is built · Tokamak Toolkit home