Beruflich Dokumente
Kultur Dokumente
A Primer
Wilhelm Kley
Institut fur Astronomie & Astrophysik
& Kepler Center for Astro and Particle Physics Tubingen
+ (~u ) = 0 (1)
t
(~u )
+ (~u ~u ) = p + ~k (2)
t
()
+ (~u ) = p~u (3)
t
p = ( 1) (4)
Using this and eq. (3), we can rewrite the energy equation as an equation
for the pressure
p
+ (p~u ) = ( 1)p ~u (5)
t
W. Kley Numerical Hydrodynamics: A Primer Bad Honnef 2016 2
Hydrodynamics: Reformulating
Expanding the divergences on the left side and use for the momentum and
energy equation the continuity equation
+ (~u ) = ~u (6)
t
~u 1
+ (~u )~u = p + ~k (7)
t
p
+ (~u )p = p~u (8)
t
Since all quantities depend on space (~r ) and time (t), for example (~r , t), we
can use for the left side the total time derivative (Lagrange-Formulation). For
example, for the density one obtains
D
= + (~u ) = ~u . (9)
Dt t
The Operator
D
= + ~u (10)
Dt t
is called material derivative (equivalent to the total time derivative, d/dt).
W. Kley Numerical Hydrodynamics: A Primer Bad Honnef 2016 3
Hydrodynamics: Lagrange-Formulation
Use now the material derivative
D
= ~u (11)
Dt
D~u 1
= p + ~k (12)
Dt
Dp
= p~u (13)
Dt
These equations describe the change of the quantities in the
comoving frame = Lagrange-Formulation.
For the Euler-Formulation, one analysed the changes at a specific,
fixed point in space !
The Lagrange-Formulation can be used conveniently for
1D-problems, for example the radial stellar oscillations, using
comoving mass-shells.
For the Euler-Formulation a fixed grid is used.
W. Kley Numerical Hydrodynamics: A Primer Bad Honnef 2016 4
Numerical Hydrodynamics: The problem
Consider the evolution of the full time-dependent hydrodynamic equations.
The non-linear partial differential equations of hydrodynamics will be solved
numerically Continuum Discretisation
moving Grid/Particle
fixed Grid - flow moved grid
- matter flows through grid
d ~u
~u
= p
+ ~u ~u = p dt
t Well known method:
Methods: Smoothed Particle Hydrodynamics, SPH
finite differences
non-conservative
Control Volume
conservative
Riemann-solver
wave properties smeared out particles
Problem: Discontinuities good for free boundaries, self-gravity
W. Kley Numerical Hydrodynamics: A Primer Bad Honnef 2016 6
Numerical Hydrodynamics: consider: 1D Euler equations
describe conservation of mass, momentum and energy
u
+ = 0 (14)
t x
u uu p
+ = (15)
t x x
u u
+ = p (16)
t x x
: density
u: velocity
p: pressure
: internal specific energy (Energy/Mass)
with the equation of state
p = ( 1) (17)
: adiabatic exponent
partial differential equation in space and time
need discretisation in space and time.
W. Kley Numerical Hydrodynamics: A Primer Bad Honnef 2016 7
Numerical Hydrodynamics: Discretisation
j1 j j+1 X
= L((x, t)) (18)
t
with a (spatial) differential operator L.
typical Discretisation (1. order in time), at time: t = t n = nt
(t + t) (t) n+1 n
= = L( n ) (19)
t t t
now at a special location, the grid point xj (with moving terms)
~
A ~ + L2 (A)
= L1 (A) ~ (21)
t
~ i = 1, 2 individul (Differential-)operators
Li (A),
~ = (, u, ).
applied to the quantities A
Here, for 1D ideal hydrodynamics
L1 : Advection
~1
A ~ n + tL1 (A
= A ~ n)
~ n+1
A ~2
=A ~ 1 + tL2 (A
= A ~ 1) (22)
u
=
t x
(u) (uu)
=
t x
() (u)
=
t x
In explicit conservation form
~u ~f (~u )
+ =0 (23)
t x
energy equation
p u
= (26)
t x
pj uj+1 uj
n+1
j = j t for j = 1, N (27)
n+1
j
x
on the right hand side we use the actual values for u, and p, i.e.
here u 1 , p1 , 1 .
This step yields: u 1 u n+1 , 1 n+1
W. Kley Numerical Hydrodynamics: A Primer Bad Honnef 2016 12
Numerical Hydrodynamics: Model equation for advection
The continuity equation was
u
+ =0 (28)
t x
Here f (x) is the initial condition at time t = 0, that is shifted by the advection
with a constant velocity a to the right.
The numerics should maintain this property as accurately as possible.
W. Kley Numerical Hydrodynamics: A Primer Bad Honnef 2016 13
Numerical Hydrodynamics: Linear Advection
FTCS: Forward Time Centered Space algorithm
+a =0 (30)
t x
j1 j j+1
Fin n
= a j1 (37) purple regions will be trans-
ported into the next neighbour
Fout = a jn (38)
cell
Upwind-Method
Information comes from upstream
W. Kley Numerical Hydrodynamics: A Primer Bad Honnef 2016 15
Numerical Hydrodynamics: Upwind-Method II
Extension for non-constant states a t
at I (x)
Fin = a I xj1/2 (39)
2
Often used is the 2nd Order Upwind (van Leer) Geometric Mean
(maintains the Monotonicity)
(j+1 j )(j j1 )
2 (j+1 j1 )
if (j+1 j )(j j1 ) > 0
j =
0 otherwise
(42)
The derivatives are evaluated at the corresponding time step level
or the intermediate time step
1 n n+1/2
n
n
j + j+1
j+1/2 = j+1 jn (43)
2 2
The corrector-step (to new time t n+1 )
n+1/2 n+1/2
jn+1 = jn j+1/2 j1/2 (44)
0.8
Phi-Achse
Width 0.6 in the intervall [1, 1] 0.4
velocity a = 1, until t = 40
0.2
periodic boundaries
= at/x = 0.8 - (Courant no.) 0
-1 -0.5 0 0.5 1
X-Achse
0.8
1
0.8
0.6
Phi-Achse
Phi-Achse
0.6
0.4
0.4
0.2
0.2 0
-0.2
0 -0.4
-1 -0.5 0 0.5 1 -1 -0.5 0 0.5 1
X-Achse X-Achse
jn = V n eij (45)
here, is defined through grid size x and the total length L
2x
= (46)
L
Consider simple Upwind method with = at/x
jn+1 jn + (jn j1
n
)=0 (47)
Substituting eq. (45)
h i
V n+1 eij = V n eij + V n ei(j1) eij
jn+1 jn + (jn j1
n
)=0 (51)
substitute differences by derivatives, i.e. Taylor-series (up to 2. order)
1 2
1 2 3
t + t +O(t )+ x x +O(tx 2 ) = 0
2
t 2 t x 2 x 2
(52)
divied by t, and substitute for
2
1
+a + t a 2 x + O(t 2 ) + O(x 2 ) = 0 (53)
t x 2 t x
Use wave equation tt = a2 xx modified equation (index M)
M M 1 2 M
+a = ax (1 ) (54)
t x 2 x 2
The FDE adds a new diffusive term to the original PDE
W. Kley Numerical Hydrodynamics: A Primer Bad Honnef 2016 22
Numerical Hydrodynamics: Modified Equation II
with the diffusion coefficient
1
D= ax (1 ) (55)
2
Note: only for D > 0 this is a diffusion equation, and it follows < 1
for stability. (Hirt-method). For Upwind-Method D > 0 Diffusion.
Lax-Wendroff yields
M t 2 a 2 3
+a M = 1 M
(56)
t x x 3
The equation has the form
t + ax = xxx (57)
2
t a 2
1= (58)
This implies Dispersion. Here: waves are too slow ( < 0)
Oscillations behind the diskontinuity (cp. square function)
W. Kley Numerical Hydrodynamics: A Primer Bad Honnef 2016 23
Numerical Hydrodynamics: The time step
From the above analysis: the time step t has to be limited for a
stable numerical evolution.
For the linear Advection (with the velocity a) we find
x
t < (59)
a
In the more general case the sound speed has to be included and it
follows the Courant-Friedrich-Lewy-condition
x
t < (60)
cs + |~u |
physically this means that information cannot travel in one timestep
more than one gridcell. Typically one writes
x
t = fC (61)
cs + |~u |
with the Courant-Factor fC . For 2D situations: fC 0.5.
Only for impliciten methods there are (theoretically) no limitations of t.
W. Kley Numerical Hydrodynamics: A Primer Bad Honnef 2016 24
Numerical Hydrodynamics: Time step size - graphically
u u
t + x = 0 t + u x + x = 0
u uu p u u 1 p
t + x = x = t + u x + x = 0
u u p p u
t + x = p x t + u x + p x = 0
As Vector equation
W W
+A =0 (62)
t x
mit
u 0
W= u und A= 0 u 1/ (63)
p 0 p u
Equations are non-linear and coupled.
Try decoupling: Diagonalisation of A
Q1 AQ = (67)
We had
W W
+A =0 (68)
t x
and
Q1 AQ =
Define:
dv Q1 dW also dW = Qdv (69)
1
Multiply eq. (68) with Q
v v
+ =0 (70)
t x
v = (v0 , v+ , v ) are the charakteristic Variables: vi = const. in curves
dx
= i
dt
W. Kley Numerical Hydrodynamics: A Primer Bad Honnef 2016 30
Hydrodynamics: The variable v0
from the definitions
1
dv0 = d dp (71)
cs2
v0 v0
+ 0 =0 mit 0 = u (72)
t x
What is dv0 ?
From thermodynamics (1. Law) for specific quantities)
1 p 1
Tds = d + p d = d 2 d (73)
with p = ( 1), = cv T , = cp /cv it follows
cp dp cp
ds = d 2 = dv0 (74)
cs
s s
+u
= =0 (75)
t x
i.e. s is const. along stream lines, hence
ds
=0 (76)
dt
Diskontinuities
W. Kley Numerical Hydrodynamics: A Primer Bad Honnef 2016 33
Examples: Shocktube
Initial discontinuity in a tube at position x0 (one-dimensional)
Riemann-Problem Jump in pressure (p) and density
Bereich 2 Bereich 1
()
Diskontinuitt
P 2
Evolution:
- a shock wave to the right (X4 )
2
(supersonically ush > cs )
- a contact discontinuity
1
density jump (along X3 )
P1
- a rarefaction wave
x0 (between X1 and X2 )
Density
0.6
0.5
0.4
0.5
0.4
Green: Nume-
0.3
0.2 0.3 rics
0.1 0.2
0
0 0.2 0.4 0.6 0.8 1
0.1
0 0.2 0.4 0.6 0.8 1
The solution is:
1.15 1 self similar
1.1
1.05
0.9
0.8
obtained
through stret-
Temperature
1 0.7
Pressure
0.95 0.6
0.9 0.5 ching
0.85 0.4
0.8 0.3
0.75 0.2
0.7 0.1
0 0.2 0.4 0.6 0.8 1 0 0.2 0.4 0.6 0.8 1
X-Axis X-Axis
W. Kley Numerical Hydrodynamics: A Primer Bad Honnef 2016 35
Examples: Sedov-Explosion
An example for bomb explosions (Sedov & Taylor, 1950s), analytical solution (Sedov)
Basic setup for Supernovae-outbusts, e.g. estimate of the remnant size
Standard test problem of multi-dimensional hydrodynamics, e.g. for
x, y [0, 1] [0, 1]
Energy-Input at origin, E = 1, in = 1, = 1.4, 200 200 grid points
Here: solution with van Leer method (solve for total energy variable). Plotted: density
(Website)
W. Kley Numerical Hydrodynamics: A Primer Bad Honnef 2016 37
Examples: Ster formation: SPH
Molecular Cloud
Mass:
50 M
Diameter:
1.2 LJ = 76,000 AU
Temperature:
10 K
(Web-Link)
W. Kley Numerical Hydrodynamics: A Primer Bad Honnef 2016 42
Examples: Diesel Injection
Finite Volumen Method (FOAM)
Velocity, Temperature, Particles (+Isosurfaces) (Nabla Ltd, 2004)
.4
.2
0
y
.2
.4
.6
1 .8 .6 .4 .2 0 .2 .4 .6
x