Simulation - Smoothed-Particle Hydrodynamics
Path of the code: [10_sph]
The objective is to model a fluid simulation using SPH model.So far, only the gravity force is applied on the particles
The blue color around the particle comes from a field function set as \(f(p)=\sum_i exp\left(-\left(\|p-p_i\|/\sigma\right)^2\right)\) and displayed as a colored texture to give the visual impression of continuous fluid material. > Fill the function "update_density" that set the density at each particle position \(\rho_i\) using a smooth kernel
-
- \(\displaystyle W_h(p) = \frac{315}{64\,\pi\,h^ 3}\,\left(1-\left(\frac{\|p\|}{h}\right)^ 2\right)^ 3\), \(\|p\|\leq h\)
- Note that this kernel is already implemented in the function W_density.
- Note: Fill the function "W_gradient_pressure" to be the gradient of the spiky kernel and use it in the computation of the pressure force
Example obtained without viscosity using 20 integration steps for each frame
Adding viscosity
Example with more samples
Extensions
- - Note that particles have been initialized in the \((x,y)\) plane and leads to a 2D simulation. But if you initialize particles in 3D (or add a small \(z\) component in their initial position), the simulation will adapt seamlessly to 3D.
- - If you have spare time: Implement an acceleration grid structure to avoid comparing all pairs of particles (ex. uniform grid).