"/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/matplotlib/quiver.py:686: RuntimeWarning: divide by zero encountered in double_scalars\n",
" length = a * (widthu_per_lenu / (self.scale * self.width))\n",
"/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/matplotlib/quiver.py:686: RuntimeWarning: invalid value encountered in multiply\n",
" length = a * (widthu_per_lenu / (self.scale * self.width))\n",
"/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/matplotlib/quiver.py:738: RuntimeWarning: invalid value encountered in less\n",
" short = np.repeat(length < minsh, 8, axis=1)\n",
"/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/matplotlib/quiver.py:751: RuntimeWarning: invalid value encountered in less\n",
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
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 piec wise function that fulfills this.
importing sympy.logic.boolalg with 'from sympy import *' has been
deprecated since SymPy 1.6. Use import sympy.logic.boolalg instead.
See https://github.com/sympy/sympy/issues/18245 for more info.
deprecated_since_version="1.6").warn()
%% Cell type:code id: tags:
``` python
definit():
dh.fill(ρ.name,1.)
dh.run_kernel(init_kernel)
dh.fill(u.name,0.0)
dh.fill(F.name,0.0)
```
%% Cell type:markdown id: tags:
## Interpolation
%% Cell type:markdown id: tags:
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.
/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/matplotlib/quiver.py:686: RuntimeWarning: divide by zero encountered in double_scalars
length = a * (widthu_per_lenu / (self.scale * self.width))
/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/matplotlib/quiver.py:686: RuntimeWarning: invalid value encountered in multiply
length = a * (widthu_per_lenu / (self.scale * self.width))
/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/matplotlib/quiver.py:738: RuntimeWarning: invalid value encountered in less
short = np.repeat(length < minsh, 8, axis=1)
/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/matplotlib/quiver.py:751: RuntimeWarning: invalid value encountered in less
tooshort = length < self.minlength
%% Cell type:markdown id: tags:
### Run the simulation until converged
### Run the simulation to show the flow profile
%% Cell type:code id: tags:
``` python
time=500
time_loop(time)
plot_v()
```
%% Output
%% Cell type:markdown id: tags:
## Checking the results
This transient shear flow (planar Couette flow) can be modeled with the Navier Stokes equation. We use this as a testcase here.
The solution of the Navier Stokes equation in this particular case yields:
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.
%% Cell type:code id: tags:
``` python
deftime_loop_2(steps):
dh.all_to_gpu()
foriinrange(steps):
dh.run_kernel(collision_kernel)
sync_pdfs()
dh.run_kernel(stream_kernel)
dh.swap(src.name,dst.name)
dh.all_to_cpu()
definit_2():
dh.fill(ρ.name,1.)
dh.run_kernel(init_kernel)
dh.fill(u.name,0.0)
dh.fill(F.name,0.0)
dh.cpu_arrays[F.name][N//3,1,:]=[1e-2,-1e-1]
```
%% Cell type:markdown id: tags:
## Run the simulation without any offset and a constant offset