lecture sheets: finite volume methods for hydrodynamics

76
Finite volume methods for HD Bochum, march 2008-1 Finite Volume Methods for Hydrodynamics Rony Keppens Centre for Plasma-Astrophysics, K.U.Leuven (Belgium) & FOM-Institute for Plasma Physics ‘Rijnhuizen’ & Astronomical Institute, Utrecht University Solaire postgraduate school, Bochum march 3-14 2008

Upload: others

Post on 09-Feb-2022

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Lecture sheets: Finite volume methods for hydrodynamics

Finite volume methods for HD Bochum, march 2008-1

Finite Volume Methods for Hydrodynamics

Rony KeppensCentre for Plasma-Astrophysics, K.U.Leuven (Belgium)

& FOM-Institute for Plasma Physics ‘Rijnhuizen’

& Astronomical Institute, Utrecht University

Solaire postgraduate school , Bochum march 3-14 2008

Page 2: Lecture sheets: Finite volume methods for hydrodynamics

Finite volume methods for HD Bochum, march 2008-2

Finite Volume Methods for hydrodynamics

Overview

• Linear hyperbolic systems and nonlinear scalar equations: Riemann problem,Burgers equation, shocks and rarefactions. Explicit time integration, CFL condition,TVD concept and TVDLF method.

• Finite Volume discretization: integral versus differential form, from 1D to multi-D.

• Euler equations: gas dynamics in 1D, solution of the Riemann problem. TVDLFsimulations.

• Roe solver for Euler equations: characteristic based shock-capturing schemes.Comparison with TVDLF.

Page 3: Lecture sheets: Finite volume methods for hydrodynamics

Finite volume methods for HD Bochum, march 2008-3

Linear Hyperbolic Systems

• constant coefficient linear system

~qt + A~qx = 0

⇒ with ~q(x, t) ∈ ℜm and matrix A ∈ ℜm×m

• hyperbolic when A is diagonalizable with real eigenvalues

⇒ strictly hyperbolic when distinct

⇒ m right eigenvectors + m real eigenvalues

A~rp = λp~rp with p : 1, . . . , m

Page 4: Lecture sheets: Finite volume methods for hydrodynamics

Finite volume methods for HD Bochum, march 2008-4

• write as

[A] [~r1 | ~r2 | . . . | ~rm] = [~r1 | ~r2 | . . . | ~rm]

λ1

λ2

. . .λm

⇒ or shorthand AR = R Λ with diagonal matrix Λ

⇒ matrix R with right eigenvectors as columns

• The solution to system ~qt + A~qx = 0 is equivalent to:

⇒ pre-multiply with R−1 or:

(R−1~q)t + R−1(R Λ R−1)~qx = 0

⇒ redefine ~v ≡ R−1~q to get

~vt + Λ~vx = 0

⇒ m independent constant coefficient linear advection equatio ns!

Page 5: Lecture sheets: Finite volume methods for hydrodynamics

Finite volume methods for HD Bochum, march 2008-5

• Each advection equation has trivial analytic solution:

vp(x, t) = vp(x − λpt, 0)

tλp

v(x,0) profile v(x,t) profilep p

⇒ analytic solution to the full linear hyperbolic system is

⇒ ~q(x, t) =∑m

p=1vp(x − λpt, 0)~rp

⇒ depends on initial data at m discrete points

⇒ superposition of m waves, advected independently without distortion

• nomenclature: ~v are ‘characteristic variables’

⇒ curves x = xo + λpt are “p-characteristics”

Page 6: Lecture sheets: Finite volume methods for hydrodynamics

Finite volume methods for HD Bochum, march 2008-6

The Riemann problem for a linear hyperbolic system

• Riemann Problem for linear hyperbolic system:

⇒ initial data ~q(x, 0) =

{~ql x < 0~qr x > 0

⇒ decompose initial data in terms of right eigenvectors as

~ql =m∑

p=1

αp~rp

~qr =m∑

p=1

βp~rp

• then at t = 0, characteristic variables are vp(x, 0) =

{αp x < 0βp x > 0

⇒ hence vp(x, t) =

{αp if x − λpt < 0βp if x − λpt > 0

Page 7: Lecture sheets: Finite volume methods for hydrodynamics

Finite volume methods for HD Bochum, march 2008-7

• the solution to the Riemann problem for linear hyperbolic system is then:

~q(x, t) =∑

all p where x−λpt<0

αp~rp +∑

all p where x−λpt>0

βp~rp

⇒ graphically illustrated for m = 3 with λ1 < λ2 < λ3

q

q

32

λ λλ

1

l

tt

x=0

Linear Hyperbolic System (m=3): solution to RP

x=

r

x= tx=

1 32

(β , α , α )

(β , β , β )(α , α , α )1 2 3

1 2 3

• constant states separated by discontinuities

⇒ traveling at characteristic speeds

⇒ Note: jumps are eigenvectors of matrix A

Page 8: Lecture sheets: Finite volume methods for hydrodynamics

Finite volume methods for HD Bochum, march 2008-8

Scalar nonlinear conservation law

• nonlinear scalar conservation law for u(x, t) written as

ut + (f(u))x = 0

• inviscid Burgers equation for f(u) = u2/2

⇒ quasi-linear form (assuming differentiability):

ut + uux = 0

⇒ characteristic speed from Jacobian, i.e. derivative, fu = u ≡ f ′(u)

⇒ similar to linear advection equation ut + v ux = 0 (fixed v), which has trivialsolution: u(x, 0) advected with speed v

Page 9: Lecture sheets: Finite volume methods for hydrodynamics

Finite volume methods for HD Bochum, march 2008-9

• Nonlinearity in inviscid Burgers ut + u ux = 0

⇒ advection with local speed u

• Consider t = 0 triangular pulse (width 2x0, height h0) given by

u(x, 0) =

u0 x ≤ −x0

u0 + h0x0+xx0

−x0 < x ≤ 0

u0 + h0x0−x

x00 < x ≤ x0

u0 x > x0

⇒ wave steepening and shock formation expected!

• tip of triangle experiences fastest rightward advection

⇒ conserving total area underneath triangle, front edge steepens.

• discontinuity forms at time ts = x0/h0

⇒ tip of triangle catches up rightmost point of front edge

⇒ discrete equivalent of conservation law across discontinu ity

⇒ Rankine-Hugoniot relation for left ul and right ur values

f(ul) − f(ur) = s (ul − ur)

Page 10: Lecture sheets: Finite volume methods for hydrodynamics

Finite volume methods for HD Bochum, march 2008-10

• for inviscid Burgers case, find shock speed s = (ul + ur)/2

• fully analytic solution to triangular pulse problem

⇒ after shock forms, base of triangle widens due to the speed difference betweenleft edge traveling with u0, and shocked right edge traveling at speed s(t). In accordwith conservation, the height of the triangle must therefore decrease in time.

t=0 pulse shock forms triangle widens, area conserving

⇒ Assignment: try different numerical schemes to simulate th is evolution

Page 11: Lecture sheets: Finite volume methods for hydrodynamics

Finite volume methods for HD Bochum, march 2008-11

The Riemann problem for Burgers

• specific initial condition separating 2 constant states

• Riemann problem for scalar conservation law

u = ul for x ≤ 0

u = ur for x > 0

• Rankine-Hugoniot states

f(ul) − f(ur) = s (ul − ur)

⇒ symmetric in arguments ul and ur

• For inviscid Burgers: only shock expected for ul > ur

⇒ extra condition for admissable shock: Lax entropy condition

f ′(ul) > s > f ′(ur)

⇒ shock speed between characteristic speeds of 2 states

⇒ characteristics ‘go into the shock’

p-shock

Ul Ur

p-characteristics

Page 12: Lecture sheets: Finite volume methods for hydrodynamics

Finite volume methods for HD Bochum, march 2008-12

• Rarefaction waves for Burgers equation

⇒ when ul < ur expect right state ‘runs away’ from left

⇒ try ‘centered simple wave’ u(ξ) = u(x/t)

⇒ conservation law translates into

f ′(u)du

dξ= ξ

du

⇒ rarefaction wave: for Burgers:

u(x, t) = u(x/t) =

ul x < ultx/t ult < x < urtur x > urt

⇒ u decreases (density: medium gets rarefied) when signal passes

Page 13: Lecture sheets: Finite volume methods for hydrodynamics

Finite volume methods for HD Bochum, march 2008-13

• Riemann problem for inviscid Burgers has two cases:

⇒ ρl > ρr: shock traveling at speed s = ρl+ρr

2

⇒ ρl < ρr: rarefaction wave ρ(x, t) = ρ(x/t) =

ρl x < ρltx/t ρlt < x < ρrtρr x > ρrt

⇒ Numerically with TVDLF scheme (see later):

Page 14: Lecture sheets: Finite volume methods for hydrodynamics

Finite volume methods for HD Bochum, march 2008-14

Numerical methods for nonlinear conservation law

• introduce spatial xi = i∆x and temporal tn = n∆t steps

⇒ try explicit scheme on Burgers, directly discretize ut + u ux = 0 to

un+1i − un

i +∆t

∆xun

i

(un

i − uni−1

)= 0

⇒ initial data [1, 1, 1, 0, 0, 0] remains solution to this scheme

⇒ WRONG !!!! should be traveling shock at speed s = 0.5

• reason: above scheme non-conservative (but ok for continuous data!)

⇒ conservative scheme is of form

Un+1i = U

ni −

∆t

∆x

[Fi+1/2 − Fi−1/2

]

⇒ numerical fluxes Fi+1/2: time-average fluxes over cell edges xi + 1

2∆x ≡ xi+1

2

Page 15: Lecture sheets: Finite volume methods for hydrodynamics

Finite volume methods for HD Bochum, march 2008-15

Explicit time integration

• calculate fluxes (and sources) from known time level tn

• Explicit: ∆t restricted by Courant, Friedrichs, Lewy conditiondomain of dependence of discretization must includePDE domain of dependence

⇒ ∆t ≤ crossing time of cells by fastest wave

⇒ ∆t ≤ ∆x/cmax with maximal physical speed cmax

ix i+1xi-1x

t

Physical DOD

DependenceDomain of

Numerical

nt

n+1

x

t

Page 16: Lecture sheets: Finite volume methods for hydrodynamics

Finite volume methods for HD Bochum, march 2008-16

Lax-Friedrichs and Max-Cormack methods

• Better explicit discretization: first order Lax-Friedrichs

un+1i =

uni+1 + un

i−1

2− ∆t

2∆x

(fn

i+1 − fni−1

)

⇒ scheme is conditionally stable : restriction by CFL condition∣∣∣∣

∆t

∆xf ′(ui)

∣∣∣∣≤ 1

⇒ conservative scheme, identify numerical flux as

F LFi+1/2 =

1

2

{

fi+1 + fi −∆x

∆t[ui+1 − ui]

}

• first order accuracy: local truncation error ∝ ∆t

Page 17: Lecture sheets: Finite volume methods for hydrodynamics

Finite volume methods for HD Bochum, march 2008-17

• another, multilevel method: two-step MacCormack method:

‘predictor’: u∗i = un

i −∆t

∆x(fn

i+1 − fni )

‘corrector’: un+1i = 1

2(uni + u∗

i ) − 12

∆t

∆x

(f∗

i − f∗i−1

)

⇒ step size in predictor now ∆t

⇒ second order accurate: local truncation error ∝ ∆t2

• Numerically simulate triangular pulse for Burgers

⇒ in agreement with theory, except for the ‘wiggles’

Page 18: Lecture sheets: Finite volume methods for hydrodynamics

Finite volume methods for HD Bochum, march 2008-18

• MacCormack method: dispersive

⇒ manifests Gibbs phenomenon : for linear advection of discontinuity

⇒ non-monotonicity preserving : monotone u(x, 0) develops extrema

Page 19: Lecture sheets: Finite volume methods for hydrodynamics

Finite volume methods for HD Bochum, march 2008-19

Total Variation Diminishing concept

• total variation of function u(x) on domain [0, 1] defined as

TV (u) ≡∫ 1

0

|du

dx| dx

⇒ total variation of numerical approximation of u

TV (un) =

N∑

i=0

|uni+1 − un

i |

• scheme is total variation diminishing (TVD) in time if

TV (un+1) ≤ TV (un) ∀n

⇒ solution scalar conservation law has TVD property ∀t2 > t1

TV (u(x, t2)) ≤ TV (u(x, t1))

Page 20: Lecture sheets: Finite volume methods for hydrodynamics

Finite volume methods for HD Bochum, march 2008-20

• a TVD scheme is clearly monotonicity preserving!

⇒ a new local extremum would raise TV

• Harten: any scheme written in general form

un+1i = un

i + Ai+1/2 (uni+1 − un

i )︸ ︷︷ ︸∆un

i+1/2

−Bi−1/2

(un

i − uni−1

)

︸ ︷︷ ︸∆un

i−1/2

⇒ is TVD when coefficients Ai+1/2 and Bi−1/2 obey

Ai+1/2 ≥ 0

Bi−1/2 ≥ 0

0 ≤ Ai+1/2 + Bi+1/2 ≤ 1

Page 21: Lecture sheets: Finite volume methods for hydrodynamics

Finite volume methods for HD Bochum, march 2008-21

• first order Lax-Friedrichs scheme is TVD , since rewrites as

un+1i = un

i +1

2

(

1 − ∆t

∆x

fni+1 − fn

i

∆ui+1

2

)

∆ui+1

2

− 1

2

(

1 +∆t

∆x

fni − fn

i−1

∆ui−1

2

)

∆ui−1

2

⇒ TVD requirements translate to CFL condition∣∣∣∣

∆t

∆x

fni+1 − fn

i

uni+1 − un

i

∣∣∣∣≤ 1

⇒ generalize Lax-Friedrichs scheme to second order, keep TVD property

Page 22: Lecture sheets: Finite volume methods for hydrodynamics

Finite volume methods for HD Bochum, march 2008-22

TVDLF scheme

• Recall: numerical flux for first-order Lax-Friedrichs is

F LFi+1/2 =

1

2

{

fi+1 + fi −∆x

∆t[ui+1 − ui]

}

⇒ can improve scheme by changing to Local Lax-Friedrichs flux

F LLFi+1/2 =

1

2

{

fi+1 + fi − |αi+1

2

| [ui+1 − ui]}

⇒ αi+1/2 =fn

i+1−fni

uni+1

−uni, proxy for local characteristic speed f ′(u)

⇒ still in accord with TVD, if CFL condition satisfied

Page 23: Lecture sheets: Finite volume methods for hydrodynamics

Finite volume methods for HD Bochum, march 2008-23

• turn into second order accurate TVDLF scheme by

⇒ use predictor-corrector approach (raise temporal accuracy)

⇒ use some form of linear interpolation in space (but keep TVD!)

• Numerically simulate triangular pulse for Burgers

⇒ Riemann problem for ul > ur

⇒ Riemann problem for ul < ur

Page 24: Lecture sheets: Finite volume methods for hydrodynamics

Finite volume methods for HD Bochum, march 2008-24

TVDLF scheme

• Robust, general scheme to ANY hyperbolic system, ensures TVD (for sc alar)

⇒ Predictor-corrector approach for temporal advance

Un+1/2 = U

n +∆t

2[−∇ · F(Un) + S(Un)]

Un+1 = U

n + ∆t[

−∇ · F(Un+1/2) + S(Un+1/2)]

⇒ CFL condition links ∆t with ∆x (explicit scheme)

• slope limited linear reconstruction and flux expression

Fi+1

2

=1

2

{

F(ULi+1

2

) + F(URi+1

2

)− | cmax(U

Li+1

2

+ URi+1

2

2) |[

URi+1

2

− ULi+1

2

]}

⇒ scalar cmax denotes maximal physical propagation speed

⇒ for 1D HD cmax is |vx| plus sound speed, for MHD cmax = |vx| + cf

Page 25: Lecture sheets: Finite volume methods for hydrodynamics

Finite volume methods for HD Bochum, march 2008-25

Integral form of conservation law

• consider cell [x1, x2] and quantity u(x, t) within cell

⇒ flux over cell edge f(u) changes total mass from t1 to t2 by∫ x2

x1

u(x, t2) dx =

∫ x2

x1

u(x, t1) dx +

∫ t2

t1

f(x1, t) dt −∫ t2

t1

f(x2, t) dt

⇒ integral form of scalar conservation law

ut + (f(u))x = 0

• integral form more general: allows for discontinuous solut ions

⇒ differential form assumes differentiable functions

Page 26: Lecture sheets: Finite volume methods for hydrodynamics

Finite volume methods for HD Bochum, march 2008-26

• Finite Volume method in 1D for system of conservation laws

⇒ interpret Ui as average value of U(x, t) in [xi−1/2, xi+1/2]:

Ui(t) ≡1

∆xi

∫ xi+1/2

xi−1/2

U(x, t) dx ,

xix

’cell interfaces’

i-1 xi+1x xi+1/2i-1/2xi-3/2 xi+3/2

u(x)

uiui-1

i+1u

cell

⇒ update volume averages by

dUi

dt+

1

∆xi

(Fi+1/2 − Fi−1/2

)= 0 .

⇒ discretized equation is integral law, weak solutions obey conservation

Page 27: Lecture sheets: Finite volume methods for hydrodynamics

Finite volume methods for HD Bochum, march 2008-27

Finite Volume on unstructured grids

• Finite volume approach: natural on general 2D and 3D unstructured grids��������� �������������� �����uiui�1 ui+1Siui+k PPPPPq um(ui;ui+1)• multidimensional set of conservation laws

∂U

∂t+ ∇ · F = 0

⇒ in 3D, the ∇ · F with three Cartesian coordinate axes

∇ · F =∂Fx

∂x+

∂Fy

∂y+

∂Fz

∂z

Page 28: Lecture sheets: Finite volume methods for hydrodynamics

Finite volume methods for HD Bochum, march 2008-28

• discretize space in control volumes Vi

⇒ bounding surfaces ∂Vi, unit normal n = (nx, ny, nz)

d∫

ViU(x, t) dx

dt= −

∂Vi

F · n dS

= −∫

∂Vi

(Fxnx + Fyny + Fznz) dS

⇒ introduce (8 × 8 for MHD) matrix T (n) which rotates vector quantities to localorthogonal coordinate system n, t, s ≡ n×t, where latter are tangential unit vectorswithin ∂Vi

1 0 0 0 0 0 0 00 sin θ cos ϕ sin θ sin ϕ cos θ 0 0 0 00 cos θ cos ϕ cos θ sin ϕ − sin θ 0 0 0 00 − sin ϕ cos ϕ 0 0 0 0 00 0 0 0 1 0 0 00 0 0 0 0 sin θ cos ϕ sin θ sin ϕ cos θ0 0 0 0 0 cos θ cos ϕ cos θ sin ϕ − sin θ0 0 0 0 0 − sin ϕ cos ϕ 0

.

Page 29: Lecture sheets: Finite volume methods for hydrodynamics

Finite volume methods for HD Bochum, march 2008-29

• HD and MHD equations must be unchanged under rotation

Fxnx + Fyny + Fznz = T−1(n)Fx (T (n)U)

⇒ obtain essentially 1D problem in direction normal to volume boundary

d∫

ViU(x, t) dx

dt= −

∂Vi

T−1(n)Fx (T (n)U) dS

• control volumes with multiple, flat surface segments

⇒ integral over boundary into discrete sum over its sides

⇒ only information of grid: volumes Vi, and geometry of cells: number ofbounding surface segments, their surface area and their nor mal directions.

Page 30: Lecture sheets: Finite volume methods for hydrodynamics

Finite volume methods for HD Bochum, march 2008-30

The Euler equations

• conservation laws for 1D dynamics of compressible gas

ρt + (ρ v)x = 0mt + (mv + p)x = 0et + (e v + p v)x = 0

• vector of conserved quantities U =

ρme

⇒ total energy density related to pressure by

e =ρv2

2︸︷︷︸kinetic

+p

γ − 1︸ ︷︷ ︸

thermal energy

⇒ ratio of specific heats γ

Page 31: Lecture sheets: Finite volume methods for hydrodynamics

Finite volume methods for HD Bochum, march 2008-31

• internal energy considerations

⇒ specific (≡ per unit mass) internal energy esi

⇒ ρesi = p/(γ − 1)

• for ideal gas: temperature defined as p = RρT with gas constant R⇒ es

i (T ) = RTγ−1

=(cp−cv)T

cpcv−1

= cvT

⇒ cv specific heat at constant volume

• generally γ = α+2α , where α is the total number of degrees of freedom over which

internal energy can be distributed

⇒ for molecules: translational, rotational, vibrational

⇒ monoatomic gas: only 3 translational DOF → γ = 5/3

Page 32: Lecture sheets: Finite volume methods for hydrodynamics

Finite volume methods for HD Bochum, march 2008-32

• deduce equation for ‘entropy’ s = pρ−γ

∂s

∂t+ v

∂s

∂x= 0

⇒ since v(x, t): Not in conservation form!

⇒ like advection equation

⇒ s constant along characteristics dxdt = v: Riemann Invariant

• equivalent to the ‘characteristic’ equation

⇒ along dxdt

= v, find

dp − c2s dρ = 0

⇒ with dp = pt dt + px dx and c2s = γp/ρ

Page 33: Lecture sheets: Finite volume methods for hydrodynamics

Finite volume methods for HD Bochum, march 2008-33

• write system as Ut + (F (U ))x = 0 with flux vector

F =

mm2

ρ3−γ

2+ (γ − 1)e

emρ γ − γ−1

2m3

ρ2

⇒ Flux Jacobian becomes

∂F

∂U=

0 1 0m2

ρ2

γ−32

mρ (3 − γ) γ − 1

−γ emρ2 + (γ − 1)m3

ρ3

eγρ + (1 − γ)3

2m2

ρ2

mγρ

⇒ 3 eigenvalues/right eigenvectors

Page 34: Lecture sheets: Finite volume methods for hydrodynamics

Finite volume methods for HD Bochum, march 2008-34

• eigenvalue λ1 = mρ −

√γpρ = v − cs

⇒ eigenvector ~r1 =

1v − cs

v2

2 − vcs + c2s

γ−1

• eigenvalue λ2 = mρ

= v

⇒ eigenvector ~r2 =

1vv2

2

• eigenvalue λ3 = mρ

+√

γpρ

= v + cs

⇒ eigenvector ~r3 =

1v + cs

v2

2+ vcs + c2

s

γ−1

Page 35: Lecture sheets: Finite volume methods for hydrodynamics

Finite volume methods for HD Bochum, march 2008-35

• Rankine-Hugoniot relations for Euler system

F (Ul) − F (Ur) = s (Ul − Ur)

ml − mr = s(ρl − ρr)[m2

l

ρl

3−γ2

+ (γ − 1)el

]

−[

m2r

ρr

3−γ2

+ (γ − 1)er

]

= s(ml − mr)[

elml

ρlγ − γ−1

2m3

l

ρ2l

]

−[

ermr

ρrγ − γ−1

2m3

r

ρ2r

]

= s(el − er)

⇒ for given right state: 3 equations for 4 unknowns s, Ul

• verify that Contact Discontinuity obeys RH

⇒ s = v, vl = vr = v, pl = pr = p while ρl 6= ρr

⇒ ‘2-wave’ for eigenvalue λ2 = v has (generalized Riemann) invariants v and p

Page 36: Lecture sheets: Finite volume methods for hydrodynamics

Finite volume methods for HD Bochum, march 2008-36

• general solution to Riemann Problem:

⇒ given two states Ul and Ur

⇒ find intermediate state Umr connected to Ur by a ‘3-wave’

⇒ which is such that its velocity and pressure

Umr =

ρmr

mmr

emr

︸ ︷︷ ︸conservative

ρmr

v∗p∗

︸ ︷︷ ︸primitive

match the velocity and pressure of intermediate state

Uml =

ρml

v∗p∗

connected to Ul by a ‘1-wave’

⇒ the states Uml and Umr can be connected by a ‘2-shock’ (contact discontinuity)

Page 37: Lecture sheets: Finite volume methods for hydrodynamics

Finite volume methods for HD Bochum, march 2008-37

• note: counts ok:

⇒ 6 equations for 6 unknowns (s1, ρml, v∗, p∗) and (s3, ρmr, v∗, p∗)

rl UU

x

1-rarefactionCD

3-shock2-shockt

mrUmlU

⇒ again only entropy-satisfying shocks allowed

• ingredients to solve RP: L – R1 or S1 – Ml – CD – Mr – R3 or S3 – R

Page 38: Lecture sheets: Finite volume methods for hydrodynamics

Finite volume methods for HD Bochum, march 2008-38

• Euler system in terms of primitive variables

ρvp

t

+

v ρ 00 v 1

ρ

0 γp v

ρvp

x

= 0

⇒ possible to deduce

vt + (v ± c) vx ±1√γpρ

(pt + (v ± c)px) = 0

Page 39: Lecture sheets: Finite volume methods for hydrodynamics

Finite volume methods for HD Bochum, march 2008-39

• since 2cγ−1 = 2

γ−1

√γpρ and under constant s = pρ−γ

⇒ can be rewritten to(

v ± 2c

γ − 1

)

t

+ (v ± c)

(

v ± 2c

γ − 1

)

x

= 0

• found (generalized) Riemann Invariants

⇒ for ‘1-wave’ v − c: invariants are s and v + 2cγ−1

⇒ for ‘2-wave’ v: invariants are v and p

⇒ for ‘3-wave’ v + c: invariants are s and v − 2cγ−1

Page 40: Lecture sheets: Finite volume methods for hydrodynamics

Finite volume methods for HD Bochum, march 2008-40

• can be written as ‘characteristic’ equations

⇒ dp − ρc dv = 0 along dxdt = v − c

⇒ dp − c2 dρ = 0 along dxdt

= v

⇒ dp + ρc dv = 0 along dxdt

= v + c

⇒ could be used to solve IVP in (x, t) space

Page 41: Lecture sheets: Finite volume methods for hydrodynamics

Finite volume methods for HD Bochum, march 2008-41

• back to Rankine-Hugoniot relations for Euler system

F (Ul) − F (Ur) = s (Ul − Ur)

⇒ consider again stationary shock s = 0 → ml = mr

⇒ two remaining equations result in

v2l

2+

c2l

γ − 1=

v2r

2+

c2r

γ − 1=

γ + 1

2(γ − 1)c2∗

⇒ last equality for sonic point where v∗ = c∗

⇒ again leads to c2∗ = vlvr Prandtl Meyer relation

⇒ stationary shock separates super- from subsonic state (w.r.t. c∗)!

Page 42: Lecture sheets: Finite volume methods for hydrodynamics

Finite volume methods for HD Bochum, march 2008-42

• further analysis of stationary shock introduces Ml = vl

cl

vl

vr=

(γ + 1)M 2l

(γ − 1)M 2l + 2

⇒ and since ml = mr we get for the density ratio

ρl

ρr=

(γ − 1)M 2l + 2

(γ + 1)M 2l

⇒ pressure ratio can be shown to obey

pl

pr=

γ + 1

1 − γ + 2γM 2l

⇒ for stationary shock: all jumps depend on γ and Ml only

Page 43: Lecture sheets: Finite volume methods for hydrodynamics

Finite volume methods for HD Bochum, march 2008-43

• moving shock: Galilean transformation

⇒ leaves all thermodynamic quantities unchanged

⇒ change to parameters α = γ+1γ−1 and P = pl

pr

⇒ stationary shock obeys

vl

vr=

α + P

αP + 1=

ρr

ρl

⇒ three parameters for a moving shock: α, P , shock speed s give

vl − s

vr − s=

α + P

αP + 1=

ρr

ρl

⇒ while also

(s − vl)2 = c2

l

[

1 +γ + 1

(pr

pl− 1

)]

Page 44: Lecture sheets: Finite volume methods for hydrodynamics

Finite volume methods for HD Bochum, march 2008-44

Numerical tests

• Perform series of Riemann Problem calculations for 1D Euler

⇒ always use 2nd order accurate, conservative, TVDLF discretization

⇒ TVDLF is ‘Total Variation Diminishing Lax-Friedrichs’ scheme

⇒ monotonicity preserving, but diffusive especially at CD

⇒ 200 grid points on [0, 1], γ = 1.4

⇒ BCs: ∂x = 0

• Start with classical ‘Sod’ problem

⇒ Ul = (ρl, vl, pl) = (1, 0, 1) and Ur = (0.125, 0, 0.1)

⇒ ‘shock tube problem’ : diaphragm separates 2 gases at rest

Page 45: Lecture sheets: Finite volume methods for hydrodynamics

Finite volume methods for HD Bochum, march 2008-45

• Sod problem at t = 0.15

⇒ note R1 where Riemann Invariants s and v + 2c/(γ − 1) are constant

⇒ CD spread over many cells

Page 46: Lecture sheets: Finite volume methods for hydrodynamics

Finite volume methods for HD Bochum, march 2008-46

• test case from Lax : initial rightwardly moving left state, till t = 0.15

⇒ Ul = (ρl, vl, pl) = (0.445, 0.698, 3.528) and Ur = (0.5, 0, 0.571)

Page 47: Lecture sheets: Finite volume methods for hydrodynamics

Finite volume methods for HD Bochum, march 2008-47

• Sod and Lax test case: remain subsonic M = v/cs < 1

⇒ Arora & Roe Mach 3 test case considers

⇒ Ul = (ρl, vl, pl) = (3.857, 0.92, 10.333) and Ur = (1, 3.55, 1)

⇒ solution at t = 0.09

Page 48: Lecture sheets: Finite volume methods for hydrodynamics

Finite volume methods for HD Bochum, march 2008-48

• supersonic shock tube problem at time t = 0.1562

⇒ Ul = (ρl, vl, pl) = (8, 0, 8) and Ur = (0.2, 0, 0.2)

⇒ better behaviour at contact than in Mach 3 case

Page 49: Lecture sheets: Finite volume methods for hydrodynamics

Finite volume methods for HD Bochum, march 2008-49

• case of a slowly moving very weak shock , show t = 0.175

⇒ Ul = (ρl, vl, pl) = (1,−1, 1) and Ur = (0.9275,−1.0781, 0.9)

⇒ leftward rarefaction and rightward shock: (too) many cells in shock!

Page 50: Lecture sheets: Finite volume methods for hydrodynamics

Finite volume methods for HD Bochum, march 2008-50

• stationary contact discontinuity

⇒ Ul = (ρl, vl, pl) = (1, 0, 0.5) and Ur = (0.6, 0, 0.5)

⇒ t = 0 and t = 0.1 and t = 1 solution

⇒ diffusion obvious: increasingly (too) many cells in CD!

Page 51: Lecture sheets: Finite volume methods for hydrodynamics

Finite volume methods for HD Bochum, march 2008-51

• recognizing a rarefaction wave

⇒ 800 cells from [0, 800] with γ = 5/3

⇒ Ul = (ρl, vl, pl) = (1,−3, 10) and Ur = (0.87469,−2.46537, 8)

⇒ t = 0 and t = 40 and t = 80 solution, plot v

⇒ two states with same entropy: rarefaction emerges

Page 52: Lecture sheets: Finite volume methods for hydrodynamics

Finite volume methods for HD Bochum, march 2008-52

• Linear sound waves: time dependent driver v = A sin (2πt/P ) at x = 0

⇒ density ρ(t = 0) = 1, v(t = 0) = 0, p(t = 0) = 0.6 with γ = 5/3

⇒ A = 0.02 with P = 1 generates sound waves (amplitude 0.01)

⇒ compare TVDLF for 100 versus 400 cells at t = 4

⇒ to follow linear dynamics: need high resolution to battle diffusion!

Page 53: Lecture sheets: Finite volume methods for hydrodynamics

Finite volume methods for HD Bochum, march 2008-53

• sound wave steepening and shock formation: take amplitude A = 0.2

⇒ nonlinear shock formation well captured

• Caution to use these methods for pure linear wave processes

⇒ high resolution prerequisite

⇒ seperate true physical diffusion from numerical effects

⇒ note that 10 % variations already imply nonlinear effects!

Page 54: Lecture sheets: Finite volume methods for hydrodynamics

Finite volume methods for HD Bochum, march 2008-54

Approximate Riemann solver based methods

• modern high resolution, shock-capturing schemes for Euler

⇒ capitalize on known solution of the Riemann problem

⇒ originally developed by Godunov

• always use conservative scheme of form

dUi

dt+

1

∆x

(Fi+1/2 − Fi−1/2

)= 0

⇒ cell values Ui change through fluxes across cell edges

⇒ edge-centered numerical flux Fi+1/2(Ui−p, Ui−p+1, . . . , Ui+q)

Page 55: Lecture sheets: Finite volume methods for hydrodynamics

Finite volume methods for HD Bochum, march 2008-55

The Godunov scheme

• values Uni for time t = tn

⇒ consider piecewise constant values in cells

⇒ serve as initial condition to solve Ut + (F (U ))x = 0 for t > tn

⇒ restrict timestep to ∆tn+1 < ∆x2 max|λ|

⇒ with λ eigenvalue of flux Jacobian FU

⇒ then exact solution given by solving RP at cell interfaces

⇒ restriction on timestep ensures no wave interaction within ∆tn+1

• Godunov scheme

⇒ denote exact RP solution for state Uni and Un

i+1 as U(

x−xi+1/2

t , Uni , Un

i+1

)

⇒ numerical flux

Fi+1/2 (Ui, Ui+1) = F (U (0, Uni , Un

i+1))

⇒ need an exact Riemann solver

Page 56: Lecture sheets: Finite volume methods for hydrodynamics

Finite volume methods for HD Bochum, march 2008-56

The Roe solver

• due to piecewise constant representation

⇒ Godunov scheme 1st order accurate

• exact solution to RP is complicated

⇒ scheme is not exact due to piecewise constant representation

⇒ might as well solve RP in approximate fashion

• schemes exploiting approximate Riemann solver

⇒ use linearization of the nonlinear problem

⇒ recall: exact solution for linear hyperbolic system known

Page 57: Lecture sheets: Finite volume methods for hydrodynamics

Finite volume methods for HD Bochum, march 2008-57

Roe-type approximate Riemann solver

• general procedure to solve system Ut + (F(U))x = 0

⇒ local Riemann problem from left and right interface values Ul and Ur.

⇒ instead of exact nonlinear solution, solve a linear Riemann problem

Ut + (G(U))x = 0

⇒ G(U) = F(Ur) + A(U − Ur) includes constant matrix A = A (Ul,Ur)

⇒ matrix must satisfy conditions

1. F(Ul) − F(Ur) = A(Ul,Ur) (Ul − Ur),2. A(Ul,Ur) → FU(Ur) as Ul → Ur,3. A(Ul,Ur) has only real eigenvalues,4. A(Ul,Ur) has a complete system of eigenvectors.

⇒ exact solution obtained when initial states obey Rankine-Hugoniot relations

⇒ consistency and solvability of the linear Riemann problem.

Page 58: Lecture sheets: Finite volume methods for hydrodynamics

Finite volume methods for HD Bochum, march 2008-58

• if Roe matrix A found, Roe scheme uses the numerical flux

Fi+1/2 (Ui,Ui+1) = F(Ui) + Ai+1/2

(

U − Ui

)

⇒ U = U(0,Ui,Ui+1) is exact solution of linear Riemann problem

• Latter solution easy: when Ai+1/2~rp = λp~r

p write

Ui+1 − Ui =∑

αp~rp

⇒ can show that the solution along the (x, t) ray (x − xi+1

2

)/t = 0

U =Ui + Ui+1

2+

1

2

λp<0

−∑

λp>0

αp~rp

• fill in for Roe flux, use first Roe condition to get

Fi+1/2 = 12 (F(Ui) + F(Ui+1)) − 1

2

∑ | λp | αp~rp

⇒ ‘upwinding’: characteristic speeds and wave directionali ty taken intoaccount

Page 59: Lecture sheets: Finite volume methods for hydrodynamics

Finite volume methods for HD Bochum, march 2008-59

• Needed: Roe matrix A, its eigenvalues λp, its right eigenvectors ~rp, and thewave strengths αp

⇒ when left eigenvectors ~lp given, wave strengths

αp = ~lp · (Ui+1 − Ui)

• In practice: use for A the Flux Jacobian FU, evaluated in average state, e.g. arith-metic average of Ul and Ur

⇒ then not all Roe conditions fullfilled though

⇒ all ingredients known: eigenvalues (characteristic speeds), eigenvectors fromR, left eigenvectors from R−1

• Note: wave strengths can also be computed from primitive jumps

αp =~lp · (Vi+1 − Vi)

⇒ left eigenvectors~lp are found from rows of

R−1 = R−1

UV

⇒ where transformation matrix relates primitive with conservative formulation

dU = UVdV

Page 60: Lecture sheets: Finite volume methods for hydrodynamics

Finite volume methods for HD Bochum, march 2008-60

• solver completely determined once matrix Ai+1/2 that satisfies the Roe conditions isconstructed

⇒ recall that U =

ρme

and F =

mm2

ρ3−γ

2 + (γ − 1)eemρ

γ − γ−12

m3

ρ2

=

ρvρv2 + pv(e + p)

⇒ introduce vector Z =

√ρ√ρv

(e + p)/√

ρ

⇒ find that

U =

z1z1

z1z21γz1z3 + γ−1

2γ z2z2

⇒ and similarly

F =

z1z2γ+12γ

z2z2 + γ−1γ

z1z3

z2z3

⇒ both U and F are quadratic functions of elements of Z

Page 61: Lecture sheets: Finite volume methods for hydrodynamics

Finite volume methods for HD Bochum, march 2008-61

• define difference δa = ai+1 − ai

⇒ verify existence of matrices B and C such that

⇒ δU = BδZ and δF = CδZ

⇒ matrices B and C have elements linear in z = 12 (zi + zi+1)

• matrix Ai+1/2 ≡ C B−1 then satisfies

⇒ Ai+1/2δU = δF

⇒ first Roe condition

Page 62: Lecture sheets: Finite volume methods for hydrodynamics

Finite volume methods for HD Bochum, march 2008-62

• define so-called Roe-averages as

v ≡√

ρivi +√

ρi+1vi+1√ρi +

√ρi+1

h ≡√

ρihi +√

ρi+1hi+1√ρi +

√ρi+1

⇒ latter uses the total specific enthalpy h = e+pρ

⇒ can write matrix Ai+1/2 as

Ai+1/2 =

0 1 0γ−3

2v2 (3 − γ)v γ − 1

γ−12 v3 − vh h − (γ − 1)v2 γv

⇒ by inspection, this is equal to FU(U)

⇒ flux Jacobian evaluated at Roe averaged state U

⇒ thus satisfies all other Roe conditions

• can be shown that matrix satisfying all Roe conditions is unique

Page 63: Lecture sheets: Finite volume methods for hydrodynamics

Finite volume methods for HD Bochum, march 2008-63

• all ingredients for Roe flux now known

⇒ eigenvalues λ1 = v − c, λ2 = v, λ3 = v + c

⇒ uses sound speed from c2 = (γ − 1)(

h − v2

2

)

⇒ recall eigenvectors ~r1 =

1v − ch − vc

~r2 =

1vv2

2

~r3 =

1v + ch + vc

⇒ coefficients αp = ~rp · (Ui+1 − Ui)

⇒ with orthogonal left eigenvectors ~lp from ~lp · ~rq = δpq given by

~l1 =

(v

4c(2 + (γ − 1)

v

c), − 1

2c(1 + (γ − 1)

v

c),

γ − 1

2

1

c2

)

~l2 =

(

1 − γ − 1

2

v2

c2, (γ − 1)

v

c2, −(γ − 1)

1

c2

)

~l3 =

(

− v

4c(2 − (γ − 1)

v

c),

1

2c(1 − (γ − 1)

v

c),

γ − 1

2

1

c2

)

Page 64: Lecture sheets: Finite volume methods for hydrodynamics

Finite volume methods for HD Bochum, march 2008-64

• coefficients αp expressed in primitive variable differences

α1 =1

2c2(∆p − cρ∆v)

α2 = ∆ρ − 1

c2∆p

α3 =1

2c2(∆p + cρ∆v)

⇒ with ρ =√

ρiρi+1

⇒ correspondence with characteristic equations

Page 65: Lecture sheets: Finite volume methods for hydrodynamics

Finite volume methods for HD Bochum, march 2008-65

Numerical tests

• Perform series of Riemann Problem calculations for 1D Euler

⇒ compare 2nd order conservative TVDLF with Roe-based TVD

⇒ 200 grid points on [0, 1], γ = 1.4 and BCs: ∂x = 0

• Start with classical ‘Sod’ problem

⇒ Ul = (ρl, vl, pl) = (1, 0, 1) and Ur = (0.125, 0, 0.1)

⇒ ‘shock tube problem’ : diaphragm separates 2 gases at rest

Page 66: Lecture sheets: Finite volume methods for hydrodynamics

Finite volume methods for HD Bochum, march 2008-66

• Sod shock tube t = 0.15: compare TVDLF (top) with Roe (bottom)

⇒ Roe: slight improvement for CD

Page 67: Lecture sheets: Finite volume methods for hydrodynamics

Finite volume methods for HD Bochum, march 2008-67

• Lax test case, TVDLF (top) versus TVD (bottom)

⇒ slight improvement for CD

Page 68: Lecture sheets: Finite volume methods for hydrodynamics

Finite volume methods for HD Bochum, march 2008-68

• Arora & Roe Mach 3 test case considers

⇒ Ul = (ρl, vl, pl) = (3.857, 0.92, 10.333) and Ur = (1, 3.55, 1)

• Mach 3 test at t = 0.09, TVDLF (top) versus Roe (bottom)

⇒ Roe gives completely wrong solution!!!!

Page 69: Lecture sheets: Finite volume methods for hydrodynamics

Finite volume methods for HD Bochum, march 2008-69

• Erroneous Mach 3 result due to presence of M = 1 point

⇒ R1-rarefaction (expansion fan) goes transonic

⇒ eigenvalue λ1 = v − c = 0 at sonic point

⇒ what if simultaneously α2 = α3 = 0?

⇒ Roe flux reduces to central discretization

Fi+1/2 =1

2(F (Ui) + F (Ui+1))

⇒ discontinuities are insufficiently smeared out

⇒ entropy-violating solution may occur (must increase through shock)

• ‘sonic entropy fix’ for Roe scheme

⇒ replace eigenvalues λ1 and λ3 in the vicinity of zero

⇒ if | λ1 |< ǫ or | λ3 |< ǫ

λp →1

2

(

λ2p

ǫ+ ǫ

)

⇒ with ǫ a small value, at play where | v |≃ c

Page 70: Lecture sheets: Finite volume methods for hydrodynamics

Finite volume methods for HD Bochum, march 2008-70

• Repeat Mach 3 with entropy fix:

⇒ Roe: (bottom) improvement over TVDLF (top)

Page 71: Lecture sheets: Finite volume methods for hydrodynamics

Finite volume methods for HD Bochum, march 2008-71

• supersonic shock tube test:

⇒ improvement over TVDLF, better at CD

Page 72: Lecture sheets: Finite volume methods for hydrodynamics

Finite volume methods for HD Bochum, march 2008-72

• case of a slowly moving very weak shock, show t = 0.175

⇒ Ul = (ρl, vl, pl) = (1,−1, 1) and Ur = (0.9275,−1.0781, 0.9)

⇒ leftward rarefaction and rightward shock

⇒ Roe (bottom) much better than TVDLF (top: many cells in shock)!

Page 73: Lecture sheets: Finite volume methods for hydrodynamics

Finite volume methods for HD Bochum, march 2008-73

• stationary contact discontinuity :

⇒ Ul = (ρl, vl, pl) = (1, 0, 0.5) and Ur = (0.6, 0, 0.5)

⇒ t = 0 and t = 0.1 and t = 1 solution

⇒ Roe (bottom): CD recognized as steady solution, no diffusio n!!!

Page 74: Lecture sheets: Finite volume methods for hydrodynamics

Finite volume methods for HD Bochum, march 2008-74

• summarizing

⇒ non-trivial calculation of Roe flux (more involved than TVDLF)

⇒ need for entropy fix for transonic expansion fans

⇒ better representation of CD, especially stationary CD

⇒ ok with slowly traveling weak shocks

• note: conclusions for 2nd order variants of TVDLF and Roe-based TVD

⇒ both heavily used in multi-D HD simulations

Page 75: Lecture sheets: Finite volume methods for hydrodynamics

Finite volume methods for HD Bochum, march 2008-75

Sedov blast wave

• astrophysical application: ‘supernova’ explosion or ‘blast wave’

⇒ modeled as 1D Euler Riemann Problem in spherical symmetry

• initial conditions vr = 0, ρ = 1, and γ = 1.4

⇒ extreme p jump pexp = 763.944 for r ∈ [0, 0.05] and pext = 10−5

⇒ take 512 grid points on r = [0, 1] run till time t = 0.1 with TVD

Page 76: Lecture sheets: Finite volume methods for hydrodynamics

Finite volume methods for HD Bochum, march 2008-76

• good agreement with analytical result

⇒ p goes to constant value at center

⇒ vr goes to linear profile in r/R(t) with R(t) shock position

⇒ density goes to profile (r/R(t))3/(γ−1) (overplotted)