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
1 view
135
45
5 months ago 00:47:52 1
Coding Adventure: Simulating Fluids
8 months ago 00:36:41 1
Fluid Simulation
9 months ago 00:00:45 1
Planetary System Formation Simulation (200 AU View)
1 year ago 00:34:15 1
SPH Fluid Simulation in Python
2 years ago 00:06:25 1
Interlinked SPH Pressure Solvers for Strong Fluid-Rigid Coupling
2 years ago 00:01:07 2
Realistic Paint Simulation based on Fluidity, Diffusion, and Absorption