Fluid Dynamics Simulation

By Dan Schroeder, Physics Department, Weber State University

This application runs only in modern browsers. For best results, use Google Chrome.
Flow speed = 0.100   Viscosity = 0.020
Animation speed:   Steps per second: 0   Faster?
Show: Tracers Flowlines Force on barriers Sensor Data

This is a simulation of a two-dimensional fluid. Initially the fluid is flowing from left to right, and a linear barrier (shown in black) diverts the fluid and creates vortices. The colors indicate the curl, or local rotational motion, of the fluid. Use the controls to adjust the flow speed and viscosity, draw different barriers, drag the fluid around, plot other quantities besides the curl, show the force exerted by the fluid on the barriers, and measure the fluid's density and velocity at any point. Enjoy!

The simulation uses a fairly simple lattice-Boltzmann algorithm, which you can see by viewing the JavaScript source code. As of mid-2013, the simulation runs fastest under Chrome on either MacOS or Windows. Firefox is somewhat slower and Safari slower still, while Opera and Internet Explorer are much slower. You can adjust the resolution to increase or decrease the simulation speed.

If you don't see the slider controls above, try updating your browser. As of August 2013, the most recent versions of all major browsers should show the sliders.

This HTML5-canvas-JavaScript web app is a work in progress. It still has a few bugs and awkward features, which I hope to address some day.

Related materials: