This examples shows how to implement Lees Edwards boundary conditions folowing the pricniples 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
%% Cell type:code id: tags:
``` python
fromlbmpy.sessionimport*
...
...
@@ -40,13 +40,12 @@
%% Cell type:markdown id: tags:
## Data structures
We allocate a set of PDFs.
For later testing we need a force field. This will be allcated as well.
We allocate a set of PDFs `src` and `dst`, the density field `ρ` and the velocity field `u`.
For later testing, we also need a force field `F`. This will be allocated as well.
To run the simulation on GPU, change the `default_target` to gpu
%% Cell type:code id: tags:
...
...
@@ -67,60 +66,51 @@
%% Cell type:markdown id: tags:
## Kernels
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 piecwise function that fulfills this.
Hence, we construct a piecewise function that fulfils this.
After applying the regular 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 just 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.
with $u$ as the resulting velocity, $v$ as shear velocity, $h$ as the height, $\nu$ as kinematic viscosity and $t$ as time.
with $w$ as the resulting velocity, $v$ as shear velocity, $h$ as the height, $\nu$ as kinematic viscosity and $t$ as time.
%% Cell type:code id: tags:
``` python
defw(x,t,nu,v=1.0,h=1.0,k_max=10):
w=x/h-0.5
forkinnp.arange(1,k_max+1):
w+=1.0/(np.pi*k)* \
np.exp(-4*np.pi**2*nu*k**2/h**2*t)* \
np.sin(2*np.pi/h*k*x)
returnv*w
w=x/h-0.5
forkinnp.arange(1,k_max+1):
w+=1.0/(np.pi*k)* \
np.exp(-4*np.pi**2*nu*k**2/h**2*t)* \
np.sin(2*np.pi/h*k*x)
returnv*w
```
%% Cell type:code id: tags:
``` python
...
...
@@ -333,11 +318,11 @@
%% Cell type:markdown id: tags:
## Testing of the interpolation scheme
We redefine our init function here. In order to test the interpolation scheme we send an impuls across the boundary in the shear gradient direction. If interpolated correctly it should appear shifted to the right by the preselected offset. Therefor 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.