initial density


It is about the Multicomponent2D case. I found that if I modify the almoseNoFluid=10e-4 to almoseNoFluid=0., the simulation result is NAN. I just want to inquire whether i can not set zero density in the code? Or if I sent zero density, I should do something to avoid the NAN result? Thank you.


As a matter of convention, most functions in Palabos are defined with respect to the momentum (“velocity*density”) rather than the velocity. Also, the data processor which computes the Shan/Chen coupling (ShanChenMultiComponentProcessor3D) multiplies the common flow velocity, which is averaged over all fluid components, by the density of a given component. The component in question then translates back from momentum to velocity when it executes the collision step. This means dividing by the density, and thus, dividing by zero.

You can circumvent this by skipping the line

momentum[iD] *= *cell.getExternal(densityOffset);

in ShanChenMultiComponentProcessor3D, and implement the BGK collision manually in ExternalMomentBGKdynamics, in such a way that it works with a velocity instead of a momentum.


Thank you for your reply. Could you please give me more details about how to implement the BGK collision manually in ExternalMomentBGKdynamics? add a template or some sentence? I am really sorry about this, becase I am not quite familiar with the palabos code. thanks,

Furthermore question, also the same case.

I tried to output the density in the beginning (t=0), it is quite strange that density is NAN in the positions where I initialize the density is zero. I am confused about this. Because when t=0, the code has not computed the velocity (Shan/Chen coupling (ShanChenMultiComponentProcessor2D) multiplies the common flow velocity), the density should be zero in the beginning.

Why the output is NAN in the beginning? I really appreciate your help. Thank you.

Need help!

Try not using zero density, but stick with a very low one (I tried 0, too, and reverted that later on). The difference between that and 0 is often negligible.