#!/usr/bin/env python # coding: utf-8 # ## Fluid Dynamics Simulation using a Lattice Boltzmann Method # # 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](https://en.wikipedia.org/wiki/Lattice_Boltzmann_methods#Derivation_of_Navier.E2.80.93Stokes_equation_from_discrete_LBE)). # # 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: # # 1. From the microscopic properties of the particles at a lattice point, find the macroscopic density and velocities # 2. Use these values to calculate the equilibrium values and update the microscopic values # 3. Stream the particles onto adjacent grid points based on their velocities # # For the theory of the method look [here](http://physics.weber.edu/schroeder/javacourse/LatticeBoltzmann.pdf), 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)* # # ### Low viscosity on bow shaped barrier # # 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) # ### High viscosity on bow shaped barrier # 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) # ### Low viscosity flow over an airfoil # 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) # In[ ]: