top of page

Simulating Fluid Flow Past a Cylinder with the Lattice Boltzmann Method

  • Writer: Chaitanya Singh
    Chaitanya Singh
  • Jul 22
  • 3 min read

In this demonstration, we use the Lattice Boltzmann Method (LBM) to model an incompressible, isothermal fluid streaming past a fixed cylinder obstacle. LBM works on a simple principle: instead of directly solving the Navier–Stokes equations, we track the evolution of particle distribution functions on a fixed grid. The result is an efficient, easy‑to‑implement approach that captures vortices, boundary layers, and flow separation.


1. The Physical Setup

  • We define a two‑dimensional rectangular domain of size 400 (horizontal) by 100 (vertical) grid cells.

  • Inside this channel, we place a circular cylinder whose center lies at one quarter of the channel length and midway up the height, with a radius equal to a quarter of the channel height.

  • The fluid has an average density of 100 units and streams from left to right with a small sinusoidal perturbation added at the inlet to trigger vortex shedding.

2. The Lattice Boltzmann Framework

  1. Discrete Velocities: We represent particle distributions on a nine‑velocity lattice (D2Q9). Each cell holds nine distribution values, corresponding to a rest state and the eight directions at 45‑degree increments.

  2. Macroscopic Quantities: At each cell we compute the fluid density ρ by summing all nine distributions. The horizontal and vertical velocities (uₓ, uᵧ) emerge by taking weighted sums of the same distributions multiplied by their respective direction components.

  3. Collision Step: We relax the distributions toward a local equilibrium defined by the current density and velocity. The equilibrium for distribution direction i is    ρ · wᵢ · [1 + 3 (cᵢ·u) + 4.5 (cᵢ·u)² – 1.5 ‖u‖²],where wᵢ is the lattice weight and cᵢ·u is the dot product of the discrete velocity vector with the local velocity. A single relaxation time τ controls fluid viscosity.

  4. Streaming (Drift) Step: After collision, each distribution “drifts” to its neighbor cell in the direction of its discrete velocity. This propagates information across the grid and enforces conservation of mass and momentum.

  5. Boundary Handling

    • Solid Cylinder: We apply a bounce‑back condition on the cylinder surface. Any distribution that streams into a solid node is reflected back along the incoming direction, ensuring zero velocity at the wall.

    • Periodic or Open Ends: The top and bottom walls are treated as simple no‑slip boundaries or can be left periodic. The left inlet maintains a prescribed density and velocity perturbation; the right outlet simply lets fluid exit.


3. Visualizing Vorticity


Rather than plotting raw velocities, we compute the vorticity magnitude at each cell as the difference between spatial derivatives of uᵧ and uₓ. High vorticity highlights swirling regions vortex streets shed behind the cylinder become immediately visible. We render vorticity in grayscale on a black background, with bright regions indicating strong rotational motion and dark regions indicating quiescent fluid or solid boundaries.


4. Putting It All Together

  • Initialization: All distributions start at the average density and zero velocity, with a tiny random noise to break symmetry.

  • Main Loop: For each time step up to 4,000 iterations:

    1. Stream distributions to neighbors.

    2. Apply bounce‑back on the cylinder.

    3. Recompute density and velocity.

    4. Relax toward equilibrium.

    5. Periodically compute vorticity and update the real‑time plot.

  • Output: After the final iteration, we save a high‑resolution vorticity snapshot that reveals the characteristic alternating vortex pattern behind the cylinder.

5. Why This Matters

  • Simplicity: LBM’s two‑step collision‑and‑streaming algorithm is conceptually straightforward and maps naturally onto parallel computing hardware.

  • Resolution of Complex Flows: Even with a coarse grid, LBM captures key features such as boundary layers, flow separation, and laminar vortex streets.

  • Extensibility: You can extend this approach to three dimensions, thermal flows, multiphase fluids, or even porous media with only modest code additions.

6. Next Steps

  • Vary the Reynolds Number: Change the relaxation time to explore laminar, transitional, and turbulent regimes.

  • Different Obstacles: Swap in an airfoil shape, a square cylinder, or an array of posts to study wake interactions.

  • Parallel Acceleration: Implement the streaming and collision steps on the GPU for large‑scale, high‑resolution simulations.


This Lattice Boltzmann demonstration offers a clear window into fluid dynamics around obstacles. Tweak parameters, watch vortices dance, and gain intuition for how real‑world flows behave!

Comentários


LinkedIn

  • LinkedIn

© 2025 by Chaitanya Singh

bottom of page