Navier-Stokes simulator (WIP)
Foreword
Under classical, non-relativistic continuum mechanics, effectively incompressible Newtonian fluids are governed with remarkable accuracy by the following system of partial differential equations:
\begin{equation*} \begin{aligned} \nabla \cdot \mathbf{q} &= 0,\\ \frac{\partial \mathbf{q}}{\partial t} + \nabla \cdot (\mathbf{q} \otimes \mathbf{q}) &= -\nabla p + \frac{1}{\text{Re}} \nabla^2 \mathbf{q}, \end{aligned} \end{equation*}where \(\mathbf{q}\) is the velocity vector, \(p\) is the pressure, and \(\text{Re}\) is the Reynolds number. We will craft a tiny solver for this system in BQN, considering a 2D domain with periodic boundary conditions.
Simulator
The simulator is based on the material from this book, but aiming for a zero dependency implementation.
z β { _p β {(-Β΄π½Β¨)β(+Β΄π½Β¨)ββ½} CβΏE β β¨ββ-Β΄Λ, β’math{π.CosβΛπ.Sin}β© } FFT β {πβΌ: z.C{β Γ·ΛΒ·π½πΎβπ½}ππ©; (1=β )βΆβ¨(+βΎ-)β(β’Γz._pΛΒ·z.Eβ-ΟΓββΈΓ·ββ )Β΄(πΒ¨β’βΛ2|βΛ), β’β©π©}