Smoothed particle hydrodynamics (SPH) - Yale University · Smoothed particle hydrodynamics (SPH)...
Transcript of Smoothed particle hydrodynamics (SPH) - Yale University · Smoothed particle hydrodynamics (SPH)...
Smoothed particle hydrodynamics (SPH)
Invented by Lucy (1977) and Gingold & Monaghan (1977)
Particlebased method for hydrodynamics:● Particles are moving interpolation centers for fluid quantities
SPH Eulerian gridbased hydro
Popular in astrophysics because:
● It is a Lagrangian scheme (resolution automatically adapts to density)● It is easy to implement on top of an existing Nbody code
w(x)
x
w(x)
x
(x)
SPH basics
Each particle is “tagged” with fluid quantities in addition to its position x:
Each quantity has an associated time update equation (an ODE).Spatial gradients in these equations are computed with the aid of a smoothing kernel W(x–x
i, h
i) with a characteristic scale h:
such that
Typically each particle carries its own value of h. The value is adjusted to keep the same number of particles (or amount of mass) in the volume h3.
mass smoothing lengthdensity compositionpressure ...velocity
A I x≡∫ A x ' W x−x ' , h d x '≈ AS x≡∑p
m p
Ap
p
W x−xp , hp
∫W x−x ' , hd x=1limh0
W x−x ' , h= x−x '
x
y
z
x
SPH smoothing kernels
Gaussian kernel (Gingold & Monaghan 1977)
Spline kernel (Monaghan & Lattanzio 1986)
where d = # of dimensions and = 2/3 (1D), 10/7 (2D), 1/ (3D)
Advantages of spline kernel:
● Compact support (interactions ≡ 0 for r > 2h)● Continuous second derivative (less sensitive to particle shot noise)● Dominant error term in integral interpolant is O(h2)
As usual, the faster the Fourier transform of W falls off with k, the better...
W x , h=1
h e− x2 /h2
W x , h=hd {1−
32 x
h 2
34 x
h 3
if 0≤xh≤1
14 [2− x
h ]3
if 1≤xh≤2
0 otherwise
SPH equations – energy formulation
Asymmetric gradient formulations such as
do not conserve momentum; typically the gradient is symmetrized via
so the momentum equation becomes
The continuity equation can be written
or
p ∇ Pp=∑q
m qPq−Pp∇ pW pq , ∇ p W pq≡∇ xpW xq−x p , h p
∇ P
=∇ P P
2 ∇
d vp
dt=−∑
qmq Pq
q2
P p
p2 ∇ p W pq
p=∑q
m q W pq
d p
dt=∑
q
mq v p−vq∇ p W pq
SPH equations – energy formulation – 2
The symmetrized specific internal energy equation
can be written
The particles are moved via
Choice of symmetrization (e.g., arithmetic, geometric, or none at all) makes little difference as the number of particles ∞
However, can be important in poorly resolved situations (Springel & Hernquist 2002)
d dt
=−P ∇⋅v=−∇⋅ P v
v⋅∇ P
d p
dt=
12∑q
mq Pq
q2
P p
p2 vp−vq⋅∇ p W pq
d x p
dt=v p
Artificial viscosity in SPH
In order to represent shocks, SPH requires the use of artificial viscosity (as with the “classic” finitedifference methods).
The form that is often used is
where
and
Fudge factors ~ 1, ~ 2, ~ 0.1h (unless physical viscosity is used)
d vp
dt=−∑
qmq Pq
q2
P p
p2 pq∇ p W pq
pq=h v p−vq⋅ xp−xq
∣xp−xq∣22
pq={− c pqpq pq2
pq
vp−vq⋅ xp−xq0
0 vp−vq⋅ xp−xq0
––
Varying the smoothing kernel size
Efficiency and usefulness of SPH are maximized when each particle is allowed to have its own smoothing kernel size h
p.
Typically hp is chosen so that the number of particles within h
p stays roughly
constant (as with adaptive particlemesh) – so it gets smaller in highdensity regions.
Typically hp is taken to satisfy
The SPH equations then must use symmetrized kernels to ensure conservation of mass, momentum, and energy:
or
dh p
dt=−
h p
p d
d p
dt, d=# of dimensions
W pq12 [W xp−xq , h pW xp−xq , hq ]
W pqW x p−xq ,12hphq
SPH equations – entropy formulation
An alternative formulation is the entropy formulation (Hernquist 1993):
In adiabatic flow we have dA/dt = 0; the specific internal energy is inferred from
With artificial viscosity added, we have
showing that entropy is generated only in shocks.
In general:
● Energy formulation does poor job of conserving entropy● Entropy formulation does poor job of conserving energy
In continuum limit both formulations give the correct answers, but for finite numbers of particles the two approaches are not equivalent.
P=A s
=A s−1
−1
dAp
dt=
12−1
p−1 ∑
q
mq pqv p−vq⋅∇ p W pq
SPH equations – conservative formulation
Springel & Hernquist (2002) find that standard formulations' treatment of entropy is poor enough that when radiative cooling is included, SPH significantly overestimates amount of cooled gas:
● Excessive broadening of shock fronts allows gas to cool more than it would otherwise (since (T) increases with decreasing T at low temperatures)
● Density estimates for hot gas in contact with cool, dense gas will be biased high, again increasing cooling rate
They propose an alternative formulation that explicitly conserves both energy and entropy (in adiabatic flow): start with Lagrangian
The independent variables are
So thermal energy is treated as a “potential,” and smoothing length is a dynamical variable.
L q , q=12∑p=1
N
m p x p2−
1−1 ∑p=1
N
m p App−1..
q≡x1 ,... , xN , h1 ,... , hN
SPH equations – conservative formulation – 2
Smoothing lengths hp are chosen by requiring a fixed amount of mass M
sph (not
number of neighbors) within a smoothing volume: leads to the N constraints
The equations of motion are then
where the Lagrange multipliers are
Thus
pq≡43
h p3 p−M sph=0
ddt
∂L∂q p
−∂L∂ qp
=∑r=1
N
r
∂r
∂q p.
p=3
4mp
h p3
Pp
p2 [13p
h p ∂p
∂ hp−1]−1
m p
d vp
dt=−∑
r=1
N
mr
P r
r2 [1 hr
3r
∂r
∂ hr]−1
∇ pr
SPH equations – conservative formulation – 3
The density gradient can be written
so the velocity update equation finally becomes
Together with the entropy formulation, this velocity update method gives automatic conservation of linear and angular momentum, energy, and entropy.
Artificial viscosity in the standard form is subtracted from the velocity update and added to the entropy update to allow for shocks.
∇ pr=m p∇ pW pr hr pr∑s=1
N
m s∇ pW sp h p
d vp
dt=−∑
r=1
N
mr [ f p
Pp
p2 ∇ pW pr hp f r
P r
r2 ∇ pW prhr]
f p≡[1 hp
3p
∂p
∂h p]−1
Intermission
Performance of SPH on hydro problems
Springel & Hernquist (2002)
Springel & Hernquist (2002)
Performance of SPH on hydro problems – 3
Performance of SPH on hydro problems – 4
Performance of SPH on hydro problems – 5
Steinmetz & Müller (1993) concluded:
1. SPH can get accurate results for problems including strong shocks.
2. In 3D SPH requires at least ~ several x 104 particles to get reasonable results on shock problems (comparable to finitedifference methods).
3. Using tree data structures for gravity solver and for finding nearest neighbors makes SPH much more complicated than original SPH method, and of comparable complexity to Godunovbased Eulerian schemes, but not as complex as AMR.
4. From shot noise arguments we might expect resolution of SPH to be no better than N1/2 per dimension. But results in 3D are better than one would expect from this argument.
Adaptive SPH (Shapiro et al. 1996; Owen et al. 1998)
Uses an anisotropic smoothing kernel to capture quasi1D flows (such as cosmological pancakes)
Smoothing length scalar h becomes a smoothing tensor H – local velocity field determines orientation of principal axes and smoothing lengths along them
Works best in irrotational flow (∇×v = 0)