The present matlab code derives from the basic Lattice Boltzmann code named LB BGK D2Q9 and submitted on 2005-02-10 (see Matlab Central). This version is particularly tailored to porous systems. Indeed, rather than keeping in memory values of density calculated in both wet and dry locations (i.e. area interested by the fluid flow and area occupied by solid obstacles), it keeps track of wet locations only (i.e. the pore space only). Thus it allows important saving in variable storage in cases of low porosity. This memory saving is achieved at the expenses of minor extra computations of wet location indices. A look-up table of absolute locations is used. A recent version of Image Processing Toolbox is needed because IPT functions are used to identify the boundaries of the obstacles (i.e. the so called bounce-back pixels).
The new code that uses a look-up table instead of a straightforward indexing is less readable than the original basic LB code.
I recommend to use the basic LB BGK D2Q9 code to understand the rational of LB before getting involved with the present implementation. Hope the code will be of some help to students.
A test to simulate flux without obstacles is included.
With minor changes one can describe any porous geometry in 2D.
Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.