# NBC - How to from lbmethod.org

Hi All, I am working on flow over a cylinder. When I use the NBC mentioned in the document “How to impose a Neumann boundary condition with the lattice Boltzmann method” by Orestis I get a strong reflection from the outlet and my result blows up. The code is as follows. Please let me know what mistake I am doing.

``````
!Outflow condition
!Macroscopic NBC
u(x,y,0) = (4.0*u(x-2,y,0) - u(x-1,y,0))/3.0; ! x velocity extrapolation
u(x,y,1) = (4.0*u(x-2,y,1) - u(x-1,y,1))/3.0; ! y velocity extrapolation
! Microscopic Zou-He
rho(x,y) = -rho0*u(x,y,0) + (f(x,y,0) + f(x,y,2) + f(x,y,4)) + 2.0*(f(x,y,5)+f(x,y,1)+f(x,y,8));
f(x,y,3) = f(x,y,1) - (2.0/3.0)*rho0*u(x,y,0);
f(x,y,7) = f(x,y,5)-(1.0/6.0)*rho0*u(x,y,0)-(1.0/2.0)*rho0*u(x,y,1)+(1.0/2.0)*(f(x,y,2)-f(x,y,4));
f(x,y,6) = f(x,y,8)-(1.0/6.0)*rho0*u(x,y,0)+(1.0/2.0)*rho0*u(x,y,1)+(1.0/2.0)*(f(x,y,4)-f(x,y,2));

``````

My flow parameters are as follows

``````
xDim = 1200
yDim = 165
obstX = 81  ! grid points
obstY = 81  ! grid points
obstR = 20  ! lattice units
Re = 100
u_in = 0.066666  ! average inlet velocity
nu = 2.0*obstR*u_in/Re = 0.026666664
tau = (6.0*nu+1.0)/2.0 = 0.58

``````

Hi,

I’ve not read the article you mention but I don’t quite understand your notes - in particular, I’m confused with what rho and rho0 are. I can’t see where your definition of rho fits into your boundary condition because you only seem to use rho0. I’m not a huge fan of Zou and He boundaries but I imagine you either want to specify a pressure at the outlet (so rho here will probably be different to that at the inlet), or you find the density (pressure) at the outlet from the know distribution functions. In this case, what you’ve called rho0 in your formulas for f3 etc should be rho, and your definition of rho should include rhou rather than rho0u.

More generally, because you can split the momentum moment into the density+ known distribution functions (eg, at the bottom wall rhou_x=rho-[f0+f2+f4-2(f3+f6+f70]) you can set either rho or rho*u_x at a boundary, but not both.

Good luck!

ps
I still think you should be fairly accurate results for this flow with fewer grid points.

Hi Pleb01,

I have used the incompressible LBM model. Hence I am using the rho0. I am extrapolating the velocities and implementing them using the zou-he boundary conditions. These boundary conditions are a little different from the original zou-he boundary conditions (which I have implemented above)

``````
rho(x,y) = -rho0*u(x,y,0) + (f(x,y,0) + f(x,y,2) + f(x,y,4)) + 2.0*(f(x,y,5)+f(x,y,1)+f(x,y,8));

``````

the above line is actually not needed in the code as the implementation of

``````
f(x,y,3) = f(x,y,1) - (2.0/3.0)*rho0*u(x,y,0);
f(x,y,7) = f(x,y,5)-(1.0/6.0)*rho0*u(x,y,0)-(1.0/2.0)*rho0*u(x,y,1)+(1.0/2.0)*(f(x,y,2)-f(x,y,4));
f(x,y,6) = f(x,y,8)-(1.0/6.0)*rho0*u(x,y,0)+(1.0/2.0)*rho0*u(x,y,1)+(1.0/2.0)*(f(x,y,4)-f(x,y,2));

``````

will automatically (add the above three equations) set

``````
rho(x,y)

``````

Thanks,
Narender

Can’t you just extrapolate the f’s at the outlet? This method has certainly been used may times with a lot less grid points(see Yu et al, for example) so if you’re code blows up you know you have a bug! You also need to be careful with corners with the Zou and He method.