Simple 2D fluid flow with viscosity can be simulated via Lattice Boltzmann Methods. These solve for the discrete Boltzmann equation with collision/viscosity models rather than the Navier-Stokes equation (although one can be turned into the other).

LBM models the fluid consisting of fictitious particles, and such particles perform consecutive streaming and collision processes over a discrete lattice mesh. Hence the general algorithm is the following:

- From the microscopic properties of the particles at a lattice point, find the macroscopic density and velocities
- Use these values to calculate the equilibrium values and update the microscopic values
- Stream the particles onto adjacent grid points based on their velocities

For the theory of the method look here, althought many other good resources can be easily found with a google search

Introducing a barrier to a flowing fluid can be simulated, see the two examples below:

*2 features of this program that show be mentioned are, firstly the barrier is placed into the flowing fluid so some transient behaviour is expected and secondly it is prone instabilities so simulations must be pick for appropriate parameters (generally by trail and error unfortunately)*

The plot shows the velocity component along the x axis

In [1]:

```
#NAME: Lattice Boltzmann Method
#DESCRIPTION: Fluid dynamics simulation using a Lattice Boltzmann Method.
import LBM
from pycav import display
animation1 = LBM.run(80,200,0.01,0.1,2200,400)
```

In [2]:

```
animation1 = display.create_animation(animation1, temp = True)
display.display_animation(animation1)
```

Out[2]:

In [3]:

```
animation2 = LBM.run(80,200,0.05,0.1,2200,400)
```

In [4]:

```
animation2 = display.create_animation(animation2, temp = True)
display.display_animation(animation2)
```

Out[4]:

In [23]:

```
animation3 = LBM.run(80,200,0.00275,0.1,2200,400,barrier_file='./airfoil.dat')
```

In [24]:

```
animation3 = display.create_animation(animation3, temp = True)
display.display_animation(animation3)
```

Out[24]: