# Newbie: Pressure boundary conditions in OpenLB

Hi:
Just getting into OpenLB and had some questions regarding pressure boundary conditions in OpenLB. I have a geometry (similar to the cylinder2d example, but in 3D) where I have a velocity boundary at the inlet and a pressure boundary at the outlet.

My question is if I specify a density at the outlet, it should be < 1 (assuming a density of 1 at the inlet) right?. What should be the components of the velocity at the pressure boundary I need to specify? Should I set the tangential velocities =0 (as in Zou and He)? and typically how low can one specify the outlet density without running into problems with mass conservation?

regards
P.

Hi and welcome,

• On a pressure boundary, you can only specify the density and nothing else. If you also specify the velocity components, OpenLB simply disregards this information. Internally, OpenLB automatically sets the tangential velocity component to zero, as in Zou/He.

• On the outlet, you can chose a density value smaller than 1, or you can chose a density equal to 1. It doesn’t matter: the density isn’t specified on the inlet anyway (it has a velocity condition). After a long enough time, the flow will adjust automatically and yield a density value at the inlet which is superior to the outlet.

• In a channel, mass is typically not conserved, especially when you impose a velocity condition both at the inlet and outlet (I am not sure what happens in case of a pressure outlet: you should simply try). This is however not a defect of the boundary condition, but rather a corollary of the fact that the density rho decreases along the channel. To put it short, if uIn=uOut and rhoIn>rhoOut, then rhoInuIn > rhoOutuOut, and you can’t avoid mass increase (see the following thread on the LB Forum for more details). You can either accept this (it’s life) or replace BGKDynamics in your code by ConstRhoBGKDynamics, which artificially removes mass from the simulation after each time step.

Good luck,
Jonas

Hi:
Thanks for the help Jonas. It makes sense now. One more point, I noticed when outputting the pressure from the cylinder2D code, that the program outputs negative pressure at some points of the lattice – is this physical? Also, I presume that if one has more than one cylinder, it would be better to count only surface nodes as bounceback, the interior of the cylinder should be instantiated with nodynamics.

thanks, P.

The density is never negative in lattice Boltzmann. However, think of the pressure in the incompressible Navier-Stokes equations: the only pressure term in these equations is grad§. Consider that grad§=grad(p+p0) for any constant p0. Thus, you may add an arbitrary constant to the pressure and still get the same solution for the velocity field. If I remember right, the computePressure method of DataAnalysis automatically subtracts a constant to emphasize the pressure interpretation of the density: it yields c_s^2(rho-1). Note that this is an arbitrary choice, which is mostly convenient for post-processing: depending on the axes on which you plot the result, you get better visibility if a curve is close to the origin instead of 1/3.

Yes, you may get a (marginal) gain of efficiency by attributing NoDynamics instead of BounceBack to interior solid nodes. The result is the same, though.

Hello Jonas,

I have a question regarding the function ConstRhoBGKDynamics.
You say that it artificially removes mass at each timestep. How does it happen? Do you divide all populations by a constant factor re-normalizing the density? Does this approach have any drawbacks? Does it influence the dynamics or the accuracy of the LBM?

Thanks,
Timm

No, the density is only modified in the equilibrium. Thus, to switch density from rho1 to rho2, the following replacement is done:

``````
f <-- f - f^eq(rho1,u) + f^eq(rho2,u)

``````

Conceptually speaking, at least. Computationally, things are of course done more efficiently. You can find more details in OpenLB Technical Report 3.

The underlying assumption here is that the fluid is close to the limit of incompressibility, and that the pressure may be changed by an arbitrary offset. As you say, another option would be to multiply all the f by the same prefactor, which should have the same effect at small Mach number. For compressible fluids, the two approaches have obviously a different effect, but then again, I don’t think it is right to fool around with the density in a compressible fluid anyway.

Hello,

I have modified my code in such a way that at every time step the mean density is set to its initial value (by multiplying the populations by \mean_rho(0) / \mean_rho(t)). This way the mass is conserved - even for velocity inlet and outlet BC - and I have found that the macroscopic observables are the same (at least for a system in steady state).
No I wonder if there has been a Chapman Enskog expansion of the artificial mass reduction schemes. Does anybody know some references?

Thanks,
Timm