# CSCI 1300 Project: Lattice Gas Wind Tunnel

Project: Lattice Gas Wind Tunnel

# CSCI 1300 Project: Lattice Gas Wind Tunnel

This is one of several possible projects for CSCI 1300. The following link tells how the projects are used:

## What the Program Should Do

This project involves a simulation of the flow of fluid using a rectangular grid of fixed points. This is called a "lattice gas" because the "gas" of particles is restricted to move about on a "lattice" gridwork and not on a continuum of sites. Even though these particles can move in only a few directions and with a fixed velocity, physicists have shown that their behavior faithfully mimics many aspects of the behavior of large collections of real molecules.

The idea here is to use this kind of technique to simulate the flow of gas through a wind tunnel which contains an obstacle. The pattern of the flow of gas around the obstacle will be visually rendered by the program.

This project description is a bit longer than some of the others because the set of rules for movement of the particles must be described.

The tunnel consists of the lattice, which is a rectangular grid of fixed points. Below are shown 12 squares of the lattice. If you connect the nearest neighbor nodes with lines you will have generated 23 lines, which are called the "edges of the lattice". All edges have the same length. Particles are restricted to moving along these edges from one point to another. During each time interval in the program, each particle moves the length of one edge.

```*          *          *          *

*          *           *          *

*          *          *          *
```
The lattice grid shown above consists of three layers of nodes. You should have several layers (e.g. more than a dozen layers) of these nodes in your grid. You will mark the top and bottom of the grid to represent the walls of the tunnel. You will also mark some of the nodes in the middle of the grid to be obstacles by drawing them in some different way. An obstacle indicates that this lattice site cannot be occupied by a particle of gas.

Particles will be shown as arrows which point in the direction the particle will move when the next time interval is computed. Particles can only move along edges in the lattice. You can show that a particle is on a lattice site by drawing the arrow as originating from that lattice site. Be careful never to put more than one particle on an edge pointing in the same direction.

Here's how to make the particles move in the grid: First look for collisions which are going to occur in the next time step. Because each node is connected with six edges, any node may have up to six particles heading into it on any given time step. Our rule will provide that only two arrangements of incoming particles will make collisions. If two particles are approaching a node from diametrically opposite edges then they will collide. If three particles are approaching a node from three equally separated edges then they will collide.

Any other arrangement of incoming particles is not a collision. For example any arrangement of four incoming particles is not a collision. Any two particles coming in at an angle other than 180 degrees will not cause a collision. Any three incoming particles where each is not separated by 120 degrees will not cause a collision.

When you find that a collision is going to occur you must rearrange those particles which are about to collide. Consider the following scheme for numbering edges for the purpose of this discussion:

```            *          *

1      2

*   6    *    3     *

5     4

*          *
```
Let us say that we have a particle approaching the center node along edge 1 and another particle approaching the center node along edge 4. By the rules stated above this is a collision. When we have a collision we must rearrange the particles. For this collision one of two rearrangements must be chosen with equal probability. One rearrangement would configure the particles so that there is one incoming particle on edge 2 and the other on edge 5. The other rearragement would configure the particles so that there is one incoming particle on edge 3 and the other on edge 6.

For a collision from three incoming particles along edges 1, 3, and 5, the rearrangement is to have incoming particles along edges 2, 4, and 6.

Once all collisions have been detected and all the rearrangements made, then we are ready to move the particles for the next time interval. Process each node and move each of its incoming particles to the next node in the direction it is pointing.

We have not addressed the collisions with the wall or the obstacle. Particles colliding with walls or obstacles are reflected back in the direction from which they came. Do this by processing the wall and obstacle nodes differently. In our earlier diagram let us say that edges 3 and 6 connect nodes on the obstacle. An incoming particle along edge 1 will collide with the obstacle at the center node. This rearrangement for this collision is to position the particle as though it is coming in along edge 4. After moving the particles for the next time step the particle will be directed away from the center node along edge 1.

To drive a flow of particles through your tunnel, at each time step you will want to introduce new particles flowing into the tunnel at the nodes along one end of the tunnel. You can have the user determine how many particles to inject at each time step. A snazzy program will permit you to control this while the program is running, and perhaps also allow you to draw obstacles on the screen.

Particles that flow out of the tunnel are simply discarded.