To predict the flow of an incompressible fluid this project provides a solver for the incompressible Navier-Stokes equation in the momentum form \[
\frac{\partial u}{\partial t} + (u \cdot \nabla)u =
-\frac{1}{\rho} \nabla p + \nu \nabla^2 u + g
\]
with the additional constraint \(\nabla \cdot u = 0\) for incompressibility. The flow velocity is described by the variable \(u[\frac{mm}{s}[\), the time by \(t[s]\), the density by \(\rho[\frac{kg}{mm^3}]\), the pressure by \(p [\frac{kg}{mm\cdot s^2}]\), the kinematic viscosity by \(\nu [cSt = \frac{mm^2}{s}]\) and body accelerations by \(g[\frac{mm}{s^2}]\).
The method
Chorin’s projection method is a rather simple algorithm to solve the incompressible Navier-Stokes equation. The algorithm is a splitted Algorithm. First, an intermediate velocity is computed and only viscous forces are taken into account. Second, the velocity is updated in time by taking pressure forces into account. To do so, it is needed to solve a Poisson-Equation. Chorin’s projection method is an iterative method. The two steps above are repeated until convergence for the velocity- and pressure field.
Example Usage
Solve the lid-driven cavity flow with cflowpy.
# import my python package# Install this with: pip install pip install git+https://git.rwth-aachen.de/JanHab/cflowpy# For further instructions see: https://git.rwth-aachen.de/JanHab/cflowpyimport cflowpy as cf# Initialize the physical problem of the lid-driven cavity flowphysical_problem_cavity = cf.Cavity_flow(1, "top")# Initialize the systemsystem = cf.System(0, 2, 30,0, 2, 30,0.1, 1, physical_problem_cavity)# Execute the solveru, v, p = system.solve(0.01, 5)# Visualize the results for the end timefig = system.contourfigure( u, v, p, velocity="streamline", cmap="coolwarm", title="Lid-driven cavity flow")