2D Computational Fluid Dynamics: Vortex Shedding Around a Cylinder
A grid-based Navier-Stokes solver drawn straight onto a Canvas2D color field — adjust inflow speed, viscosity and grid resolution to watch the wake behind a cylinder shed vortices as the Reynolds number climbs.
This 2D companion runs the same advect-diffuse Navier-Stokes lattice as the 3D version — inflow entering from the left, a circular obstacle, viscous diffusion followed by semi-Lagrangian advection, and a small wake-injection term that seeds vortex shedding once the Reynolds number climbs past the laminar regime — but draws every lattice cell straight onto a flat Canvas2D grid instead of an orbitable 3D plane. Dropping the camera makes the wake easier to read at a glance: watching the velocity view, the boundary layer thickens and separates as inflow speed rises; switching to the vorticity view exposes the alternating red/blue rotation bands of the von Kármán vortex street directly, cell by cell, as they peel off the back of the cylinder.
Canvas2D CFD lattice around a cylinder: viscous diffusion, semi-Lagrangian advection and a wake-shedding term reproduce vortex shedding and Reynolds-number effects, colored per-cell by velocity magnitude or vorticity.
2D · HTML5 Canvas 2D · 60 FPS target · runs fully client-side, no install
Below a Reynolds number of roughly 40 the flow stays laminar and the wake is a symmetric pair of trailing streaks. Raise the inflow speed or lower the viscosity and the Reynolds number climbs, the wake becomes unstable, and the built-in shedding term makes it peel off as alternating vortices — the same von Kármán vortex street seen behind real bridge piers and chimney stacks.
The velocity view colors each cell by how fast the fluid there is moving, which highlights the boundary layer and the free-stream. The vorticity view colors by local rotation (curl) of the flow instead, which is what actually makes the alternating vortex bands in the wake visible — velocity magnitude alone hides them.