Professional Documents
Culture Documents
Finite Difference Method: I I I X N
Finite Difference Method: I I I X N
Principle: derivatives in the partial dierential equation are approximated by linear combinations of function values at the grid points 1D: = (0, X), grid points ui u(xi ), xi = ix i = 0, 1, . . . , N mesh size x =
X N
u () x x =
lim
u x i u x i u x i
n=0
(xxi )n n!
nu xn i
T1 : T2 :
ui+1 = ui + x ui1 = ui x
u x u x
(x)2 + 2 i (x)2 + 2 i
2u x2 2u x2
(x)3 + 6 (x)3 6
+ ...
i
2u x2
(x)2 6
3u x3
+ ...
i
T2
u x
ui ui1 x + = x 2
backward dierence
2u x2
(x)2 6
3u x3
+ ...
i
T1 T2
u x
3u x3
+ ...
i
2u x2
=
i
u x
= lim
i
x0
Variable coecients f x
i
ui+1 ui x
f (x) = d(x) u x
fi+1/2 fi1/2 di+1/2 ui+1 ui di1/2 ui ui1 x x = x x di+1/2 ui+1 (di+1/2 + di1/2 )ui + di1/2 ui1 (x)2
u y
u x
u y
2u xy u y u y
u y
i+1,j
i,j
2x
i1,j
+ O(x)2
i+1,j
i1,j
backward/central dierence approximations would need u1 which is not available Polynomial tting u(x) = u0 + x u x x2 + 2 0 2u x2 x3 + 6 0 3u x3 u x + ...
0
u(x) a + bx + cx2 ,
u b + 2cx, x
b
0
approximate u by a polynomial and dierentiate it to obtain the derivatives u0 = a u1 = a + bx + cx2 u2 = a + 2bx + 4cx2 b= cx2 = u1 u0 bx 3u0 + 4u1 u2 2x
ui+1 = ui + x ui+2 = ui + 2x
ui +ui+1 +ui+2 x
(x)2 + 2 i (2x)2 + 2 i + ( + 2)
2u x2
u x i
(2x)3 + 6 i
x 2 (
3u x3
2u x2
+ ...
i
++ x ui
+ 4)
+ O(x2 )
Second-order accurate if
3 = 2,
+ + = 0,
u x i
+ 2 = 1, =
+ 4 = 0 + O(x2 )
= 2,
1 = 2
ui+1 = ui + x ui+2 = ui + 2x
ui +ui+1 +ui+2 x2
2u x2
2u x2
u x i
(2x)3 + 6 i
+4 2 2u x2
3u x3
+ ...
i
++ x2 ui
+ O(x)
First-order accurate if = 1, = 2,
+ + = 0,
u x i
+ 2 = 0,
ui 2ui+1 +ui+2 x2
+ 4 = 2 + O(x)
=1
High-order approximations
u x u x u x 2u x2 =
i
2ui+1 + 3ui 6ui1 + ui2 + O(x)3 6x ui+2 + 6ui+1 3ui 2ui1 + O(x)3 6x ui+2 + 8ui+1 8ui1 + ui2 + O(x)4 12x
=
i
=
i
=
i
Pros and cons of high-order dierence schemes more grid points, ll-in, considerable overhead cost high resolution, reasonable accuracy on coarse grids Criterion: total computational cost to achieve a prescribed accuracy
in = (0, 1),
u(0) = u(1) = 0
fi = f (xi )
xi = ix,
x =
1 , N
i = 0, 1, . . . , N
Result: the original PDE is replaced by a linear system for nodal values
= f1 = f2 = f3 = fN 1
Matrix form
Au = F
A RN 1N 1
u, F RN 1 u1 u2 u3 f1 f2 f3 fN 1
2 1 1 1 2 1 1 2 1 , A= (x)2 ... 1 2
u=
uN 1
F =
=0 uN +1 = uN 1 central dierence
uN +1 uN 1 =0 2x
A RN N
2 1 1 2 1 1 1 2 1 A= ... (x)2 1
, 2 1 1 1
u= u
uN
F = f
f1 f2 f3
N 1 1 2 fN
= g1
u x (1)
+ u(1) = g2
fi,j = f (xi , yj ),
i, j = 0, 1, . . . , N
Central dierence approximation O(h2 ) ui1,j +ui,j1 4ui,j +ui+1,j +ui,j+1 = fi,j , h2 ui,0 = ui,N = u0,j = uN,j = 0
i, j = 1, . . . , N 1
i, j = 0, 1, . . . , N
(N 1)2
u, F R(N 1)
u = [u1,1 . . . uN 1,1 u1,2 . . . uN 1,2 u1,3 . . . uN 1,N 1 ]T F = [f1,1 . . . fN 1,1 f1,2 . . . fN 1,2 f1,3 . . . fN 1,N 1 ]T 4 1 1 4 1 ... ... B= 1
B I I B I ... ... A= I I= 1 1 1 1
, B I I B
4 1 1 4
The matrix A is sparse, block-tridiagonal (for the above numbering) and SPD. cond2 (A) = |max | = O(h2 ) |min |
in on
u = g0
stencil of Q
curvilinear boundary
u4 = u0
h + g0 (R) h h
Substitution yields
h u0 + u3 = h2 f0 + g0 (R) h
Grid transformations
Purpose: to provide a simple treatment of curvilinear boundaries
The original PDE must be rewritten in terms of (, ) instead of (x, y) and discretized in the computational domain rather than the physical one. Derivative transformations u u , ,... x y
dicult to compute
u u , ,...
easy to compute
u u u = + , x x x
2u + 2 2u + 2
x y
u = f x
2
turns into y
2
2u 2
2 u + 2 x x y y
u 2 2 2 u 2 + 2 + 2 =f x2 y x2 y
, , , x y x y
unknown
= =
u x x u x x
+ +
u y y u y y
u u
x x J
y y
u x u y
where J =
(x,y) (,)
+ + + +
y dy y dy x d y d x y
d d dx dy
x x x y
y y x y
dx dy d d
x y
1 det J
y y
x x
1 x = , y det J
1 x = y det J