Week 3 PE546 Chapter 2 Finite Difference
Week 3 PE546 Chapter 2 Finite Difference
FINITE DIFFERENCES
Solution to Partial Differential Equations (PDEs)
α (2 n +1)n π 2t
∂ p 1 ∂p
2
4 pinit ∞
(−1)n
(2n + 1)π x
∂x 2
=
α ∂t
⇒ p ( ) B1
x , t = p −
π
∑
n = 0 2n + 1
e 4 L2
cos
2L
• Usually we transform the PDE into algebraic equations which are easier
to solve
• We “discretize” the derivatives
• Assume constant pressure and properties over an area/block
Solutions for PDEs ∂ 2 p 1 ∂p
=
∂x 2
α ∂t
p ( x, t ) time step
Grid block
x
x
Finite Difference Approximations
f(x)
∂P P( x + ∆x) − P( x)
≈
∂x forward ∆x
x x+∆x
x
• Secant connects P(x) to P(x+∆x). Slope of the secant line is the “rise”
over the “run”
∂P P( x + ∆x) − P ( x) 1 ∂2 P 1 ∂3 P
= − ( ∆x ) + ( ∆x ) 2
+
∂x x ∆x 2! ∂x x
2
3! ∂x x
3
Secant line
Tangent line
P(x)
∂P P( x) − P( x − ∆x)
≈
∂x backward ∆x
x-∆x x
• Secant now connects P(x) to P(x-∆x). Slope of the secant line is the
“rise” over the “run”
∂P P( x) − P ( x − ∆x) 1 ∂2 P 1 ∂3 P
= + ( ∆x ) − ( ∆x ) 2
+
∂x x ∆x 2! ∂x x
2
3! ∂x x
3
Tangent
P(x) line
Secant line
∂P P ( x + ∆x) − P( x − ∆x)
≈
∂x centered 2∆x
x-∆x x x+∆x
• Secant now connects P(x+∆x) to P(x-∆x). Slope of the secant line is the
“rise” over the “run”
You can subtract forward and backward Taylor series to get centered
∂P 1 ∂2 P 1 ∂3 P
P( x + ∆x) = P( x) + ∆x + ( ∆x ) 2
+ ( ∆x ) 3
+
∂x x 2! ∂x x
2
3! ∂x x
3
∂P 1 ∂2 P 1 ∂3 P
− P( x − ∆x) = P( x) − ∆x + ( ∆x ) 2
− ( ∆x ) 3
∂x x 2! ∂x 2 x 3! ∂x 3 x
∂P 2 ∂3 P
P( x + ∆x) − P( x − ∆x) = 2 ∆x + ( ∆x ) 3
+ ...
∂x x 3! ∂x x
3
∂P 1 ∂2 P 1 ∂3 P
P( x + ∆x) = P( x) + ∆x + ( ∆x ) 2
+ ( ∆x ) 3
+
∂x x 2! ∂x 2 x 3! ∂x 3 x
∂P 1 ∂2 P 1 ∂3 P
+ P( x − ∆x) = P ( x) − ∆x + (∆x) −
2
(∆x)3 + ...
∂x x 2! ∂x x
2
3! ∂x x
3
∂2 P
P( x + ∆x) + P( x − ∆x) = 2 P( x) + 2 (∆x) 2 + ...
∂x x