Create Your Own Finite Volume Fluid Simulation (With Python) Part 2: Boundary Conditions & Source Terms
For today’s recreational coding exercise, we will expand on the Finite Volume method for simulating the compressible fluid equations. We will add boundary conditions and source terms. For Part 1, please see the Python tutorial on the Kelvin-Helmholtz Instability, which we build on. Here in Part 2, we will simulate a different instability: the Rayleigh-Taylor Instability, which is what occurs when a heavy fluid sits on top of a light fluid and is pulled down by gravity. In this problem, we will learn how to add source terms for gravitational acceleration and reflective boundary conditions.
You may find the accompanying Python code on github.
Before we begin, below is a gif of what running our simulation looks like:
Boundary Conditions
In Part 1 of the tutorial, we have assumed a simulation domain with periodic boundary conditions. That meant we did not have to do anything special in setting the fluid flow near the boundaries of the simulation and we could focus on the heart of the fluid solver algorithm. However, rarely are fluid problems periodic in real life, and setting boundary conditions is an important aspect of setting up your own simulations.