LBM Examples

Cavitation simulation

This example deals with a multiphase simulation of an LBM fluid under a cavitation condition. There are no boundary conditions imposed. In Mechsys LBM when no boundary conditions are imposed, then periodic boundary conditions are applied by default Therefore there is no Setup function or UserData structure as in the previous example.
int main(int argc, char **argv) try
{
size_t Nproc = 1;
if (argc==2) Nproc=atoi(argv);
size_t nx = 100;
size_t ny = 100;
size_t nz = 100;
double nu = 1.0/6.0;
double dx = 1.0;
double dt = 1.0;
double Tf = 10000.0;
LBM::Domain Dom(D3Q15, nu, iVec3_t(nx,ny,nz), dx, dt);
Dom.Lat.G      = -200.0;

for (size_t i=0; i<nx; ++i)
for (size_t j=0; j<ny; ++j)
for (size_t k=0; k<nz; ++k)
{

double rho0 = (200.0 +(1.0*rand())/RAND_MAX)*dx*dx;
Dom.Lat.GetCell(iVec3_t(i,j,k))->Initialize (rho0, OrthoSys::O);
}

// Solve
Dom.Solve(Tf,50.0,NULL,NULL,"bubble",true,Nproc);
}
MECHSYS_CATCH

As can be seeing the example is considerably shorter and simpler than the previous one. One key difference is that it is in 3D and the LBM scheme chosen is D3Q15. Another key difference is the values assigned to the parameter Dom.Lat.G of -200. This parameter comes from the way LBM models multiphase fluids. The implementation follows the description of the LBM text book Lattice Boltzmann Modeling An Introduction for Geoscientists Engineers.

To obtain a cavitation, the fluid density has do be distributed randomly across the domain. In this case a random density between 200 and 201 is distributed in each cell:

for (size_t i=0; i<nx; ++i)
for (size_t j=0; j<ny; ++j)
for (size_t k=0; k<nz; ++k)
{

double rho0 = (200.0 +(1.0*rand())/RAND_MAX)*dx*dx;
Dom.Lat.GetCell(iVec3_t(i,j,k))->Initialize (rho0, OrthoSys::O);
}

Simulation result

The cavitation phenomenon will happen because the density has neither the gas or liquid phase equilibrium value. The fluid then naturally will produce a free surface separating both phases. To visualize the surface, an isovolume filter should be imposed over the density field in the VisIt software. The result should resemble this video.