# Week 4: More Pretty Pictures

April 1, 2023

Hey everyone, welcome to week 4! This week was mainly working on my simulation and looking at more pretty pictures.

~~~

Bounce-back method for simulating walls: The simpler way

Last week, I worked on the bounce-back method for simulating the presence of top and bottom walls. It worked out pretty well! For a little refresher, here is a picture showing the vorticity of the fluid (basically how “spinny” the fluid is). The pink is spin counterclockwise and the green is spin clockwise, white no spin.

At first, I was a bit confused as to why my simulation output image was not symmetric. But after a discussion with my mentor, we realized that I had overlooked a parameter at the beginning, where I added a bit of randomization to my initial particle distributions… Surely with randomization, my results would be a bit random! I remembered why I added that bit of randomization to the initial conditions: to simulate the not so perfect nature of fluids that naturally occur.

And with that question answered, I moved on to bigger and better things. Jk just more coding. I read up on the extrapolation scheme, an “upgraded” version of the bounce-back method, just to see if it would make much of a difference.

~~~

Extrapolation scheme: The harder (better?) way

Essentially, the main idea of the extrapolation scheme was to create a line of “ghost nodes” in the wall. The subscript f describes a fluid node, b a boundary node, and w a ghost node inside the wall. h is the lattice length, q ∈ (0, 1] is adjustable ratio, and nˆ is the unit vector from wall towards the fluid.

We decompose the distribution function into an equilibrium and non-equilibrium part.

When calculating feq for the lattice nodes the walls, instead of using the equation described in the previous blog post, we approximate feq with the equation

where ρ ̄w ≊ ρ(xf) approximates ρw and uw is an approximation of the wall velocity to be chosen, depending on q. In my program, q = 0.5, and the extrapolation scheme was used at the top and bottom wall boundaries. Following finding feq, the algorithm carries on with calculating the post-collision distribution.

Understanding this method theoretically was pretty easy, as it just seemed like a slightly different equation, but coding it proved more difficult. I encountered too many bugs on the way, but randomly editing the slightest bit would fix things. Eventually, I got it to produce images!

I looked at simulation results for 4 different Reynolds numbers which shows the evolution from laminar to turbulent flow. From top to bottom they are Re 60, 120, 180, 290. You can see the tail start to wiggle a bit at somewhere between Re 120 and 180, and at Re 290, you can see a vortex street. The pictures look more symmetric than those produced by the simpler bounce-back method, despite the minor randomization found in the initial conditions, so I am led to believe I didn’t code the more complicated boundary condition for nothing!

~~~

Next steps:

The next thing I want to do is try to optimize my code. It’s pretty slow when it runs, so if I can figure out how to use multithreading in python, that would speed it up. One advantage to LBM is that it’s local interactions mean it is easily parallelizable, in contrast to traditional Navier-Stokes solvers. To calculate the distribution at a certain time step, we only need information from the neighboring nodes (not every node across the entire channel) from the previous time step. And so a possibility for parallel computation is dividing the channel into sections, where the only information that is duplicated are the distributions on the boundaries of sections. Just a thought, but I’ll read more into parallel computing with Python to decide how I’ll go about it.

~~~

Thank you for following my blog, see you next week

~~~

Sources

Guo, Zhaoli & Zheng, Chuguang & Shi, Baochang. (2002). An extrapolation method for boundary conditions in lattice Boltzmann method. Physics of Fluids. 14. 10.1063/1.1471914.

Cheng-Hsien Lee, Zhenhua Huang & Yee-Meng Chiew (2015) An extrapolation-based boundary treatment for using the lattice Boltzmann method to simulate fluid-particle interaction near a wall, Engineering Applications of Computational Fluid Mechanics, 9:1, 370-381, DOI: 10.1080/19942060.2015.1061554