Post on 03-Jun-2018
transcript
8/12/2019 6 Finite Difference Methods
1/44
5. Finite difference methods
Finite difference formulae Dirichlet and Neumannproblems Elliptic, parabolic and hyperbolic equations
8/12/2019 6 Finite Difference Methods
2/44
1. Finite difference operators
Recall finite difference operators from numerical
differentiations Central difference
Forward / Backward difference
][][][2][
][''2
][][][' 2
2
1111 hOh
xfxfxfxf
h
xfxfxf iiii
iii
][][2][5][4][
][''
2
][3][4][]['
2
2
123
12
hO
h
xfxfxfxf
xf
h
xfxfxfxf
iiiii
iiii
8/12/2019 6 Finite Difference Methods
3/44
2. Rectangular even grid
Grid size
8/12/2019 6 Finite Difference Methods
4/44
3. Taylors series expansion
3
,
33
2
,
22,
,,1
3
,
33
2
,
22,
,,1
!3!2!1
!3!2!1
x
uh
x
uh
x
uhuu
x
uh
x
uh
x
uh
uu
jijiji
jiji
jijiji
jiji
2
,1,,1
),(
2
2
,1,1
),(
2
,2
huuu
xu
h
uu
x
u
jijiji
yx
jiji
yx
ii
ii
2
1,,1,
),(
2
2
1,1,
),(
2
,2
k
uuu
y
u
k
uu
y
u
jijiji
yx
jiji
yx
ii
ii
8/12/2019 6 Finite Difference Methods
5/44
3.1 Mixed second-order derivative
hk
khO
hk
uuuu
yx
u
khOkyhxukyhxu
kyhxukyhxuhku
hkuukuh
kuhuyxukyhxu
jijijijiji
xy
xyyyxx
yx
41,11,11,11,1,
2
4
22
)(
4
])[(],[],[
],[],[4
!2
2
!1],[],[
8/12/2019 6 Finite Difference Methods
6/44
4. Uneven grid system
8/12/2019 6 Finite Difference Methods
7/44
5. Difference equations
in uneven grid system
][
)(
22
)(
2
][)(
)(
!3!2
!3!2
,1,,1
2
,
2
,12
,22
,12
,
3
,
33
2
,
22,
,,1
3
,
33
2
,
22,
,,1
hnO
nhn
u
nh
u
nhn
u
x
u
hnOnhhn
ununhuh
x
u
x
uh
x
uh
x
uhuu
xun
xun
xunuu
jijijiji
jijijiji
jijiji
jiji
jijiji
jiji
8/12/2019 6 Finite Difference Methods
8/44
6. Solution technique
Replace derivatives by difference equations
Lay the derivatives on the grid Substitute the required BC
Solve the algebraic difference equation system
02
2
2
2
y
u
x
u
.04,if
022
,1,1,,1,1
2
1,,1,
2
,1,,1
jijijijiji
jijijijijiji
uuuuuhk
k
uuu
h
uuu
8/12/2019 6 Finite Difference Methods
9/44
7. Computational molecule
.04,if
022
,1,1,,1,1
2
1,,1,
2
,1,,1
jijijijiji
jijijijijiji
uuuuuhk
k
uuu
h
uuu
Grid generation (even/uneven)
Apply computational molecule at each node Setup algebraic equations for entire grid
Insert/Deal with boundary conditions
Solve algebraic equations for each node
8/12/2019 6 Finite Difference Methods
10/44
7.1 Liemanns method
(Dirichlets problem)
.40,3
,20,0
,8,3
,10,0
;10
3
2
2
2
2
Ty
Ty
yTx
Tx
xyy
T
x
T
8/12/2019 6 Finite Difference Methods
11/44
1
104
2
,1,1,,1,1
kh
yxh
TTTTTii
jijijijiji
),2)(2()1(104:P
),2)(1()1(104:P
),1)(2()1(104:P
),1)(1()1(104:P
2
222332211222
2
121322110212
2
212231201121
2111221100111
TTTTT
TTTTT
TTTTT
TTTTT
8/12/2019 6 Finite Difference Methods
12/44
.40,20,64,8,10
conditionsboundary
23132010
32310201
TTTTTTTT
667.22
583.10
083.16
667.11
64
8
30
10
4110
1401
1041
0114
22
21
12
11
22
21
12
11
T
T
T
T
T
T
T
T
8/12/2019 6 Finite Difference Methods
13/44
7.2 Liemanns problem (Neumann BC)
.4]1,[
,0]0,[
,0],5.1[,0],0[
;02
2
2
2
xxy
u
xu
yuyu
y
u
x
u
8/12/2019 6 Finite Difference Methods
14/44
, , , 1
12 11 22 2112 22
11
12
21
22
11 12 21 22
Method 1: backward difference
P : 2 P : 40.5 0.5
4 1 1 0 0
1 1 0 0 1
1 0 4 1 0
0 0 1 1 2
0.625 1.625 0.875 2.875
i j i j i j
T
u u uy h
u u u u
u
u
u
u
u u u u
4)0.1(4:P
2)5.0(4:P
04:P
04:P
2222
1212
22211121
12211111
y
u
yu
uuu
uuu
][kO
8/12/2019 6 Finite Difference Methods
15/44
443:P
243:P
2
43
differencebackward:2Method
212222
111212
2,1,,,
uu
uu
h
uuu
y
u jijijiji][ 2kO
255.2691.0346.1509.0
4
0
2
0
3400
1401
0034
0114
22211211
22
21
12
11
Tuuuu
u
u
u
u
8/12/2019 6 Finite Difference Methods
16/44
42
22
04:P
04:P
nodesVirtual:3Method
212322111312
223221231222
121322110212
h
uu
y
u
h
uu
y
u
uuuuu
uuuuu
503.1472.0068.1385.0
)5.0(8
0
)5.0(4
0
4210
1401
1042
0114
22211211
22
21
12
11
Tuuuu
u
u
u
u
8/12/2019 6 Finite Difference Methods
17/44
7.3 Accuracy of various method
1 22 3
2sinh
3
2sin
3
2cosh
cos18],[
n
ynxn
nn
nyxu exact
Analytical Method 1 Method 2 Method 3
u11 0.4320 44.7% 17.9% 10.9%
u21 0.5248 66.7% 31.7% 10.1%
u12 1.1870 36.9% 13.4% 10.0%
u22 1.8037 59.4% 25.0% 16.7%
8/12/2019 6 Finite Difference Methods
18/44
Most numerical solutions involve systems of much larger
size, impossible to solve using Gaussian elimination
To accelerate, over-relaxation or successive-over-relaxation (SOR) is used
4
)(
1,
)(
1,
)(
,1
)(
,1)1(
,
k
ji
k
ji
k
ji
k
jik
ji
uuuuu
)(,GS)1(
,
)1(
, 1 k
ji
k
ji
k
ji uuu
4
)(
1,
)(
1,
)(
,1
)(
,1
GS
)1(
,
k
ji
k
ji
k
ji
k
jik
ji
uuuuu
7.4 Successive-over-relaxation
8/12/2019 6 Finite Difference Methods
19/44
7.5 Alternating-direction-implicit (ADI)
04 ,1,1,,1,1 jijijijiji uuuuu
Row junknown Row iknown from
previous iteration
)(4 )1(
,1
)1(
,1
)2(
,
)2(
1,
)2(
1,
k
ji
k
ji
k
ji
k
ji
k
ji uuuuu
Row iunknown Row jknown from
previous iteration
Rearranging
)(4 )(
1,
)(
1,
)1(
,
)1(
,1
)1(
,1
k
ji
k
ji
k
ji
k
ji
k
ji uuuuu
8/12/2019 6 Finite Difference Methods
20/44
Row junknown Row iknown from
previous iteration
)1(
,1
)1(
,
)1(
,1
)2(
,
)2(
1,
)2(
1, )2()2(
k
ji
k
ji
k
ji
k
ji
k
ji
k
ji uuuuuu
Row iunknown Row jknown from
previous iteration
)(
1,
)(
,
)(
1,
)1(
,
)1(
,1
)1(
,1 )2()2( k
ji
k
ji
k
ji
k
ji
k
ji
k
ji uuuuuu
incorporating with the SOR method
8/12/2019 6 Finite Difference Methods
21/44
7 7 ADI th d ( l )
8/12/2019 6 Finite Difference Methods
22/44
7.7 ADI method (example)
02 u
)1(
,1
)1(
,
)1(
,1
)2(
1,
)2(
,
)2(
1,
)(
1,
)(
,
)(
1,
)1(
,1
)1(
,
)1(
,1
89.011.3
89.011.3
k
ji
k
ji
k
ji
k
ji
k
ji
k
ji
k
ji
k
ji
k
ji
k
ji
k
ji
k
ji
uuuuuu
uuuuuu
80 oC
80 oC
0 oC
0 oC
11.1x
y
8/12/2019 6 Finite Difference Methods
23/44
)(
22
)(
23
)(
21
)1(
32
)1(
22
)1(
1222
)(
12
)(
13
)(
11
)1(
22
)1(
12
)1(
0212
)(
21
)(
22
)(
20
)1(
31
)1(
21
)1(
1121
)(
11
)(
12
)(
10
)1(
21
)1(
11
)1(
0111
89.011.3:P
89.011.3:P
89.011.3:P
89.011.3:P
kkkkkk
kkkkkk
kkkkkk
kkkkkk
uuuuuu
uuuuuu
uuuuuu
uuuuuu
Row junknown
8089.0
808089.089.0
8089.0
11.3100
111.3000011.31
00111.3
)(
22
)(
21
)(
12
)(
11
)(
22
)(
21
)(
12
)(
11
)1(
22
)1(
12
)1(
21
)1(
11
kk
kk
kk
kk
k
k
k
k
uu
uuuu
uu
u
uu
u
Row unknown
8/12/2019 6 Finite Difference Methods
24/44
Column unknown
8089.0
89.0
8089.080
89.080
11.3100
111.300
0011.31
00111.3
)1(
22
)1(
12
)1(
21
)1(
11
)1(
22
)1(
12
)1(
21
)1(
11
)2(
22
)2(
21
)2(
12
)2(
11
kk
kk
kk
kk
k
k
k
k
uu
uu
uu
uu
u
u
u
u
8/12/2019 6 Finite Difference Methods
25/44
8089.0
808089.0
89.0
8089.0
11.3100
111.300
0011.31
00111.3
)0(
22
)0(
21
)0(12
)0(11
)0(
22
)0(
21
)0(
12
)0(
11
)1(
22
)1(12
)1(
21
)1(
11
uu
uu
uu
uu
u
u
u
u
First loop
140.47
604.66
225.9
690.28
)1(
22
)1(
12
)1(21
)1(
11
u
u
u
u
Second loop
8/12/2019 6 Finite Difference Methods
26/44
8089.0
89.0
8089.080
89.080
11.3100
111.300
0011.31
00111.3
)1(
22
)1(
12
)1(21
)1(11
)1(
22
)1(
12
)1(
21
)1(
11
)2(
22
)2(12
)2(
21
)2(
11
uu
uu
uu
uu
u
u
u
u
891.39
412.19371.60
891.38
)2(
22
)2(
21
)2(
12
)2(
11
u
uu
u
Second loop
k u11 u21 u12 u22
0 0.000 0.000 0.000 0.000
1 39.891 19.412 60.371 39.891
2 40.000 20.011 59.988 40.000
3 40.000 20.000 60.000 40.000
8 P b li ti
8/12/2019 6 Finite Difference Methods
27/44
8. Parabolic equations
2
22
x
uc
t
u
8 1 N i l i t bilit
8/12/2019 6 Finite Difference Methods
28/44
8.1 Numerical instability
Occurs due to marching:Accumulation of error
8/12/2019 6 Finite Difference Methods
29/44
8.2 Forward time central space
(FTCS) method
2
1
:
21
2
2
2
,,1,11,
2
,1,,12,1,
2
22
h
kc
F
uFuuFu
huuuc
kuu
x
uc
t
u
nininini
ninininini
Fourier number
8 3 FTCS (e ample)
8/12/2019 6 Finite Difference Methods
30/44
nininini uuuu
kFh
xxu
yuyu
x
u
t
u
,,1,11,
2
2
5.025.0
01.025.0,2.0
sin]0,[
,0],1[],0[
;
8.3 FTCS (example)
8/12/2019 6 Finite Difference Methods
31/44
0 1 2 3 4 5
0 0.000 0.588 0.951 0.951 0.588 0.000
1 0.000 0.532 0.860 0.860 0.532 0.000
2 0.000 0.481 0.778 0.778 0.491 0.000
3 0.000 0.435 0.704 0.704 0.435 0.000
4 0.000 0.393 0.637 0.637 0.393 0.000
5 0.000 0.356 0.576 0.576 0.356 0.000
6 0.000 0.322 0.521 0.521 0.322 0.000
7 0.000 0.291 0.471 0.471 0.291 0.000
8 0.000 0.263 0.426 0.426 0.263 0.000
9 0.000 0.238 0.385 0.395 0.238 0.000
10 0.000 0.215 0.349 0.349 0.215 0.000
8 4 Crank Nicolson (CN) scheme
8/12/2019 6 Finite Difference Methods
32/44
8.4 Crank-Nicolson (CN) scheme
2,1,,1
2
1,11,1,1
2
,
2
2
1,
2
2
2/1,
2
,1,2/1,
2
2
2
1
2
1
huuu
h
uuu
x
u
x
u
x
u
k
uu
t
u
ninini
ninini
ninini
ninini
8/12/2019 6 Finite Difference Methods
33/44
nininininini FuuFFuFuuFFu
,1,,11,11,1,1 )1(2)1(2
ninininini uuuuu
F
,1,11,11,1,1 4
1set
Implicit scheme, cannot obtain solution explicitly fromprevious data
need to solve the algebraic system for each time step
8 5 Crank Nicolson scheme (example)
8/12/2019 6 Finite Difference Methods
34/44
8.5 Crank-Nicolson scheme (example)
0 1 2 3 4 5
0 0.000 0.588 0.095 0.095 0.588 0.000
1 0.000 0.399 0.646 0.646 0.399 0.000
2 0.000 0.271 0.439 0.439 0.271 0.000
3 0.000 0.184 0.298 0.298 0.184 0.000
4 0.000 0.125 0.203 0.203 0.125 0.000
5 0.000 0.085 0.138 0.138 0.085 0.000
6 0.000 0.058 0.093 0.093 0.058 0.000
7 0.000 0.039 0.064 0.064 0.039 0.000
8 0.000 0.027 0.043 0.043 0.027 0.000
9 0.000 0.018 0.029 0.029 0.018 0.000
10 0.000 0.012 0.020 0.020 0.012 0.000
04.0
2.0
k
h
8 6 Other schemes for parabolic equations
8/12/2019 6 Finite Difference Methods
35/44
8.6 Other schemes for parabolic equations
Richardsons scheme
Central-time
No practical use
Du FortFraenkels scheme
Replace RHS of Richardson by average
0:2
2
1,,,1,11,
2
,1,,121,1,
FuFuuuFu
h
uuuc
k
uu
ninininini
ninininini
0:21
21
21
21,,1,11,
2
,11,1,,121,1,
FuF
Fuu
F
Fu
h
uuuuc
k
uu
nininini
nininininini
8 7 Parabolic equations
8/12/2019 6 Finite Difference Methods
36/44
8.7 Parabolic equations
in two-spatial dimensions
ADI + Crank-Nicolsons scheme
2
1,,1,
2
,1,,12
2
,,21
21
21
21
22
2 y
l
ji
l
ji
l
ji
x
l
ji
l
ji
l
ji
k
l
ji
l
ji
h
uuu
h
uuucuu
2
1,,1,
2
1
,1
1
,
1
,12
2
,
1
,21
21
21
21
22
2y
l
ji
l
ji
l
ji
x
l
ji
l
ji
l
ji
k
l
ji
l
ji
h
uuu
h
uuucuu
1ststep
2ndstep
8/12/2019 6 Finite Difference Methods
37/44
hx= hy,F= 1
21
21
21
21
21
1,11,
1
,1
1
,
1
,1
,1,11,,1,
4
4
l
ji
l
ji
l
ji
l
ji
l
ji
l
ji
l
ji
l
ji
l
ji
l
ji
uuuuu
uuuuu
9 Hyperbolic equations
8/12/2019 6 Finite Difference Methods
38/44
9. Hyperbolic equations
02
22
2
2
x
uc
t
u
9 1 Central time central space (CTCS)
8/12/2019 6 Finite Difference Methods
39/44
9.1 Central-time central space (CTCS)
1
)1(2
)(
2
2
0
,
2
,1,1
2
1,1,
2
,1,,12
2
1,,1,
2
22
2
2
hckR
uR
uuRuu
h
uuu
c
k
uuu
x
u
ct
u
ni
nininini
ninini
ninini
Courant number
8/12/2019 6 Finite Difference Methods
40/44
][)1()(2
][2
],[
][]0,[],[]0,[
conditionsinitial
)1(2)(
0
0,
2
0,10,1
2
1,
1,1,0,
0,2
0,10,12
1,1,
iiiii
iii
ii
t
iiiii
xkguRuuR
u
xgkuuxfu
xgxuxfxu
uRuuRuu
n
8/12/2019 6 Finite Difference Methods
41/44
8/12/2019 6 Finite Difference Methods
42/44
0 1 2 3 4 5 6
0 0.00000 0.01750 0.03500 0.05250 0.07000 0.03500 0.00000
1 0.00000 0.01750 0.03500 0.05250 0.04375 0.03500 0.00000
2 0.00000 0.01750 0.03500 0.02625 0.01750 0.00875 0.00000
3 0.00000 0.01750 0.08750 0.00000 -0.00875 -0.01750 0.00000
4 0.00000 -0.00875 -0.01750 -0.05250 -0.03500 -0.01750 0.00000
5 0.00000 -0.03500 -0.04375 -0.05250 -0.03500 -0.01750 0.00000
6 0.00000 -0.03500 -0.07000 -0.05250 -0.03500 -0.01750 0.00000
7 0.00000 -0.03500 -0.04375 -0.02620 -0.03500 -0.01750 0.00000
8 0.00000 -0.00875 -0.01750 0.00000 -0.03500 -0.01750 0.00000
9 0.00000 0.01750 0.00875 0.02625 -0.00875 -0.01750 0.00000
10 0.00000 0.01750 0.03500 0.05250 0.01750 0.00875 0.00000
9 3 Transport equation
8/12/2019 6 Finite Difference Methods
43/44
9.3 Transport equation
Transport equation
0
02
22
2
2
ux
ctx
ct
x
u
ct
u
0
u
xc
t
8/12/2019 6 Finite Difference Methods
44/44