Introduction to Finite Di erence Methods

Introduction
to Finite
Dierence
Methods
Discretisation
Mathematical
derivation
Time
derivatives
Heat
conduction
equation
Summary
Introduction to Finite Dierence Methods
SOE3213/4: FD Lecture 2
Introduction
to Finite
Dierence
Methods
Discretisation
Mathematical
derivation
Time
derivatives
Heat
conduction
equation
Summary
Discretisation
Aim : to solve continuum mechanics problems governed by
PDE's using computers. However : : : computers can only add
up!
Need to nd a representation of the PDE that the computer
can deal with.
Represent the continuous eld T (x) as values at specied
points in space T1 , T2 , T3 etc.
T
x
T1
T2
T3
T4
T5
T6
T7
Introduction
to Finite
Dierence
Methods
Discretisation
Mathematical
derivation
Time
derivatives
Heat
conduction
equation
Summary
I.E. we need to discretize the PDE { produces a dierence
equation
How do we deal with terms such as
@T
@2T
;
;
@x
@x 2
@T
?
@t
A derivative is a rate of change { a tangent to the curve T (x).
dT
dx x=p
T
@T
= tangent
@x
p
x
Introduction
to Finite
Dierence
Methods
Approximate this by dierences :
dT
dx x=p
T
Discretisation
Forward Difference
@ T Te Tp
=
@x
x
Mathematical
derivation
Time
derivatives
Heat
conduction
equation
Summary
w
x
e
p
δx
{ a forward dierence. Alternatively :
T
Backward difference
dT
dx x=p
@ T Tp Tw
=
@x
x
w
p
δx
e
{ a backward dierence
x
Introduction
to Finite
Dierence
Methods
Discretisation
Mathematical
derivation
Finally,
dT
dx x=p
T
Central difference
Time
derivatives
@ T Te Tw
=
@x
2 x
Heat
conduction
equation
Summary
w
p
e
x
2δx
{ central dierencing.
Note : there is no inherent reason to prefer one over the other
{ however each will produce dierent errors. Dierent choices
= dierent numerical schemes = dierent errors.
Introduction
to Finite
Dierence
Methods
Discretisation
Mathematical
derivation
Time
derivatives
Mathematical derivation
Need to be able to derive these expressions rigorously. Start
from Taylor's theorem :
@ 2 T @ T 1
2
+
(
x)
@ x x 2
@ x 2 x
@3T
1
+ ( x)3 3 + : : :
3!
@x x
T (x + x) = T (x) + x
Heat
conduction
equation
Summary
Here we can write
@T 1
@2T Te = Tp + x + ( x)2 2 + : : :
@x p 2
@x p
Truncating this at the ( x)2 term and rearanging,
@ T ' Te x Tp
@ x p
(1)
Introduction
to Finite
Dierence
Methods
Discretisation
Mathematical
derivation
Time
derivatives
Heat
conduction
equation
The largest error here is a term which contains x { this is a
1st order approximation.
We can apply this to any derivative. For example,
Tw = Tp
x
@ 2 T @ T 1
2
+
(
x)
@ x p 2
@ x 2 p
If we subtract (2) from (1), we get
Summary
Te
Tw = 2 x
@ T + O( x 3 )
@ x p
in other words
Te Tw
@ T + O( x 2 )
=
@x p
2 x
{ so this expression is 2nd order accurate.
:::
(2)
Introduction
to Finite
Dierence
Methods
Discretisation
Mathematical
derivation
Time
derivatives
Heat
conduction
equation
As you rene the mesh, 2nd order errors disappear faster than
1st order ones. However this does not necessarily mean that
the 2nd order expression is better! (Checkerboarding).
If we add (2) and (1), the @@Tx terms will cancel. This gives
Te + Tw = 2Tp + x 2
Summary
so
@2T
@x 2
@ 2 T @ x 2 p
p + Tw
' Te 2T
x 2
Introduction
to Finite
Dierence
Methods
Discretisation
Mathematical
derivation
Time
derivatives
Heat
conduction
equation
Time derivatives
We need to discretize @@Tt . Do this by time-marching
0
T1
0
T2
t=0
0
T3
0
T4
t
Summary
Time derivative becomes
@ T T n+1 T n
=
@t
t
0
T5
0
T6
Introduction
to Finite
Dierence
Methods
Heat conduction equation
Thus for the heat conduction equation
Discretisation
@2T
@T
= 2
@t
@x
Mathematical
derivation
Time
derivatives
Heat
conduction
equation
Summary
we have
Tpn+1
t
Tpn
Tn
= e
2Tpn + Twn
x 2
Rearanging this we have an algorithm
Tpn+1 = Tpn +
t n
T
x 2 e
2Tpn + Twn
This could also be written as
Tpn+1 = sTen + (1
with s = t = x 2
2s)Tpn + sTwn
Introduction
to Finite
Dierence
Methods
We can depict this pictorially :
1st step :
0
Discretisation
T1
0
T2
0
T3
t=0
Mathematical
derivation
0
T4
0
T5
0
T6
δt
t
Time
derivatives
Heat
conduction
equation
Summary
2nd step :
0
T1
t=0
0
T2
0
T3
0
T4
0
T5
0
T6
t
δt
Introduction
to Finite
Dierence
Methods
Summary
Discretisation
Mathematical
derivation
Time
derivatives
Heat
conduction
equation
Summary
PDE's need to be discretized { converted to dierence
equation form { for computational solution.
We can discretize time and space derivatives on a grid or
mesh. Dierent dierencing schemes give dierent errors,
dierent algorithms
For time-dependent problems, we time-step, or
time-march.
Need to start this process { provide initial conditions for
the solution
Also need to provide values at the two ends { boundary
conditions.