Physics simulations and visualizations

A stalling wing and a confined plasma, computed live.

  • Physics simulation

Date: 2026

A personal project, out of passion: understanding physical phenomena by simulating them, and getting better at fluid mechanics, plasma physics or the study of crowds. Rather than isolated scripts, a workshop: a shared core, display engines and a shared control panel, where each new simulation is cheap to add and the physics is checked by tests against known results.

Two simulations run there today, in the browser, with nothing to install: a wind tunnel, to see the air carry a wing then stall, and a tokamak, to see a magnetic field hold a plasma and its particles; a third, simpler one moves a crowd towards a goal. Fourteen situations are ready to watch, and every setting is shared through the page’s address. The project dates from 2026, taken up again in the autumn to show interesting physical effects.

These simulations also serve as a base when I build models for client projects: the same core animates the crowd on this site’s home page.

The result

Isometric drawing. In front, a wind-tunnel test section with a NACA 0012 wing profile and the smoke filaments the simulation computed: at 4°, they follow the profile; at 16°, they separate and roll up into vortices. Behind, a tokamak: the plasma edge as a wireframe and a field line winding in a helix. By step: a control panel, with its situations, its sliders and a measurement curve; a section of the torus showing the banana orbit of a trapped particle, then, with no plasma current, arrows rising to the wall; a plan where agents go round two pillars towards a goal.
Simulation of a NACA 0012 wing section at 16°, as black smoke lines on paper: the air leaves the top of the profile and rolls up into vortices that drift to the right. Two red arrows, lift and drag, start from the profile.
At 16°, the profile stalls: the air rolls up into vortices. The “Soufflerie” (wind tunnel) app, run locally
The same stall as vorticity: blue and red vortices leave the profile one after the other, on paper.
The vortices of the stall: blue one way, red the other. The “Soufflerie” (wind tunnel) app, run locally
The flow behind a black cylinder: smoke lines and blue and red tints form a street of alternating vortices.
Behind a cylinder, the von Kármán street. The “Soufflerie” (wind tunnel) app, run locally
The tokamak in two views: on the left, a grey wireframe torus and the blue path of a particle going back and forth; on the right, the cut through the torus, where that path draws a blue crescent on the outer side.
A trapped deuteron: its orbit draws a banana. The “Tokamak” app, run locally
The tokamak in two views: on the left, a red field line that goes round twice and closes; on the right, the cut, covered with nested circles of dots, with two crescent-shaped islands near the edge.
A 1 ‰ perturbation opens two magnetic islands. The “Tokamak” app, run locally
The tokamak in two views, with no plasma current: a cloud of black dots around the torus; in the cut, the dots have moved upwards, up to the wall.
With no plasma current, the ions drift upwards. The “Tokamak” app, run locally
The wind-tunnel app: on the left, the stalled profile and its smoke lines; on the right, the panel with the ready-made situations, the play, step and restart buttons (in French), and the settings for the profile and the incidence.
The app, with its situations and settings. The “Soufflerie” (wind tunnel) app, run locally

What was done

  1. 01

    The workshop

    A shared core: the fixed-step computation loop, separate from drawing, bodies, a spatial grid, flocking behaviours, and typed parameters from which the control panel, the situations and the URL parameters derive.

    TypeScript · Vite · pnpm

  2. 02

    The display engines

    Three ways to draw the same simulation: a 2D canvas with its colour maps and charts, PixiJS, and Three.js with instancing for thousands of bodies.

    Canvas 2D · PixiJS · Three.js

  3. 03

    The wind tunnel

    The air computed with the lattice Boltzmann method, on the processor, tens of millions of cells per second; profiles drawn from their equations; lift and drag measured on the body.

    Lattice Boltzmann (D2Q9)

  4. 04

    The tokamak

    An analytic, divergence-free magnetic field whose twist follows the plasma current, islands on demand; field lines and their Poincaré sections; particles as full orbits or guiding centres.

    Boris pusher · Guiding centre

  5. 05

    The crowd

    Agents that keep apart, align and gather, drawn to a goal and pushed away by obstacles, on a grid to stay fast.

    Boids

  6. 06

    The checks

    Computations compared with known results: a cylinder’s wake, the stall, the divergence-free field, energy conserved, banana widths, the trapped share, the drift with no current.

    Vitest

  7. 07

    The generator

    A new simulation created in one command, with its app, its port and its place in the workshop.

    Node.js

Isometric drawing. In front, a wind-tunnel test section with a NACA 0012 wing profile and the smoke filaments the simulation computed: at 4°, they follow the profile; at 16°, they separate and roll up into vortices. Behind, a tokamak: the plasma edge as a wireframe and a field line winding in a helix. By step: a control panel, with its situations, its sliders and a measurement curve; a section of the torus showing the banana orbit of a trapped particle, then, with no plasma current, arrows rising to the wall; a plan where agents go round two pillars towards a goal.

How it works

  1. Scroll: the drawing follows.

  2. 01 / 08

    A workshop of simulations, in the browser

    A project to build visual physics simulations that run in any browser, with nothing to install. A shared core carries the computation loop, at a fixed time step, separate from the drawing; display engines in 2D and 3D; a control panel derived from each simulation’s parameters. A new simulation is cheap to add, and its physics must be right and checked.

  3. 02 / 08

    Set, watch, measure, share

    Every simulation offers the same services: situations ready to watch, each with its sentence; grouped controls, changed while it runs; readings taken live and charted over time; play, pause, one step, restart, from the keyboard. Every setting is written into the page’s address, to share a situation or capture an image of it after a given number of steps, identically.

  4. 03 / 08

    The wind tunnel: see the air carry a wing

    To understand what makes a wing fly. You pick a body, four wing profiles, a flat plate or a cylinder, its incidence from −10° to 30°, and the speed of the air, from an insect’s flight to a small drone’s. The air is computed live, cell by cell, and watched as smoke, vortices, speed or pressure. At 4°, the smoke follows the profile and the lift stays steady.

  5. 04 / 08

    The stall, and a cylinder’s wake

    At 16°, the air leaves the top of the wing and rolls up into vortices: drag jumps, lift oscillates. Behind a cylinder, vortices shed alternately, the von Kármán street. Tests compare these computations with known results: no lift at 0°, the stall at 16°, and the rate of the cylinder’s vortices, within a few percent of the value measured in the laboratory.

  6. 05 / 08

    The tokamak: see the field hold a plasma

    To understand how a magnetic field holds a plasma. A tokamak in 3D, to turn and zoom, and its section. You set the field, from 1 to 6 teslas, the plasma current, from 0 to 2 megaamperes, and the machine’s shape. Each field line winds in a helix on its surface; the safety factor is plotted live, and a small perturbation tears a surface into magnetic islands.

  7. 06 / 08

    A trapped particle

    A deuteron, an electron or an alpha particle, at the chosen energy, released at the speed and the place you want. Too slow along the field, it bounces back on the inner side, where the field is stronger, and traces a banana whose width shows in centimetres; otherwise it passes, or is lost on the wall. Or a cloud of one hundred to four thousand particles, and the share that stays trapped. Tests check the banana’s width and the trapped share against theory, within a few percent.

  8. 07 / 08

    With no current, the plasma escapes

    Cut the plasma current: the lines no longer twist, ions drift up, electrons down, to the wall, at the speed theory predicts. Eight situations are ready, from helical lines to the fusion alpha, which a stronger current keeps in the machine.

  9. 08 / 08

    The crowd: agents heading for a goal

    A third, simpler simulation: agents that head for a goal while keeping clear of their neighbours and going round two pillars, from ten to twelve hundred of them, with a goal you move with a click. The same core animates the crowd on this site’s home page.

Specifications

Date
2026
Built with
TypeScript · Canvas 2D · Three.js · Vite · Vitest
Platforms
Web
Scale
14 ready-made situations · 16 physics tests