This example shows how to implement Lees Edwards boundary conditions following the principles discussed in Wagner, A.J., Pagonabarraga, I. Lees–Edwards Boundary Conditions for Lattice Boltzmann. Journal of Statistical Physics 107, 521–537 (2002). https://doi.org/10.1023/A:1014595628808
This example shows how to implement Lees Edwards boundary conditions following the principles discussed in Wagner, A.J., Pagonabarraga, I. Lees–Edwards Boundary Conditions for Lattice Boltzmann. Journal of Statistical Physics 107, 521–537 (2002). https://doi.org/10.1023/A:1014595628808
Following Wagner et al., we need to find all the populations that will cross the boundary in the direction normal to the shearing direction and alter their equilibrium distribution.
Following Wagner et al., we need to find all the populations that will cross the boundary in the direction normal to the shearing direction and alter their equilibrium distribution.
Hence, we construct a piecewise function that fulfils this.
Hence, we construct a piecewise function that fulfils this.
After applying the normal periodic boundary conditions, we interpolate back in the original cells by using a linear interpolation scheme. In this step, the corners are not special anymore so that we can use the entire upper and lower slab.
After applying the normal periodic boundary conditions, we interpolate back in the original cells by using a linear interpolation scheme. In this step, the corners are not special anymore so that we can use the entire upper and lower slab.
We redefine our init function here. In order to test the interpolation scheme, we send an impulse across the boundary in the shear gradient direction. If interpolated correctly, it should appear shifted to the right by the preselected offset. Therefore we also need to fix the offset and redefine the time loop.
We redefine our init function here. In order to test the interpolation scheme, we send an impulse across the boundary in the shear gradient direction. If interpolated correctly, it should appear shifted to the right by the preselected offset. Therefore we also need to fix the offset and redefine the time loop.
%% Cell type:code id: tags:
%% Cell type:code id: tags:
``` python
``` python
deftime_loop_2(steps):
deftime_loop_2(steps):
dh.all_to_gpu()
dh.all_to_gpu()
foriinrange(steps):
foriinrange(steps):
dh.run_kernel(collision_kernel)
dh.run_kernel(collision_kernel)
sync_pdfs()
sync_pdfs()
dh.run_kernel(stream_kernel)
dh.run_kernel(stream_kernel)
dh.swap(src.name,dst.name)
dh.swap(src.name,dst.name)
dh.all_to_cpu()
dh.all_to_cpu()
definit_2():
definit_2():
dh.fill(ρ.name,1.)
dh.fill(ρ.name,1.)
dh.run_kernel(init_kernel)
dh.run_kernel(init_kernel)
dh.fill(u.name,0.0)
dh.fill(u.name,0.0)
dh.fill(F.name,0.0)
dh.fill(F.name,0.0)
dh.cpu_arrays[F.name][N//3,1,:]=[1e-2,-1e-1]
dh.cpu_arrays[F.name][N//3,1,:]=[1e-2,-1e-1]
```
```
%% Cell type:markdown id: tags:
%% Cell type:markdown id: tags:
## Run the simulation without any offset and a constant offset
## Run the simulation without any offset and a constant offset