31
Computational Fluid Dynamics I P P PI I I W W W Elementary Numerical Analysis: Finite Difference Approximations-III Instructor: Hong G. Im University of Michigan Fall 2001

WPI Computational Fluid Dynamics I - Unicampphoenics/SITE_PHOENICS... · WPIPI Computational Fluid Dynamics I Convergence – the solution to the finite-difference equation approaches

  • Upload
    others

  • View
    25

  • Download
    4

Embed Size (px)

Citation preview

Page 1: WPI Computational Fluid Dynamics I - Unicampphoenics/SITE_PHOENICS... · WPIPI Computational Fluid Dynamics I Convergence – the solution to the finite-difference equation approaches

Computational Fluid Dynamics IPPPPIIIIWWWW

ElementaryNumerical Analysis:

Finite Difference Approximations-III

Instructor: Hong G. ImUniversity of Michigan

Fall 2001

Page 2: WPI Computational Fluid Dynamics I - Unicampphoenics/SITE_PHOENICS... · WPIPI Computational Fluid Dynamics I Convergence – the solution to the finite-difference equation approaches

Computational Fluid Dynamics IPPPPIIIIWWWW• The linear advection-diffusion equation• Finite difference approximations• Finite Difference Approximation of the linear

advection-diffusion equation• Accuracy• Stability• Consistency• Higher order finite difference approximations in

space• Time integration: implicit versus explicit and higher

accuracy • Finite Volume Approximations

Outline

Page 3: WPI Computational Fluid Dynamics I - Unicampphoenics/SITE_PHOENICS... · WPIPI Computational Fluid Dynamics I Convergence – the solution to the finite-difference equation approaches

Computational Fluid Dynamics IPPPPIIIIWWWW

Stability

Page 4: WPI Computational Fluid Dynamics I - Unicampphoenics/SITE_PHOENICS... · WPIPI Computational Fluid Dynamics I Convergence – the solution to the finite-difference equation approaches

Computational Fluid Dynamics IPPPPIIIIWWWW

As long as accuracy is reasonable, integration at larger time steps is more efficient and desirable.

Can we increase the time step indefinitely?

Let’s repeat the 1-D advection-diffusion equation with larges time step.

Stability

Page 5: WPI Computational Fluid Dynamics I - Unicampphoenics/SITE_PHOENICS... · WPIPI Computational Fluid Dynamics I Convergence – the solution to the finite-difference equation approaches

Computational Fluid Dynamics IPPPPIIIIWWWW

Evolution forU=1; D=0.05; k=1

N=21∆t=0.2

Exact

Numerical

Stability

Page 6: WPI Computational Fluid Dynamics I - Unicampphoenics/SITE_PHOENICS... · WPIPI Computational Fluid Dynamics I Convergence – the solution to the finite-difference equation approaches

Computational Fluid Dynamics IPPPPIIIIWWWW

Instead of decaying as it should, the amplitude of the numerical solution keeps increasing.

Indeed, if we continued the calculations, we would eventually produce numbers larger than the computer can handle. This results in an “overflow” or “NaN” (not a number).

Stability

Page 7: WPI Computational Fluid Dynamics I - Unicampphoenics/SITE_PHOENICS... · WPIPI Computational Fluid Dynamics I Convergence – the solution to the finite-difference equation approaches

Computational Fluid Dynamics IPPPPIIIIWWWWStability

Stability Analysis of1st Order ODE(Euler Method)

Page 8: WPI Computational Fluid Dynamics I - Unicampphoenics/SITE_PHOENICS... · WPIPI Computational Fluid Dynamics I Convergence – the solution to the finite-difference equation approaches

Computational Fluid Dynamics IPPPPIIIIWWWW

0)0(),,(' yytyfy ==

Stability

Consider a differential equation

Stability analysis seeks the conditions (of stepsize h)for which the numerical solution remains bounded.

Taylor Expansion:

[ ]20

20000

00000

)(,)(),()(

),()(),(),(

ttyyOtyftttyfyytyftyf

−−+′−+

′−+=

!+++=′ tyy βαλ

Page 9: WPI Computational Fluid Dynamics I - Unicampphoenics/SITE_PHOENICS... · WPIPI Computational Fluid Dynamics I Convergence – the solution to the finite-difference equation approaches

Computational Fluid Dynamics IPPPPIIIIWWWW

0)0(,' yyyy == λ

Stability

A Linearized Model Equation

where IR iλλλ +=For the Euler Method

)1(1 hyhyyy nnnn λλ +=+=+

Solution at time step nn

n hyy )1(0 λ+=

Page 10: WPI Computational Fluid Dynamics I - Unicampphoenics/SITE_PHOENICS... · WPIPI Computational Fluid Dynamics I Convergence – the solution to the finite-difference equation approaches

Computational Fluid Dynamics IPPPPIIIIWWWW

11 ≤+ hλ

Stability

The numerical solution is stable (bounded) if

Stability boundary

1)1( 222 =++ hh IR λλ

)( IR iλλλ +=

Stable

hIλ

hRλ−1

−1

1

If λ is real and negative,

λ2≤h

Page 11: WPI Computational Fluid Dynamics I - Unicampphoenics/SITE_PHOENICS... · WPIPI Computational Fluid Dynamics I Convergence – the solution to the finite-difference equation approaches

Computational Fluid Dynamics IPPPPIIIIWWWWStability

Stability Analysis ofAdvection-Diffusion Equation:

Von Neumann Method

Page 12: WPI Computational Fluid Dynamics I - Unicampphoenics/SITE_PHOENICS... · WPIPI Computational Fluid Dynamics I Convergence – the solution to the finite-difference equation approaches

Computational Fluid Dynamics IPPPPIIIIWWWW

Generally, stability analysis of the full nonlinear system of equations is too involved to be practical, and we study a model problem that in some way mimics the full equations.The linear advection-diffusion equation is one such model equation, and we will apply von Neumann's method to check the stability of a simple finite difference approximation to that equation.

Stability

Page 13: WPI Computational Fluid Dynamics I - Unicampphoenics/SITE_PHOENICS... · WPIPI Computational Fluid Dynamics I Convergence – the solution to the finite-difference equation approaches

Computational Fluid Dynamics IPPPPIIIIWWWW

2

2

xfD

xfU

tf

∂∂

∂∂

∂∂ =+

21111

1 22 h

fffD

hff

Ut

ff nj

nj

nj

nj

nj

nj

nj −+−+

+ +−=

−+

∆−

Stability

Consider the 1-D advection-diffusion equation:

In finite-difference form:

Page 14: WPI Computational Fluid Dynamics I - Unicampphoenics/SITE_PHOENICS... · WPIPI Computational Fluid Dynamics I Convergence – the solution to the finite-difference equation approaches

Computational Fluid Dynamics IPPPPIIIIWWWW

fj ,exactn+1 + ε j

n+1( )− fj ,exactn + ε j

n( )∆t

+

Ufj +1,exact

n + ε j +1n( )− fj −1,exact

n + ε j −1n( )

2h=

Dfj +1,exact

n + ε j +1n( )− 2 f j,exact

n + ε jn( )+ fj −1,exact

n + ε j −1n( )

h2

fjn = f j,exact

n + ε jn

Stability

Substitute

into the finite difference equation

Page 15: WPI Computational Fluid Dynamics I - Unicampphoenics/SITE_PHOENICS... · WPIPI Computational Fluid Dynamics I Convergence – the solution to the finite-difference equation approaches

Computational Fluid Dynamics IPPPPIIIIWWWWStability

Since

22

21111

1

hD

hU

t

nj

nj

nj

nj

nj

nj

nj −+−+

+ +−=

−+

∆− εεεεεεε

nexactjf , satisfies the equation, we get

Write the error as a wave:

∑∞

−∞=

==k

ikxnkj

nnj

jex εεε )(

Dropping the subscriptjikxnn

j eεε =

Page 16: WPI Computational Fluid Dynamics I - Unicampphoenics/SITE_PHOENICS... · WPIPI Computational Fluid Dynamics I Convergence – the solution to the finite-difference equation approaches

Computational Fluid Dynamics IPPPPIIIIWWWW

ε jn = εneikx j

ε j +1n = εneikx j+1 = εneik (x j + h) = εneikx j eikh

ε n+1 − εn

∆ t+ U

ε n

2h(eikh − e− ikh) = D

ε n

h2 (eikh − 2 + e−ikh )

Stability

The error at node j is:

The error at j+1 and j -1 can be written as

ε j −1n = ε neikx j−1 = ε neik (x j −h) = ε neikx j e−ikh

Substituting and canceling yields:eikx j

Page 17: WPI Computational Fluid Dynamics I - Unicampphoenics/SITE_PHOENICS... · WPIPI Computational Fluid Dynamics I Convergence – the solution to the finite-difference equation approaches

Computational Fluid Dynamics IPPPPIIIIWWWW

ε j +1n = ε neikx j eikh

ε n+1eikx j − ε neikx j

∆t+ U εn

2h(eikheikx j − e− ikheikx j ) =

Dε n

h2 (eikheikx j − 2eikx j + e− ikheikx j )

Stability

Substituting

ε j −1n = ε neikx j e−ikh

ε jn+1 − ε j

n

∆t+ U

ε j +1n − ε j −1

n

2h= D

ε j +1n − 2ε j

n + ε j −1n

h2

ε jn = εneikx j

into

yields

Page 18: WPI Computational Fluid Dynamics I - Unicampphoenics/SITE_PHOENICS... · WPIPI Computational Fluid Dynamics I Convergence – the solution to the finite-difference equation approaches

Computational Fluid Dynamics IPPPPIIIIWWWW

)2()(2

1 2

1ikhikhikhikh

n

n

eeh

tDeehtU −−

+

+−∆+−∆−=ε

ε

Stability

= 1 −U∆t2h

2i sin kh +D∆th2 2(cos kh −1)

= 1 − 4D∆th2 sin2 k

h2

− iU∆t2h

sin kh

Dividing by the error amplitude at n:

or

amplification factor

Page 19: WPI Computational Fluid Dynamics I - Unicampphoenics/SITE_PHOENICS... · WPIPI Computational Fluid Dynamics I Convergence – the solution to the finite-difference equation approaches

Computational Fluid Dynamics IPPPPIIIIWWWW

ε n+1

ε n = 1− 4D∆th2 sin2 k

h2

− iU∆t2h

sin kh

ε n+1

ε n ≤ 1

Stability requires that

Since the amplification factor is a complex number, and k, the wave number of the error, can be anything, the determination of the stability limit is slightly involved.

We will look at two special cases: (a) U = 0 and (b) D = 0

Stability

The ratio of the error amplitude at n+1 and n is:

Page 20: WPI Computational Fluid Dynamics I - Unicampphoenics/SITE_PHOENICS... · WPIPI Computational Fluid Dynamics I Convergence – the solution to the finite-difference equation approaches

Computational Fluid Dynamics IPPPPIIIIWWWW

ε n+1

ε n = 1− 4D∆th2 sin2 k

h2

Since the amplification factor is always less than 1, and we find that it is bigger than -1 if

sin2 () ≤ 1

(a) Consider first the case when U = 0, so the problem reduces to a pure diffusion

21

2 ≤∆h

tD

−1 ≤ 1− 4D∆th2 ≤ 1

Stability

Page 21: WPI Computational Fluid Dynamics I - Unicampphoenics/SITE_PHOENICS... · WPIPI Computational Fluid Dynamics I Convergence – the solution to the finite-difference equation approaches

Computational Fluid Dynamics IPPPPIIIIWWWW

Since the amplification factor has the form 1+i() the absolute value of this complex number is always larger than unity and the method is unconditionally unstable for this case.

ε n+1

ε n = 1− iU∆t2h

sin kh

(b) Consider now the other limit where D = 0 and we have a pure advection problem.

iU∆t2h

sin kh

1

ε n+1

ε n

Stability

Page 22: WPI Computational Fluid Dynamics I - Unicampphoenics/SITE_PHOENICS... · WPIPI Computational Fluid Dynamics I Convergence – the solution to the finite-difference equation approaches

Computational Fluid Dynamics IPPPPIIIIWWWWStability

(c) For the general case (Hirsch v.1, pp. 403-408)

Stability Condition

)1(cos2sin1 −+−= khkhiG βσRecall amplification factor

2,h

tDhtU ∆=∆= βσ

0 1

Re(G)

Im(G)

G σ

2β122 ≤≤ βσ

Page 23: WPI Computational Fluid Dynamics I - Unicampphoenics/SITE_PHOENICS... · WPIPI Computational Fluid Dynamics I Convergence – the solution to the finite-difference equation approaches

Computational Fluid Dynamics IPPPPIIIIWWWWIn summary, the stability condition for a general 1-Dconvection-diffusion equation becomes:

Notice that high velocity and low viscosity lead to instability according to the second restriction.

21

2 ≤∆h

tD2

2

≤∆D

tUand

Stability

or

≤∆

Dh

UDt

2,2Min

2

2

Page 24: WPI Computational Fluid Dynamics I - Unicampphoenics/SITE_PHOENICS... · WPIPI Computational Fluid Dynamics I Convergence – the solution to the finite-difference equation approaches

Computational Fluid Dynamics IPPPPIIIIWWWW

ε i, jn = ε nei(kxi +ly j )

41

2 ≤∆h

tD4|)||(| 2

≤∆+D

tVUand

81

2 ≤∆h

tD and 8|)||||(| 2

≤∆++D

tWVU

Stability

For a two-dimensional problem, assume an error of the form

A stability analysis gives:

For a three-dimensional problem we get:

Page 25: WPI Computational Fluid Dynamics I - Unicampphoenics/SITE_PHOENICS... · WPIPI Computational Fluid Dynamics I Convergence – the solution to the finite-difference equation approaches

Computational Fluid Dynamics IPPPPIIIIWWWW

Convergence – the solution to the finite-difference equation approaches the true solution to the PDE having the same initial and boundary conditions as the mesh is refined.

Stability

Lax’s Equivalence TheoremGiven a properly posed initial value problem and a finite-difference approximation to it that satistfies the consistencycondition, stability is the necessary and sufficient condition for convergence.

Stability – Now you know!

Page 26: WPI Computational Fluid Dynamics I - Unicampphoenics/SITE_PHOENICS... · WPIPI Computational Fluid Dynamics I Convergence – the solution to the finite-difference equation approaches

Computational Fluid Dynamics IPPPPIIIIWWWW

ConsistencyDoes the error always

go to zero?

Page 27: WPI Computational Fluid Dynamics I - Unicampphoenics/SITE_PHOENICS... · WPIPI Computational Fluid Dynamics I Convergence – the solution to the finite-difference equation approaches

Computational Fluid Dynamics IPPPPIIIIWWWW

Modified Equation (Finite Difference Equation):Using the finite difference approximation, we are effectively solving for equations that are slightly different from the original partial differential equations.

Does the finite difference equation approach the partial differential equation in the limit of zero ∆t and h?

Consistency

Page 28: WPI Computational Fluid Dynamics I - Unicampphoenics/SITE_PHOENICS... · WPIPI Computational Fluid Dynamics I Convergence – the solution to the finite-difference equation approaches

Computational Fluid Dynamics IPPPPIIIIWWWWConsider the 1-D advection-diffusion equation

and its finite-difference approximation

fjn+1 − fj

n

∆t+ U

fj +1n − fj −1

n

2h= D

f j+1n − 2 fj

n + fj −1n

h2

Consistency

2

2

xfD

xfU

tf

∂∂

∂∂

∂∂ =+

The discrepancy between the two equations can be found by deriving the modified equation.

Page 29: WPI Computational Fluid Dynamics I - Unicampphoenics/SITE_PHOENICS... · WPIPI Computational Fluid Dynamics I Convergence – the solution to the finite-difference equation approaches

Computational Fluid Dynamics IPPPPIIIIWWWWSubstituting

into the finite difference equation

fjn+1 − fj

n

∆t=

∂f (t)∂t

−∂ 2 f (t)

∂t2∆t2

+!

""

fj +1n − fj −1

n

2h=

∂f (x)∂x

−∂ 3 f (x)

∂x3h2

6+!

""

fj +1n − 2 f j

n + fj −1n

h2 =∂ 2 f (x)

∂x 2 −∂ 4 f (x)

∂x4h2

12+!

fjn+1 − fj

n

∆t+ U

fj +1n − fj −1

n

2h= D

f j+1n − 2 fj

n + fj −1n

h2

Consistency

Page 30: WPI Computational Fluid Dynamics I - Unicampphoenics/SITE_PHOENICS... · WPIPI Computational Fluid Dynamics I Convergence – the solution to the finite-difference equation approaches

Computational Fluid Dynamics IPPPPIIIIWWWW

),(12

)(6

)(2

)( 22

4

42

3

3

2

2

2

2

htOhx

xfDhx

xfUtt

tfx

fDxfU

tf

∆=+−+∆+

=−+

!∂

∂∂

∂∂

∂∂∂

∂∂

∂∂

Therefore, the finite-difference scheme is effectively solving the above modified equation.In this case, the error goes to zero as h�0 and ∆t�0, so the approximation is said to be consistent. Although most finite difference approximations are consistent, innocent-looking modifications can sometimes lead to approximations that are not!

Page 31: WPI Computational Fluid Dynamics I - Unicampphoenics/SITE_PHOENICS... · WPIPI Computational Fluid Dynamics I Convergence – the solution to the finite-difference equation approaches

Computational Fluid Dynamics IPPPPIIIIWWWWHW Examine the Frankel-Dufort method

2

2

xf

tf

∂∂ν

∂∂ =

Diffusion Equation

In finite-difference form

[ ]nj

nj

nj

nj

nj fff

htff

112

11

22 −+

−+

+−=∆− ν

Leapfrog method