Lecture 13 Fluid Simulation 01| The Particle-based (Lagrangian) Methods
Lagrangian Method = Particle-Based
# Incompressible Fluid Dynamics
usually compressible for explosion / shock wave / … ; incompressible for slower dynamics
# Forces for Incompressible Fluids
m\vb{a} = \vb{f} = \vb{f}_{\text{ext}} +\vb f_{\text{pres}} +\vb f_{\text{visc}}
# Incompressible Navier–Stokes Equations
The Navier-Stokes Equation ()
\left\{\begin{array}{ll} \underbrace{\rho \frac{\mathrm{D}v}{\mathrm{D}t}} _{ma/V} = \underbrace{\rho g}_{mg /V} -\underbrace{\grad p}_{\text{adv}} + \underbrace{\mu \laplacian v}_{\text{diff}} & \text{(Momentum Equation)} \\ \div\ v = 0 \Leftrightarrow \frac{\mathrm{D}\rho}{\mathrm{D}t} = \rho (\div\ v ) = 0\ &\text{(Divergence free -- Mass conserving)} \end{array}\right.# The Spatial Derivative Operators
Gradient: \grad: \R^1 \rightarrow \R^3
\grad s = \left[\frac{\partial s}{\partial x}, \frac{\partial s}{\partial y}, \frac{\partial s}{\partial z} \right]^{\mathrm{T}}
Divergence: : \R^3 \rightarrow \R^1
Curl: $\curl $ : \R^3 \rightarrow \R^3
\curl\ v = \left[\frac{\partial v_{z}}{\partial y}-\frac{\partial v_{y}}{\partial z}, \frac{\partial v_{z}}{\partial x}-\frac{\partial v_{x}}{\partial z}, \frac{\partial v_{y}}{\partial x}-\frac{\partial v_{x}}{\partial y}\right]^{\mathrm{T}}
Laplace: \Delta = \laplacian = \div \grad: \R^n \rightarrow \R^n (Diffusion)
\laplacian s = \div(\grad s) = \frac{\partial^{2} s}{\partial x^{2}}+\frac{\partial^{2} s}{\partial y^{2}}+\frac{\partial^{2} s}{\partial z^{2}}
# Time Discretization
# Operator Splitting
# General Steps
Separate the N-S Eqn into 2 parts and use half the timestep to solve each part (Advection-Projection)
- Step 1: Input , output : (Explicit, everything is known)
- \rho \frac{\mathrm{D}v}{\mathrm{D}t} = \rho g + \mu \laplacian v
- Step 2: Input , output : (Implicit: and \grad p are unknown)
- \rho \frac{\mathrm{D}v}{\mathrm{D}t} = -\grad p
# Time Integration
Given &
- Step 1: Advection / external and viscosity force integration
- Solve: \mathrm{d}v = g + v\laplacian v_n
- Update:
- Step 2: Projection / pressure solver (Poisson Solver)
- Solve: \mathrm{d}v = -\frac{1}{\rho} \grad(k(\rho - \rho_0)) and
- Update:
- Step 3: Update position
- Update:
- Return ,
# Integration with the Weakly Compressible (WC) Assumption
Storing the density as an individual var that advect with the vel field
\frac{\mathrm D v}{\mathrm D t}=g-\frac{1}{\rho} \nabla p+v \nabla^{2} v\ ;\quad \cancel{\div\ v = 0}\ \text{(weak compressible)}
# Time Integration
Symplectic Euler Integration: In this case step 1 and 2 can be combined since they are both explicit (no order diff)
- Step 1: Advection / external and viscosity force integration
- Solve: \mathrm{d}v = g + v\laplacian v_n
- Update:
- Step 2: Projection / pressure solver (Use the current-point-evaluated )
- Solve: \mathrm{d}v = -\frac{1}{\rho} \grad(k(\rho - \rho_0))
- Update:
- Step 3: Update position
- Update:
- Return ,
# Spatial Discretization (Lagrangian View)
- Previous knowledge using Lag. View: Mesh-based simulation (FEM)
- Today: Mesh-free simulation => a simular example: marine balls
# Basic Idea
Cont. view -> Discrete view (using particles):
\frac{d v_{i}}{d t}=\underbrace{g-\frac{1}{\rho} \nabla p\left(x_{i}\right)+\nu \nabla^{2} v\left(x_{i}\right)}_{a_i}\ , \text{ where }\nu = \frac{\mu}{\rho_0}Time integration (Symplectic Euler):
&
But still need to evaluate , \grad p(x_i) & \laplacian v(x_i)
# Smoothed Particle Hydrodynamics (SPH)
# Dirac Delta
# Trivial Indentity
The Dirac function only tends to infinity at 0 but equals to 0 otherwise. And its overall integral is 1.
f(r) = \int^{\infty}_{-\infty} f(r') \delta (r-r')\ \mathrm{d}r\\ \delta(r)=\left\{\begin{array}{l} +\infty, \text { if } r=0 \\ 0, \text { otherwise } \end{array} \text { and } \int_{-\infty}^{\infty} \delta(r)\ \mathrm{d} r=1\right.# Widen the Dirac Delta

- kernel funciton:
- Symmetric:
- Sum to unity:
- Compact support: (Sampling radius - )
e.g. (Error: , can be reduced by decreasing the sampling radius )

# Finite Probes: Summation
f(r) \approx \int f\left(r^{\prime}\right) W\left(r-r^{\prime}, h\right)\ \mathrm{d} r^{\prime} \approx \sum_{j} V_{j} f\left(r_{j}\right) W\left(r-r_{j}, h\right)
# Smoother Kernel Function
Still use the summation: . But “trust” the closer probes (the orange & yellow ones) better => Smoother function

Use a \C^3 cont. spline: e.g. (The figure below shows the 1st / 2nd / 3rd order der)

# Smoothed Particle Hydrodynamics (SPH)
# Discretization
1D:
2D:

Par stored in every particles
- Intrinsic quantities:
- : support radius
- : particle radius -> : particle volume
- Time varying quantities:
- : density
- : velocity
- : position
# Evaluate 2D fields using the SP

# SPH Spatial Derivatives
The operators will affect only on the kernel func ()
- \nabla\cdot \vb{F}(r) \approx \sum_{j} \frac{m_{j}}{\rho_{j}} \vb{F}\left(r_{j}\right) \cdot \nabla W\left(r-r_{j}, h\right)
- \nabla \times \boldsymbol{F}(r) \approx-\sum_{j} \frac{m_{j}}{\rho_{j}} f\left(r_{j}\right) \times \nabla W\left(r-r_{j}, h\right)
# Improving Approximations for Spatial Derivatives
- Let : (Red line)
- in the graph: not exactly 1.0
- 0 \approx \sum_{j} \frac{m_{j}}{\rho_{j}} \grad W\left(r-r_{j}, h\right) not equal = 0 exactly (even if increase sampling points)

# Anti-symmetric Form
Better for projection / divergence / …
=> Since \grad f(r) \equiv \grad f(r) \cdot 1:
- \grad f(r) = \grad f(r) \cdot 1 + f(r) \cdot \grad 1
- Or equivalently: \grad f(r) = \grad f(r) - f(r) \cdot \grad 1 => the 2 grads can be evaluated using SPH
\grad f(r) \approx \sum_{j} \frac{m_{j}}{\rho_{j}} f\left(r_{j}\right) \grad W\left(r-r_{j}, h\right)-f(r) \sum_{j} \frac{m_{j}}{\rho_{j}} \grad W\left(r-r_{j}, h\right) \approx \sum_{j} m_{j} \frac{f\left(r_{j}\right)-f(r)}{\rho_{j}} \nabla W\left(r-r_{j}, h\right) (Anti-symmetric form, green line)
# Symmetric Form
Better for forces
- A more gen case:
- \grad\left(f(r) \rho^{n}\right)=\grad f(r) \cdot \rho^{n}+f(r) \cdot n \rho^{n-1} \grad\rho
- \Rightarrow \grad f(r)=\frac{1}{\rho^{n}}\left(\grad\left(f(r) \cdot \rho^{n}\right)-f(r)\cdot n \cdot \rho^{n-1} \grad\rho\right)
- \grad f(r) \approx \sum_{j} m_{j}\left(\frac{f\left(r_{j}\right) \rho_{j}^{n-1}}{\rho^{n}}-\frac{n f(r)}{\rho}\right) \grad W\left(r-r_{j}, h\right)
- Special Case: when :
- \grad f(r) \approx \rho \sum_{j} m_{j}\left(\frac{f\left(r_{j}\right)}{\rho_{j}^{2}}+\frac{f(r)}{\rho^{2}}\right) \grad W\left(r-r_{j}, h\right) (Symmetric form)
# Implementation Details (WCSPH)
# Simulation Pipeline
For i in particles:
Search for neighbors j -> Apply the support radius
For i in particles:
- Sample the / fields using SPH
- Desity: ( is for )
- Viscosity: \nu\grad^{2} v_{i}=v \sum_{j} m_{j} \frac{v_{j}-v_{i}}{\rho_{j}} \grad^{2} W_{i j} (Asymmetric form)
- Pressure Gradient:
- Compute / using N-S Eqn
- \frac{\mathrm{d} v_{i}}{\mathrm{d} t}=g-\frac{1}{\rho_{i}} \grad p_{i}+v \grad^{2} v_{i}
- Sample the / fields using SPH
For i in particles (Symplectic Euler)
- Update using
- Update using
- Update using
# Boundary Conditions

# Problems of Boundaries
Insufficient samples
Free Surface: lower density and pressure => Generate outward pressure
-> Sol: Clamp the negative pressure (everywhere), (only be compressed, cannot be streched)\
Solid Boundary: lower density and pressure => Fluid leakage (outbound velocity)
-> Sol:
for leakage:
- Refect the outbound veclocity when close to boundary
- Pad a layer of SP underneath the boundaries: & => increases numerical viscosity
# Neighbor Search
Navie search: time
=> Use background grid: Common grid size = (same support radius in SPH)
(Each neighbor search takes 9 grids in 2D and 27 grids in 3D)
