finite difference approximations! numerical...

9
Computational Fluid Dynamics Elementary Numerical Analysis Grétar Tryggvason Spring 2011 http://www.nd.edu/~gtryggva/CFD-Course/ Computational Fluid Dynamics Outline • Finite Difference Approximations • Analysis of a Numerical Scheme • Modified Equation • Consistency • Richardson Extrapolation • Conservation Computational Fluid Dynamics Derivation of Finite Difference Approximations Computational Fluid Dynamics A second order upwind approximation to the first derivative: f ( x ! h) = f ( x) ! "f ( x) "x h + " 2 f ( x) "x 2 h 2 2 ! " 3 f ( x) "x 3 h 3 6 + " 4 f ( x) "x 4 h 4 24 ! L f ( x ! 2h) = f ( x) ! "f ( x) "x 2h + " 2 f ( x) "x 2 4 h 2 2 ! " 3 f ( x) "x 3 8h 3 6 + " 4 f ( x) "x 4 16h 4 24 !! Expand for x-h Expand for x-2h Subtract to eliminate the second derivative: Or: 4 f ( x ! h) ! f ( x ! 2h) = 3 f ( x) ! "f ( x) "x 2h + ! " 3 f ( x) "x 3 8h 3 6 + ! !f ( x) !x = 3 f ( x) " 4 f ( x " h) + f ( x " 2h) 2h + O(h 2 ) Finite Difference Approximations Computational Fluid Dynamics Subtracting the second equation from the first: f ( x + h) = f ( x) + !f ( x) !x h + ! 2 f ( x) !x 2 h 2 2 + ! 3 f ( x) !x 3 h 3 6 + ! 4 f ( x) !x 4 h 4 24 + O(h 5 ) f ( x ! h) = f ( x) ! "f ( x) "x h + " 2 f ( x) "x 2 h 2 2 ! " 3 f ( x) "x 3 h 3 6 + " 4 f ( x) "x 4 h 4 24 ! O(h 5 ) f ( x + h) ! f ( x ! h) = 2 "f ( x) "x h + 1 3 " 3 f ( x ) "x 3 h 3 + O( h 5 ) Start by expressing the value of f(x+h) and f(x-h) in terms of f(x) Finite Difference Approximations A fourth order centered approximation to the first derivative: Computational Fluid Dynamics By subtraction we found: f ( x + h) ! f ( x ! h) = 2 "f ( x) "x h + 1 3 " 3 f ( x ) "x 3 h 3 + O( h 5 ) Finite Difference Approximations Replacing h by 2h gives: f ( x + 2h) ! f ( x ! 2h) = 4 "f ( x) "x h + 8 3 " 3 f ( x ) "x 3 h 3 + O( h 5 ) f ( x + 2h) ! 8 f ( x + h) + 8 f ( x ! h) ! f ( x ! 2h) = !12 "f ( x) "x h + O(h 5 ) Subtract these two to eliminate the third derivative !f ( x) !x = f ( x " 2h) " 8 f ( x " h) + 8 f ( x + h) " f ( x + 2h) 12h + O(h 4 ) Or:

Upload: phungnga

Post on 08-Mar-2018

224 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Finite Difference Approximations! Numerical Analysisgtryggva/CFD-Course/2011-Lecture-8.pdfComputational Fluid Dynamics! Analysis of a numerical scheme! Another example! Computational

Computational Fluid Dynamics

Elementary!Numerical Analysis!

Grétar Tryggvason!Spring 2011!

http://www.nd.edu/~gtryggva/CFD-Course/!Computational Fluid Dynamics Outline!

•  Finite Difference Approximations!•  Analysis of a Numerical Scheme!•  Modified Equation!•  Consistency!•  Richardson Extrapolation!•  Conservation!

Computational Fluid Dynamics

Derivation of!Finite Difference!Approximations!

Computational Fluid Dynamics

A second order upwind approximation to the first derivative:!

f ( x! h) = f (x) !

"f (x)"x

h +" 2 f (x)"x 2

h2

2!" 3 f ( x)"x3

h3

6+" 4 f (x)"x 4

h4

24!L

f (x ! 2h) = f (x) ! "f (x)"x

2h + " 2 f (x)"x 2

4h2

2! "

3 f (x)"x 3

8h3

6+ " 4 f (x)

"x 416h4

24!!

Expand for x-h!

Expand for x-2h!

Subtract to eliminate the second derivative:!

Or:!

4 f (x ! h) ! f (x ! 2h) = 3 f (x) ! "f (x)"x

2h + !"3 f (x)"x 3

8h3

6+!

!f (x)!x

= 3 f (x) " 4 f (x " h) + f (x " 2h)2h

+ O(h2)

Finite Difference Approximations!

Computational Fluid Dynamics

Subtracting the second equation from the first:!

f (x + h) = f (x) + !f (x)!x

h + ! 2 f (x)!x 2

h2

2+ ! 3 f (x)

!x 3h3

6+ ! 4 f (x)

!x 4h4

24+ O(h5)

f (x ! h) = f (x) ! "f (x)"x

h + " 2 f (x)"x 2

h2

2! "

3 f (x)"x 3

h3

6+ " 4 f (x)

"x 4h4

24!O(h5)

f (x + h) ! f (x ! h) = 2"f (x)"x

h + 13" 3 f (x)"x 3

h3 + O(h5)

Start by expressing the value of f(x+h) and f(x-h) in terms of f(x)

Finite Difference Approximations!

A fourth order centered approximation to the first derivative:!

Computational Fluid Dynamics

By subtraction we found:!

f (x + h) ! f (x ! h) = 2"f (x)"x

h + 13" 3 f (x)"x 3

h3 + O(h5)

Finite Difference Approximations!

Replacing h by 2h gives:!

f (x + 2h) ! f (x ! 2h) = 4 "f (x)"x

h + 83" 3 f (x)"x 3

h3 + O(h5)

f (x + 2h) ! 8 f (x + h) + 8 f (x ! h) ! f (x ! 2h) = !12"f (x)"x

h + O(h5)

Subtract these two to eliminate the third derivative!

!f (x)!x

= f (x " 2h) " 8 f (x " h) + 8 f (x + h) " f (x + 2h)12h

+ O(h4 )

Or:!

Page 2: Finite Difference Approximations! Numerical Analysisgtryggva/CFD-Course/2011-Lecture-8.pdfComputational Fluid Dynamics! Analysis of a numerical scheme! Another example! Computational

Computational Fluid Dynamics

Similarly, we can find approximations of different order, using different points, for the different derivatives.!

The next two slides list several such approximations (using subscripts to denote the different grid points)!

Finite Difference Approximations!Computational Fluid Dynamics

!f!x

=f j+1 " f j

h+ O(h)

!f!x

=f j " f j"1

h+ O(h)

!f!x

=f j+1 " f j"12h

+ O(h2)

!f!x

=" f j+2 + 4 f j+1 " 3 f j

2h+ O(h2)

!f!x

=3 f j " 4 f j"1 + f j"2

2h+ O(h2)

!f!x

=" f j+2 + 8 f j+1 " 8 f j"1 + f j"2

12h+ O(h4 )

Downwind!

Upwind!

Centered!

Centered!

Downwind!

Upwind!

Finite Difference Approximations!

Computational Fluid Dynamics

! 2 f!x 2

=f j+1 " 2 f j + f j"1

h2+ O(h2)

! 2 f!x 2

=" f j+2 +16 f j+1 " 30 f j +16 f j"1 " f j"2

12h2+ O(h4 )

Centered approximations for the second derivative!

! 3 f!x 3

=f j+2 " 2 f j+1 + 2 f j"1 " f j"2

2h3+ O(h2)

! 4 f!x 4

=f j+2 " 4 f j+1 + 6 f j " 4 f j"1 + f j"2

h4+ O(h2)

Centered second order approximations for the third and fourth derivative!

Finite Difference Approximations!Computational Fluid Dynamics

Example!

Step size Error!h f’ (x=1) f’’ (x=1)!0.2 -0.4016 -0.4000!0.1 -0.1001 -0.1000!0.05 -0.0250 -0.0250!0.025 -0.0063 -0.0062!0.0125 -0.0016 -0.0016!

f (x) = x 5

!f!x

= 5x 4

! 2 f!x 2

= 20x 3

Error versus 1/h for the first derivative!

-2!

!f!x

=f j+1 " f j"12h

+ O(h2)

Finite Difference Approximations!

Computational Fluid Dynamics

Analysis of a numerical scheme!

The Modified Equation!

Computational Fluid Dynamics

Use the leap-frog method (centered differences) to integrate the diffusion equation !

in time. Use the standard centered difference approximation for the second order spatial derivative.!(a) Write down the finite difference equation.!(b) Write down the modified equation!(c) Find the accuracy of the scheme!(d) Use the von Neuman's method to derive an equation for the amplification factor g. Hint: assume that the amplification is the same for each step:!

!f!t

= D! 2 f!x 2

D > 0

g = ! n+1 ! n = ! n ! n"1

Numerical Analysis—Example!

Page 3: Finite Difference Approximations! Numerical Analysisgtryggva/CFD-Course/2011-Lecture-8.pdfComputational Fluid Dynamics! Analysis of a numerical scheme! Another example! Computational

Computational Fluid Dynamics

f jn+1 ! f j

n!1

2"t= D

f j+1n ! 2 f j

n + f j!1n

h2

(a) Write down the finite difference equation!

!f!t

= D! 2 f!x 2

Approximate both terms by centered differences!

Numerical Analysis—Example!Computational Fluid Dynamics

(b) Write down the modified equation!

1( ) f jn+1 = f j

n +!f j

n

!t"t +

! 2 f jn

!t 2"t 2

2+! 3 f j

n

!t 3"t 3

6+!

2( ) f jn#1 = f j

n #!f j

n

!t"t +

! 2 f jn

!t 2"t 2

2#! 3 f j

n

!t 3"t 3

6+!

3( ) f j+1n = f j

n +!f j

n

!xh +

! 2 f jn

!x 2h2

2+! 3 f j

n

!x 3h3

6+!

4( ) f j#1n = f j

n #!f j

n

!xh +

! 2 f jn

!x 2h2

2#! 3 f j

n

!x 3h3

6+!

Substitute into !

f jn+1 ! f j

n!1

2"t= D

f j+1n ! 2 f j

n + f j!1n

h2

Numerical Analysis—Example!

Computational Fluid Dynamics

1( ) ! 2( )2"t

= D3( ) ! 2 f jn + 4( )

h2

!f!t

+ ! 3 f!t 3

"t 2

6= D! 2 f

!x 2+ D! 4 f

!x 4h2

12+ …

O !t 2,h2( )

!f!t

"D! 2 f!x 2

= D! 4 f!x 4

h2

12" !

3 f!t 3

#t 2

6+ …

(c) Find the accuracy of the scheme!

Rearrange!

yielding!

Substitute!

Modified Equation!

Numerical Analysis—Example!Computational Fluid Dynamics

(d) Use the von Neuman's method to derive an equation for the amplification factor g.!

jikxnnj e!! =

! jn+1 "! j

n"1

2#t= D

! j+1n " 2! j

n + ! j"1n

h2

!n+1eikx j "!n"1eikx j

2#t= D !n

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

Substitute!

into!

giving!

Numerical Analysis—Example!

Computational Fluid Dynamics

!n+1eikx j "!n"1eikx j

2#t= D !n

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

Cancel the common factor!

!n+1 "!n"1

2#t= D !n

h2(eikh " 2 + e" ikh )

Rearrange!

!n+1

!n" !

n"1

!n= 2#tD

h2(eikh " 2 + e"ikh )

g = ! n+1 ! n = ! n ! n"1Using that!

g ! 1g

= ! 2"tDh2

4 sin2 kh2

eikh + e!ikh = 2coskh2sin2" =1! cos2"Gives:!

Numerical Analysis—Example!Computational Fluid Dynamics

g ! 1g

= ! 2"tDh2

4 sin2 kh2

g2 !1= !Bg

B = 8!tDh2sin2 kh

2

Putting!

gives!

g2 + Bg!1= 0

Solution!

x 2 + bg + c = 0

x = ! b2

± b2" # $

% & ' 2

! c

g = ! B2

± B2

" # $

% & ' 2

+1

Which is always > 1 ! Unconditionally unstable!

Numerical Analysis—Example!

Page 4: Finite Difference Approximations! Numerical Analysisgtryggva/CFD-Course/2011-Lecture-8.pdfComputational Fluid Dynamics! Analysis of a numerical scheme! Another example! Computational

Computational Fluid Dynamics

Analysis of a numerical scheme!Another example!

Computational Fluid Dynamics

The following finite difference approximation is given

(a) Write down the modified equation (b) What equation is being approximated? (c) Determine the accuracy of the scheme (d) Use the von Neuman's method to derive an equation for the stability conditions

f jn+1 ! f j

n

"t= ! 1

2U2h

f j+1n ! f j!1

n( ) + U2h

f j+1n+1 ! f j!1

n+1( )# $ %

& ' (

Numerical Analysis—Another Example!

Computational Fluid Dynamics

f jn+1 ! f j

n

"t= ! 1

2U2h

f j+1n ! f j!1

n( ) + U2h

f j+1n+1 ! f j!1

n+1( )# $ %

& ' (

h h

fjn+1

fjn fj+1

nfj!1n !t

f j+1n+1

f j!1n+1

(a) Write down the modified equation!

Numerical Analysis—Another Example!Computational Fluid Dynamics

1( ) f jn+1 = f j

n +!f j

n

!t"t +

! 2 f jn

!t 2"t 2

2+! 3 f j

n

!t 3"t 3

6+!

2( ) f j+1n = f j

n +!f j

n

!xh +

! 2 f jn

!x 2h2

2+! 3 f j

n

!x 3h3

6+!

3( ) f j#1n = f j

n #!f j

n

!xh +

! 2 f jn

!x 2h2

2#! 3 f j

n

!x 3h3

6+!

4( ) f j+1n+1 = f j

n+1 +!f j

n+1

!xh +

! 2 f jn+1

!x 2h2

2+! 3 f j

n+1

!x 3h3

6+!

5( ) f j#1n+1 = f j

n+1 #!f j

n+1

!xh +

! 2 f jn+1

!x 2h2

2#! 3 f j

n+1

!x 3h3

6+!

Numerical Analysis—Another Example!

Computational Fluid Dynamics

∂ f∂t

+∂ 2 f∂t2

Δt2+

⎝⎜⎞

⎠⎟ j

n

= −U2

∂ f∂x

+∂ 3 f∂x3

h2

6+

⎝⎜⎞

⎠⎟ j

n

+∂ f∂x

+∂ 3 f∂x3

h2

6+

⎝⎜⎞

⎠⎟ j

n+1⎛

⎝⎜⎜

⎠⎟⎟

yielding!

Substitute!

(1) ! f jn

"t= ! 1

2U2h

(2) ! (3)( ) + U2h

(4) ! (5)( )# $ %

& ' (

Using (1) again we can write!

∂ f jn+1

∂x=∂ f j

n

∂x+∂ 2 f j

n

∂t∂xΔt +

∂ 3 f jn

∂t2∂xΔt2

2+∂ 4 f j

n

∂t3∂xΔt3

6+

∂ 3 f jn+1

∂x3 =∂ 3 f j

n

∂x3 +∂ 4 f j

n

∂t∂x3 Δt +∂ 5 f j

n

∂t2∂x3

Δt2

2+

∂ 6 f jn

∂t3∂x3

Δt3

6+

Numerical Analysis—Another Example!Computational Fluid Dynamics

∂ f∂t

+∂ 2 f∂t2

Δt2+

⎝⎜⎞

⎠⎟ j

n

= −U2

∂ f∂x

+∂ 3 f∂x3

h2

6+

⎝⎜⎞

⎠⎟ j

n

+⎛

⎝⎜⎜

∂ f jn

∂x+∂ 2 f j

n

∂t∂xΔt +

∂ 3 f jn

∂t2∂xΔt2

2++

∂ 3 f jn

∂x3 +⎛

⎝⎜

⎠⎟

h2

6+

⎝⎜⎜

⎠⎟⎟

j

n+1⎞

⎟⎟

Substitute again:!

Collecting the terms!

∂ f∂t

+∂ 2 f∂t2

Δt2+ = −

U2

∂ f∂x

+∂ 3 f∂x3

h2

6+∂ f∂x

+∂ 2 f∂t∂x

Δt + ∂ 3 f∂t2∂x

Δt2

2+∂ 3 f j

n

∂x3

h2

6+

⎝⎜

⎠⎟

!f!t

= "U !f!x

# "U2! 2 f!t!x

= "U2

!!x

!f!t

$ % &

' ( ) = 12! 2 f!t 2

Numerical Analysis—Another Example!

Page 5: Finite Difference Approximations! Numerical Analysisgtryggva/CFD-Course/2011-Lecture-8.pdfComputational Fluid Dynamics! Analysis of a numerical scheme! Another example! Computational

Computational Fluid Dynamics

Rearrange!

O !t 2,h2( )(c) Find the accuracy of the scheme !

∂ f∂t

+U ∂ f∂x

= −U ∂ 3 f∂x3

h2

6−U ∂ 3 f

∂t2∂xΔt2

4+

(b) What equation is being approximated !

!f!t

+U !f!x

= 0

Modified Equation!

Numerical Analysis—Another Example!Computational Fluid Dynamics

(d) Use the von Neuman's method to derive an equation for the amplification factor g.!

jikxnnj e!! =

! jn+1 "! j

n

#t= " 1

2U2h

! j+1n "! j"1

n( ) + U2h

! j+1n+1 "! j"1

n+1( )$ % &

' ( )

!n+1eikx j "!neikx j

#t= U4h

!n eikheikx j " e"ikheikx j( ) + !n+1 eikheikx j " e"ikheikx j( )( )

Substitute!

into!

giving!

Numerical Analysis—Another Example!

Computational Fluid Dynamics

Cancel the common factor!

Rearrange!

writing!

eikh ! e!ikh = 2isinkhGives:!

!n+1eikx j "!neikx j

#t= U4h

!n eikheikx j " e"ikheikx j( ) + !n+1 eikheikx j " e"ikheikx j( )( )

!n+1 "!n

#t= U4h

!n eikh " e"ikh( ) + !n+1 eikh " e" ikh( )( )

!n+1

!n"1= #tU

4heikh " e"ikh( ) + !n+1

!neikh " e"ikh( )

$

% &

'

( )

g !1= 1+ g( ) "tU4h

2isinkh( )

g = !n+1 !n

Numerical Analysis—Another Example!Computational Fluid Dynamics

g !1= 1+ g( ) "tU4h

2isinkh( )

g 1! A 2isinkh( )( ) =1+ A 2isinkh( )

g =1+ A 2isinkh( )1! A 2isinkh( )

g = 1! 4A2 sin2 kh + iA2sinkh1+ 4A2 sin2 kh

g = 1! B2 + iB

1+ B2

g 2 =1! B2( )2 + B2

1+ B2( )2

1! B2 + B4 <1+ 2B2 + B4 Unconditionally Stable!

z = x + iy

z 2 = x + iy( ) x ! iy( ) = x 2 + y 2

Numerical Analysis—Another Example!

Computational Fluid Dynamics

Notes:!You will do a few other schemes as homework problems.!

Generally we assume that results for the linear equations hold for the nonlinear one as well.!

The algebraic equation for the amplification factor can often be fairly complicated. It is, however, routinely solved. !

Computational Fluid Dynamics

Consistency!Does the error always

go to zero?!

Page 6: Finite Difference Approximations! Numerical Analysisgtryggva/CFD-Course/2011-Lecture-8.pdfComputational Fluid Dynamics! Analysis of a numerical scheme! Another example! Computational

Computational Fluid Dynamics

Using the finite difference approximation, we are effectively solving an equation that is slightly different than the original partial differential equations.!

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

Consistency!Computational Fluid Dynamics

Consider the 1-D advection-diffusion equation!

and its finite-difference approximation!

f jn +1 ! f j

n

"t+U

f j+1n ! f j!1

n

2h= D

f j+1n ! 2 f j

n + f j!1n

h2

∂ f∂t

+U ∂ f∂x

= D ∂ 2 f∂x2

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

Consistency!

Computational Fluid Dynamics

Substituting!

f jn+1 ! f j

n

"t= #f (t)

#t+ # 2 f (t)

#t 2"t2

+!

f j+1n ! f j!1

n

2h= "f (x)

"x+ " 3 f (x)

"x 3h2

6+!

f j+1n ! 2 f j

n + f j!1n

h2= " 2 f (x)

"x 2+ " 4 f (x)

"x 4h2

12+!

into the finite difference equation!fjn+1 ! fj

n

"t+U

fj+1n ! fj!1

n

2h= D

f j+1n ! 2 fj

n + fj!1n

h2

Consistency!Computational Fluid Dynamics

!f!t

+U !f!x

"D! 2 f!x 2

= "!2 f (t)!t 2

#t2"U ! 3 f (x)

!x 3h2

6+ D! 4 f (x)

!x 4h2

12+!

In this case, the error goes to zero as h0 and Δt0, so the approximation is said to be CONSISTENT!

Results in:!

Original Equation! Error terms!

!f!t

+ U !f!x

"D! 2 f!x 2

= O(#t,h2 )

Shorthand:!

Consistency!

Computational Fluid Dynamics

Although most finite difference approximations are consistent, innocent-looking modifications can sometimes lead to approximations that are not!!

The Frankel-Dufort is an example of an non-consistent scheme.!

You will examine it in the homework!

Consistency!Computational Fluid Dynamics

HW: Examine the Frankel-Dufort method!

!f!t

= D! 2 f!x 2

Solve the diffusion equation!

Using the Leapfrog time integration method and standard finite-difference approximation for the spatial derivative gives:!

f jn+1 ! f j

n!1

2"t= Dh2

f j+1n ! 2 f j

n + f j!1n[ ]

Leapfrog method!

Consistency!

Page 7: Finite Difference Approximations! Numerical Analysisgtryggva/CFD-Course/2011-Lecture-8.pdfComputational Fluid Dynamics! Analysis of a numerical scheme! Another example! Computational

Computational Fluid Dynamics

This gives:!

f jn+1 ! f j

n!1

2"t= Dh2

f j+1n ! 2 f j

n + f j!1n[ ]

f jn =

12f jn +1 + f j

n!1( )

f jn+1 = f j

n!1 + 2"t D

h2f j+1n ! f j

n+1 ! f jn!1 + f j!1

n( ).Which is easily solved for f at the new time step!

Now modify it slightly:!

In the HW, you will examine the error!!

Replace by:!

Consistency!Computational Fluid Dynamics

The MODIFIED EQUATION is obtained by substituting the expression for the finite difference approximations, including the error terms, into the finite difference equation. For a CONSISTENT finite difference approximation the error terms go to zero as h0 and Δt0.

The modified equation can often be used to infer the nature of the error of the finite difference scheme. More about that later.!

Consistency!

Computational Fluid Dynamics

Richardson Extrapolation!

Computational Fluid Dynamics

Extrapolation to h=0:!The best way to estimate the error in a finite difference computation is to repeat the calculation on a different (finer or coarser) grid. Usually, the cost of doing another computation on a coarser grid is small. We can, however, estimate the error in the following way. Assume have a second order. The approximate solution can be written as a function of the resolution, h, as follows:!

f h( ) = f 0( ) + Ch2 + HOT

Richardson Extrapolation!

Computational Fluid Dynamics

Here, f(0) is the (unknown) exact solution and C is a constant determining the magnitude of the error. Given f(h) and f(2h), estimate C. Once C is known, we can use the above formula to find a better estimate for the solution. This procedure is called Richardson Extrapolation and is widely used in practice.!

f h( ) = f 0( ) + Ch2 + HOT

The approximate solution can be written as a Taylor series around the exact solution f(0):!

Richardson Extrapolation!Computational Fluid Dynamics

We have:!similarly, the solution on twice as coarse grid is:!

subtracting to eliminate the h2 term:!

Solving for the exact solution:!

Since the Higher Order Terms (HOT) are at least O(h3), f(0) is a better estimate than either f(h) or f(h2). Similar formulas can be derived for schemes of different orders.!

f h( ) = f 0( ) + Ch2 + HOT

f 2h( ) = f 0( ) + C4h2 + HOT

4 f h( ) ! f 2h( ) = 4 f 0( ) ! f 0( ) + HOT

f 0( ) =4 f h( ) ! f 2h( )

3+ HOT

Richardson Extrapolation!

Page 8: Finite Difference Approximations! Numerical Analysisgtryggva/CFD-Course/2011-Lecture-8.pdfComputational Fluid Dynamics! Analysis of a numerical scheme! Another example! Computational

Computational Fluid Dynamics

For an n-th order scheme we have:!

similarly, the solution on twice as coarse grid is:!

subtracting to eliminate the hn term:!

Solving for the exact solution:!

f h( ) = f 0( ) + Chn + HOT

f 2h( ) = f 0( ) + C2n hn + HOT

2n f h( ) ! f 2h( ) = 2n f 0( ) ! f 0( ) + HOT

f 0( ) =2n f h( ) ! f 2h( )

2n !1+ HOT

Richardson Extrapolation!Computational Fluid Dynamics

Conservative discretization!

Computational Fluid Dynamics

In finite volume method, equations in conservative forms are needed in order to satisfy conservation properties.!

As an example, consider a 1-D equation!

∂f (x, t)∂t

+∂F[ f (x, t)]

∂x= 0

where F denotes a general advection/diffusion term, e.g.!

F =12f 2; F = µ(x) ∂f

∂x

Conservative Schemes!Computational Fluid Dynamics

∂F∂x

dxL∫ =

Fj+1/ 2 − Fj−1/ 2

Δx∑ Δx

Xj-1/2 xj+1/2 !

f j+1

f j−1

f j

x!

In discretized form:!

= + Fj−1/ 2 − Fj−3 / 2 + Fj+1/ 2 − Fj−1/ 2 + Fj+3 / 2 − Fj+1/ 2 +[ ]

= FL − F0

If F = 0 at the end points of the domain, f is conserved.!

Integrating over the domain L,!

∂f∂tdx

L∫ +

∂F∂x

dxL∫ = 0

F(L) − F (0) = 0

⇒ddt

fdxL∫ = 0

Conservative Schemes!

Computational Fluid Dynamics

∂f∂t

+ ∂∂x

12f 2

⎛ ⎝ ⎜

⎞ ⎠ ⎟ = 0

Examples of Conservative Form!

Discretize using upwind !

∂∂x

12f 2

⎛ ⎝ ⎜

⎞ ⎠ ⎟ ≈

12h

fi2 − f i−1

2( ) Conservative!�

∂f∂t

+ f ∂f∂x

= 0

f ∂f∂x

≈ f ih

f i − f i−1( ) Non-conservative!

versus!

Conservative Schemes!Computational Fluid Dynamics

∂F∂x

dxL∫ ≈ Fj+1/ 2 − Fj−1/ 2∑ =

+ fi−12 − f i−2

2 + f i2 − f i−1

2 + f i+12 − fi

2 +

∂F∂x

dxL∫ ≈ Fj+1/ 2 − Fj−1/ 2∑ =

+ fi−12 − f i−1 f i + f i

2 − f i f i−1 + f i+12 − f i+1 f i +

∂∂x

12f 2

⎛ ⎝ ⎜

⎞ ⎠ ⎟ ⎞ ⎠ ⎟ i

≈ 12h

fi2 − f i−1

2( )

f ∂f∂x

⎞ ⎠ ⎟ i

≈ f ih

fi − f i−1( )

Conservative Schemes!

Page 9: Finite Difference Approximations! Numerical Analysisgtryggva/CFD-Course/2011-Lecture-8.pdfComputational Fluid Dynamics! Analysis of a numerical scheme! Another example! Computational

Computational Fluid Dynamics

∂f∂t

+ ∂∂x

µ(x) ∂f∂x

⎛ ⎝ ⎜

⎞ ⎠ ⎟ = 0

Another example (variable diffusion coefficient)!

Discretize !

∂∂x

µ(x) ∂f∂x

⎛ ⎝

⎞ ⎠

Conservative!

µ∂2 f∂x 2

+∂µ∂x

∂f∂x

Non-conservative!

versus!

Conservative Schemes!Computational Fluid Dynamics

∂f∂t

+ f ∂f∂x

= 0

f ∂f∂t

+ f ∂f∂x

⎛ ⎝ ⎜

⎞ ⎠ ⎟ = 0

∂∂t

f 2

2+ ∂∂x

f 3

3= 0

ddt

f 2

2dx∫ = − ∂

∂xf 3

3dx∫ = f 3

3⎡

⎣ ⎢

⎦ ⎥ −∞

= 0

f ∞( ) = f −∞( ) = 0

ddt

f n

ndx∫ = 0

Similarly, it can be shown that!

Conservation of higher order quantities!Consider:!

Integrate:!

Conservative Schemes!

Computational Fluid Dynamics

Generally it is believed that conservative schemes are superior to non-conservative ones and that the more conserved quantities the discrete approximation preserves, the better the scheme. While mostly true, there are exceptions as we will discuss later!!