SPH Fluid Simulation in Python

Smoothed Particle Hydrodynamics is a Lagrangian technique to perform Computational Fluid Dynamics. It is especially powerful to simulate free surface flows, like pouring a beer. This is a simple implementation in Python/NumPy. Here is the code: The particle algorithm we use here is based on a 2003 paper by Matthias Müller that you can find here: There you will also find more details on why we use our particular kernels. ------- 📝 : Check out the GitHub Repository of the channel, where I upload all the handwritten notes and source-code files (contributions are very welcome): 📢 : Follow me on LinkedIn or Twitter for updates on the channel and other cool Machine Learning & Simulation stuff: and 💸 : If you want to support my work on the channel, you can become a Patreon here: ------- ⚙️ My Gear: (Below are affiliate links to Amazon. If you decide to purchase the product or something else on Amazon through this link, I earn a small commission.) - 🎙️ Microphone: Blue Yeti: - ⌨️ Logitech TKL Mechanical Keyboard: - 🎨 Gaomon Drawing Tablet (similar to a WACOM Tablet, but cheaper, works flawlessly under Linux): - 🔌 Laptop Charger: - 💻 My Laptop (generally I like the Dell XPS series): - 📱 My Phone: Fairphone 4 (I love the sustainability and repairability aspect of it): If I had to purchase these items again, I would probably change the following: - 🎙️ Rode NT: - 💻 Framework Laptop (I do not get a commission here, but I love the vision of Framework. It will definitely be my next Ultrabook): As an Amazon Associate I earn from qualifying purchases. ------- Timestamps: 00:00 Introduction 00:59 Scenario 01:23 Idea of SPH 02:36 Solution Algorithm 04:21 Computational Aspects 05:23 Imports 05:51 Defining Constants 08:36 Boilerplate 08:50 Initializing Variables 09:53 Time iteration 10:03 Add new particles 13:33 Neighborhood Computation 15:53 Computing Density 18:57 Computing Pressure 19:17 Force Computation Preparation 20:57 Pressure Force 23:12 Viscous/Viscosity Force 24:48 Gravity Force 25:11 Time Integration 26:23 Enforce Boundary Conditions 28:45 Visualization 30:55 Bug Fixing 31:24 Discussing the Simulation 33:17 Outro
Back to Top