Writing a Turbulence Simulation in Julia

Writing a Turbulence Simulation in Julia

6.884 Lượt nghe
Writing a Turbulence Simulation in Julia
Most engineering fluid simulations in Computational Fluid Dynamics are turbulent. Turbulence is a difficult phenomenon caused by the non-linearity in the Navier-Stokes Equations. Yet, it is also beautiful to look at. Let's code a simple solver in Julia: https://github.com/Ceyron/machine-learning-and-simulation/blob/main/english/simulation_scripts/kolmogorov_turbulence.jl The approach we are using is based on the Stable Fluids Algorithm by Jos Stam, which you might have seen in one of other videos on the channel: - An implementation of the classical Stable Fluids in Python using NumPy https://youtu.be/wbYe58NGJJI - A modification of the solver using the FFT on Periodic Domains in Julia: https://youtu.be/F7rWoxeGrko - An extension of the FFT Julia solver to 3D: https://youtu.be/bvPi6XwdM0U A Kolmogorov Flow is defined by a stratified forcing that creates fluid motion in layerwise opposing directions. These layers yield high shear stresses at the interfaces that lead to a breakup into turbulence at a certain point. From there on, the fluid behaves according to isotropic turbulence. The setup and the color scale is inspired by this amazing paper: https://www.pnas.org/doi/10.1073/pnas.2101784118 ------- 📝 : Check out the GitHub Repository of the channel, where I upload all the handwritten notes and source-code files (contributions are very welcome): https://github.com/Ceyron/machine-learning-and-simulation 📢 : Follow me on LinkedIn or Twitter for updates on the channel and other cool Machine Learning & Simulation stuff: https://www.linkedin.com/in/felix-koehler and https://twitter.com/felix_m_koehler 💸 : If you want to support my work on the channel, you can become a Patreon here: https://www.patreon.com/MLsim ------- Timestamps: 00:00 Intro 01:21 Kolmogorov Flow Simulation 02:50 Details for the Stable Fluids Simulation 04:01 Hint on FFMPEG 04:17 Imports 04:51 Defining Constants 06:20 Creating the Mesh 08:51 Preparing the wavenumbers 12:51 Pre-Computing the Diffusion Decay 13:32 Pre-Computing normalized wavenumbers 14:43 Pre-Computing the forcing array 15:37 Pre-Allocate Arrays 17:54 Prepare the time loop 18:17 (1) Apply Forces 18:35 (2) Backtrace on streamline 21:00 (2) Interpolate with backtraced coordinates 23:20 (3) First Stabilization 24:12 (4.1) Transform into Fourier Domain 24:38 (4.2) Diffusion in Fourier Domain 25:31 (4.3) Compute Pressure by Divergence in Fourier Domain 26:24 (4.4) Project Velocities to Incompressibility 26:56 (4.5) Transform back to Spatial Domain 28:16 (5) Another Stabilization 28:17 (6) Advance in time 28:52 Computing Curl in Fourier Domain 29:55 Prepare the visualization with Plots.jl 33:33 Curl Intensification 34:45 Bug Fixing 37:33 Simulation is running 39:09 Creating a Movie with FFMPEG 40:18 Discussing the Simulation movie 41:08 Correcting the force application 41:58 Feel free to contribute 42:26 Outro