Smoothed Particle Hydrodynamics

+ Positional Based Dynamics

by Leon Montealegre

References

Particle-Based Fluid Simulation for Interactive Application Müller et al. Unified Particle Physics for Real-Time Applications Macklin and Müller et al. Position Based Fluids Müller and Macklin

SPH: General Idea

  • Fluid discretized as particles that each represent an amount of volume
  • Each particle has discretized attributes which are interpolated to evalute anywhere
  • Attributes interpolated via "kernels"
  • Attributes derived from Navier-Stokes Equation
  • $$ \rho\frac{\partial u}{\partial t} = -\nabla p + \mu\nabla^2u + \rho g $$
  • Attributes computed from summing up contributions from neighboring particles, j
  • $$ A_i = \sum_j \frac{m_j}{\rho_j}A_jW(x_{ij}, h) $$
  • Gradient and Laplacian are easy to compute!
  • $$ \nabla A_i = \sum_j \frac{m_j}{\rho_j}A_j\nabla W(x_{ij}, h) $$ $$ \nabla^2 A_i = \sum_j \frac{m_j}{\rho_j}A_j\nabla^2 W(x_{ij}, h) $$

Density and Pressure

$$ \rho\frac{\partial u}{\partial t} = -\nabla p + \mu\nabla^2u + \rho g $$
Density Pressure
$$ A = \rho $$
$$ \rho_i = \sum_j m_jW(x_{ij}, h) $$
$$ A = p $$
$$ p = k\rho $$
$$ p_i = k(\rho_i - \rho_0) $$

Forces

$$ \rho\frac{\partial u}{\partial t} = -\nabla p + \mu\nabla^2u + \rho g $$
External (Gravity) Pressure Viscosity
$$ f^{gravity}_i = \rho_i g $$ $$ f^{pressure}_i = -\nabla p_i $$
$$ f^{pressure}_i = \sum_j\frac{m_j}{\rho_j}p_j\nabla W(x_{ij}, h) $$
$$ f^{viscosity}_i = \mu\nabla^2 p_i $$
$$ f^{viscosity}_i = \mu\sum_j \frac{m_j}{\rho_j}u_j\nabla^2 W(x_{ij}, h) $$

Kernels

3 Types:
  • Poly6: Used for most attributes
  • $$ W_{poly6}(r, h) = \frac{315}{64\pi h^9} \begin{cases} (h^2 - r^2)^3 & 0 \leq r \leq h \\ 0 & \text{otherwise} \end{cases}$$
  • Spiky: Used for pressure
  • $$ W_{spiky}(r, h) = \frac{15}{\pi h^6} \begin{cases} (h - r)^3 & 0 \leq r \leq h \\ 0 & \text{otherwise} \end{cases}$$
  • Viscosity: Used for viscosity
  • $$ W_{viscosity}(r, h) = \frac{15}{2\pi h^3} \begin{cases} -\frac{r^3}{2h^3} + \frac{r^2}{h^2} + \frac{h}{2r} - 1 & 0 \leq r \leq h \\ 0 & \text{otherwise} \end{cases}$$

PBD: General Idea

  • Particles are connected via "constraints" which replace forces & numerical integration
  • Very fast, very stable and produce plausible results
  • Provot correction is a type of constraint
Density Constraint Distance Constraint (AKA Provot Correction)
$$ C_i(x_i,\ldots,x_n) = \frac{\rho_i}{\rho_0} - 1 $$
$$ C(x + \Delta x) = 0 $$
$$ C_i(x_i, x_j) = |x_i - x_j| - d_0 $$
$$ C(x + \Delta x) = 0 $$

Demos

Demos

Demos

Demos

Demos

Demos

Demos

Viscosity:

Future Work

  • Using Compute Shaders to dramatically increase the efficiency of the simulation
  • Better rendering techniques such as Marching Cubes or Ellipsoid Splatting
  • Coupled rigidbody simulation/cloth simulation by extending PBD

Questions?