Computational Fluid Dynamics in Python
Using NumPy to solve the equations of fluid mechanics ??? together with Finite Differences, explicit time stepping and Chorin's Projection methods.
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
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
to get a simulation that plots throughout time. By this you can see how the Lid Driven cavity is reaching its steady-state.
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
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.