Wind Tunnel
What it is
A wind tunnel you can run in a browser tab. Pick a shape, watch the air go round it as smoke, speed or pressure, and read off the drag and lift. You can run two tunnels side by side to compare them, or look down on Plymouth city centre and see where the wind gets squeezed between buildings.
Why I built it
I wanted to watch air move. Proper simulation of this is done by paid cloud services, and a real tunnel is out of the question, but a flat slice of the flow is cheap enough to run on any graphics card. Once it worked on a car, I had the building outlines from Plymouth 3D sitting there, so the city went in too.
How it works
It’s a lattice Boltzmann solver. The tunnel is a grid of cells, and each cell holds nine numbers for how much air is heading in each direction. Every step the air streams to its neighbours and then relaxes, and the whole grid does that at once on the graphics card, one shader pass per step.
The first version grew a grey fuzz along the edges of every swirl at the default speed. A more careful version of the relaxing step got rid of it, and it can’t blow up any more, which I tested by running every shape at top speed and the thinnest air.
Drag and lift are averaged once the flow has settled, because a car sheds eddies and the numbers swing. The readout says how much they swing rather than hiding it.
Plymouth is 3,405 buildings round Armada Way, from OpenStreetMap with heights from the Environment Agency’s laser survey. A flat slice can’t let air go over the rooftops, so the street-level flow is nudged towards the wind above. Treat those street speeds as a rough guide.
What I’d change
A single slice exaggerates some things. A time-trial cyclist comes out about 60% better than an upright one, where the real figure is nearer 30%. A proper 3D version would fix that, and it would be the way to do wind at street level properly.
How to use it
Pick a shape along the bottom, and choose Side or Above. Drag the shape to move it, or drag the map to pan round Plymouth. The views are Smoke, Speed, Pressure and Vorticity (keys 1 to 4). A and B splits it into two tunnels: click a tunnel to change its shape, and the panel compares the two. Wind speed and viscosity are sliders. Space pauses and R resets the flow. Copy link saves exactly what you’re looking at.
JavaScriptWebGL2GLSLCanvas 2DOpenStreetMapEnvironment Agency LIDAR