SPH Lecture
SPH Lecture
Introduction into
Smoothed Particle
Hydrodynamics
Ralf Klessen
Astrophysikalisches Institut Potsdam
Overview
• Some words about hydrodynamics
• SPH – The Standard Implementation
• Modifications and Extensions
• Some Caveats
Hydrodynamics:
• text books on hydrodynamics
◦ Landau & Lifshitz, Volume VI - Hydrodynamics
◦ Landau & Lifshitz, Volume X - Kinetic theory
◦ Reichl, A modern course in statistical physics, Wiley, New York (1998)
◦ Shu, The physics of astrophysics 2, Univ. Sc. Books, Mill Valley (1992)
• derivation
◦ gases and fluids are large ensembles of interacting particles
◦ −→ state of system is described by location in 6N dimensional
phase space f (N )(~q1...~qN , p~1...~pN )d~q1...d~qN d~p1...d~pN
◦ time evolution governed by ‘equation of motion’ for 6N -dim
probability distribution function f (N )
◦ f (N ) → f (n) by integrating over all but n coordinates −→
BBGKY hierarchy of equations of motion (after Born, Bogoli-
ubov, Green, Kirkwood and Yvon)
◦ physical observables are typically associated with 1- or 2-body
probability density f (1) or f (2)
◦ at lowest level of hierarchy: 1-body distribution function de-
scribes the probability of finding a particle at time t in the vol-
ume element d~q at ~q with momenta in the range d~p at p~.
◦ Boltzmann equation – equation of motion for f (1)
df ∂f ˙ ~
≡ + ~q · ∇q f + p~˙ · ∇
~p f
dt ∂t
∂f ~q f + F~ · ∇ ~p f = fc .
= + ~v · ∇
∂t
Hydrodynamics:
• derivation
◦ Boltzmann equation
df ∂f ˙ ~
≡ + ~q · ∇q f + p~˙ · ∇
~p f
dt ∂t
∂f ~q f + F~ · ∇ ~p f = fc .
= + ~v · ∇
∂t
→ first line: transformation from comoving to spatially fixed
coordinate system.
→ second line: velocity ~v = ~q˙ and force F~ = p~˙
→ all higher order terms are ’hidden’ in the collision term fc
∂ ~ ~ ~
Z
nhξii + ∇q (nhξi~v i) + nF h∇p ξii = ξifc d~p
∂t
(Maxwell-Boltzmann transport equation for hξii)
Eulerian Lagrangian
dρ ∂ρ ~ = −ρ∇
~ · ~v
= + ~v · ∇ρ (continuity equation)
dt ∂t
d~v ∂~v ~ 1~ ~ ~ 2 η! ~ ~
= + (~v · ∇)~v = − ∇p − ∇φ + η ∇ ~v + ζ + ∇(∇ · ~v )
dt ∂t ρ 3
(Navier-Stokes equation)
d ∂ ~ = T ds − p ∇
~ · ~v
= + ~v · ∇ (energy equation)
dt ∂t dt ρ
~ 2φ = 4πGρ
∇ (Poisson’s equation)
~2
B 1 ~ ~ ~
~ ~
FB = −∇ + (B · ∇)B (magnetic force)
8π 4π
∂B~
~ × (~v × B)
=∇ ~ (Lorentz equation)
∂t
• concept of SPH
◦ ‘invented’ independently by Lucy (1977) and Gingold & Mon-
aghan (1977)
◦ originally proposed as Monte Carlo approach to calculate the
time evolution of gaseous systems
◦ more intuitively understood as interpolation scheme:
The fluid is represented by an ensemble of particles i, each
carrying mass mi, momentum mi~vi, and hydrodynamic
properties (like pressure pi, temperature Ti, internal energy
i, entropy si, etc.). The time evolution is governed by
the equation of motion plus additional equations to modify
the hydrodynamic properties of the particles. Hydrodynamic
observables are obtained by a local averaging process.
SPH Basics:
• properties of local averaging processes
◦ local averages hf (~r)i for any quantity f (~r) can be obtained by
convolution with an appropriate smoothing function W (~r, ~h):
f (~r 0)W (~r − ~r 0, ~h) d3r0 .
Z
hf (~r)i ≡
(shown by integrating by parts and assuming that the surface term vanishes; if the solution space is
extended far enough, either the function f itself or the kernel approach zero)
→ Gaussian kernel:
2
1 r
W (r, h) = 3/2 3 exp −
h2
π h
· pro: mathematically sound
· pro: derivatives exist to all orders and are smooth
· contra: all particles contribute to a location
→ spline functions with compact support
→ the standard kernel: cubic spline
with ξ = r/h it is defined as
1 − 32 ξ 2 + 34 ξ 3, for 0 ≤ ξ ≤ 1;
1
1
(2 − ξ)3,
W (r, h) ≡ 3 4 for 1 ≤ ξ ≤ 2;
πh
0,
otherwise.
· pro: compact support −→ all interactions are zero for
r > 2h −→ number of particles involved in the average
remains small (typically between 30 and 80)
· pro: second derivative is continuous
· pro: dominant error term is second order in h
→ in principle different kernel functions could be used for dif-
ferent equations (but it brings no obvious advantage, except
maybe in the case of XSPH)
→ specialized kernels can be constructed for different types of
problems
SPH Basics:
• variable smoothing length h
◦ spatial resolution of SPH is limited by h, the scale over which
forces and physical properties are smeared out
◦ to make optimum use of the Lagrangian nature of SPH one has
to allow for variations of h: in high-density regions h should be
small, in regions of low density h should be large
◦ the optimum value of h is such that every particle has ∼ 50
neighbors within the smoothing volume
◦ caveats:
→ introduction of additional errors (the Taylor series now con-
~
tains contributions from ∇h, furthermore time derivatives
∂h/∂t occur); however, these errors are of second or higher
order and thus the same as the one inherent to SPH anyway
→ modification of the kernel gradient
~ 0 ~ 0
∂ 0 ~
∇W (|~r−~r |, h) = ∇W (|~r−~r |, h)h+ W (|~r−~r |, h)∇h~r
∂h
the new term is ∝ ∇h ~ and becomes important only if the
smoothing length varies on scales less than the smoothing
lengths itself −→ it is generally neglected (see Nelson &
Papaloizou 1994).
◦ equation of ‘motion’ for h can be coupled to the density: from
h = h0 (ρ0/ρ)3 it follows from using the continuity equation
dh 1 h dρ 1 ~
=− = h ∇·~v (1)
dt 3 ρ dt 3
alternative methods exist (see e.g. Steinmetz & Müller 1993)
SPH Basics:
• the fluid equations in SPH
◦ there is an infinite number of possible SPH implementations of
the hydrodynamic equations!
◦ some notation: hij = (hi +hj )/2, ~rij = ~ri −~rj , ~vij = ~vi −~vj , and
~ i is the gradient with respect to the coordinates of particle i;
∇
all measurements are taken at particle positions (e.g. ρi = ρ(~ri))
◦ general form of SPH equations:
Ni mj
hfii = fj W (rij , hij )
X
j=1 ρj
j=1
dρi Ni
or =
X
~ iW (rij , hij )
mj~vij · ∇
dt j=1
(the second implementation is almost never used, see however
Monaghan 1991 for an application to water waves)
important
density is needed for ALL particles BEFORE computing
other averaged quantities −→ at each timestep, SPH com-
putations consist of TWO loops, first the density is obtained
for each particle, and then in a second round, all other par-
ticle properties are updated.
= + (~v · ∇)~ ~ = −∇
~ v = − ∇p ~ (∗)
dt ∂t ρ ρ ρ 2
~
here, the identity ∇(pρ −1
) = ρ−1∇p ~ is used
~ − pρ−2∇ρ
→ in the SPH formalism this reads as
d~vi Ni pi pj ~
=− mj + ∇iW (rij , hij )
X
ρ2i ρ2j
dt j=1
j=1
where the viscosity tensor Πij is defined by
(−αcij µij + βµ2ij )/ρij for ~vij · ~rij ≤ 0 ,
Πij = 0 for ~vij · ~rij > 0 ,
where
h~vij · ~rij
µij = 2 .
~rij + 0.01h2
with ~rij = ~ri − ~rj , ~vij = ~vi − ~vj , mean density ρij =
(ρi + ρj )/2, and mean sound speed cij = (ci + cj )/2.
◦ instead of the artithmetic mean for the quantity p/ρ2 use the
geometric one:
√
pi pj
1 pi pj
+ −→
2 ρ2i ρ2j
ρi ρj
dt j=1 ρij
where η ≈ 0.5.
◦ this allows for a strongly reduced artificial viscosity term −→
reach higher Reynolds numbers when modeling interstellar tur-
bulence
◦ XSPH also allows for the introduction of the Cassama-Holm
subgrid model of turbulence (Monaghan 2002 – astro-ph/0204118)
Modifications of SPH:
• alternative formulations of viscosity
◦ Balsara viscosity:
→ standard viscosity generates entropy in shear flows (Balsara
1989)
→ add a correction term ∝ ∇~ × ~v
→ new viscosity:
(−αcij µij + βµ2ij )/ρij for ~vij · ~rij ≤ 0 ,
Πij =
0 for ~vij · ~rij > 0 ,
where now
h~vij · ~rij fi + fj
µij =
~rij2 + 0.01h2 2
with
~ · ~v |i
|∇
fi =
~ · ~v |i + |∇
|∇ ~ × ~v |i + 0.0001ci/h
where
hi ∂ρi
fi = 1 +
3ρi ∂hi