Overview
I came across Lattice Boltzmann methods while auditing the Coursera course Simulation and Modeling of Natural Processes from the University of Geneva, which I ended up completing fully. Until then I had only done CFD with finite volume and finite element methods, which are expensive to compute. LBM was completely new to me, so I was curious to try it.
The code is based on the course material by Jonas Latt (Week 5: Lattice Boltzmann modeling of fluid flow). I restructured it a bit, added comments, added video export, and changed the obstacles to try out different shapes and arrangements.
Lattice Boltzmann Method
Instead of solving the Navier-Stokes equations directly, LBM simulates fluid particles on a grid. In this 2D version (called D2Q9), each grid point has nine particle populations, one resting and eight moving to the neighbouring points. Every time step has two parts:
- Streaming: each population moves to its neighbouring grid point.
- Collision: at each point, the populations relax towards a local equilibrium. How fast they relax sets the viscosity of the fluid.
Density and velocity at each point are just sums over the nine populations. The obstacle is handled with a bounce-back condition, where particles hitting it are sent straight back. This acts as a no-slip wall. The inlet on the left has a fixed velocity and the outlet on the right lets the flow leave.
The nice thing about it is that each step only needs the neighbouring points, so it is simple to write and easy to parallelize.
Flow Around Obstacles
I studied vortex shedding (von Kármán vortex street) behind cylinders during my masters, so that was the first thing I wanted to see. Behind a single obstacle, the flow separates and vortices shed alternately from the top and bottom.
Then I tried different shapes and arrangements, mostly out of curiosity: an ellipse, an obstacle close to the wall, two cylinders touching, and two cylinders one behind the other. With two cylinders close together, the second one sits in the wake of the first and most of the shedding happens behind the second one.
The four cylinder setup was intentional. In another assignment during my masters, we did a modal analysis of a radio tower under wind loads. The tower had four legs, so a 2D slice through it at one height is four cylinders in a square. I did not analyze the loads or vibrations here, I just wanted to see what the flow field around the legs looks like.
Limitations
This is a 2D simulation. The Reynolds number in the code is 220, but it is defined using the cylinder radius, so it is about 440 based on the diameter, which is how it is usually defined. Real flow behind a cylinder becomes 3D at around Re 190, so at this Reynolds number the clean 2D vortex street is more of a model than what you would see in a wind tunnel. It is still a good way to see how the flow behaves.
