problem with Rayleigh-Bénard convection code

Dear All,

I’ve tired this code for:

Ra=10^5, Pr=0.7.

lx=118,ly=118 (square enclosure),gr=0.00001.

I run this code with the information above. The temperature and velocity profile obtained through this investigation corroborate the results obtained from classic CFD with some errors; however, the condition for stability does not satissfied with this collection:

?t???x?^2(not satisfied) because ?t=0.0086,?x=2.936101097573517e-04.

but I’ve run this this information:

lx=118,ly=118 (square enclosure),gr=0.000001.

with this selection, the condition for stability is satissfied :


however, the results are really bad.

I’d really appreciate that if you can tell me which gr is good for this problem.

Thank you

sorry in my post
in the line 8:
deltat=deltax^2(not satisfied) because deltat=0.0086,deltax=2.936101097573517e-04.
in the line 12:


actually I think that there is some confusion here. The condition delta t ~ delta x^2 is not a stability condition for the LBM (maybe for your alternative CFD solver…). For the LBM it is a condition to suppress the compressibility error terms.

Furthermore I am not sure to understand exactly your problem. In what sense are your results really bad?

What are you comparing?

Dear Malaspin,
thank you for your reply.

I compare the results with some publications pertaining to the thermal study in the enclosure using classical CFD.

I was wrong to say a stability condition instead of a condition to suppress the compressibility error terms. Thank you for correcting me.

the inputs of my code are:

Run #1
Ra=10^5, Pr=0.7.

lx=118,ly=118 (square enclosure),gr=0.00001.

deltat=deltax^2(not satisfied) because deltax=0.0086,deltat=2.936101097573517e-04.

the results are fairly good in comparison to literature.

Ra=10^5, Pr=0.7.
lx=118,ly=118 (square enclosure),gr=0.000001.
deltat=deltax^2(satisfied) because deltat=0.0086,deltax=9.284766908852593e-05.

The streamlines are deviated from the true results as well as velocity profiles. !!!

my cardinal question is how to choose gr??

is the condition deltat=deltax^2 our first priority. if so, why I cannot get the best set of results by considering this condition…

Many thanks in advance…


The “rule” dx^2~dt is usefull only when you try to increase the lattice resolution. It only tells you that when you refine by a factor two dx you should refine by a factor four the time, in order to get rid of the compressibility errors.

Otherwise This rule has no real meaning. The two important conditions that must be satisfied are that the Mach number must be of the order 0.1 or smaller, and that the Knudsen number must also be small.

you can read this ( unit how to )

unit how to


u=sqrt( gr * beta * deltaTemperature * length) = ( visc/ length ) * sqrt (Ra / Pr )


u<=0.1 to reduce compressibility errors as malaspin said

Dear malaspin and SaS

Many thanks for your help.