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
  Contrast:
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!

This simulation is intended for qualitative and semi-quantitative educational demonstrations—not for serious engineering use. One obvious limitation is that it simulates a fluid in only two dimensions rather than three. It is also limited to modeling fluids at constant temperature and with flow velocities that are at least a few times less than the speed of sound. Perhaps the most important limitation, though, concerns the length and time scale. The simulation uses an arbitrary system of units, so the only way to compare to the real world is through the dimensionless Reynolds number, defined as (length)(velocity)/(viscosity), where “length” is the characteristic size of whatever the fluid is flowing around or through. The practical limit on the Reynolds number in this simulation is a few hundred, whereas a typical Reynolds number for air flowing around a bicyclist is roughly 100,000. Higher Reynolds numbers result in more levels of structure and turbulence in the fluid. This simulation simply cannot handle the many high-Reynolds-number situations that are so important in everyday life.

The simulation uses a fairly simple lattice-Boltzmann algorithm, which you can see by viewing the JavaScript source code (use your browser's View Source or Page Source menu command). As of 2019, it runs at pleasing speeds on most personal computers in the Chrome, Firefox, and Opera browsers. Other browsers, not to mention mobile devices, may give inferior performance. Some very old browsers may not even be able to display the slider controls.

Related materials: