Fluid Dynamics


Fluid dynamics is a rich field which can be used to, e.g., model the behavior of gases and liquids or to calculate forces on airplanes or even to study the weather. Fluid dynamics is a very complex subject and many of its aspects are still not fully understood, turbulence being a prime example. There are many approaches to model fluid dynamics which vary according to their goals. For my project I have used cellular automata to model a two-dimensional fluid travelling between 2 walls.

Cellular automata are arrays of cells which contain discrete (often boolean) values. If it is large enough, it is possible to coarse-grain the array and to then observe continuous macroscopic behavior. This makes it a good candidate to simulate fluids. When it is used for this purpose, an array is populated by particles whose velocities may be one of a few choices and Wolfram has shown that, for certain choices of lattices in two and three dimensions, the hydrodynamical equations derived from cellular automata yield slightly modified Navier-Stokes equations [2].

The Model

I studied a two-dimensional fluid flowing between two walls. I used a hexagonal array (to preserve isotropy [2]) in which each site can contain up to 6 particles. Each particle can be uniquely described by its position in the array and its velocity (i.e. no two particles may occupy the same site and have the same velocity). This allows us to use a boolean array, which will simplify all of the calculations considerably. Velocities will then be v = (cos(60*a), sin(60*a)) where a = 0, 1, ..., 5. The figure below, taken from Wolfram's paper on fluid dynamics [2], shows what such a lattice could look like at a given time.


At the beginning of the simulation, 52000 particles are randomly placed in 24000 cells, close to the suggested particle density of 2.1 particles per cell [3]. All of the particles initially have a equal to 0, 1 or 5 to simulate a flow.

At each time-step (of which there were 10000 in my simulation), all of the particles move one lattice site in a direction according to v and, if they meet another particle at their new lattice site, they collide in a way that conserves momentum. Also, if the particle hits a smooth wall it bounces off it elastically whereas it bounces randomly off a rough wall. After all of these steps happen, we can calculate macroscopic quantities such as total velocity and particle density. Finally, as there will clearly be some particles leaving the studied region in the direction of the flow, we must add new particles each time-step to simulate the incoming flow. The figure below, also taken from Wolfram's paper on fluid dynamics [2], shows some possible "in states" and some of their corresponding "out states".

coll1 coll2

As the fluid is constructed randomly, we cannot expect it to be in equilibrium immediately. Therefore, a first 1000 iterations occur before any macroscopic quantities are recorded. After those initial iterations, I averaged all recorded macroscopic quantities over a large number of iterations.


I was interested in seeing how the average fluid velocity depends upon the fluid's distance to the walls. I studied this for both smooth (code) and rough (code) walls and obtained quite different results.

smooth rough

Here Vx is in the direction of the fluid flow and Vy is transverse to it.

As should be expected, Vy averages out to zero, except at the walls (as the particles can't travel into them). What is interesting is that, for smooth walls, Vx only drops right at the walls but rough walls have a larger effect and noticeably slow the flow to a significant distance away from them.

I also looked at what happened during the initial evolution from inequilibrium to a stable configuration. Below are the graphs showing what the fluid flow looked like, averaged over the first hundred iterations (#1), iterations 101 to 200 (#2), 201 to 300 (#3) and 301 to 400 (#4).

1 2 3 4

We can see that initially the fluid flow was more homogeneous and, as the effect of the rough walls began to spread, the fluid's velocity began to depend more importantly on its distance from the walls.


After studying how a fluid's velocity depended on its distance from the walls, I saw that smooth walls have a minimal effect whereas rough walls slow down the flow in their vicinity. An interesting (though difficult) extension to this project would be to do the same study in three dimensions and to incorporate gravity into the model. This model would be particularly difficult to implement as lattices which preserve isotropy in three dimensions are quite exotic. However, the results of such a model would most likely be very interesting.


[1] T. Pang, An Introduction to Computational Physics, 2nd Ed., Cambridge University Press (2006).

[2] S. Wolfram, J. Stat. Phys. 45, 471 (1986).

[3] G. R. McNamara and G. Zanetti, Phys. Rev. Lett. 61, 20 (1988).

Further reading:

[4] G. Gallavotti, Foundations of Fluid Dynamics, Springer (2002).

[5] T. J. Chung, Computational Fluid Dynamics, Cambridge University Press (2002).