Page 274 - Numerical Methods for Chemical Engineering
P. 274
The finite difference method applied to a 2-D BVP 263
We can approximate second derivatives similarly by adding the expansions,
2 2
df ( x) d f
f (x 0 + x) = f (x 0 ) + ( x) +
dx 2 dx 2
x 0 x 0
3 3 1
( x) d f 4
+ + O[( x) ]
3 dx 3
x 0
2 2
(6.24)
df ( x) d f
+ f (x 0 − x) = f (x 0 ) − ( x) +
dx 2 dx 2
x 0 x 0
3 3 1
( x) d f 4
− + O[( x) ]
3! dx 3
x 0
The first-and third-order terms cancel, yielding
2
2
4
f (x 0 + x) + f (x 0 − x) = 2 f (x 0 ) + [( x) ] d f + O[( x) ] (6.25)
dx 2
x 0
and an approximation for the second derivative,
2
d f f (x 0 − x) − 2 f (x 0 ) + f (x 0 + x) 2
= + O[( x) ] (6.26)
dx 2 ( x) 2
x 0
that has the same order of accuracy as (6.23). For partial derivatives, similar finite difference
approximations exist:
f (x 0 + x, y 0 ) − f (x 0 − x, y 0 )
∂ f
≈
∂x 2( x)
(x 0 ,y 0 )
f (x 0 + x, y 0 ) − f (x 0 , y 0 ) f (x 0 , y 0 ) − (x 0 − x, y 0 )
≈ ≈ (6.27)
( x) ( x)
2
∂ f f (x 0 − x, y 0 ) − 2 f (x 0 , y 0 ) + f (x 0 + x, y 0 )
≈ (6.28)
∂x 2 (x 0 ,y 0 ) ( x) 2
Finite difference solution of a Poisson BVP
We apply (6.28) to approximate the local partial derivatives in (6.17),
2
∂ ϕ ϕ(x i−1 , y j ) − 2ϕ(x i , y j ) + ϕ(x i+1 , y j )
≈
∂x 2 ( x) 2
(x i ,y j )
(6.29)
2
∂ ϕ ϕ(x i , y j−1 ) − 2ϕ(x i , y j ) + ϕ(x i , y j+1 )
≈
∂y 2 (x i ,y j ) ( y) 2
and obtain a linear equation for each (x i , y j )(a discretization of the PDE),
−ϕ(x i−1 , y j ) + 2ϕ(x i , y j ) − ϕ(x i+1 , y j ) −ϕ(x i , y j−1 ) + 2ϕ(x i , y j ) − ϕ(x i , y j+1 )
+
( x) 2 ( y) 2
= f (x i , y j ) (6.30)
We write this equation in standard matrix-vector form by employing the labeling