Vous êtes sur la page 1sur 34

Ho Chi Minh City University of Technology

Faculty of Geology & Petroleum Engineering


Modeling & Simulation Division

PARTIAL DIFFERENTIAL EQUATIONS


(PDEs)
Presenter: Dr. Do Quang Khanh
Email: doquangkhanh@yahoo.com
Website: www.hcmut.edu.vn

Partial Differential Equations (PDEs)


HCMUT

Physical meaning of PDE


Initial and boundary conditions
Classification
parabolic vs. hyperbolic
linear vs. nonlinear
Solution Methods
Analytical, numerical, transformation methods

Dr. Do Quang Khanh

Classification
HCMUT

T T
2 = 0
2 +
y
x
2

2p
p
2 =
x
t

2y 1 2y
= 2 2
2
x
c t

Laplace

steady-state

Elliptic

Diffusitivity
(heat cond)

transient

Parabolic

Wave

transient

Hyperbolic

Dr. Do Quang Khanh

Example: Diffusivity Equation


HCMUT

p=
2

ct p
t

Expresses conservation of mass


Slightly compressible fluid
Porous media
Single phase flow
4

Dr. Do Quang Khanh

Linearity
HCMUT

ct

If
does not depend on p the
k
equation is linear.

ct

If
does depend on p the
k
equation is nonlinear.

Dr. Do Quang Khanh

Coordinate Systems
HCMUT

Cartesian

2 p 2 p ct p
+ 2 =
2
x
y
k t

Radial
2 p 1 p ct p
=
+
2
r
r r
k t
These 2equations are for 2D problems. To go to 3D
add p .
z 2
6

Dr. Do Quang Khanh

Transient versus Steady-State


HCMUT

2p
p
2 =
x
t

2p
2 = 0
x

Neeeds initial
and boundary conditions

Neeeds only
boundary conditions

Late-time solution
at least with const pressures
at the ends

Dr. Do Quang Khanh

Derivatives
HCMUT

The diffusivity equation includes


derivatives of pressure in space and in
time.
To solve the diffusivity equation
numerically we must find ways to
represent these derivatives.

Dr. Do Quang Khanh

Taylor Series
HCMUT

p
p(x+ x)
p(x)

x+x

2
(
x )
p(x + x ) = p(x ) + x p(x ) +
p(x ) +

2!

(x )n
n!
9

p n (x ) +
Dr. Do Quang Khanh

First Derivative (Forward)


HCMUT

Truncate series after second term and rearrange


p(x ) =

p(x + x ) p(x )
+ O(x )
x

This is usually written


p i +1 p i
pi
x

10

Dr. Do Quang Khanh

First Derivative (Backward)


HCMUT

Similarly,

p(x ) p(x x )
p(x ) =
+ O(x )
x

which is usually written


p i p i 1
pi
x
11

Dr. Do Quang Khanh

First Derivative (Central)


HCMUT

Subtract the forward and backward series


p(x + x ) p(x x )
2
+ O(x )
p(x ) =
2x

which is usually written


p i +1 p i 1
pi
2x
12

Dr. Do Quang Khanh

Second Derivative (Central)


HCMUT

Add the forward and backward series

p(x + x ) 2p(x ) + p(x x )


2
p(x ) =
+ O(x )
2
(x )

which is usually written


p i +1 2p i + p i 1
"
pi
(x )2

13

Dr. Do Quang Khanh

Accuracy
HCMUT

Getting the derivatives approximated


correctly is an important part of getting an
accurate numerical solution.
How accurate are these Taylor series
forms?

14

Dr. Do Quang Khanh

Accuracy
HCMUT

Experiment with the spreadsheet to


learn for yourself how x and t
affect the accuracy of the derivative.
How accurate is a second derivative
term (space) ?
How accurate is a first derivative
term (time)?

15

Dr. Do Quang Khanh

Accuracy
HCMUT

You can study the accuracy of the


derivatives (as a function of x) by
plotting the absolute error between the
true f(x) and the calculated f(x). [Also
f(x)]
You may want to consider using
logarithmic axes on these plots.

16

Dr. Do Quang Khanh

Accuracy
HCMUT

You should have found that the space


derivative is O(x2) and the time
derivative is O(t).
Knowing this if you wanted to improve the
accuracy of your solution and could halve
either x or t which would you choose?

17

Dr. Do Quang Khanh

Linear Reservoir
Constant Pressure Boundaries

HCMUT

ft
day
psi
1/psi
md
cp

p const
(left)

p const
(right)

2p
ct
p
2 =
x
0.00633k t

0
x
18

Dr. Do Quang Khanh

Uni_Names
HCMUT

(ft^3/day)*cp/(md*ft*psi)
(md*ft*psi)/(cp*ft^3/day)

19

158.00836
0.00633

Dr. Do Quang Khanh

Diffusivity: Numerical Solution


HCMUT

p
p
=
2
x
t
2

where =

ct
0.00633k

First discretize the region on


interest over both space and time.
Xi-2

Xi-1

xi

Xi+1

Xi+2

t = t1 , t 2 , t 3 , ...
20

Dr. Do Quang Khanh

Diffusivity: Numerical Solution


HCMUT

Replace the analytical derivatives by numerical


approximations.
Central difference in space
Backward difference in time
Right now we are not stating what timestep (n or
n+1) the terms on the left are being evaluated.

n +1
i

pi +1 2 pi + pi 1
p p
=
2
t
(x )
21

n
i

Dr. Do Quang Khanh

Implicit Solution Template


HCMUT

t
t

x i-1

xi
22

x i+1

n+1

Dr. Do Quang Khanh

Implicit - Time Level of Terms


HCMUT

An implicit solution scheme means that


the pressures at the nodes will be
evaluated at the new timestep (n+1) in
second derivative (space) term.
pin++11 2 pin +1 + pin+11
pin +1 pin
=
2
t
(x )
2
(
x )
=

0.00633k t

n +1
i +1

2p

n +1
i +1

(2 + ) p

n +1
i

(x )2

ct
n +1
i 1

+p

n +1
i
23

= p

n +1
i 1

= p

n +1
i

+p

n
i

n
i
Dr. Do Quang Khanh

Boundary Conditions
HCMUT

We must specify the conditions of the left and right


boundaries
constant pressure
pi = const (I = 1 or n)
constant rate

p
Specity rate :
= const
x
p
= 0 is a " no flow" boundary
x
for example, p2 p1 = x const

or ,

p N p N 1 = x const
Dr. Do Quang Khanh

24

System of Equations
HCMUT

p1n +1

= given left value

n +1
pnx

= given rightvalue

pin+11 (2 + ) pin +1 + pin++11 = pin


b1

a
2

c1
b2
a3

c2
b3

c3

a4

b4
a5

x d
1 1
x2 d 2
x = d
3 3
x4 d 4

c4 x5 d 5

b5
25

Thomas algorithm

Dr. Do Quang Khanh

Thomas Algorithm
HCMUT

The problem Ax=b can be solved very efficiently


when A is a tridiagonal matrix. The matrix itself is not
stored. Only three vectors a,b and c are stored.
These hold the values on the matrix diagonals.
b1

a
2

c1
b2

c2

a3

b3

c3

a4

b4
a5
26

x d
1 1
x2 d 2
x = d
3 3
x4 d 4


c4 x5 d 5

b5
Dr. Do Quang Khanh

HCMUT

n : int, inp
a(n) : real, inp b(n) : real, inp c(n) : real, inp d(n) : real, inp
x(n) : real, out
Sub Thomas(a() As Double, b() As Double, c() As Double, _
d() As Double, x() As Double)
'Tridiagonal system of equations
Dim n As Integer, i As Integer
n = UBound(b)
ReDim w(n) As Double, g(n) As Double
w(1) = b(1)
g(1) = d(1) / w(1)
For i = 2 To n
w(i) = b(i) - a(i) * c(i - 1) / w(i - 1)
g(i) = (d(i) - a(i) * g(i - 1)) / w(i)
Next i
x(n) = g(n)
For i = n - 1 To 1 Step -1
x(i) = g(i) - c(i) * x(i + 1) / w(i)
Next i
End Sub
27
Dr. Do Quang Khanh

HCMUT

Sub VBA111()
' Linear reservoir: constant pressures at the two end points
Dim nx As Integer, nt As Integer, ipr As Integer

Program Structure

'Input
ReDim a(nx) As Double, b(nx) As Double, c(nx) As Double
ReDim d(nx) As Double, p(nx) As Double
'
dx = xlen / (nx - 1)
dt = tend / nt
alpha = phi * mu * ct / (0.00633 * k) * dx ^ 2 / dt
'Initialization
t=0
'Time steps
For it = 1 To nt
'make a, b, c, d,
Call Thomas(a, b, c, d, p)
Next it
End With
End Sub
28

Dr. Do Quang Khanh

Explicit Solution Scheme


HCMUT

Discretize the region of interest


Discretize the diffusivity equation
Central difference in space
Forward difference in time

pin+1 2 pin + pin1


where =

2
(
x )
=
( p n +1 p n )

ct
0.00633k
29

Dr. Do Quang Khanh

Finite Difference Template


HCMUT

t
n+1

t
n
t
t
x i-1

xi
30

x i+1

x
Dr. Do Quang Khanh

Explicit Solution
HCMUT

Explicit equations
Left boundary (i = 1)

p1 = given left value

(or no flow)

Interior points (i = 2,,nx-1)


pin1 (2 ) pin + pin+1

pin +1

Right boundary (i = nx)

n +1
nx

= given right value


31

(or no flow)
Dr. Do Quang Khanh

Stability
HCMUT

Implicit: stable
Explicit: at less than 2 it is unstable!
Ex: What is the maximum timestep that
we can take with the explicit FDE for the
following data:

32

Dr. Do Quang Khanh

ASSIGNMENTS, TEST PROBLEMS


HCMUT

Linear Reservoir with Const. Press. Boundaries:


Suppose we have a sand packed core container 20ft
long. We pressure it with air at 100 psia. Then we open
valve on both ends to the atmospheric pressure, 14.7
psia. Consider the finite difference equation for this
flow problem in the following form:
n +1
i +1

n +1
i

2p

n +1
i 1

+p

=(p

n +1
i

p )
n
i

Suppose we are using 5 grid points with a grid point on


each end. Fill in the table of the matrix coefficients and
right hand side for the first timestep. Include the
proper boundary conditions. Use exact values where
you can, but use the math symbols elsewhere.
34

Dr. Do Quang Khanh