




Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
An explanation of the finite difference method for solving differential equations, with a focus on the numerical diffusion equation. It covers topics such as truncation error, roundoff error, and the explicit (ftcs) and crank-nicholson methods. The document also includes examples and results.
Typology: Slides
1 / 8
This page cannot be seen from the preview
Don't miss anything!





Seminar in Engineering Analysis
March 18, 2009
2
Outline
equation in one space dimension
3
Review Numerical Analysis
system of algebraic equations
domain
and finite elements
measure of error with their use
4
Review Finite Difference Grids
variables: x, y, z and t
x
= x
x
= x
x
= Δx
y
= y
y
= y
y
= Δy
z
= z
z
= z
z
= Δz
t
= t
t
= t
t
= Δt
points u(x
, y
, z
, t
)
( , , , ) i j k n
n
ijk
u = u x y z t
5
Review Truncation Error
∑ ∑
∞
= (^) = = + =
= + 0 1
( -) !
1 (-) !
1 ( ) nm
n
xa
n
m n
n
n
xa
n
n
xa dx
d f
n
xa dx
d f
n
fx
Terms used Truncation error, ε
at unknown location (derivation based
on the theorem of the mean)
1 1
1
1
=
∞ +
= (^) ∑ =
m
x
m
m
nm
n
xa
n
n
ξ
ε
6
Review Order of the Error
proportional to h
error
) to indicate this error
reduces n
order error by a
n
h
h
⎟
⎟
⎠
⎞
⎜
⎜
⎝
⎛ ≈
1
ε ε
7
Review Derivative Expressions
( ) 2
' 1 1 2 Oh h
f f f
i i i +
' (^1)
i i i
h
f f f
i i i +
−
'' 1 1 2 Oh
h
f f f f
i i i i +
8
Find f’ and f’’ for sin at x = 1
( ) 2
' 1 1 2 Oh h
f f f
i i i +
Second order central
( )
2 2
'' 1 1 2 Oh h
f f f f
i i i i +
− =
−
2 (. 1 )
' sin(^1 +.^1 )−sin(^1 −.^1 ) f (^) i =^2 (. 1 )
sin( 1. 1 ) sin( 1. 1 ) 2 sin( 1 ) ''
f
2 (. 01 )
i
f
2 (. 001 )
' sin(^1 +.^001 )−sin(^1 −.^001 ) fi =
2 (. 01 )
sin( 1. 01 ) sin( 1. 01 ) 2 sin( 1 ) ''
2 (. 001 )
sin( 1. 001 ) sin( 1. 001 ) 2 sin( 1 ) ' '
9
Review Roundoff Error
subtracting close differences
: f’(x) ≈ (e
)/(2h)
and error at x = 1 is (e
)/(2h) - e
3
718282 4. 510 2 ( 0. 1 )
004166 2. (^722815) − − =
− E = x
9
718281828459 4. 510 2 ( 0. 0001 )
7185536702 2. (^7180100139) − − =
− E = x
9
718281828 5. 910 2 ( 0. 0000001 )
71828210028724 2. (^71828155660388) − − =
− E = x
Second order error
1.E-
1.E-
1.E-
1.E-
1.E-
1.E-
1.E-
1.E-
1.E-
1.E-
1.E-
1.E+
1.E+
1.E-17 1.E-15 1.E-13 1.E-11 1.E-09 1.E-07 1.E-05 1.E-03 1.E-
Step Size
Error
Slope of a log error – log h
plot is order n
Δ(log ε) = 10; Δ(log h) = 5
Slope = order = 2
11
Numerical PDE Solutions
independent variables (x, y, z, t)
whose values are found from boundary
conditions for the problem
equation into a finite difference equation
12
Diffusion Equation
ordinary derivatives to partial derivatives
coordinate directions
to get simple finite-difference equation
n
i
α
[( ) ] ( )
2 ( )
2 2
1 1 2
1 2
O x x
u u u
x
u O t and t
u u
t
u
n i
n i
n i
n
i
n i
n i
n
i
Δ Δ
− = ∂
∂
∂
∂ (^) + −
19
Explicit Results f = 0.
Error t = 0.20 0 385.9 422.5 385.9 0
Exact t = 0.20 0 125.1 176.9 125.1 0
n = 5 t = 0.20 0 -260.9 599.3 -260.9 0
n = 4 t = 0.16 0 419.2 -224.2 419.2 0
n = 3 t = 0.12 0 -35.3 639.6 -35.3 0
n = 2 t = 0.08 0 539.2 180.8 539.2 0
n = 1 t = 0.04 0 360 1000 360 0
n = 0 t = 0+ 0 1000 1000 1000 0
t = 0 1000 1000 1000 1000 1000
x = 0.00 x = 0.25x = 0.50x = 0.75 x = 1.
i = 0 i = 1 i = 2 i = 3 i = 4
20
What Happened?
21
Stability of Explicit Method
and u
are fixed an
increase in u
should increase u
will cause a decrease in u (^) i
keeping f = αΔt/(Δx)
≤ 0.
be less than the limit required for
accuracy in the solution
22
FTCS Truncation Error
solving PDEs gives this equation
∞
=
− −
2
2
1 2 2 2
k
n
i
k
k k n k i
= 1/6 eliminates
first term in the truncation error
23
Crank-Nicholson Method
n+
n+
24
Space Derivative at t
time steps n and n + 1
( ) 2
..... 2 4 48
..... 24
2 2
2 2
..... 2 6
..... 2 6
1 1 2
4 ''''
2 1 1 ''
4 ''''
2 ''' 1 1
3 '''
2 ' '' 1
3 '''
2 ' '' 1
O h
h f f f
h f
f f f
h f
h f f f f
h f
h f f fh f
h f
h f f fh f
i i i i
i i i
i i i i i
i i i i i
i i i i i
− − + =
=
= − + − +
= + + + +
− + −
−
−
+
25
n
i
n
i
n
i
[( ),( )] 0 ( )
2
( )
2
2
⎥
⎥
⎦
⎤
⎢
⎢
⎣
⎡
Δ
Δ
α + − −
Δ
∂
∂ −α ∂
∂
O t x x
u u u
x
u u u
t
u u
x
u
t
u
n i
n i
n i
n i
n i
n i
n i
n i
n
i
n
i
26
27
−
−
−
−
n N
n N
n N
n
n
n n
n N
n N
n
n
n
1
2
3
2
1 0
1 1
1 2
1 3
1 2
1 1
28
29
30
i i i
i i i i
i i i
i i
37
Fully Implicit Results III
Error t = 0.0125 0 0.779 1.542 2.273 2.
Exact t = 0.0125 0 50.43 100.66 150.48 199.
n = 25 t = 0.0125 0 51.21 102.20 152.76 202.
n = 24 t = 0.012 0 52.30 104.36 155.96 206.
n = 23 t = 0.0115 0 53.46 106.67 159.38 211.
n = 22 t = 0.011 0 54.70 109.13 163.04 216.
n = 21 t = 0.0105 0 56.03 111.78 166.95 221.
n = 20 t = 0.01 0 57.47 114.62 171.16 226.
n = 19 t = 0.0095 0 59.02 117.70 175.71 232.
n = 18 t = 0.009 0 60.70 121.03 180.64 239.
x = 0 x = .01 x = .02 x = .03 x =.
i = 0 i = 1 i = 2 i = 3 i = 4
38
Richardson/Leapfrog
[( ) ] ( )
2 [( )] 2
O x x
u u u
x
u O t t
u u
t
u
n i
n i
n i
n
i
n i
n i
n
i
Δ Δ
− =α ∂
∂
∂
∂ (^) + −
accuracy in time
( ) ( )
n i
n i
n i
n i
n i
n i
n i
n i
n i u u u u fu u u x
t u u 2 2 2
( )
2 1 1
Δ
αΔ = + + −
and cannot be used
39
DuFort Frankel
provide stability
in second derivative by
average at time steps n+1 and n-
] error
⎥
⎥
⎦
⎤
⎢
⎢
⎣
⎡
Δ
Δ
Δ Δ Δ
− − =α Δ
−
( )
( ) ( ),( ), (^2) ( ) x
t O x t x
u T u u
t
u u
n i
n i
n i
n i
n i
n i
1 1 2
n i
n i
n
n i
n i
n i
n
i
n i
n i
n
i
40
DuFort Frankel
( ) ( )
n i
n i
n i
n i
n i
n i
n i
n i
n i
n
( ) ( ) ( )
f u u f fu u
1 2 1 2 2
values at time n-
1.E-
1.E-
1.E-
1.E-
1.E-
1.E-
1.E-
0.001 0.01 0.1 1 f = αΔ t/( Δ x)
2
RMS Temperature Erro
Nx = 5 Nx = 10 Nx = 20 Nx = 50 Nx = 100 Nx = 200 Nx = 500 Nx = 1000
Thermal Diffusivity = 1 0 <= x <= (L = 1) T(x,0) = 1000 T(0,t) = T(L,t) = 0 End Time = 1
1.E-
1.E-
1.E-
1.E-
1.E-
1.E-
1.E-
1.E-
0.0001 0.001 0.01 0.1 1 10 100 1000 f = αΔ t/( Δ x)
2
RMS Temperature Erro
Nx = 5 Nx = 10 Nx = 20 Nx = 50 Nx = 100 Nx = 200 Nx = 500 Nx = 1000
Thermal Diffusivity = 1 0 <= x <= (L = 1) T(x,0) = 1000 T(0,t) = T(L,t) = 0 End Time = 1
0.
0.
0.
0.
0.
1
0.0001 0.001 0.01 0.1 1 10 100 1000 10000 100000 f = αΔ t/( Δ x)
2
RMS Temperature Erro
Nx = 5 Nx = 10 Nx = 20 Nx = 50 Nx = 100 Nx = 200 Nx = 500 Nx = 1000 Thermal Diffusivity = 1 0 <= x <= (L = 1) T(x,0) = 1000 T(0,t) = T(L,t) = 0 End Time = 1
1.E-
1.E-
1.E-
1.E-
1.E-
1.E-
1.E-
1.E-
0.0001 0.001 0.01 0.1 1 10 100 1000 f = αΔ t/( Δ x)
2
RMS Temperature Erro
Nx = 5 Nx = 10 Nx = 20 Nx = 50 Nx = 100 Nx = 200 Nx = 500 Nx = 1000
Thermal Diffusivity = 1 0 <= x <= (L = 1) T(x,0) = 1000 T(0,t) = T(L,t) = 0 End Time = 1
RMS Temperature Error by Execution Time
1.E-
1.E-
1.E-
1.E-
1.E-
1.E-
1.E-
1.E-
1.E+
1.E+
1.E+
1.E+
1.E-02 1.E-01 1.E+00 1.E+01 1.E+02 1.E+03 1.E+04 1.E+ Execution Time (seconds)
RMS Temerature Error
Crank-Nicholson Explicit Fully Implicit DuFort-Frankel
46
This Week’s Homework
just shown for one of the suggested
assignments
47
Explicit Method Example
initial conditions below with f = 0.
( ) ( )
??
??
??
? 70 80 90 100 90 80 70?
?
?
?
?
???
?????
80 90 95 90 80
88.75 (^) 92.588.