Density loss using MRT?

Hi All!

First of all thank you for this great open source project and these forums.

I tried to use the multi-relaxation time model in conjunction with the example code for the 2D lid driven cavity and discovered a
slow decrease of rho with time. Is this a known “feature” or am I doing something wrong?

I manipulated the code in the following way:

-substitution of D2Q9Descriptor with MRTD2Q9Descriptor in the whole file

  • replacing the following:

ConstRhoBGKdynamics<T, DESCRIPTOR> bulkDynamics (


MRTdynamics<T, DESCRIPTOR> bulkDynamics (

The file can be downloaded here:
Just put it in the example directory of cavity2D_olb and compile and execute it.

Kind regards,



Global conservation of mass is not guaranteed in the example of a cavity flow. That’s due to the treatment of the corner nodes, in which the velocity profile is discontinuous. I don’t know of an elegant way of getting around this problem and would actually be happy if somebody had a suggestion.

Using ConstRhoBGKdynamics is a possible workaround. At every time step, a constant density offset is added to all lattice sites in such a way as to keep the average value of rho constant. The physical assumption which is made here is that you can split rho into a slowly oscillating density component and a rapidly oscillating pressure component. If you accept the point of view that the gain resp. loss of mass through non-mass-conserving corner nodes acts on the density component of rho, and given that we are simulating an incompressible fluid, adding such an offset is a valid thing to do.

You will experience global density variations for any dynamics other than ConstRhoBGKdynamics, including MRTdynamics and BGKdynamics. I guess we should add ConstRhoMRTdynamics to the OpenLB library. In the meantime, you may want to do this by hand by invoking a command such as


after each iteration step. That’s less efficient that a native implementation, but it has the same effect.

In fact one way of dealing with this kind of disconituities is to put a polynomial profile on the moving wall (a very fast decrease at the corners and constant velocities on the rest). I don’t know if it will cure the mass loss, but it’s the way it is done for the “calssical” methods.

Thanks for the quick reply. A few questions to the ConstRhoBGK approach:

  1. How is the constant density offset determined
  2. Is this density offset divided by the number of (bulk?) lattice sites in the domain and than added to every (bulk?) lattice site in that domain?
  3. Where can I find more information on this approach?

Thanks a lot for you help,



I added a technical report to the OpenLB web site, which explains the ConstRhoBGK model:

This should answer your question.

Thanks a lot Jonas!