Vous êtes sur la page 1sur 12

Chapter 3

Analysis of Numerical Methods


Several numerical methods for scalar and vector conservation equations of compressible
ows will be presented in the next chapters. To understand them better, the basic analysis
of numerical methods is presented in this chapter. First, the basics of Finite Dierence
Method (FDM) and the Finite Volume Method (FVM) are presented, with the example
of a simple linear convection equation. Then, the concepts of consistency and stability
of a numerical method are briey introduced, followed by the discussion on numerical
dissipation, numerical dispersion and order of accuracy, illustrated by the analysis of
Modied Partial Dierential Equations (MPDE).

3.1

Basics of Finite Dierence and Finite Volume


Methods

In this course, we shall limit ourselves the appplication of Finite Dierence Method (FDM)
and Finite Volume Method to the typical scalar and vector conservation equations, concentrating mostly on the Finite Volume Method, which is the most popular method used
in compressible uid ow simulations.

3.1.1

Upwind Method in Finite Dierence Form

Consider a linear convection equation


u
u
+c
=0
t
x

(3.1)

Let us discretize the above hyperbolic equation on a three point stencil shown in the
gure (3.1). We discretize the time derivative using forward dierencing since we will
be marching forward in time for the solution of the convection equations. For the space
35

DRAFT -- DRAFT -- DRAFT -- DRAFT -- DRAFT --

CHAPTER 3. ANALYSIS OF NUMERICAL METHODS

36






xj1

 
 


  
  










 
 
 
 
 
 





   























 

















 





 
 
 
 
 
 
 



  











  




 















 
















 
 
 
 
 
  




 







  



















 
  
  
  
  
  
  
  





 
 

















 



 












 


 
 
 
 
 








 
 





















 























 














  
  
  
 

 
 


 










 



 
 
 
 

 



 








 
  




 
 
 
 

 


 
















 








 

















































 
 
 c
 
 t
   
 
  
  c
  
  t
    
x

xj

  


t+t










 


xj+1

Figure 3.1: 3-Point Stencil

derivative, the simplest approximation seems to be central diferencing.


unj
unj+1 unj1
un+1
j
+c
=0
(3.2)
t
2x
Here, the superscript n denotes the time level t and n + 1 denotes the time level t + t.
This discretization known as the Forward Time Centered Space discretization, actually
leads to an unstable scheme! To understand why, let us see the analytical solution of the
linear convection equation (3.1). The analytical solution is given by
u (x, t) = u (x ct, t = 0)

(3.3)

which, for the 3-point stencil shown in the gure (4.1), can be written as
u (x, t + t) = u (x ct, t)

(3.4)

So, the solution at the new time level can be found by tracing the foot of the characteristic
on the line connecting the points j 1, j and j + 1 at the old time level. Obviously, it
depends on the sign of the convection speed c. If c is positive, the information to the point
j comes from the left, from the point j 1 and if c is negative, the information to the
point j comes from the right, from the point j + 1. Therefore, the information comes only
from one side, depending on the sign of c. The FTCS discretization takes information
from the wrong side also, thus leading to instability. To respect the hyperbolicity of
the equation, we have to introduce one sided dierencing, depending on the sign of the
convection speed. To do so, let us rst split the convection speed into a positive part and
a negative part as
c + |c| c |c|
(3.5)
c=
+
= c+ + c
2
2
Here, c+ is always positive and c is always negative. Therefore, the linear convection
eqution becomes
u
u
u
+ c+
+ c
=0
(3.6)
t
x
x

DRAFT -- DRAFT -- DRAFT -- DRAFT -- DRAFT --

3.1. BASICS OF FINITE DIFFERENCE AND FINITE VOLUME METHODS

37

Now, for the c+ term, information comes to the point j only from the left, and hence
a backward dierencing can be used. Similarly, for the c term, the information comes
only from the right, and therefore, forward dierencing can be used. Such a discretization
where we go up the wind and take the information is called upwind dierencing and the
resulting scheme is an upwind scheme.
n
n
n
n
un+1
unj
j
+ uj uj1
uj+1 uj
+c
+c
=0
(3.7)
t
x
x
The above method is a Finite Dierence Method (FDM) as we have used the nite differences for the derivatives in a partial dierential equation.
The upwind method can also be derived in a dierent way. Since we know the exact
solution of the linear convection equation, we can use it to trace the foot of the characteristic on the 3-point stencil and use a linear interpolation between the grid points. The
solution of the linear convection equation is

u (x, t + t) = u (x ct, t)

(3.8)

Now, consider a 3-point stencil as shown in gure (4.1). The foot of the characteristic falls
between points j and j 1 if c > 0 and between j and j +1 if c < 0. Let us denote the foot
of the characteristic by P and consider the c > 0 case rst. Using a linear interpolation
between j and j 1, we can now write
u(xP ) = u(xj1 ) +

u(xj ) u(xj1)
(xP xj1 )
(xj xj1 )

(3.9)

Therefore,
u(xj ) u(xj1)
(x ct)
x
(u(xj ) u(xj1 ))
= u(xj1 ) + (u(xj ) u(xj1)
ct
x
t
= u(xj ) c
[u(xj ) u(xj1 )]
x
= u(xj ) [u(xj ) u(xj1 )]

u(xP ) = u(xj1 ) +

t
where = c x
. Thus, we recover the upwind method. Therefore, the upwind method
follows exact solution with the accuracy of linear interpolation. If c < 0, then we need to
interpolate the foot of the characteristic between the points j and j + 1 which will lead to

u(t + t, xj ) = u(t, xj ) [u(t, xj+1 ) u(t, xj )]

(3.10)

Both the cases c > 0 and c < 0 can be combined using


1
c+ = max(c, 0) = (c + |c|) where c+ 0 always
2
1
c = min(c, 0) = (c |c|) where c 0 always
2

DRAFT -- DRAFT -- DRAFT -- DRAFT -- DRAFT --

CHAPTER 3. ANALYSIS OF NUMERICAL METHODS

38

Here, if c > 0, c = 0 and if c < 0, c+ = 0. Therefore, we can write


c = c + + c
1
1
(c + |c|) + (c |c|)
or c =
2
2
u
u
+c
=0
t
x

u
u
u
+ c+
+ c
=0
t
x
x

becomes

(3.11)
or

u c + |c| u c |c| u
+
+
=0
t
2 x
2 x

and then the upwind method becomes




un+1
= unj + unj unj1 unj+1 unj
j
where
=

3.1.2

t c |c|
x 2

(3.12)

(3.13)

Upwind Method in Finite Volume Form

Let us discretize the linear convection equation by using a Finite Volume Method (FVM).
First, let us write the linear convection equation in conservative form so that the FVM
we shall derive now is equally applicable to any conservative convection equation, linear
or non-linear.
u g (u)
1
+
= 0 , where g (u) = u2
(3.14)
t
x
2
Let us now discretize our 1-D computational domain as a set of cells or nite volumes,
assuming that within each cell the solution has a piecewise polynomial variation. The
simplest choice is to have a piecewise constant approximation in each cell, as shown in
gure (3.2). We can also choose more accurate approximations, like a piecewise linear












































j3

j2

j1

j+1


j+2

j+3




















j3/2

j1/2

j+1/2




j+3/2

Figure 3.2: Piecewise Constant Approximation


approximation shown in gure (3.3) or piecewise quadratic or cubic approximations. The
approximation we choose determines the order of accuracy of the disretization. Let us

DRAFT -- DRAFT -- DRAFT -- DRAFT -- DRAFT --

3.1. BASICS OF FINITE DIFFERENCE AND FINITE VOLUME METHODS

39











































j1

j2

j3

j+1

j+2

j+3























j3/2

j1/2

j+1/2




j+3/2

Figure 3.3: Piecewise Linear Approximation

now use the nite volume method, which starts with the integral form of the conservation equation in which the integration is over a nite volume or cell [xj 1 , xj+ 1 ] and a
2
2
time interval [tn , tn+1 ]. For simplicity, let us assume a piecewise constant approximation.
The integral form of the scalar conservation equation we have chosen (linear convection
equation) is


tn+1

tn

dt

xj+ 1

u g
dx
=0
+
t
x

xj 1
2

which can be written as




xj+ 1



tn+1

tn

xj 1
2

u
dt dx =
t

tn+1
tn

xj+ 1

g
dx dt
x

xj 1
2

Note the changing of the order of time and space integrations in the left hand side so that
a simple integration can be performed easily. Completing the integrations, we obtain


xj+ 1
2

xj 1

n+1
[u]ttn

dx =

tn+1
tn

xj+ 1

[g (x)]xj 21 dt
2

or


xj+ 1
2

xj 1

n+1

dx =

tn+1

tn

g xj+ 1 g xj 1

dt

or


xj+ 1
2

xj 1
2

n+1

dx =

xj+ 1
2

xj 1

u dx



tn+1

g xj+ 1 dt
2

tn

tn+1

tn

xj 1 dt
2

(3.15)

Let us now dene the cell integral averages as


1
x

xj+ 1
2

xj 1

u (x) dx = uj

(3.16)

DRAFT -- DRAFT -- DRAFT -- DRAFT -- DRAFT --

CHAPTER 3. ANALYSIS OF NUMERICAL METHODS

40

Using the above denitions, the update formula of the nite volume method can be written
as
x
un+1
j

x
unj



tn+1

tn

g xj+ 1 dt
2

or
= unj
un+1
j

tn+1
tn

g xj 1 dt
2


t 
gj+ 1 gj 1
2
2
x

(3.17)

where



1  tn+1
1  tn+1
g xj 1 dt =
g u xj 1 dt
(3.18)
2
2
2
t tn
t tn
are the time-averaged uxes. We have to now reconstruct the value of u at xj 1 , as we
2
have the cell integral averages uj (equation (3.16)) only at the cell-centres xj . (Since
we converted u (x), a continuous variable, to a cell-integral average u j , we have lost the
variation of u and now that we require the variation of u at the cell interfaces, we have
to reconstruct the variation of u.) We reconstruct a piecewise polynomial form of u (x)
in each cell and denote it by pr (x). We can get this reconstructed polynomial from the
cell-centre values uj , uj1, uj2 etc. The general form of the polynomial pr (x) is

gj 1 =

pr (x) = a + b (x xi ) + c (x xi )2 + d (x xi )3 + . . .
If we retain only the rst term on the right hand side, then we have a piecewise constant
approximation. Retaining the rst two terms on the right hand side leads to piecewise
linear approximation and retaining rst three terms leads to piecewise quadratic approximation.
For the piecewise constant approximation, we have
pr (x) = unj

(3.19)

We also need to know how pr (x) evolves, which we denote by pe (x), as we need to
substitute pe (x) in the place of u (x) in formula (3.18) to obtain uxes gj 1 . Since
2
pr (x) u (x, t) by our approximation, for the evolution of p (x) we take the evolution of
u (x) , following the exact solution of (1), i.e.,
u (x, t) = u (x c (t tn ) , tn )

(3.20)

Therefore

pe xj+ 1 , t = pr xj+ 1 c (t tn ) , tn
2

(3.21)

where n and n + 1 represent two consecutive time-levels with their dierence being the
time-step, (tn+1 tn = t). Referring to the gure (3.2), we can approximate (3.21) as

pe xj+ 1 , t =
2

unj for 0 ct
1
x
ct
n
uj+1 for 1 x 0

(3.22)

DRAFT -- DRAFT -- DRAFT -- DRAFT -- DRAFT --

3.1. BASICS OF FINITE DIFFERENCE AND FINITE VOLUME METHODS

41

Similarly, we can write


unj1 for 0 ct
1
x
ct
n
uj for 1 x 0

pe xj 1 , t =
2

(3.23)

From (3.18)
1
t

gj+ 1 =
2

tn+1

g u xj+ 1 , t dt
2

tn

or
gj+ 1
2

1
=
t

tn+1

g pe xj+ 1
2

tn

1
, t dt =
t

tn+1
tn

c pe

xj+ 1 , t dt
2

(since g (u) = cu). Substituting for pe and completing the integration, we obtain
gj+ 1
2

1
=
t
t

or

gj+ 1 =
2

c unj f or 0 ct
1
x
ct
n
c uj+1 f or 1 x 0

c unj f or 0 ct
1
x
ct
n
c uj+1 f or 1 x 0

(3.24)

Similarly, we can derive


gj 1 =
2

c unj1 f or 0
c unj f or 1

ct
x
ct
x

1
0

(3.25)

Substituting the expressions for above uxes in the update formula (3.17), we obtain

un+1
j
or
un+1
j

unj

t c unj unj1 f or c > 0


= unj
x c unj+1 unj f or c < 0
t



c + |c| n
c |c| n
uj unj1 +
uj+1 unj
2
2

(3.26)

Thus, we can see that the piecewise constant approximation with the upwinding in nite
volume method yields the rst order accurate upwind nite dierence method. This
equivalence is possible for a linear convection equation. The main advantage of the upwind
nite volume method is that the update formula leads to a conservative discretization.
To understand the importance of the conservation at the discrete level, let us sum up the
general nite volume update formula (3.17) for all the N nite volumes or cells in our
1-D domain.

N
N
N



t
n
n

un+1
=
unj
gj+
j
(3.27)
1 g
1
j
2
2
x j=1
j=1
j=1

DRAFT -- DRAFT -- DRAFT -- DRAFT -- DRAFT --

CHAPTER 3. ANALYSIS OF NUMERICAL METHODS

42
or
N

j=1

un+1
=
j

N

j=1

unj


t  n
n
n
n
n
g 3 gn1 + gn5 gn3 + gn7 gn5 + + gN

1 g
3 + g
1 g
1
2
N 2
N+ 2
N 2
2
2
2
2
2
x 2
(3.28)

or

N

j=1

un+1
j

N

j=1

unj


t  n
gN + 1 gn1
2
2
x

(3.29)

Thus, all the uxes in the middle of the domain cancel and only the uxes at the boundaries remain, and the net ux (outgoing ux minus the incoming ux) balances the rate
of change of the conservative variable. Thus, the nite volume method preserves conservation at the discrete level and hence the positions of the discontinuities like the shocks or
contact discontinuities are automatically captured correctly on an average. This property
of all the uxes in the middle of the domain getting cancelled is called the telescoping
property of the uxes. This is a unique property of the Finite Volume Method (FVM).

3.2

Modied Partial Dierential Equations

Let us now understand the numerical methods like upwind method a little more, analyzing
the truncation error. Since we are solving the governing equation (say linear convection
by an upwind method, for example) approximately, there will be some errors associated
with the approximation. To nd out the truncation error, let us substitute Taylor Series
expansions into the numerical method, to recover the actual equation we are solving
exactly. The resulting equation is called as Modied Partial Dierential Equation or
Equivalent Dierential Equation. For the linear convection equation
u
u
+c
=0
t
x

(3.30)

the upwind method is


un+1
= unj + unj unj1 unj+1 unj
j

(3.31)

(c + |c|) t
(c |c|) t
and =
(3.32)
2
x
2
x
The above equation is an approximation to the linear convection equation as we have
discretized the derivatives. If we are not solving the linear convection equation exactly,
but only approximately, then which equation are we solving exactly? To answer this
question, let us expand the terms in the upwind method using Taylor series.
where + =

uj

n+1

u n

= u (x, t + t) = uj + t

t2 2 u
t3 3 u
+
+
+ 0(t4 ) (3.33)
2
3
2 t j
6 t j

DRAFT -- DRAFT -- DRAFT -- DRAFT -- DRAFT --

3.2. MODIFIED PARTIAL DIFFERENTIAL EQUATIONS

43

unj+1 = un (x + x)
u n

unj+1 = uj n + x

x2 2 u
x3 3 u
+
+ 0(x4 )
2 x2 j
6 x3 j

(3.34)

unj1 = un (x x)
unj1

u n

= uj x

x2 2 u
x3 3 u
+

+ 0(x4 )
2
3
2 x j
6 x j

(3.35)

Substituting (3.33), (3.34) & (3.35) in (3.31) and dividing it by t, we get


u n

u n
t 2 u
t2 3 u
+ 
+
+
=
x
+
2 t2 j
6 t3 j
t
x j
n
u n

x2 2 u
+
x

t
x j
2 x2 j

x2 2 u
x3 3 u 

2 x2 j
6 x3 j
n
4
x3 3 u 
3 x
)
+
0(t
,
6 x3 j
t
(3.36)

To simplify the above equation, we have to replace the time derivatives by space derivatives
for which we use the original linear convection equation itself.
u
u
+c
=0
t
x
[u]
[u]
= c
t
x

(3.37)

u
[ ]
2u
t
=
2
t
t
u
]
x
c
x
2

u
c2 2
x
2u
[c2 2 ]
x
c
x
3u
c3 3
x
[c

=
=
3u
=
t3
3u
=
t3

(3.38)

(3.39)

DRAFT -- DRAFT -- DRAFT -- DRAFT -- DRAFT --

CHAPTER 3. ANALYSIS OF NUMERICAL METHODS

44

Using the above formulae, we obtain


u n

u n
t 2 2 u
t2 3 3 u
+ 
c
c
+

=
x
+
2
x2 j
6
x3 j
t
x j
n
u n

x2 2 u
+
x

t
x j
2 x2 j

x2 2 u
x3 3 u 

2
x2 j
6 x3 j
n
4
x3 3 u 
3 x
)
+
0(t
,
6 x3 j
t
(3.40)

u n

u n
u n


t  x2 2 u
+

+
= + c 2
x
x
t
x j t
x j
2 2t x2 j
n
2
3
3
4



u
+

3 t x
3 x
)
+ +c
+ 0(t ,
6 6t x3 j
t

+
c + |c|
x =
t
2

c |c|

x =
t
2

(3.41)

(3.42)

From the above two equations we get


+ = |c|

t
t
and + + = c
x
x

(3.43)

Therefore, we obtain
u n

c + |c| u n
2

c |c| u n

|c|t  2 u
x j
2
x j
2
x
x2 j
n
2
2
3
4
 cx
c t 2  u
3 x
)
+
1+
t
+ 0(t ,
6
x2
x3 j
t
+

 |c|x

(3.44)

Therefore
n

4
2 u
3 u
u n |c|x
cx2 2
3 x
+c
) (3.45)
=
1 ||
+

1
+
0(t
,
t
x j
2
x2 j
6
x3 j
t

3u
x
term, Then the scheme is
If
= constant and we drop
t
x3
u

2 u
u n |c|x
=
1 ||
+ 0(t2 , x2 )
+c
2
j
t
x
2
x j

DRAFT -- DRAFT -- DRAFT -- DRAFT -- DRAFT --

3.2. MODIFIED PARTIAL DIFFERENTIAL EQUATIONS

45

Therefore, the scheme is I order accurate in time and space. To understand the terms in
the truncation error better, let us consider the momentum equation of conservation laws
for a uid in expanded form.
u
u 1 p
2u
+u
+
= 2
t
x x
x

(3.46)

The second order term on right hand side represents a viscous term. Therefore, the
2 u
|c|x
upwind scheme has introduced an articial viscosity term,
1 ||
and the
2
x2
method is rst order accurate. That is
u
u
+c
= 0(t, x)
t
x

(3.47)

What is the role of articial viscosity? Just as the physical viscosity has the stabilizing
eect on uid ows, articial viscosity stabilizes the numerical methods, keeping the errors
without growing (or damping them). We can rewrite the upwind method as follows :

un+1
= unj + unj unj1 unj+1 unj
j
un+1
= unj (
j

(3.48)

un un
un un
c + |c|
c |c|
j
j1
j+1
j
(
)t
)t
2
x
2
x

un+1
j

n
n
n
n
n
ct uj+1 uj1
|c|t uj+1 2uj + uj1
n
= uj
+
2
x
2
x

unj+1 unj1

(3.49)

unj+1 2unj + unj1

(3.50)

|c|t
x
(3.51)
2x
2
x2
If we omit the last term on the right hand side, we get the Forward Time and Centered
u
u
Space (FTCS) approximation to
+c
= 0,
t
x
= unj ct
un+1
j

unj+1 unj1
unj
un+1
j
+c
=0
t
2x
Therefore, the upwind method has added an articial viscosity term to the central dif|c|t 2 u
x
. We know that
ferencing method, and this articial viscosity term is
2
x2
FTCS is unstable. The articial diusion stabilizes the FTCS method. Thus, there are
two routes to obtain a stable scheme :
1. By adding explicit articial viscosity to the central dierencing scheme.
2. By using an upwind scheme which has an inherent (implicit) articial viscosity.

DRAFT -- DRAFT -- DRAFT -- DRAFT -- DRAFT --

CHAPTER 3. ANALYSIS OF NUMERICAL METHODS

46

The second one is preferable, as there are no tuning parameters which are problem dependent. For the rst option,the tuning parameters come in while answering the question
How much articial viscosity is to be added? The MPDE for FTCS method is
u
c2 t 2 u
u
+ 0(t3 , x3 )
+c
=
t
x
2 x2
Therefore, the FTCS method is actually removing some viscosity from a II order method.
Thus, it makes sense to explicitly add some viscosity to stabilize it. Jameson, Smith &
Turkel(1981) (AIAA-81-1259) developed such a central dierence scheme with explicit
articial viscosity for Euler equations. But, because of the tuning parameters, central
dierence schemes are not as popular as upwind schemes.

3.3

Consistency of Numerical Methods

A numerical method is said to be consistent to the equation it approximates if the local


truncation error vanishes when the grid-spacing and the time-step go to zero. As an
example, consider the linear convection equation
u
u
+c
=0
t
x
and the upwind scheme for the above equation given by

(3.52)



(c + |c|) t  n
(c |c|) t  n
uj unj1
uj+1 unj
(3.53)
x
x
We have seen in the previous section that the Modied Partial Dierential Equation
(MPDE) for the above upwind scheme is given by

= unj
un+1
j

+c

2 u
3 u
cx2 2
u n |c|x
=
1 ||
+

1
+ 0(t3 , x4 ) (3.54)
x j
2
x2 j
6
x3 j

The right hand side of the above equation represents the local truncation error of the
numerical method (upwind method here). We can see that as x 0 and t 0, the
local truncation error on the right hand side completely vanishes and we recover the linear
convection equation. Thus, the upwind scheme is consistent with the linear convection
equation that it approximates here.

3.4

Stability Analysis

While designing and using numerical methods for partial dierential equations, it is important to know if the numerical method is stable or not. Before studying the stability
analysis, let us rst understand the Fourier series in complex wave form, which we will
use in the stability analysis.

DRAFT -- DRAFT -- DRAFT -- DRAFT -- DRAFT --

Vous aimerez peut-être aussi