WPPII Computational Fluid Dynamics I

Numerical Methods for Wave Equations: Part I: Smooth Solutions

Instructor: Hong G. Im University of Michigan Fall 2001 Computational Fluid Dynamics I WPPII Outline

Solution Methods for Wave Equation Part I • Method of Characteristics • Finite Volume Approach and Conservative Forms • Methods for Continuous Solutions - Central and Upwind Difference - Stability, CFL Condition - Various Stable Methods Part II • Methods for Discontinuous Solutions - Burgers Equation and Shock Formation - Entropy Condition - Various Numerical Schemes WPPII Computational Fluid Dynamics I

Method of Characteristics WPPII Computational Fluid Dynamics I

1st Order Wave Equation ∂f ∂f + c = 0 ∂t ∂x The characteristics for this equation are: dx df = c; = 0; f dt dt t

f

x WPPII Computational Fluid Dynamics I

1-D Wave Equation (2nd Order Hyperbolic PDE) ∂ 2 f ∂ 2 f − c2 = 0 ∂t 2 ∂x2 Define ∂f ∂f v = ; w = ; ∂t ∂x which leads to ∂v ∂w − c2 = 0 ∂t ∂x ∂w ∂v − = 0 ∂t ∂x WPPII Computational Fluid Dynamics I

In matrix form v   − 2 v   t  + 0 c  x  = + =      0 or ut Au x 0  w  −1 0  w  t λ x Can it be transformed into the form v   0λv   t  +   x  = + λ =      0 or ut u x 0 ?  wt  0  wx  Find the eigenvalue, eigenvector ()AT − λI q = 0 λ − −1 l    1  = 0 − 2 − λ    c l2  WPPII Computational Fluid Dynamics I

λ Eigenvalue λ dx AT − I = 0; 2 − c2 = 0; λ = = ±c dt Eigenvector  1  For λ = +c, − cl − l = 0; q =   1 2 1 − c 1  For λ = −c, cl − l = 0; q =   1 2 2 c

The solution (v,w) is governed by ODE’s along the characteristic lines dx / dt = ±c WPPII Computational Fluid Dynamics I

On dx / dt = +c,

T ⋅()+ = ()− 2 − ()− q1 ut Au x vt c wx c wt vx dv dw = ()()v + cv − c w + cw = − c = 0 t x t x dt dt ≡ − If r1 v cw (Riemann Invariant), we have

d(v − cw) = 0 on dx = +cdt (If c = const) dt WPPII Computational Fluid Dynamics I

On dx / dt = −c,

T ⋅()+ = ()− 2 + ()− q2 ut Au x vt c wx c wt vx dv dw = ()()v − cv + c w − cw = + c = 0 t x t x dt dt ≡ + If r1 v cw (Riemann Invariant), we have

d(v + cw) = 0 on dx = −cdt (If c = const) dt WPPII Computational Fluid Dynamics I

3 dx / dt = −c

P 2 dx / dt = +c dv dw − c = 0 on dx = +cdt dt dt 1 dv + dw = = − ∂f ∂f c 0 on dx cdt f , , known dt dt ∂t ∂x = + df ft dt f x dx WPPII Computational Fluid Dynamics I

Finite difference approximation to determine f (P) dx / dt = +c []= = v ft , w f x 2 P dx / dt = −c 1  − = [][]+ −  x(P) x(1) c(P) c(1) t(P) t(1) dx 2  on = +c 1 1  dt v(P) − v(1) = [][]c(P) + c(1) w(P) − w(1)  2  1  − = − [][]+ −  x(P) x(2) c(P) c(2) t(P) t(2) dx 2  on = −c 1  dt v(P) − v(2) = − [][]c(P) + c(2) w(P) − w(2)  2  1 1 f (P) − f (1) = [][]v(P) + v(1) t(P) − t(1) + [][]w(P) + w(1) x(P) − x(1) 2 2 – iterative procedure WPPII Computational Fluid Dynamics I

Numerical Methods: Finite Volume Approach WPPII Computational Fluid Dynamics I

When using finite volume approximations, we work directly with the integral form of the conservation principles. The average values of f over a small volume are stored

f f j−1

f j f j+1

x xj−1/2 xj+1/2 WPPII Computational Fluid Dynamics I

In , equations in conservative forms are needed in order to satisfy conservation properties.

As an example, consider a 1-D equation

∂f (x,t) ∂F[ f (x,t)] + = 0 ∂t ∂x

where F denotes a general advection/diffusion term, e.g. 1 ∂f F = f 2 ; F = µ(x) 2 ∂x WPPII Computational Fluid Dynamics I

Integrating over the domain L,

∂f ∂F dx + dx = 0 ∫ ∂ ∫ ∂ L t L x F(L) − F(0) = 0 d ⇒ ∫ fdx = 0 dt L

If F = 0 at the end points of the domain, f is conserved. WPPII Computational Fluid Dynamics I

f j−1

In discretized form: f j f j+1 − ∂F F + F − ∫ dx = ∑ j 1/ 2 j 1/ 2 ∂x ∆x L xj−1/2 xj+1/2 x 1 = []+ F − − F − + F + − F − + F + − F + + ∆x ! j 1/ 2 j 3/ 2 j 1/ 2 j 1/ 2 j 3/ 2 j 1/ 2 ! 1 = []F − F ∆x L 0 WPPII Computational Fluid Dynamics I

Examples of Conservative Form

∂f ∂  1  ∂f ∂  ∂f  +  f 2  = 0, +  µ(x)  = 0 ∂t ∂x  2  ∂t ∂x  ∂x  ∂  ∂f  Discretizeµ  µ(x)  ∂x  µ ∂x  1  ∂f  ∂f     −   = h ∂x  µ ∂x   j+1/ 2 µ j−1/ 2  1 µ []()()()()+ f − f − + µ f − f 2h2 j+1 j j+1 j j j−1 j j−1 Conservative WPPII Computational Fluid Dynamics I

Examples of Non-conservative Form ∂f ∂f ∂f µ ∂ 2 f ∂µ ∂f + f = 0, + + = 0 µ ∂t ∂x ∂t ∂x2 ∂x ∂x µ ∂ 2 ∂µ ∂ f µ f Discretize + µ µ ∂x2 ∂x ∂x µ   1 ()+ − +µ1 ()()− − = 2  j f j+1 f j−1 2 f j j+1 µ j−1 f j+1 f j−1  h  4 µ   µ  1 ()+ − + 1 ()− − + µ  j f j+1 j f j−1 2 j f j j+1 f j+1 j+1 f j−1 j−1 f j+1 j−1 f j−1  h2  4  Non-conservative WPPII Computational Fluid Dynamics I

Finite Volume Method for Conservative Equations ∂f ∂F + = 0 ∂t ∂x

F = Uf Advection ∂f F = D Diffusion ∂x ∂f F = Uf − D Advection/Diffusion ∂x WPPII Computational Fluid Dynamics I

Finite Volume Formulation f j−1 f j ∂f ∂F f + + = 0 j 1 ∂t ∂x ∂f ∂F j−1 j j+1 x ∫ dx + ∫ dx = 0 ∂ ∂ Fj−1/2 Fj+1/2 ∆x t ∆x x d + − = ∫ f dx Fj+1/ 2 Fj−1/ 2 0 dt ∆x d (hf ) + F − F = 0 dt j j+1/ 2 j−1/ 2 WPPII Computational Fluid Dynamics I

1-D Advection-Diffusion Equation ∂f ∂  ∂f  + Uf − D  = 0 ∂t ∂x  ∂x  FVM Equation: d  ∂f ∂f  h f = −U ( f − f ) + D −  j j+1/ 2 j−1/ 2  ∂ ∂  dt  x j+1/ 2 x j−1/ 2  Approximating f ≈ 1 ( f n + f n ) j+1/ 2 2 j+1 j ∂ f n − f n f ≈ j+1 j ∂ x j+1/ 2 h

d 1 + f ≈ ( f n 1 − f n ) dt j ∆t j j WPPII Computational Fluid Dynamics I

Substituting:

h + ( f n 1 − f n ) = ∆t j j  f n − f n f n − f n  − []1 n + n − 1 n + n +  j+1 j − j j−1  U ( f j+1 f j ) ( f j f j−1 ) D  2 2  h h  Rearranging the terms: f n+1 − f n j j U n n D ()n n n + ( f + − f − ) = f + − 2 f + f − ∆t 2h j 1 j 1 h2 j 1 j j 1 Which is exactly the same as the equation if we take the average value to be the same as the value in the center of the cell WPPII Computational Fluid Dynamics I

Numerical Methods for 1-D Advection Equation: Stability Consideration (Finite Difference Approach) WPPII Computational Fluid Dynamics I

We will start by examining the linear advection equation: ∂f ∂f +U = 0 ∂t ∂x The characteristic for this equation are: dx df = U; = 0; dt dt Showing that the initial conditions t f are simply advected by a constant velocity U f x WPPII Computational Fluid Dynamics I

Finite difference equation ∂f ∂f +U = 0 ∂t ∂x A forward in time, centered in space (FTCS) discretization yields ∆ n+1 n t n n f = f − U ( f + − f − ) j j 2h j 1 j 1

n+1 n j−1 j j+1 WPPII Computational Fluid Dynamics I

This scheme is O(∆t, ∆x2) accurate, but a stability analysis shows that the error grows as

+ ε n 1 U∆t = 1− i sin kh ε n 2h n+1 Since the amplification ε factor has the form 1+i() ε n the absolute value of this complex number is always U∆t i sin kh larger than unity and the 2h method is unconditionally unstable for this case. 1 WPPII Computational Fluid Dynamics I

Alternative Scheme: Upwind Difference f j−1 f j f j+1 ∂f ∂f +U = 0 ∂t ∂x U A forward in time but “upwind” (windward) in space discretization yields

+ ∆t f n 1 = f n − U ( f n − f n ) j j h j j−1

n+1 This scheme is O(∆t, ∆x) n accurate. j−1 j WPPII Computational Fluid Dynamics I

To examine the stability we use the von Neuman’s method: n = n + ε n f j f j j

Substituting intoε the εmodified equation, + n 1 − n U ε j j + ( n −ε n ) = 0 ∆t h j j−1

ε ikx n = ε n j j e ε ε n+1 − n ε n +U (1− e−ikh ) = 0 ∆t h WPPII Computational Fluid Dynamics I

ε ε n+1 − n ε n +U (1− e−ikh ) = 0 ∆t h Amplification factor

ε n+1 U∆t − U∆t U∆t =1− (1− e ikh ) =1− (1− cos kh) − isin kh ε n h h h

or + ε n 1 2U∆t kh U∆t =1− sin 2 − isin kh ε n h 2 h WPPII Computational Fluid Dynamics I

Amplificationλ Factor − U∆t G =1− (1− e ikh ), λ = h Im(G) Stability Condition: λ <1 1

U∆t Stable ≤ 1 G h kh Re(G) 1 CFL Condition (Courant-Friedrichs-Lewy; 1932) 1−λ λ Computational Fluid Dynamics I WPPII Stability

Implication of the CFL Condition (Hirsch, vol.1, p. 288)

The domain of dependence of the differential equation should be contained in the domain of dependence of the discretized equations. WPPII Computational Fluid Dynamics I

Stability Consideration (Finite Volume Approach) WPPII Computational Fluid Dynamics I

f − Finite Volume Formulation j 1 f j ∂f ∂F f + = 0 j+1 ∂t ∂x ∂f ∂F j-1 j j+1 x ∫ dx + ∫ dx = 0 ∂ ∂ F F ∆x t ∆x x j-1/2 j+1/2 d + − = ∫ f dx Fj+1/ 2 Fj−1/ 2 0 dt ∆x ()()n+1 − n + ∆ n − n = h f j f j t Fj+1/ 2 Fj−1/ 2 0 ∆ n+1 n t n n f = f − ()F + − F − j j h j 1/ 2 j 1/ 2 WPPII Computational Fluid Dynamics I

f − Approximating the advective fluxes: j 1 U f j Taking the average (Central): f j+1 ≈ 1 + Fj+1/ 2 ( f j+1 f j )U 2 j-1 j j+1 x ∆   n+1 = n − t U ()n + n − U ()n + n f j f j  f j+1 f j f j f j−1  h  2 2  ∆ n t n n = f − []Uf + −Uf − j 2h j 1 j 1 Upwind: ≈ Fj+1/ 2 f jU ∆ n+1 n t n n f = f − ()Uf −Uf − j j h j j 1 WPPII Computational Fluid Dynamics I

Central Differencing and Stability Consider the following initial conditions: U n = n + n = U Fj−1/ 2 ( f j−1 f j ) 1.0 n = n + n = 2 Fj+1/ 2 ( f j f j+1) 0.5 2 1 U =1.0 ∆ f − f t j 1 j f j+1 = 0.5 h

∆ n+1 n t n n f = f − (F + − F − ) =1.0 − 0.5(0.5 −1) =1.25 j j h j 1/ 2 j 1/ 2 ∆ n+1 n t n n f + = f + − (F + − F + ) = 0 − 0.5(0 − 0.5) = 0.25 j 1 j 1 h j 3/ 2 j 1/ 2 WPPII Computational Fluid Dynamics I

Central Differencing and Stability Next time step (n+2):

n+1 U n+1 n+1 = + = + U + + Fj−1/ 2 ( f j−1 f j ) 1.125 n 1 = n 1 + n 1 = 2 Fj+1/ 2 ( f j f j+1 ) 0.75 2 1 U =1.0 ∆ f − f t j 1 j f j+1 = 0.5 h

∆ n+2 n+1 t n+1 n+1 f = f − (F + − F − ) =1.125 − 0.5(0.75 −1.125) =1.3125 j j h j 1/ 2 j 1/ 2 Cell j will overflow immediately !!! WPPII Computational Fluid Dynamics I

By considering the fluxes, it is easy to see why the centered difference approximation is always unstable.

+ ∆t  1  f n 1 = f n −  Uf n −Uf n  1 j j h  2 i i  f − j 1 f j f j+1 U∆t = f n + f n > f n j 2h j j

n+1 > n f j f j Always ! WPPII Computational Fluid Dynamics I

Upwind Differencing and Stability

Consider the following initial conditions:

U

1

f j−1 f j f j+1 WPPII Computational Fluid Dynamics I

≈ Upwind: Fj+1/ 2 f jU

= n = Fj −1/2 Uf j −1 U = n = Fj +1/2 Uf j 0 1 U f j−1 f j f j+1

∆ n+1 n t n n f = f − (F + − F − ) j j h j 1/ 2 j 1/ 2 Upwinding is ∆ n t n n effectively an = f − (Uf −Uf − ) j h j j 1 averaging process! WPPII Computational Fluid Dynamics I

Average

1 WPPII Computational Fluid Dynamics I

Advect

1 WPPII Computational Fluid Dynamics I

Average

1 WPPII Computational Fluid Dynamics I

Advect

1 WPPII Computational Fluid Dynamics I

Average

1 WPPII Computational Fluid Dynamics I

Advect

1 WPPII Computational Fluid Dynamics I

Upwind Differencing: Unstable Case Consider the following initial conditions:

1

f j−1 f j f j+1

= n = Fj+1/ 2 Uf j 0 = n = Fj−1/ 2 Uf j−1 1

During one time step, U∆t of f flows into cell j, increasing the average value of f by U∆t/h. WPPII Computational Fluid Dynamics I

Integration using : ∆t U∆t  U =1 =1.5  >1 h  h  = n = Fj −1/2 Uf j −1 U n Fj +1/2 = Uf j = 0 1 f j−1 f j f j+1

+ ∆t f n 1 = f n − (F n − F n ) = 0 −1.5(0 −1) =1.5 j j h j+1/ 2 j−1/ 2 WPPII Computational Fluid Dynamics I

n = n = Fj −1/2 = Uf j −1 = U Fj +1/2 Uf j 1.5U

1

f j−1 f j f j+1

+ ∆t f n 1 = f n − (F n − F n ) = 0 −1.5(1.5 −1) = 0.75 j j h j+1/ 2 j−1/ 2 + ∆t f n 1 = f n − (F n − F n ) = 0 −1.5(0 −1.5) = 2.25 j+1 j+1 h j+3/ 2 j+1/ 2 WPPII Computational Fluid Dynamics I

n Fj +1/2 = Uf j = 0.75U n Fj +1/2 = Uf j = 2.25U = n = Fj −1/2 Uf j −1 U

1

f j−1 f j f j+1

Taking a third step will result in an even larger positive value, and so on until the compute encounters a NaN (Not a Number). WPPII Computational Fluid Dynamics I

If U∆t/h > 1, the average value of f in cell j will be larger than in cell j−1. In the next step, f will flow out of cell j in both directions, creating a larger negative value of f. Taking a third step will result in an even larger positive value, and so on until the compute encounters a NaN (Not a Number). WPPII Computational Fluid Dynamics I

Consideration of Modified Equations:

Why is upwind scheme stable? (Ref: Tannehill et al., Ch. 4) WPPII Computational Fluid Dynamics I

Derive modified equation for upwind difference method: n+1 − n f j f j U n n + ( f − f − ) = 0 ∆t h j j 1 Using Taylor expansion:

2 2 3 3 + ∂f ∂ f ∆t ∂ f ∆t f n 1 = f n + ∆t + + + j j ∂t ∂t 2 2 ∂t 3 6 ! ∂f ∂ 2 f h2 ∂3 f h3 f n = f n − h + − + j−1 j ∂x ∂x2 2 ∂x3 6 ! WPPII Computational Fluid Dynamics I

Substituting 1  ∂f ∂ 2 f ∆t 2 ∂3 f ∆t 3    f n + ∆t + + + − f n   j 2 3 ! j ∆t  ∂t ∂t 2 ∂t 6   U   ∂f ∂ 2 f h2 ∂3 f h3  +  f n − f n − h + − +  = 0 j  j 2 3 ! h   ∂x ∂x 2 ∂x 6 

Therefore, ∂f ∂f ∆t Uh ∆t 2 Uh2 +U = − f + f − f − f + ∂t ∂x 2 tt 2 xx 6 ttt 6 xxx !

It helps the interpretation if all terms are written in f xx , f xxx WPPII Computational Fluid Dynamics I

Taking further derivatives: ∆t Uh ∆t 2 Uh2 f +Uf = − f + f − f − f + tt xt 2 ttt 2 xxt 6 tttt 6 xxxt ! U∆t U 2h U∆t 2 U 2h2 −Uf −U 2 f = f − f + f + f + + tx xx 2 ttx 2 xxx 6 tttx 6 xxxx !  − f U  f = U 2 f + ∆t ttt + f + O(∆t) tt xx  2 2 ttx  U U 2  +∆x u − u + O(h)  2 xxt 2 xxx  WPPII Computational Fluid Dynamics I

Similarly, we get = − 3 + ∆ fttt U f xxx O( t,h) = 2 + ∆ fttx U f xxx O( t,h) f = −Uf + O(∆t,h) xxt xxx ∆ λ = U t Final form of the modified equation:λ h ∂f ∂f Uh Uh2 λ +U = ()1− f − ()2 2 − 3λ +1 f ∂t ∂x 2 xx 6 xxx + O[]h3 ,h2∆t,h∆t 2 ,∆t 3 WPPII Computational Fluid Dynamics I

By applying upwind differencing, we are effectively solving: λ ∂f ∂f Uh Uh2 λ +U = ()1− f − ()2 2 − 3λ +1 f + ∂t ∂x 2 xx 6 xxx ! Numerical dissipation (diffusion) U∆t Also note that the CFL condition λ = <1 h ensures a positive diffusion coefficient

() ! f xx Dissipation () ! f xxx Dispersion WPPII Computational Fluid Dynamics I

Dissipation vs. Dispersion

Exact Dissipative Dispersive

The nature of the numerical scheme depends on the nature of the lowest order truncation error term. WPPII Computational Fluid Dynamics I

Generalized Upwind Scheme (for both U > 0 and U < 0 ) ∆ n+1 n U t n n f = f − ( f − f − ), U > 0 j j h j j 1 ∆ n+1 n U t n n f = f − ( f + − f ), U < 0 j j h j 1 j Define + 1 − 1 U = ()U + U , U = ()U − U 2 2 The two cases can be combined into a single expression: ∆ n+1 n t + n n − n n f = f − []U ( f − f − ) +U ( f + − f ) j j h j j 1 j 1 j WPPII Computational Fluid Dynamics I

Or, substituting U + , U −

∆ ∆ n+1 n t n n U t n n n f = f −U ( f + − f − ) + ( f + − 2 f + f − ) j j 2h j 1 j 1 2h j 1 j j 1 central difference + artificial viscosity  U h α =   2 

; General representation of various flux formula WPPII Computational Fluid Dynamics I

While the first-order upwind scheme was found to be stable, it is in general too dissipative (smoothes out all the steep gradients).

Stable and accurate methods: - Lax-Wendroff (I and II) - Leapfrog - Lax-Friedrichs - MacCormack - 2nd order upwind - etc., etc., … Computational Fluid Dynamics I WPPII Implicit Method 1. Implicit (Backward Euler) Method n+1 − n f f U + + j j + ()f n 1 − f n 1 = 0 ∆t 2h j+1 j−1

- Unconditionally stable - 1st order in time, 2nd order in space - Forms a tri-diagonal matrix (Thomas algorithm)

U + 1 + U + 1 f n 1 + f n 1 − f n 1 = f n 2h j+1 ∆t j 2h j−1 ∆t j

n+1 + n+1 + n+1 = a j f j+1 d j f j bj f j−1 C j Computational Fluid Dynamics I WPPII Implicit Method

Thomas Algorithm n+1 + n+1 + n+1 = a j f j+1 d j f j bj f j−1 C j

d a 0 ⋅ ⋅ ⋅ 0  f n+1  C   1 1  1   1  ⋅ n+1 b2 d2 a2  f2  C2  0 b d a ⋅  ⋅   ⋅   3 3 3      ⋅ ⋅  ⋅  =  ⋅   ⋅ ⋅  ⋅   ⋅        n+1  0 bM −1 d M −1 aM −1  f − CM −1    M 1    0 ⋅ ⋅ 0 b d n+1 C  M M  f M   M  Computational Fluid Dynamics I WPPII Implicit Method

Thomas Algorithm – The Algorithm

Forward Sweep: b = − j = d j d j a j−1 j 2,3,!, M d j−1 b = − j = C j C j C j−1 j 2,3,!, M d j−1

Backward Sweep:

n+1 + C − a f n 1 = k k k +1 = − − f j k M 1, M 2,!,1 dk Computational Fluid Dynamics I WPPII Lax Method 2. Lax (Lax-Friedrichs) Method The forward Euler method can be made stable by n → ()n + n f j f j+1 f j−1 / 2

+ 1 U∆t f n 1 = ()f n + f n − ()f n − f n j 2 j+1 j−1 2h j+1 j−1 Modified equation λ ∂f ∂f Uh  1λ  Uh2 + =  −  + ()− λ2 + U f xx 1 f xxx ! ∂t ∂x 2   3 - Stable for λ <1 ()λ = U∆t / h - Not uniformly consistent - Still 1st order (dissipative) Computational Fluid Dynamics I WPPII Leap Frog Method 3. Leap Frog Method The simplest stable second-order accurate (in time) method: + − ∂f f n 1 − f n 1 = j j + O(∆t 2 ) ∂t 2∆t

+ − U∆t f n 1 = f n 1 − ()f n − f n j j h j+1 j−1 Modified equation ∂ ∂ 2 f + f = Uh ()λ2 − + U 1 f xxx ! ∂t ∂x 6 - Stable for λ <1 - Dispersive (no dissipation) – error will not damp out - Initial conditions at two time levels - Oscillatory solution in time (alternating) Computational Fluid Dynamics I WPPII LW-I Method

4. Lax-Wendroff’s Method (LW-I)

First expand the solution in time ∂f ∂2 f ∆t 2 ∂3 f ∆t 3 f (t + ∆t) = f (t) + ∆t + + + ∂t ∂t 2 2 ∂t 3 6 ! Then use the original equation to rewrite the time derivatives ∂f ∂f = −U ∂t ∂x ∂ 2 f ∂  ∂f  ∂  ∂f  ∂ ∂f ∂2 f =   = − U  = −U = U 2 ∂t 2 ∂t  ∂t  ∂t  ∂x  ∂x ∂t ∂x2 Computational Fluid Dynamics I WPPII LW-I Method

Substituting ∂f ∂2 f ∆t 2 f (t + ∆t) = f (t) −U ∆t +U 2 + O(∆t 3 ) ∂x ∂x2 2 Using central differences for the spatial derivatives

2 2 + U∆t U ∆t f n 1 = f n − ()f n − f n + ()f n − 2 f n + f n j j 2h j+1 j−1 2h2 j+1 j j−1

2nd order accurate in space and time

U∆t Stable for <1 h Computational Fluid Dynamics I WPPII LW-II Method

5. Two-Step Lax-Wendroff’s Method (LW-II)

LW-I into two steps: f n+1/ 2 − ( f n + f n ) / 2 f n − f n j+1/ 2 j+1 j +U j+1 j = 0 Step 1 (Lax) ∆t / 2 h n+1 n n+1/ 2 n+1/ 2 f − f f + − f − j j +U j 1/ 2 j 1/ 2 = 0 Step 2 (Leapfrog) ∆t h - Stable for U∆t / h <1 - Second order accurate in time and space

For the linear equations, LW-II is identical to LW-I (prove it!) Computational Fluid Dynamics I WPPII MacCormack Method

6. MacCormack Method

Similar to LW-II, without j +1/ 2, j −1/ 2 ∆t f t = f n −U ()f n − f n Predictor j j h j+1 j  ∆  n+1 = 1 n + t − t ()t − t f j  f j f j U f j f j−1  Corrector 2  h 

- A fractional step method - Predictor: forward differencing - Corrector: backward differencing - For linear problems, accuracy and stability properties are identical to LW-I. Computational Fluid Dynamics I WPPII 2nd Order Upwind Method

7. Second-Order Upwind Method Warming and Beam (1975) – Upwind for both steps ∆t f t = f n −U ()f n − f n Predictor j j h j j−1 Corrector  ∆ ∆  n+1 = 1 n + t − t ()t − t − t ()n − n + n f j  f j f j U f j f j−1 U f j 2 f j−1 f j−2  2  h h 

Combining the two:λ

+ 1 f n 1 = f n − ()f n − f n + λ(λ −1)()f n − 2 f n + f n j j j j−1 2 j j−1 j−2 - Stable if 0 ≤ λ ≤ 2 - Second-order accurate in time and space WPPII Computational Fluid Dynamics I

And the list goes on… WPPII Computational Fluid Dynamics I

+ = ft Uf x 0

FTCS n+1 − n n − n 2 2 f f f + f − U Uh Unconditionally j j +U j 1 j 1 = 0 − ∆t f − ()1+ 2λ2 f ∆t 2h 2 xx 6 xxx Unstable

λ Uh Upwind ()1− f n+1 − n n − n 2 xx Stable for f j f j f j f j−1 +U = 0 2 ∆ Uh λ λ ≤ t h − ()2 2 − 3λ +1 f 1 6 xxx Implicit n+1 − n ()n+1 − n+1 U 2∆t 1 1  Unconditionally f j f j f j+1 f j−1 − 2 + 3∆ 2 +U = 0 f xx  Uh U t  f xxx ∆t 2h 2 6 3  Stable

f n+1 − ()f n + f n / 2 Lax-Friedrichs j j+1 j−1 λ Conditionally ∆t Uh  1λ  Uh2  −  f + ()1− λ2 f consistent ()n − n xx xxx f + f − 2   3 +U j 1 j 1 = 0 Stable for λ ≤1 2h WPPII Computational Fluid Dynamics I

+ = ft Uf x 0

Leap Frog f n+1 − f n−1 f n − f n 2 Stable for j j + j+1 j−1 = Uh ()λ2 − U 0 1 f xxx 2∆t 2h 6 λ ≤1

n+1 − n ()n − n 2 λ Lax-Wendroff I f j f j f j+1 f j−1 Uh 2 +U − ()1− f ∆t 2h 6 xxx Stable for ()f n − 2 f n + f n Uh3 λ λ ≤ 2 2 j+1 j j−1 − ()− λ2 1 −U ∆t = 0 1 f xxxx 2h2 8 f n+1/ 2 − ( f n + f n ) / 2 f n − f n Lax-Wendroff II j+1/ 2 j+1 j +U j+1 j = 0 ∆t / 2 h Stable for n+1 n n+1/ 2 n+1/ 2 Same as LW-I f − f f − f j j +U j+1/ 2 j−1/ 2 = 0 λ ≤1 ∆t h f t − f n ()f n − f n MacCormack j j +U j+1 j = 0 ∆t h Stable for f n+1 − ()f n + f t / 2 ()f t − f t Same as LW-I j j j +U j j−1 = 0 λ ≤1 ∆t h WPPII Computational Fluid Dynamics I

Closing Remarks WPPII Computational Fluid Dynamics I

Summary by CFD School A

“In solving inviscid flow equations as found in many gas dynamic applications, central differencing scheme is inherently unstable and thus cannot be used. One should use more robust methods such as upwind or other higher order methods in order to ensure stability and accuracy. In general, central differencing scheme is a deficient method in capturing true physical behavior and should be avoided if at all possible.” WPPII Computational Fluid Dynamics I

Summary by CFD School B

“Upwind-type schemes applied to the Navier-Stokes equations inherently introduce numerical dissipation which depends on numerical parameters, not on actual physical processes. Sometimes these uncontrolled numerical dissipation may interfere with physical solution, thereby degrading the fidelity of simulation. Central differencing does not suffer from artificial dissipation and thus preferred as an accurate numerical method.”