Hello all,

I am writing my first programme of lattice boltzmann for the poiseuille flow for 2D rectangular channel. Flow is driven by a force in the X direction with periodic boundary condition (in the X direction). Boune back boundary condition is used at y=0,L. I have posted below essential part of the code.

c_x[] :array of velocity component in x direction

c_y[] :array of velocity component in y direction

f : population at time t

f_temp : population at time t+1

[code=“cpp”]

for(int index=0;index<10;index++)

{

//for the lattice points in the bulk

for(int i=0;i<n_x;i++)

{

for(int j=1; j<n_y-1;j++)

{

for (int k=0; k<beta ; k++)

{

double t ;

//collision step

```
t = f[i+n_x*j+n_x*n_y*k] - (delta_t*1.0/tau)*(f[i+n_x*j+n_x*n_y*k] - f_eq[i+n_x*j+n_x*n_y*k]) + getNeighbour(k,1)*drivingForce/10 ;
//streaming step
int x1 = mod(i+getNeighbour(k,1),n_x);
int y1 = mod(j+getNeighbour(k,0),n_y);
f_temp[x1+n_x*y1+n_x*n_y*k] = t;
}
}
}
```

//for the lattice points at the boundary

int x1;

if(index!=0)

for(int i=0;i<n_x;i++)

{

for(int j=0; j<n_y;j++)

{

if(j==1)

{

x1 = mod(i-1,n_x);

f[i+n_x*j+n_x*n_y*5] = f_temp[x1+n_x*(j-1)+n_x*n_y*7] ;

x1 = mod(i,n_x);

f[i+n_x*j+n_x*n_y*2] = f_temp[x1+n_x*(j-1)+n_x*n_y*4] ;

x1 = mod(i+1,n_x);

f[i+n_x*j+n_x*n_y*6] = f_temp[x1+n_x*(j-1)+n_x*n_y*8] ;

}

if(j==n_y-2)

{

x1 = mod(i-1,n_x);

f[i+n_x*j+n_x*n_y*8] = f_temp[x1+n_x*(j+1)+n_x*n_y*6] ;

x1 = mod(i,n_x);

f[i+n_x*j+n_x*n_y*4] = f_temp[x1+n_x*(j+1)+n_x*n_y*2] ;

x1 = mod(i+1,n_x);

f[i+n_x*j+n_x*n_y*7] = f_temp[x1+n_x*(j+1)+n_x*n_y*5] ;

}

}

}

//set f_temp to f

for(int i=0;i<n_x;i++)

for(int j=0; j<n_y;j++)

for (int k=0; k<beta ; k++)

f[i+n_x*j+n_x*n_y*k] = f_temp[i+n_x*j+n_x*n_y*k];

}

```
I am not able to see where I am making a mistake. Any suggestion or clarification will be greatly appreciated.
```