Skip to content

๐Ÿซ— Lattice Boltzmann

JavaScriptThree.js

Source

๐Ÿง  Inspired by the famous Fluid Dynamics simulation by Daniel V. Schroeder (Weber State University)
๐Ÿ‘‰ Check out the accompanying Lattice-Boltzmann Fluid Dynamics PDF!

๐Ÿšจ This section is a reproduction of From Boltzmann Statistics to Fluid Dynamics

For simplicity, this simulation works in two dimensions, and discretizes space into a square grid or lattice. Each lattice site is big enough to hold a large number of gas molecules, which will be moving in various directions due to their thermal motion plus any large-scale fluid flow.

We approximate this rich complexity by allowing only nine different velocity vectors only, corresponding to nine elementary displacements during a unit of time: up, down, right, left, along any 45ยฐ diagonal,or zero (staying in place). The nine elementary displacements are illustrated and listed below, using a unit system in which the lattice spacing is one unit.

e0โ†’=0\overrightarrow{ e_0} = 0
e1โ†’=(1,0)\overrightarrow{ e_1} = (1,0)
e2โ†’=(0,1)\overrightarrow{ e_2} = (0,1)
e3โ†’=(โˆ’1,0)\overrightarrow{ e_3} = (-1,0)
e4โ†’=(0,โˆ’1)\overrightarrow{ e_4} = (0,-1)
e5โ†’=(1,1)\overrightarrow{ e_5} = (1,1)
e6โ†’=(โˆ’1,1)\overrightarrow{ e_6} = (-1,1)
e7โ†’=(โˆ’1,โˆ’1)\overrightarrow{ e_7} = (-1,-1)
e8โ†’=(1,โˆ’1)\overrightarrow{ e_8} = (1,-1)

To keep track of how many gas molecules at a site are moving in each of these nine directions, weโ€™ll need nine variables. Iโ€™ll call these variables nin_i, for i=0โ€ฆ8i=0\ldots8, and define them as the respective densities of molecules with the corresponding velocities. Then the total density ฯ\rho of all molecules at any given site is their sum:

ฯ=โˆ‘i=08ni.\rho = \sum_{i=0}^8 n_i.

We can also calculate the macroscopic fluid flow velocity, by taking a weighted average of the nine elementary velocities. Iโ€™ll call the flow velocity uโ†’\overrightarrow{ u}, and use the symbol cc for the natural unit of velocity, one grid site per unit time. Then the flow velocity at any given site is

uโ†’=โˆ‘i=08niฯeiโ†’c,\overrightarrow{ u} = \sum_{i=0}^8 \frac{n_i}{\rho} \overrightarrow{ e_i} c,

which we can write more explicitly as

ux=cฯ(n1+n5+n8โˆ’n3โˆ’n6โˆ’n7)uy=cฯ(n2+n5+n6โˆ’n4โˆ’n7โˆ’n8)\begin{array}{ll} u_x &=& \frac{c}{\rho}(n_1 + n_5 + n_8 - n_3 - n_6 - n_7) \\ u_y &=& \frac{c}{\rho}(n_2 + n_5 + n_6 - n_4 - n_7 - n_8) \end{array}

taking the xx and yy directions to point rightward and upward, respectively.

The thermal velocities of ideal gas molecules are described by the Boltzmann distribution, which in two dimensions is

D(vโ†’)=m2ฯ€kTeโˆ’mโˆฃvโ†’โˆฃ2/2kT.D(\overrightarrow{ v}) = \frac{m}{2\pi kT} e^{-m|\overrightarrow{ v}|^2/2kT}.

This is the function that, when integrated over any range of vxv_x and vyv_y values, gives the probability of a moleculeโ€™s velocity being in that range, where mm is the moleculeโ€™s mass, kk is Boltzmannโ€™s constant, and TT is the temperature. The exponent in the last equation is the moleculeโ€™s kinetic energy, and the prefactor m/2ฯ€kTm/2\pi kT ensures that the integral of D(vโ†’)D(\overrightarrow{ v}) over all velocity vectors equals 11 (which you can easily check).