particle dynamics - college of computing
TRANSCRIPT
![Page 1: Particle dynamics - College of Computing](https://reader031.vdocuments.net/reader031/viewer/2022012508/6184c02f55cfea43ff4666fa/html5/thumbnails/1.jpg)
Particle dynamics
![Page 2: Particle dynamics - College of Computing](https://reader031.vdocuments.net/reader031/viewer/2022012508/6184c02f55cfea43ff4666fa/html5/thumbnails/2.jpg)
• Particle overview
• Particle system
• Forces
• Constraints
• Second order motion analysis
![Page 3: Particle dynamics - College of Computing](https://reader031.vdocuments.net/reader031/viewer/2022012508/6184c02f55cfea43ff4666fa/html5/thumbnails/3.jpg)
Particle system
• Particles are objects that have mass, position, and velocity, but without spatial extent
• Particles are the easiest objects to simulate but they can be made to exhibit a wide range of objects
![Page 4: Particle dynamics - College of Computing](https://reader031.vdocuments.net/reader031/viewer/2022012508/6184c02f55cfea43ff4666fa/html5/thumbnails/4.jpg)
• Each particle has a position, mass, and velocity
• maybe color, age, temperature
• Seeded randomly at start
• maybe some created each frame
• Move each frame according to physics
• Eventually die when some condition met
Particle animation
![Page 5: Particle dynamics - College of Computing](https://reader031.vdocuments.net/reader031/viewer/2022012508/6184c02f55cfea43ff4666fa/html5/thumbnails/5.jpg)
Sparks from a campfire
• Add 2-3 particles at each frame
• initialize position and temperature randomly
• Move in specified turbulent smoke flow and decrease temperature as evolving
• Render as a glowing dot
• Kill when too cold to glow visibly
![Page 6: Particle dynamics - College of Computing](https://reader031.vdocuments.net/reader031/viewer/2022012508/6184c02f55cfea43ff4666fa/html5/thumbnails/6.jpg)
Rendering
• Simplest rendering: color dots
• Animated sprites
• Deformable blobs
• Transparent spheres
• Shadows
![Page 7: Particle dynamics - College of Computing](https://reader031.vdocuments.net/reader031/viewer/2022012508/6184c02f55cfea43ff4666fa/html5/thumbnails/7.jpg)
A Newtonian particle• First order motion is sufficient, if
• a particle state only contains position
• no inertia
• particles are extremely light
• Most likely particles have inertia and are affected by gravity and other forces
• This puts us in the realm of second order motion
![Page 8: Particle dynamics - College of Computing](https://reader031.vdocuments.net/reader031/viewer/2022012508/6184c02f55cfea43ff4666fa/html5/thumbnails/8.jpg)
Second-order ODE
f = ma
What is the differential equation that describes the behavior of a mass point?
What does f depend on?
x(t) =f(x(t), x(t))
m
![Page 9: Particle dynamics - College of Computing](https://reader031.vdocuments.net/reader031/viewer/2022012508/6184c02f55cfea43ff4666fa/html5/thumbnails/9.jpg)
Second-order ODE
Add a new variable, v(t), to get a pair of coupled first order equations
This is not a first oder ODE because it has second derivatives
{x = v
v = f/m
x(t) =f(x(t), x(t))
m= f(x, x)
![Page 10: Particle dynamics - College of Computing](https://reader031.vdocuments.net/reader031/viewer/2022012508/6184c02f55cfea43ff4666fa/html5/thumbnails/10.jpg)
Phase space
[
x
v
]
=
x1
x2
x3
v1
v2
v3
Concatenate position and velocity to form a 6-vector: position in phase space
First order differential equation: velocity in the phase space
[
x
v
]
=
[
v
f
m
]
![Page 11: Particle dynamics - College of Computing](https://reader031.vdocuments.net/reader031/viewer/2022012508/6184c02f55cfea43ff4666fa/html5/thumbnails/11.jpg)
• Particle overview
• Particle system
• Forces
• Constraints
• Second order motion analysis
![Page 12: Particle dynamics - College of Computing](https://reader031.vdocuments.net/reader031/viewer/2022012508/6184c02f55cfea43ff4666fa/html5/thumbnails/12.jpg)
Particle structure
x
v
f
m
Particle
position
velocity
force accumulator
mass
a point in the phase space
![Page 13: Particle dynamics - College of Computing](https://reader031.vdocuments.net/reader031/viewer/2022012508/6184c02f55cfea43ff4666fa/html5/thumbnails/13.jpg)
Solver interface
system solversolver
interface
x
v
f
m
particle GetDim 6
Get/Set State
x
v
Deriv Evalv
f
m
![Page 14: Particle dynamics - College of Computing](https://reader031.vdocuments.net/reader031/viewer/2022012508/6184c02f55cfea43ff4666fa/html5/thumbnails/14.jpg)
system
Particle system structure
n time
...
x1
v1
f1
m1
x2
v2
f2
m2
xn
vn
fn
mn
particles
![Page 15: Particle dynamics - College of Computing](https://reader031.vdocuments.net/reader031/viewer/2022012508/6184c02f55cfea43ff4666fa/html5/thumbnails/15.jpg)
system
Particle system structure
solversolver
interface
GetDim 6n
Get/Set State
x1
v1
x2
v2
xn
vn
. . .
Deriv Evalvn
fnmn
v1
f1m1
v2
f2m2
. . .
particles
timen
![Page 16: Particle dynamics - College of Computing](https://reader031.vdocuments.net/reader031/viewer/2022012508/6184c02f55cfea43ff4666fa/html5/thumbnails/16.jpg)
Deriv Eval
Clear forces: loop over particles, zero force accumulatorCalculate forces: sum all forces into accumulator
Gather: loop over particles, copy v and f/m into destination array
![Page 17: Particle dynamics - College of Computing](https://reader031.vdocuments.net/reader031/viewer/2022012508/6184c02f55cfea43ff4666fa/html5/thumbnails/17.jpg)
• Particle overview
• Particle system
• Forces
• Constraints
• Second order motion analysis
![Page 18: Particle dynamics - College of Computing](https://reader031.vdocuments.net/reader031/viewer/2022012508/6184c02f55cfea43ff4666fa/html5/thumbnails/18.jpg)
Forces
• Constant• gravity
• Position/time dependent• force fields, springs
• Velocity dependent• drag
![Page 19: Particle dynamics - College of Computing](https://reader031.vdocuments.net/reader031/viewer/2022012508/6184c02f55cfea43ff4666fa/html5/thumbnails/19.jpg)
system
particles
n time
Particle systems with forces
...
x1
v1
f1
m1
x2
v2
f2
m2
xn
vn
fn
mn
F1 F2 Fm...forces
![Page 20: Particle dynamics - College of Computing](https://reader031.vdocuments.net/reader031/viewer/2022012508/6184c02f55cfea43ff4666fa/html5/thumbnails/20.jpg)
Force structure
• Unlike particles, forces are heterogeneous (type-dependent)
• Each force object “knows”
• which particles it influences
• how much contribution it adds to the force accumulator
![Page 21: Particle dynamics - College of Computing](https://reader031.vdocuments.net/reader031/viewer/2022012508/6184c02f55cfea43ff4666fa/html5/thumbnails/21.jpg)
system
particles
n time
Particle systems with forces
...
x1
v1
f1
m1
x2
v2
f2
m2
xn
vn
fn
mn
forces F1 F2 Fm...
![Page 22: Particle dynamics - College of Computing](https://reader031.vdocuments.net/reader031/viewer/2022012508/6184c02f55cfea43ff4666fa/html5/thumbnails/22.jpg)
F
Gravity
p
sys apply_fun
Gparticle system
. . .
x1
v1
f1
m1
x2
v2
f2
m2
xn
vn
fn
mn
p->f += p->m*F->G
Unary force: f = mG
Exerting a constant force on each particle
![Page 23: Particle dynamics - College of Computing](https://reader031.vdocuments.net/reader031/viewer/2022012508/6184c02f55cfea43ff4666fa/html5/thumbnails/23.jpg)
F
Viscous drag
k
sys
particle system
p . . .
x1
v1
f1
m1
x2
v2
f2
m2
xn
vn
fn
mn
apply_fun
p->f += p->v*F->k
At very low speeds for small particles, air resistance is approximately:
fdrag = −kdragv
![Page 24: Particle dynamics - College of Computing](https://reader031.vdocuments.net/reader031/viewer/2022012508/6184c02f55cfea43ff4666fa/html5/thumbnails/24.jpg)
AttractionAct on any or all pairs of particles, depending on their positions
xp
xq
l
fq = −fp
fp = −kmpmq
|l|2l
|l|
l = xp − xq
![Page 25: Particle dynamics - College of Computing](https://reader031.vdocuments.net/reader031/viewer/2022012508/6184c02f55cfea43ff4666fa/html5/thumbnails/25.jpg)
Attraction
p
sys apply_fun
kparticle system
F
xp
vp
fp
mp
xq
vq
fq
mqfp = −kmpmq
|l|2l
|l|
![Page 26: Particle dynamics - College of Computing](https://reader031.vdocuments.net/reader031/viewer/2022012508/6184c02f55cfea43ff4666fa/html5/thumbnails/26.jpg)
Damped spring
fp = −
[
ks(|l|− r) + kdl · l
|l|
]
l
|l|
r| l |
xp
xql = xp − xq
fq = −fp
![Page 27: Particle dynamics - College of Computing](https://reader031.vdocuments.net/reader031/viewer/2022012508/6184c02f55cfea43ff4666fa/html5/thumbnails/27.jpg)
Damped spring
p
sys apply_fun
ksparticle system
F
xp
vp
fp
mp
xq
vq
fq
mq
kd
r
fp = −
[
ks(|l|− r) + kdl · l
|l|
]
l
|l|
![Page 28: Particle dynamics - College of Computing](https://reader031.vdocuments.net/reader031/viewer/2022012508/6184c02f55cfea43ff4666fa/html5/thumbnails/28.jpg)
Deriv Eval
...
x1
v1
f1
m1
x2
v2
f2
m2
xn
vn
fn
mn
1. Clear force accumulators
F1 F2 Fm...
2. Invoke apply_force functions
3. Return derivatives to solver[
x
v
]
=
[
v
f
m
]
![Page 29: Particle dynamics - College of Computing](https://reader031.vdocuments.net/reader031/viewer/2022012508/6184c02f55cfea43ff4666fa/html5/thumbnails/29.jpg)
ODE solver
Euler’s method: x(t0 + h) = x(t0) + hf(x, t)
xt+1 = xt + hxt
vt+1 = vt + hvt
![Page 30: Particle dynamics - College of Computing](https://reader031.vdocuments.net/reader031/viewer/2022012508/6184c02f55cfea43ff4666fa/html5/thumbnails/30.jpg)
2.4.Get/Set State
Euler step
system
GetDim
Deriv Eval
solversolver
interfacext+1 = xt + hxt
vt+1 = vt + hvt
3.
time5. Advance time
Deriv Eval
1.. . .
vn
fnmn
v1
f1m1
v2
f2m2
x1
v1
x2
v2
xn
vn
. . .
particles
![Page 31: Particle dynamics - College of Computing](https://reader031.vdocuments.net/reader031/viewer/2022012508/6184c02f55cfea43ff4666fa/html5/thumbnails/31.jpg)
• Particle overview
• Particle system
• Forces
• Constraints
• Second order motion analysis
![Page 32: Particle dynamics - College of Computing](https://reader031.vdocuments.net/reader031/viewer/2022012508/6184c02f55cfea43ff4666fa/html5/thumbnails/32.jpg)
Particle Interaction
• We will revisit collision when we talk about rigid body simulation
• For now, just simple point-plane collisions
![Page 33: Particle dynamics - College of Computing](https://reader031.vdocuments.net/reader031/viewer/2022012508/6184c02f55cfea43ff4666fa/html5/thumbnails/33.jpg)
Collision detection
vT
vNv
x
N
Normal and tangential components
vN = (N · v)N
vT = v − vN
![Page 34: Particle dynamics - College of Computing](https://reader031.vdocuments.net/reader031/viewer/2022012508/6184c02f55cfea43ff4666fa/html5/thumbnails/34.jpg)
Collision detection
vT
vNv
p
x
N
Particle is on the legal side if
Particle is heading in if
Particle is within of the wall ifε
(x − p) · N ≥ 0
(x − p) · N < ε
v · N < 0
![Page 35: Particle dynamics - College of Computing](https://reader031.vdocuments.net/reader031/viewer/2022012508/6184c02f55cfea43ff4666fa/html5/thumbnails/35.jpg)
Collision response
v
vT
vN
Before collision
v′
vT
−krvN
After collision
coefficient of restitution: 0 ≤ kr < 1
v′= vT − krvN
![Page 36: Particle dynamics - College of Computing](https://reader031.vdocuments.net/reader031/viewer/2022012508/6184c02f55cfea43ff4666fa/html5/thumbnails/36.jpg)
Contact
p
N
Conditions for resting contact:
f fN
fT
If a particle is pushed into the contact plane a contact force fc is exerted to cancel the normal component of f
x
1. particle is on the collision surface
v
2. zero normal velocity
![Page 37: Particle dynamics - College of Computing](https://reader031.vdocuments.net/reader031/viewer/2022012508/6184c02f55cfea43ff4666fa/html5/thumbnails/37.jpg)
• Particle overview
• Particle system
• Forces
• Constraints
• Second order motion analysis
![Page 38: Particle dynamics - College of Computing](https://reader031.vdocuments.net/reader031/viewer/2022012508/6184c02f55cfea43ff4666fa/html5/thumbnails/38.jpg)
Linear analysis
• Linearly approximate acceleration
• Split up analysis into different cases
• constant acceleration
• linear acceleration
a(x,v) ≈ a0 − Kx − Dv
![Page 39: Particle dynamics - College of Computing](https://reader031.vdocuments.net/reader031/viewer/2022012508/6184c02f55cfea43ff4666fa/html5/thumbnails/39.jpg)
Constant acceleration
• Solution is
• v(t) only needs 1st order accuracy, but x(t) demands 2nd order accuracy
v(t) = v0 + a0t
x(t) = x0 + v0t +1
2a0t
2
![Page 40: Particle dynamics - College of Computing](https://reader031.vdocuments.net/reader031/viewer/2022012508/6184c02f55cfea43ff4666fa/html5/thumbnails/40.jpg)
Linear acceleration
• When K (or D) dominates ODE, what type of motion does it correspond to?
• Need to compute the eigenvalues of A
a(x,v) = −Kx − Dv
d
dt
[
x
v
]
=
[
0 I
−K −D
] [
x
v
]
= A
[
x
v
]
![Page 41: Particle dynamics - College of Computing](https://reader031.vdocuments.net/reader031/viewer/2022012508/6184c02f55cfea43ff4666fa/html5/thumbnails/41.jpg)
Linear acceleration
Assume is an eigenvalue of A, is the corresponding eigenvector
α
[
u1
u2
]
[
0 I
−K −D
] [
u1
u2
]
= α
[
u1
u2
]
The eigenvector of A has the form[
u
αu
]
Often, D is linear combination of K and I (Rayleigh damping)That means K and D have the same eigenvectors
![Page 42: Particle dynamics - College of Computing](https://reader031.vdocuments.net/reader031/viewer/2022012508/6184c02f55cfea43ff4666fa/html5/thumbnails/42.jpg)
Linear acceleration
Now assume u is an eigenvector for both K and D
For any u, if is an eigenvector of A, following must be true
[
u
αu
]
[
0 I
−K −D
] [
u
αu
]
= α
[
u
αu
]
−λku − αλdu = α2u
α = −1
2λd ±
√
(1
2λd)2 − λk
![Page 43: Particle dynamics - College of Computing](https://reader031.vdocuments.net/reader031/viewer/2022012508/6184c02f55cfea43ff4666fa/html5/thumbnails/43.jpg)
Eigenvalue approximation
• If D dominates
• exponential decay
• If K dominates
• oscillation
α ≈ −λd, 0
α ≈ ±√−1
√
λk
![Page 44: Particle dynamics - College of Computing](https://reader031.vdocuments.net/reader031/viewer/2022012508/6184c02f55cfea43ff4666fa/html5/thumbnails/44.jpg)
Analysis• Constant acceleration (e.g. gravity)
• demands 2nd order accuracy for position
• Position dependence (e.g. spring force)
• demands stability but low or zero damping
• looks at imaginary axis
• Velocity dependence (e.g. damping)
• demands stability, exponential decay
• looks at negative real axis
![Page 45: Particle dynamics - College of Computing](https://reader031.vdocuments.net/reader031/viewer/2022012508/6184c02f55cfea43ff4666fa/html5/thumbnails/45.jpg)
Explicit methods• First-order explicit Euler method
• constant acceleration:• position dependence:• velocity dependence:
• RK3 and RK4• constant acceleration:• position dependence:• velocity dependence:
bad (1st order)
very bad (unstable)
ok (conditionally stable)
great (high order)
ok (conditionally stable)
ok (conditionally stable)
![Page 46: Particle dynamics - College of Computing](https://reader031.vdocuments.net/reader031/viewer/2022012508/6184c02f55cfea43ff4666fa/html5/thumbnails/46.jpg)
Implicit methods• Implicit Euler method
• constant acceleration:• position dependence:• velocity dependence:
• Trapezoidal rule• constant acceleration:• position dependence:• velocity dependence:
bad (1st order)
ok (stable but damped)
great (monotone)
great (2nd order)
great (stable and no damp)
good (stable, not monotone)
![Page 47: Particle dynamics - College of Computing](https://reader031.vdocuments.net/reader031/viewer/2022012508/6184c02f55cfea43ff4666fa/html5/thumbnails/47.jpg)
What’s next?
![Page 48: Particle dynamics - College of Computing](https://reader031.vdocuments.net/reader031/viewer/2022012508/6184c02f55cfea43ff4666fa/html5/thumbnails/48.jpg)
• How do we enforce constraints on the particles?
• Read (optional): Particle animation and rendering using data parallel computation, SIG90, Karl Sims