Computational Fluid Dynamics in Python
Using NumPy to solve the equations of fluid mechanics
You can find more details in the corresponding video which you can also use to code along
How to use
Make sure you have the relevant packages installed. These pip commands should be sufficient
pip install numpy matplotlib tqdm
Then you can either execute
python lid_driven_cavity_python_simple.py
for a simulation which runs all the way through and in the end plots a contour plot of the (pseudo) pressure with a vector field layed on top. Or you can execute
python lid_driven_cavity_python_simple_interactive_plotting.py
to get a simulation that plots throughout time. By this you can see how the Lid Driven cavity is reaching its steady-state.
Parameters
In the beginning of both files, directly after the explaining docstring, you find Python constants to adapt the scenario and the numerics.
Details on the methods
The method is based on the operator splitting due to Chorin. Also see this Wikipedia page for some details.
Big parts of the of the code, including the approach to solve the pressure-poisson equation using Jacobi Smoothing, are inspired by the 11th lesson of Lorena Barba's 12 steps to Navier Stokes.
Also check out the docstring in the beginning of the file for some more details.