Summary
Fusion reactors hold plasma hotter than the sun’s core in place with magnetic fields. Whether that works depends on how billions of charged particles move together, and the only way to see that in detail is to simulate them. Hyperion is my simulation of that plasma, built on the GPU one stage at a time, and every stage has to reproduce physics with a known answer before the next one starts.
- Built so far
- A CUDA particle engine with real-time rendering, verified against an exact orbital solution.
- Shows
- GPU programming, numerical methods, tests that check physics against exact answers, and benchmarks with their method written down.
- Next
- Electrostatic particle-in-cell: 84 million particles on a 128³ grid.
- O(dt²)Leapfrog convergence, measured
- 254 fps24,576 bodies, direct sum, RTX 2060
- 13 / 13Engine tests passing, GPU checked against FP64
- 1 of 5Roadmap stages done
Idea
Plasma behaves like a crowd. Each particle moves in the field all the others make together, and that decides how it has to be simulated.
A tokamak plasma has a density around 1020 particles per cubic metre at roughly 10 keV. Each charge’s field is screened by its neighbours beyond the Debye length, about 74 µm here, and around 1.7×108 particles share each Debye sphere. Individual collisions barely matter. What matters is the collective field all of them make together.
That rules out the tools that work for gravity. A Barnes-Hut tree exists to compute long-range pair forces cheaply, but in a plasma the long range is carried by the field instead. So Hyperion uses particle-in-cell: spread the charge onto a grid, solve for the field there, and push each particle through it. The same family of method runs production fusion codes like GENE, XGC, GTC and OSIRIS.
Architecture
The engine is split so the physics can change without touching anything else.
Interfaces take whole particle buffers, never single particles, so there’s one virtual call per step instead of one per body. Particle state is a structure of arrays, which is what the GPU wants. Next to the fast FP32 CUDA path sits a slow FP64 CPU path whose only job is to be right: the tests check the GPU against it. The renderer reads particle positions straight from GPU memory through CUDA-OpenGL interop, so nothing is copied back to the CPU to draw a frame.
Stage 2 swaps the direct sum for the particle-in-cell loop. Each step does four things, and three of them are linear in the number of particles. That’s the point: particle count stops being the limit.
Design decisions
Each of these had a reasonable alternative. Here’s what I picked and why.
The first four are built and tested in Stage 1. The last four are Stage 2 design, settled before writing the code.
-
Structure of arrays
Over an array of particle structs.
Neighbouring GPU threads read neighbouring memory, so loads coalesce. The original
struct Particlewas ported, and the Kepler test proved the port changed nothing. -
Leapfrog, kick-drift-kick
Over semi-implicit Euler, the integrator it replaced.
Second order and symplectic for the same memory: energy stays bounded instead of drifting. At the large timesteps a real-time sim needs, it’s the biggest accuracy gain per cost. Measured: halving dt cuts the error about 4x.
-
An FP64 oracle checks the FP32 GPU
Over trusting the kernel because the picture looks right.
FP64 is 40x slower on this GPU, measured, so the fast path has to be FP32. A slow CPU path in FP64 gives every GPU test a reference. Tests assert finiteness first, because
std::max(0, NaN)is 0 and would let a broken kernel pass. -
A p99.9 frame-time gate
Over “never drop below 120 fps”.
The worst single frame keeps getting worse the longer you measure, so no finite run can pass it. Average ≥ 144 fps and p99.9 ≥ 120 fps keeps the intent and can actually be measured.
-
Normalized units on the GPU Stage 2
Over SI units.
The electron charge squared is 2.6×10−38, only twice FP32’s smallest normal number. In SI, anything that multiplies it by a small length drops into denormals or to zero. In Debye lengths and plasma periods, everything is order one.
-
Spectral field solve Stage 2
Over finite-differencing the potential.
Ek = −ikφk is an exact derivative. It keeps charge deposit and field gather adjoint, so a particle feels no force from itself and total momentum is conserved. Both get their own tests.
-
The k = 0 mode forced to zero Stage 2
Over leaving the FFT’s mean term alone.
It’s the undefined average potential. Left in, it shows up as a slow global drift that looks like a bug somewhere else. Stage 2 has a test just for this.
-
Periodic boundaries first Stage 2
Over walls or toroidal geometry from day one.
The FFT assumes periodicity, and every analytic test (Langmuir, two-stream, ion-acoustic) is a periodic problem. Real geometry needs a different solver, and comes later.
Evidence
Every number here comes from the repository, along with the program that produced it.
Roadmap
Each stage has to pass physics with a known answer before the next one begins.
-
Done
GPU particle engine
CUDA direct sum, leapfrog on the device, real-time rendering.
Kepler orbit to 4.8 mm, second-order convergence, GPU against FP64
-
Designed
Electrostatic particle-in-cell
Two species, 128³ grid, cuFFT field solve, about 84 million particles.
Langmuir oscillation, two-stream growth rate, ion-acoustic dispersion
-
Planned
Boris pusher
Magnetized particles. Tokamak physics starts here.
Gyrofrequency and Larmor radius, exact
-
Planned
Electromagnetic PIC
Full Maxwell on a Yee grid.
Energy and momentum, CFL c·dt < dx
-
Planned
Gyrokinetics
Averaging over the fast gyration to reach reactor timescales.