![Page 1: Smoothed Particle Hydrodynamics (SPH)wang.3602/courses/cse...Smoothed Particle Interpolation • Suppose each particle j has a physical quantity A j. • The quantity can be: velocity,](https://reader036.vdocuments.us/reader036/viewer/2022070214/61143dff6fa4e958b6393829/html5/thumbnails/1.jpg)
Smoothed Particle Hydrodynamics (SPH)
Huamin Wang
![Page 2: Smoothed Particle Hydrodynamics (SPH)wang.3602/courses/cse...Smoothed Particle Interpolation • Suppose each particle j has a physical quantity A j. • The quantity can be: velocity,](https://reader036.vdocuments.us/reader036/viewer/2022070214/61143dff6fa4e958b6393829/html5/thumbnails/2.jpg)
Fluid Representation• Fluid is represented using a set of particles.• Particle i has position xi, velocity vi, and mass mi.
![Page 3: Smoothed Particle Hydrodynamics (SPH)wang.3602/courses/cse...Smoothed Particle Interpolation • Suppose each particle j has a physical quantity A j. • The quantity can be: velocity,](https://reader036.vdocuments.us/reader036/viewer/2022070214/61143dff6fa4e958b6393829/html5/thumbnails/3.jpg)
Animation Example
• Using 10 million particles– http://www.youtube.com/watch?v=Q4_quqtGtM
A
![Page 4: Smoothed Particle Hydrodynamics (SPH)wang.3602/courses/cse...Smoothed Particle Interpolation • Suppose each particle j has a physical quantity A j. • The quantity can be: velocity,](https://reader036.vdocuments.us/reader036/viewer/2022070214/61143dff6fa4e958b6393829/html5/thumbnails/4.jpg)
Smoothed Particle Interpolation• Suppose each particle j has a physical quantity Aj.• The quantity can be: velocity, pressure, density, temperature….• How to estimate the quantity at a new location Xi?• A simple solution:
Ai?
A0
A4
A3
A2
A1
A5
A6
Aismooth = Aj
j∑ For |Xi – Xj| < r
![Page 5: Smoothed Particle Hydrodynamics (SPH)wang.3602/courses/cse...Smoothed Particle Interpolation • Suppose each particle j has a physical quantity A j. • The quantity can be: velocity,](https://reader036.vdocuments.us/reader036/viewer/2022070214/61143dff6fa4e958b6393829/html5/thumbnails/5.jpg)
Smoothed Particle Interpolation• Instead of assuming a particle is volumeless, let us assume
each one has a volume Vi.• So a better solution is:
Ai?
A0
A4
A3
A2
A1
A5
A6
Aismooth = Vj Aj
j∑ For |Xi – Xj| < r
![Page 6: Smoothed Particle Hydrodynamics (SPH)wang.3602/courses/cse...Smoothed Particle Interpolation • Suppose each particle j has a physical quantity A j. • The quantity can be: velocity,](https://reader036.vdocuments.us/reader036/viewer/2022070214/61143dff6fa4e958b6393829/html5/thumbnails/6.jpg)
Smoothed Particle Interpolation• One problem of this solution:
• Not smooth! (red 7 -> green 9!)
i
Aismooth = Vj Aj
j∑ For |Xi – Xj| < r
![Page 7: Smoothed Particle Hydrodynamics (SPH)wang.3602/courses/cse...Smoothed Particle Interpolation • Suppose each particle j has a physical quantity A j. • The quantity can be: velocity,](https://reader036.vdocuments.us/reader036/viewer/2022070214/61143dff6fa4e958b6393829/html5/thumbnails/7.jpg)
Smoothed Particle Interpolation
• Final solution:• Wij is called smoothing kernel.• When |Xi – Xj| is large, Wij is small. • When |Xi – Xj| is small, Wij is large.
i
For |Xi – Xj| < rAismooth = Vj AjWij
j∑
![Page 8: Smoothed Particle Hydrodynamics (SPH)wang.3602/courses/cse...Smoothed Particle Interpolation • Suppose each particle j has a physical quantity A j. • The quantity can be: velocity,](https://reader036.vdocuments.us/reader036/viewer/2022070214/61143dff6fa4e958b6393829/html5/thumbnails/8.jpg)
Particle Volume• But how do we get the volume of particle i?
ρi = Vjρ jWijj∑
m0
m4
m3
m2
m1
m5
m6
ρi = mjWijj∑
Vi =mi
ρi Vi =mi
mjWijj∑
![Page 9: Smoothed Particle Hydrodynamics (SPH)wang.3602/courses/cse...Smoothed Particle Interpolation • Suppose each particle j has a physical quantity A j. • The quantity can be: velocity,](https://reader036.vdocuments.us/reader036/viewer/2022070214/61143dff6fa4e958b6393829/html5/thumbnails/9.jpg)
Final Interpolation Solution• So the actual solution is:
Vj =mj
mkWjkk∑Ai
smooth = Vj AjWijj∑
Aismooth =
mj
mkWjkk∑
AjWijj∑
![Page 10: Smoothed Particle Hydrodynamics (SPH)wang.3602/courses/cse...Smoothed Particle Interpolation • Suppose each particle j has a physical quantity A j. • The quantity can be: velocity,](https://reader036.vdocuments.us/reader036/viewer/2022070214/61143dff6fa4e958b6393829/html5/thumbnails/10.jpg)
The advantage of This Interpolation
• We can easily compute its derivatives:– Gradient
– Laplacian
Aismooth = Vj AjWij
j∑ ∇Ai
smooth = Vj Aj∇Wijj∑
Aismooth = Vj AjWij
j∑ ∆Ai
smooth = Vj Aj∆Wijj∑
![Page 11: Smoothed Particle Hydrodynamics (SPH)wang.3602/courses/cse...Smoothed Particle Interpolation • Suppose each particle j has a physical quantity A j. • The quantity can be: velocity,](https://reader036.vdocuments.us/reader036/viewer/2022070214/61143dff6fa4e958b6393829/html5/thumbnails/11.jpg)
A Smoothing Kernel Example
Wij =3
2πh3
23− q2 +
12
q3 (0 ≤ q < 1)
16
(2 − q)3 (1 ≤ q < 2)
0 (2 ≤ q)
q =xi − x j
h
h is called smoothing length
![Page 12: Smoothed Particle Hydrodynamics (SPH)wang.3602/courses/cse...Smoothed Particle Interpolation • Suppose each particle j has a physical quantity A j. • The quantity can be: velocity,](https://reader036.vdocuments.us/reader036/viewer/2022070214/61143dff6fa4e958b6393829/html5/thumbnails/12.jpg)
Kernel Derivatives• Gradient at particle i (a vector)
∇iWij =
∂Wij
∂xi
∂Wij
∂yi
∂Wij
∂zi
=∂Wij
∂q∇iq =
∂Wij
∂qxi − x j
xi − x j h q =xi − x j
h
∂Wij
∂q=
32πh3
−2q + 32
q2 (0 ≤ q < 1)
−12
(2 − q)2 (1 ≤ q < 2)
0 (2 ≤ q)
Wij =3
2πh3
23− q2 +
12
q3 (0 ≤ q < 1)
16
(2 − q)3 (1 ≤ q < 2)
0 (2 ≤ q)
![Page 13: Smoothed Particle Hydrodynamics (SPH)wang.3602/courses/cse...Smoothed Particle Interpolation • Suppose each particle j has a physical quantity A j. • The quantity can be: velocity,](https://reader036.vdocuments.us/reader036/viewer/2022070214/61143dff6fa4e958b6393829/html5/thumbnails/13.jpg)
Kernel Derivatives
• Laplacian at particle i (a scalar)
∇iWij =∂2Wij
∂xi2 +
∂2Wij
∂yi2 +
∂2Wij
∂zi2 =
∂2Wij
∂q2
1h2 +
∂Wij
∂q2h q =
xi − x j
h
∂Wij
∂q=
32πh3
−2q + 32
q2 (0 ≤ q < 1)
−12
(2 − q)2 (1 ≤ q < 2)
0 (2 ≤ q)
∂2Wij
∂q2 =3
2πh3
−2 + 3q (0 ≤ q < 1)2 − q (1 ≤ q < 2)0 (2 ≤ q)
![Page 14: Smoothed Particle Hydrodynamics (SPH)wang.3602/courses/cse...Smoothed Particle Interpolation • Suppose each particle j has a physical quantity A j. • The quantity can be: velocity,](https://reader036.vdocuments.us/reader036/viewer/2022070214/61143dff6fa4e958b6393829/html5/thumbnails/14.jpg)
Fluid Dynamics• We model fluid dynamics by applying three
forces on particle i.– Gravity– Fluid Pressure– Fluid Viscosity
i
![Page 15: Smoothed Particle Hydrodynamics (SPH)wang.3602/courses/cse...Smoothed Particle Interpolation • Suppose each particle j has a physical quantity A j. • The quantity can be: velocity,](https://reader036.vdocuments.us/reader036/viewer/2022070214/61143dff6fa4e958b6393829/html5/thumbnails/15.jpg)
Gravity Force• Gravity Force is:
i
Figravity = mig
![Page 16: Smoothed Particle Hydrodynamics (SPH)wang.3602/courses/cse...Smoothed Particle Interpolation • Suppose each particle j has a physical quantity A j. • The quantity can be: velocity,](https://reader036.vdocuments.us/reader036/viewer/2022070214/61143dff6fa4e958b6393829/html5/thumbnails/16.jpg)
Pressure Force• Pressure is related to the density
– First compute the density of Particle i:
– Convert it into pressure (some empirical function):
High Pressure Low pressure
ρi = mjj∑ Wij
Pi = k ρi
ρconstant
7
−1
![Page 17: Smoothed Particle Hydrodynamics (SPH)wang.3602/courses/cse...Smoothed Particle Interpolation • Suppose each particle j has a physical quantity A j. • The quantity can be: velocity,](https://reader036.vdocuments.us/reader036/viewer/2022070214/61143dff6fa4e958b6393829/html5/thumbnails/17.jpg)
Pressure Force• Pressure force depends on the difference of
pressure:
i
High Pressure
High Pressure
High Pressure
High Pressure
High Pressure
No pressure force!
i
High Pressure
High Pressure
LowPressure
LowPressure
High Pressure
Pressure force!
![Page 18: Smoothed Particle Hydrodynamics (SPH)wang.3602/courses/cse...Smoothed Particle Interpolation • Suppose each particle j has a physical quantity A j. • The quantity can be: velocity,](https://reader036.vdocuments.us/reader036/viewer/2022070214/61143dff6fa4e958b6393829/html5/thumbnails/18.jpg)
Pressure Force• Mathematically, the difference of pressure =>
Gradient of pressure.
• To compute this pressure gradient, we assume that the pressure is also smoothly represented:
• So:
Fipressure = −Vi∇iP
smooth
Pismooth = VjPjWij
j∑
Fipressure = −Vi VjPj∇iWij
j∑
![Page 19: Smoothed Particle Hydrodynamics (SPH)wang.3602/courses/cse...Smoothed Particle Interpolation • Suppose each particle j has a physical quantity A j. • The quantity can be: velocity,](https://reader036.vdocuments.us/reader036/viewer/2022070214/61143dff6fa4e958b6393829/html5/thumbnails/19.jpg)
Viscosity Force• Viscosity effect means: particles should move together
in the same velocity.• In other words, minimize the difference between the
particle velocity and the velocities of its neighbors.
Before Ultimately
![Page 20: Smoothed Particle Hydrodynamics (SPH)wang.3602/courses/cse...Smoothed Particle Interpolation • Suppose each particle j has a physical quantity A j. • The quantity can be: velocity,](https://reader036.vdocuments.us/reader036/viewer/2022070214/61143dff6fa4e958b6393829/html5/thumbnails/20.jpg)
Viscosity Force• Mathematically, it means:
• To compute this Laplacian, we assume that the velocity is also smoothly represented:
• So:
Fivis cos ity = −νmi∆iv
smooth
v ismooth = Vjv jWij
j∑
Fivis cos ity = −νmi Vjv j∆iWij
j∑
![Page 21: Smoothed Particle Hydrodynamics (SPH)wang.3602/courses/cse...Smoothed Particle Interpolation • Suppose each particle j has a physical quantity A j. • The quantity can be: velocity,](https://reader036.vdocuments.us/reader036/viewer/2022070214/61143dff6fa4e958b6393829/html5/thumbnails/21.jpg)
Algorithm• For every particle i
– Compute its neighborhood set– Using the neighborhood, compute:
• Force = 0• Force + = The gravity force• Force + = The pressure force• Force + = The viscosity force
– Update vi = vi + t * Force / mi;– Update xi = xi + t *vi; What is the bottleneck of the
performance here?
![Page 22: Smoothed Particle Hydrodynamics (SPH)wang.3602/courses/cse...Smoothed Particle Interpolation • Suppose each particle j has a physical quantity A j. • The quantity can be: velocity,](https://reader036.vdocuments.us/reader036/viewer/2022070214/61143dff6fa4e958b6393829/html5/thumbnails/22.jpg)
Exhaustive Neighborhood Search• Search over every particle pair? O(N2)• 10M particles means: 100 Trillion pairs…
i
![Page 23: Smoothed Particle Hydrodynamics (SPH)wang.3602/courses/cse...Smoothed Particle Interpolation • Suppose each particle j has a physical quantity A j. • The quantity can be: velocity,](https://reader036.vdocuments.us/reader036/viewer/2022070214/61143dff6fa4e958b6393829/html5/thumbnails/23.jpg)
Solution: Spatial Partition– Separate the space into cells– Each cell stores the particles in it– To find the neighborhood of i, just look at the surrounding
cells
i
![Page 24: Smoothed Particle Hydrodynamics (SPH)wang.3602/courses/cse...Smoothed Particle Interpolation • Suppose each particle j has a physical quantity A j. • The quantity can be: velocity,](https://reader036.vdocuments.us/reader036/viewer/2022070214/61143dff6fa4e958b6393829/html5/thumbnails/24.jpg)
Spatial Partition
– What if particles are not uniformly distributed?– Solution: Octree, Binary Spatial Partitioning tree…
i
![Page 25: Smoothed Particle Hydrodynamics (SPH)wang.3602/courses/cse...Smoothed Particle Interpolation • Suppose each particle j has a physical quantity A j. • The quantity can be: velocity,](https://reader036.vdocuments.us/reader036/viewer/2022070214/61143dff6fa4e958b6393829/html5/thumbnails/25.jpg)
Fluid Display• Need to reconstruct the water surface from
particles!
![Page 26: Smoothed Particle Hydrodynamics (SPH)wang.3602/courses/cse...Smoothed Particle Interpolation • Suppose each particle j has a physical quantity A j. • The quantity can be: velocity,](https://reader036.vdocuments.us/reader036/viewer/2022070214/61143dff6fa4e958b6393829/html5/thumbnails/26.jpg)
Ongoing Research
• How to make the simulation more efficient?
• How to make fluids incompressible?
• When simulating water, only use water particles, no air particles. So particles are sparse on the water-air boundary. How to avoid artifacts there?