# Zou-He Boundary condition D3Q19

Hello,

I am trying to compute the 3D lid-driven cavity test (code C++). I have used Bounce back boundary conditions for the wall. For the lid, I want to use the Zou-He boundary condition. I follow this paper ’ Implementation of on-site velocity boundary condition for D3Q19 lattice Boltzmann’ Hecht, 2012.
My D3Q19 Model :

[code=“cpp”]
(14) 18(5)15 (11)
\ | /
\ /
\ | /
8(2)10________________4(0)3_________________9(1)7
/ |
/ |
/ | \ z
(12) 16(6)17 (13) |_ x

``````         (18)                 11(5)14                 (15)
\                   |                     /
\                             /
\           |         /
9(4)8________________1(0)2_________________7(3)10
/       |          \
/             |              \
/                  |                    \          z
(16)                 13(6)12                  (17)      |_ y
``````
``````

My function for Zou He boundary condition is :
[code="cpp"]
void Zou_He (DistFunctArray& df, DistFunctArray& df_tmp)

{
int NZ = df.sizeZ()-1;
for(int x=1; x<df.sizeX()-1; x++)
for(int y=1; y<df.sizeY()-1; y++)
{

const real Vx = 1e-3;

const real rho = df(0,x,y,NZ) + df(1,x,y,NZ) + df(2,x,y,NZ) + df(3,x,y,NZ)
+ df(4,x,y,NZ) + df(7,x,y,NZ) + df(8,x,y,NZ) + df(9,x,y,NZ) + df(10,x,y,NZ)
+ 2*(df(5,x,y,NZ) + df(11,x,y,NZ) + df(14,x,y,NZ) + df(15,x,y,NZ) + df(18,x,y,NZ));

const real Nxz = 0.5 * (df(1,x,y,NZ) + df(9,x,y,NZ) + df(7,x,y,NZ) - (df(8,x,y,NZ)
+ df(2,x,y,NZ) + df(10,x,y,NZ))) - (rho * Vx )/3;
const real Nyz = 0.5 * (df(3,x,y,NZ) + df(7,x,y,NZ) + df(10,x,y,NZ) - (df(9,x,y,NZ)+ df(4,x,y,NZ) + df(8,x,y,NZ)));

df_tmp(6,x,y,NZ) = df(5,x,y,NZ);
df_tmp(13,x,y,NZ) = df(14,x,y,NZ) +  (rho * Vx )/6 ; //- Nxz;
df_tmp(12,x,y,NZ) = df(11,x,y,NZ) - (rho * Vx )/6 ;// + Nxz;
df_tmp(16,x,y,NZ) = df(15,x,y,NZ) ;//+ Nyz;
df_tmp(17,x,y,NZ) = df(18,x,y,NZ) ;//- Nyz;

}
}

``````

If I do not use Nxz and Nyz it gives me results. But this is not the real Zou-He boundary condition, right? It is more a bounce back with a velocity.

I don’t understand where i am wrong about the Zou-He boundary condition. When I ran with Nxz and Nyz i obtained Nan for df_tmp.