Introduction To Finite Dierence Methods: 2.1 Discretisation

Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

Introduction to Finite Di erence Methods

SOE3213/4: FD Lecture 2

2.1 Discretisation

Aim : to solve continuum mechanics problems governed by PDE's using com-


puters. 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 speci ed points in space T1 ,
T2 , T3 etc.
T

T1 T2 T3 T4 T5 T6 T7

I.E. we need to discretize the PDE { produces a di erence equation


How do we deal with terms such as
@T @2T @T
; ; ?
@x @x2 @t
A derivative is a rate of change { a tangent to the curve T (x).

T dT
dx x=p

p x

1
@T
= tangent
@x
Approximate this by di erences :
T dT
dx x=p Forward Difference

w p e x

δx

@T Te Tp
=
@x x
{ a forward di erence. Alternatively :
T Backward difference dT
dx x=p

w p e x

δx

@T Tp Tw
=
@x x
{ a backward di erence
Finally,
T dT
dx x=p Central difference

w p e x

2δx

@T Te Tw
=
@x 2x
{ central di erencing.
Note : there is no inherent reason to prefer one over the other { however each
will produce di erent errors. Di erent choices = di erent numerical schemes =
di erent errors.

2
2.2 Mathematical derivation

Need to be able to derive these expressions rigorously. Start from Taylor's


theorem :
@T 1 2
T (x + x) = T (x) + x + (x)
2 @ T
@x x 2 @x2 x
1 3
@T
+ (x)3 3 + : : :
3! @x x
Here we can write
@T 1 2
Te = Tp + x + (x)
2 @ T + : : : (1)
@x p 2 @x2 p
Truncating this at the (x)2 term and rearanging,
@T Te Tp
@x p
' x
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,
@T 1 2
Tw = Tp x + (x)
2 @ T : : : (2)
@x p 2 @x2 p
If we subtract (2) from (1), we get
@T
Te Tw = 2x + O(x3 )
@x p
in other words
@T Te Tw
= + O(x2 )
@x p 2x
{ so this expression is 2nd order accurate.
As you re ne 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 @T terms will cancel. This gives
@x

@2T
Te + Tw = 2Tp + x2 2
@x p
so
@2T
@x2
' Te 2xTp2 + Tw

3
2.3 Time derivatives

We need to discretize @T . Do this by time-marching


@t
0 0 0 0 0 0
T1 T2 T3 T4 T5 T6
t=0

Time derivative becomes


@T T n+1 T n
=
@t t

2.4 Heat conduction equation

Thus for the heat conduction equation


@T @2T
= 2
@t @x
we have
Tpn+1 Tpn T n 2Tpn + Twn
= e
t x2
Rearanging this we have an algorithm
t n 
Tpn+1 = Tpn + 2 Te 2Tpn + Twn
x
This could also be written as
Tpn+1 = sTen + (1 2s)Tpn + sTwn
with s = t=x2
We can depict this pictorially :
1st step :
0 0 0 0 0 0
T1 T2 T3 T4 T5 T6
t=0

t δt

4
2nd step :
0 0 0 0 0 0
T1 T2 T3 T4 T5 T6
t=0

δt

2.5 Summary

 PDE's need to be discretized { converted to di erence equation form { for


computational solution.
 We can discretize time and space derivatives on a grid or mesh. Di erent
di erencing schemes give di erent errors, di erent 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.

You might also like