Professional Documents
Culture Documents
+ +
+ =
!
...
! 3 ! 2
3
3
3
2
2
2
( )
H
x
x x
x
x x
x x x
i
i i
i
i i
i i
i i
i
+
+ +
+
+
3
3
2
1
2
2
1
1
1
6 2
Higher order derivatives are unknown and can be dropped when the
distance between grid points is small.
By writing Taylor series at different nodes, x
i-1
, x
i+1
, or both x
i-1
and
x
i+1
, we can have:
i i
i i
i
x x x
+
+
1
1
1
1
i i
i i
i
x x x
1 1
1 1
+
+
i i
i i
i
x x x
Forward-FDS Backward-FDS
Central-FDS
1
st
order, order of accuracy P
kest
=1
2
nd
order, order of accuracy P
kest
=1
3-4
Chapter 3: Basics of Finite Difference
Applied Computational Fluid Dynamics
Y.C. Shih Spring 2009
3-2 Introduction to Finite Difference (1)
Numerical solutions can give answers at only discrete points in the domain,
called grid points.
If the PDEsare totally replaced by a system of algebraic equations which
can be solved for the values of the flow-field variables at the discrete points
only, in this sense, the original PDEshave been discretized. Moreover, this
method of discretizationis called the method of finite differences.
3-5
Chapter 3: Basics of Finite Difference
Applied Computational Fluid Dynamics
Y.C. Shih Spring 2009
3-2 Introduction to Finite Difference (2)
A partial derivative replaced with a suitable algebraic difference quotient is
called finite difference. Most finite-difference representations of derivatives
are based on Taylors series expansion.
Taylors series expansion:
Consider a continuous function of x, namely, f(x), with all derivatives
defined at x. Then, the value of f at a location can be estimated
from a Taylor series expanded about point x, that is,
In general, to obtain more accuracy, additional higher-order terms must be
included.
x x +
( ) ( ) ... ) (
!
1
...
! 3
1
! 2
1
) ( ) (
3
3
3
2
2
2
+
+ +
+ = +
n
n
n
x
x
f
n
x
x
f
x
x
f
x
x
f
x f x x f
3-6
Chapter 3: Basics of Finite Difference
Applied Computational Fluid Dynamics
Y.C. Shih Spring 2009
3-2 Introduction to Finite Difference (3)
3-7
Chapter 3: Basics of Finite Difference
Applied Computational Fluid Dynamics
Y.C. Shih Spring 2009
3-2 Introduction to Finite Difference (4)
Forward, Backward and Central Differences:
(1) Forward difference:
Neglecting higher-order terms, we can get
( )
... ) (
!
) (
... ) (
! 3
) (
! 2
) (
) ( ) ( ) ( ) (
1
3
3
3
1
2
2 2
1
1 1
+
+ +
+ =
+ + +
+ + i
n
n n
i i
i
i i
i
i i
i i i i i
x
f
n
x x
x
f x x
x
f x x
x x
x
f
x f x f
i i i
i
i i
i i
i i
i
x x x
x
x f x f
x x
x f x f
x
f
=
+ +
+
+
+
+
1 1
1
1
1
1
;
) ( ) ( ) ( ) (
) (
(a)
3-8
Chapter 3: Basics of Finite Difference
Applied Computational Fluid Dynamics
Y.C. Shih Spring 2009
3-2 Introduction to Finite Difference (5)
(2) Backward difference:
Neglecting higher-order terms, we can get
(3) Central difference:
(a)-(b) and neglecting higher-order terms, we can get
( )
... ) (
!
) (
) 1 ( ... ) (
! 3
) (
! 2
) (
) ( ) ( ) ( ) (
1
3
3
3
1
2
2 2
1
1 1
+
+ +
=
i
n
n n
i i n
i
i i
i
i i
i i i i i
x
f
n
x x
x
f x x
x
f x x
x x
x
f
x f x f
1
1
1
1
;
) ( ) ( ) ( ) (
) (
i i i
i
i i
i i
i i
i
x x x
x
x f x f
x x
x f x f
x
f
(b)
1 1
1 1
) ( ) (
) (
+
+
i i
i i
i
x x
x f x f
x
f
(c)
3-9
Chapter 3: Basics of Finite Difference
Applied Computational Fluid Dynamics
Y.C. Shih Spring 2009
3-2 Introduction to Finite Difference (6)
(4) If , then (a), (b), (c) can be expressed as
Forward:
Backward:
Central:
Note:
x x x
i i
= =
+1
x
f f
x
f
i i
i
+1
) (
x
f f
x
f
i i
i
1
) (
x
f f
x
f
i i
i
+
2
) (
1 1
) (
) (
) (
1 1
1 1
+ +
=
=
=
i i
i i
i i
x f f
x f f
x f f
(d)
(e)
(f)
3-10
Chapter 3: Basics of Finite Difference
Applied Computational Fluid Dynamics
Y.C. Shih Spring 2009
3-2 Introduction to Finite Difference (7)
Truncation error:
The higher-order term neglecting in Eqs. (a), (b), (c) constitute the
truncation error. The general form of Eqs. (d), (e), (f) plus truncated terms
can be written as
Forward:
Backward:
Central:
) ( ) (
1
x o
x
f f
x
f
i i
i
+
+
) ( ) (
1
x o
x
f f
x
f
i i
i
+
2
1 1
) (
2
) ( x o
x
f f
x
f
i i
i
+
+
3-11
Chapter 3: Basics of Finite Difference
Applied Computational Fluid Dynamics
Y.C. Shih Spring 2009
3-2 Introduction to Finite Difference (8)
Second derivatives:
* Central difference:
If , then (a)+(b) becomes
* Forward difference:
* Backward difference:
x x x
i i
= =
+1
2
2
1 1
2
2
) (
) (
2
) ( x o
x
f f f
x
f
i i i
i
+
+
=
+
) (
) (
2
) (
2
1 2
2
2
x o
x
f f f
x
f
i i i
i
+
+
=
+ +
) (
) (
2
) (
2
2 1
2
2
x o
x
f f f
x
f
i i i
i
+
+
=
3-12
Chapter 3: Basics of Finite Difference
Applied Computational Fluid Dynamics
Y.C. Shih Spring 2009
3-2 Introduction to Finite Difference (9)
Mixed derivatives:
* Taylor series expansion:
* Central difference:
* Forward difference:
* Backward difference:
] ) ( , ) [(
! 2
) )( (
2
! 2
) (
! 2
) (
) , ( ) , (
3 3
2
2
2 2
2
2 2
y x o
y x
f y x
y
f y
x
f x
y
f
y
x
f
x y x f y y x x f +
+
+ = + +
] ) ( , ) [(
) )( ( 4
2 2 1 , 1 1 , 1 1 , 1 1 , 1
,
2
y x o
y x
f f f f
y x
f
j i j i j i j i
j i
+
+
=
+ + + +
] ) ( , ) [(
) )( (
, , 1 1 , 1 , 1
,
2
y x o
y x
f f f f
y x
f
j i j i j i j i
j i
+
+
=
+ + + +
] ) ( , ) [(
) )( (
1 , 1 1 , , 1 ,
,
2
y x o
y x
f f f f
y x
f
j i j i j i j i
j i
+
+
=
3-13
Chapter 3: Basics of Finite Difference
Applied Computational Fluid Dynamics
Y.C. Shih Spring 2009
3-2 Introduction to Finite Difference (10)
Polynomial fitting:
Many applications of polynomial fitting are observed in CFDand heat
transfer. The technique can be used to develop the entire finite-difference
representation for a PDE. However, the technique is perhaps most
commonly employed in the treatment of boundary conditions.
3-14
Chapter 3: Basics of Finite Difference
Applied Computational Fluid Dynamics
Y.C. Shih Spring 2009
3-2 Introduction to Finite Difference (11)
(1) Consider a second-order polynomial, f(x)=Ax
2
+Bx+C
(a) Select the origin at x
i
, thus,
(b)
(2) For a first-order polynomial f(x)=ax+b
(a)
(b)
x x x x x
i i i
= = =
+ +
2 0
2 1
( ) ( )
( ) ( )
+ + = + + =
+ + = + + =
= = + + =
+ + +
+ + +
C x B x A C Bx Ax f
C x B x A C Bx Ax f
x C C Bx Ax f
i i i
i i i
i i i i
2 2
0
2
2
2
2 2
2
1
2
1 1
2
Q
( )
( )
2
1 2
1 2
2
2
2
3 4
x
f f f
A
x
f f f
B
f C
i i i
i i i
i
+
=
+
=
=
+ +
+ +
+ =
+ =
+ +
b ax f
b ax f
i i
i i
1 1
( ) b x a f
b f
i
i
+ =
=
+1
x
f f
a
f b
i i
i
=
=
+1
x
f f
a
x
f
i i
i
= =
+1
3-15
Chapter 3: Basics of Finite Difference
Applied Computational Fluid Dynamics
Y.C. Shih Spring 2009
3-2 Introduction to Finite Difference (12)
(3) Finite-difference grid near wall
If we assume that the temperature distribution near the
boundary is a second-degree polynomial of the form
T= a+ by+c y
2
&
Thus, we can evaluate the wall heat flux by the
approximation
b
y
T
y
=
= 0
( )
2
3 2 1 3 2 1
1
2
2
,
) ( 2
4 3
,
y
T T T
c
y
T T T
b T a
+
=
+
= =
( )
) 4 3 (
2
3 2 1
0
T T T
y
k
kb
y
T
k q
y
w
+
= =
=
=
3-16
Chapter 3: Basics of Finite Difference
Applied Computational Fluid Dynamics
Y.C. Shih Spring 2009
3-2 Introduction to Finite Difference (13)
Alternatively, we can identify the second-degree polynomial as a truncated Taylors
series expansion about y=0.
(1) Second-degree polynomial: T=a+by+cy
2
(2) Taylor series:
(3) Thus, the approximation is equivalent to
utilizing the first three terms of a Taylor series expansion with
the resulting T.E. in the expansion for T being .
Solving the Taylor series for an expression for involves
division by , which reduces the T.E. in the expansion for
to
...
! 3 ! 2
) 0 (
. .
3
0
3
3 2
0
2
2
0
+
+ =
43 42 1
E T
y
y
T y
y
T
y
y
T
T T
2
cy by a T + +
( ) [ ]
3
y o
0
y
T
y
0
y
T
( ) [ ]
2
y o
3-17
Chapter 3: Basics of Finite Difference
Applied Computational Fluid Dynamics
Y.C. Shih Spring 2009
3-2 Introduction to Finite Difference (14)
The accuracy of changing the mesh size:
(1) To obtain higher resolution in the region where the gradients are
expected to vary rapidly, it is desirable to use a finer mesh over
that particular region rather than refining the mesh over the
entire domain.
(2) Consider a change of the mesh size from to at some
node i.
1
x
2
x
3-18
Chapter 3: Basics of Finite Difference
Applied Computational Fluid Dynamics
Y.C. Shih Spring 2009
3-2 Introduction to Finite Difference (15)
(3) Approximation of first derivative:
(i) The function f(x) is expanded about the node i in forward and
backward Taylor series, respectively, as
(a)-(b)=>
where means the largest of or
( )
( ) ( )
( ) [ ]
( )
( ) ( )
( ) [ ] ) ( ...
! 3 ! 2
) ( ...
! 3 ! 2
4
1
3
3
3
1
2
2
2
1
1 1
4
2
3
3
3
2
2
2
2
2
2 1
b x o
dx
f d x
dx
f d x
dx
df
x f f
a x o
dx
f d x
dx
f d x
dx
df
x f f
i i
i
i i
i i
i
i i
+
+ =
+
+ + =
+
( ) ( )
( ) [ ] ) ( ...
2
1
2
2
2
1 2
2
1
2
2
1 2
1 1
c x o
dx
f d
x x
x x
x x
f f
dx
df
i
i i
i
+
+
+
=
+
( ) [ ]
2
x o ( ) [ ]
2
1
x o ( ) [ ]
2
2
x o
3-19
Chapter 3: Basics of Finite Difference
Applied Computational Fluid Dynamics
Y.C. Shih Spring 2009
3-2 Introduction to Finite Difference (16)
(ii) Then the finite-difference approximation of the first derivative
at the node I where the mesh size is changed from to
becomes
Eq. (c) implies eq. (d) is second-order accurate only if
(iii) We note that, if the mesh size varies from to
abruptly, say , then the accuracy of the differencing
at i deteriorates to first-order.
1
x
2
x
) ( ...
1 2
1 1
d
x x
f f
dx
df
i i
i
+
=
+
1 2
x x
1
x
2
x
1 2
2 x x =
3-20
Chapter 3: Basics of Finite Difference
Applied Computational Fluid Dynamics
Y.C. Shih Spring 2009
3-2 Introduction to Finite Difference (17)
(4) Approximation of second derivative:
(i) (a)+(b)x
=>
where
and means the largest of and
2
1
2
x
x
( ) ( )( ) ( )
( )( ) ( ) [ ] ) ( ...
6
1
1 1
4
3
3
2
2 1 2
2
2
2
2 2
2
1
2
1
e x o
dx
f d
x x x
dx
f d
x
dx
df
x f f f
i
i
i
i i i
+
+ + + + = +
+
( ) [ ]
4
x o
( ) [ ]
4
1
x o ( ) [ ]
4
2
x o
1
2
x
x
=
3-21
Chapter 3: Basics of Finite Difference
Applied Computational Fluid Dynamics
Y.C. Shih Spring 2009
3-2 Introduction to Finite Difference (18)
(ii) From eq. (e), we can get
The above expression becomes second-order accurate as
and it implies that, unless the mesh spacing is
changed slowly, the truncation error deteriorates.
( )
( )
( ) [ ]
1 2
2
2
2
1
2 2
1
2
2
1 1
x x o
dx
df
x
x
f f f
dx
f d
i
i i i
i
+
+ +
=
+
1 2
x x
3-22
Chapter 3: Basics of Finite Difference
Applied Computational Fluid Dynamics
Y.C. Shih Spring 2009
3-3 Errors Involved in Numerical Solutions (1)
In the solution of differential equations with finite differences, a variety of
schemes are available for the discretizationof derivatives and the solution
of the resulting system of algebraic equations.
In many situations, questions arise regarding the round-off and truncation
errorsinvolved in the numerical computations, as well as the consistency,
stability and the convergence of the finite difference scheme.
Round-off errors:computations are rarely made in exact arithmetic. This
means that real numbers are represented in floating point form and as a
result, errors are caused due to the rounding-off of the real numbers. In
extreme cases such errors, called round-off errors, can accumulate and
become a main source of error.
3-23
Chapter 3: Basics of Finite Difference
Applied Computational Fluid Dynamics
Y.C. Shih Spring 2009
3-3 Errors Involved in Numerical Solutions (2)
Truncation error: In finite difference representation of derivative with
Taylors series expansion, the higher order terms are neglected by
truncating the series and the error caused as a result of such truncation is
called the truncation error.
The truncation error identifies the difference between the exact solution of
a differential equation and its finite difference solution without round-off
error.
3-24
Chapter 3: Basics of Finite Difference
Applied Computational Fluid Dynamics
Y.C. Shih Spring 2009
3-4 Example (1)
3-25
Chapter 3: Basics of Finite Difference
Applied Computational Fluid Dynamics
Y.C. Shih Spring 2009
3-4 Example (2)
3-26
Chapter 3: Basics of Finite Difference
Applied Computational Fluid Dynamics
Y.C. Shih Spring 2009
3-4 Example (3)
3-27
Chapter 3: Basics of Finite Difference
Applied Computational Fluid Dynamics
Y.C. Shih Spring 2009
3-4 Example (4)
3-28
Chapter 3: Basics of Finite Difference
Applied Computational Fluid Dynamics
Y.C. Shih Spring 2009
3-4 Example (5)
3-29
Chapter 3: Basics of Finite Difference
Applied Computational Fluid Dynamics
Y.C. Shih Spring 2009
3-4 Example (6)
3-30