You are on page 1of 29

CHAPTER 2

Finite Difference Equations,


Continuous Approach

Introduction

Finite Difference Equation for the Diffusivity Equation (1-D)

Types and Methods of Solution of F.D.E.

Accuracy of Solutions

Implicit vs. Explicit F.D.E.

Stability of Convergence of Finite Difference Equation


(Von Neumann Analysis)

0
F.D.E. - Continuous Approach

Finite Difference Equations, Continuous Approach

Introduction
It is not possible to develop analytical solutions for many problems. The most common
reasons are the heterogeneity and irregular shapes of reservoirs. Another common reason, as in
the case for gases, is the nonlinearity of the equations (properties changing with pressure).
Reservoir simulation is a viable method for solving such problems and has become the standard
method for solving reservoir flow problems in both field offices and in research environments.
Reservoir simulation has become a common tool in reservoir engineering. Reservoir
simulation is used to solve research-type problems, such as analysis of enhanced oil recovery,
horizontal wells, well stimulation techniques, etc. More common applications, however, are the
simulation of actual wells and actual reservoirs. Since the late 1960's the technology and
computer hardware have advanced enormously and the cost and speed of doing reservoir
simulation have been improved dramatically.
The valuable aspect of reservoir simulation for field problems is the ability to make
production forecasts. Usually a number of different simulated cases are compared for the purpose
of making decisions. Drilling locations, production rates, injection plans, etc. are factors that may
vary from case to case.
The simulator data is taken from available information such as well logs, core analysis,
geological description, pressure data, and production data. In many cases, the well or wells have
already produced. For these cases, the past production period is simulated for the purpose of
"history matching". The input data usually must be adjusted in order to match the past
performance. This calibration process provides a more accurate reservoir "model" to be used for
forecasts.
In this chapter, we introduce the finite difference approach as an alternative to analytical
solutions. This approach is usually called reservoir simulation. The theory and practice of
reservoir simulation are covered in several publications.

1
F.D.E. - Continuous Approach

Finite Difference Approach for The Diffusivity Equation (1-D)


We can start with the diffusivity equation in one dimension:

c p
2 p
=
2
x
0.00633k t

(1)

This applies, of course, to the flow of a liquid with a small compressibility. We will discuss
gas flow later.
In order to solve problems which involve this equation, the finite difference method can be
used. This equation is "discretized" into the following finite difference form
n+1
n+1
- 2 pin+1 + pi+1
pi-1
pin+1 - pin
c
=
0.00633 k
t
( x )2

(2)

The n superscript indicates the "old" time level. All of the unknowns have already been
solved at the n time level. The n+1 superscript indicates the "new" time level. We want to solve
for these unknown values at the new time level.
Eq. 2 is called an implicit finite difference equation since it involves more than one
unknown. Three unknowns, pi-1n+1, pin+1, and pi+1n+1 occur because we chose the n+1 time level to
discretize the left-hand side of the equation. A template of this finite difference equation is shown
in
Fig. 1.

2
F.D.E. - Continuous Approach

p
t

P(x)

P(x+x)

Fig. 1 - Finite difference template,


involved in the finite
difference equation.

x+x

Fig. 2 - Illustration of Taylor showing pressures


series analysis.

We know the value of p at the n time level and we are trying to determine the values of p
at the n+1 time level.
The solution procedure for the finite difference equations is as follows:
(1) specify values for all pi0 at t = 0. (this is the initial condition)
(2) solve for all pin+1 for timestep 1.
(3) repeat this procedure for a sequence of timesteps, using the values from the previous
timestep as the "old" n values.
(4) stop when the desired time has been simulated.
It would have been possible to discretize the left-hand side of Eq. 1 at the n time level. In
that case, we would have only had one unknown, pin+1. This method would be called an explicit
finite difference equation. This would be easier to solve, but is of no practical use because it is
unstable (oscillates or blows up) for practical timestep sizes.
Theoretical basis, Taylor series.
Our justification for approximating Eq.1 with Eq.2 is based on Taylor series analysis.
Consider the function p(x) in Fig. 2. Suppose we know the value of p(x) at the point x. Also
suppose we know all the derivatives of p(x) at the point x. If we want to approximate the value of
p(x+x) at the point x+x, we can do this with a Taylor series as follows,
p(x + x) = p(x)+ xp (x)+

x2
x3
xn n
p (x)+
p (x)+ +
p (x)+
2!
3!
n!
3
F.D.E. - Continuous Approach

(3)

where pn is the n th derivative of p. This is an infinite series which is theoretically exact for an
infinite number of terms. However, if we truncate the series after n terms, then we introduce a
truncation error, et , (the remaining terms which are not included). This truncation error is
et =

n+1
p(x ) ( x ) n 1
+
(n + 1)!

et =

n+1
p(x + ) ( x ) n 1
(n + 1)!

(4)

and is equal to
(0 x)

(5)

It should be remembered that the function p(x) and all its derivatives must be continuous
throughout the interval under consideration. (In fact, we often deal with discontinuities in both
time and space. That limits the Taylor series analysis. Still we will continue our discussion about
using Taylor series for developing our finite difference equations.)
We will now simplify our notation by using pi rather than p(x), pi+1 rather than p(x+x),
and pi-1 rather than p(x-x). We can expand our Taylor series in either direction as follows:

pi+1

2
p ( x ) 2 p
( x )3 3 p
( x )4 4 p
= pi + x +
+
+
+
x
2! x 2
3! x 3
4! x 4

pi-1 = pi - x

p ( x )2 2 p ( x )3 3 p
( x )4 4 p
+
+
-
x
2! x 2
3! x 3
4! x 4

(6)

(7)

Notice that the right-hand side now uses partial derivatives (evaluated at xi) since p is a
function of both x and t, p(x,t).
We have a couple of choices of approximations to p/x:

Forward difference (from Eq. 6):


p - pi
p
i+1
x
x

(8)
4
F.D.E. - Continuous Approach

Backward difference (from Eq. 7):


p pi - pi -1

(x)
x
x

(9)

These expressions are both (x) (pronounced "first order correct") since the first term
truncated has x in it. The terms with higher powers of x are called "higher order terms".
We can also develop an approximation for 2p/x2 by combining Eqs. 6 and 7. This gives us
Central difference (from Eqs. 6 and 7):
2
p pi -1 - 2 pi + pi+1

(x 2 )
2
2
x
( x )

(10)

This e
xpression is used for the left hand side of Eq.1. It is (x2) (second order correct) since the x
terms cancel and the first term truncated contains x2.
We apply our Taylor series in terms of t to find the finite difference expression for p/t.
In this case, we will use a backward difference (in the negative t direction from tn+1). We will
simplify our notation to use superscripts to indicate the time level. Again, n is the "old" time level
for which we have a complete solution and know all variables and properties. n+1 is the new
time level for which the solution is unknown. With this notation, our finite difference
approximations to the 1-D diffusivity equation is
n+1
n+1
n+1
pi -1 - 2 pi + pi+1

( x )2

n+1
n
pi - pi
c
=
( x, t )
0.00633 k
t

(11)

Eq. 2 is the basic finite difference equation for the 1-D diffusivity equation. We say that it
is (x2,t). It must be solved for all the new pressures, pn+1, simultaneously. Once these new
pressures are solved, then they become the old pressures for the next timestep. In this manner,
solutions to Eq. 2 are solved in a time sequence for as many timesteps as required.
Now we will turn our attention to the initial conditions and boundary conditions which
complete the specification of the problem.
Initial conditions. Initial conditions are required to begin the timestep sequence. For the initial
conditions, n=0, a value is specified for each pressure. The most common initial condition is to
specify each pressure to be equal to a constant, such as

5
F.D.E. - Continuous Approach

p0i = pinitial

(11)

i = 1,.., IMAX

where IMAX is the total number of points in the x direction. This typifies a well or reservoir at
initial conditions of no fluid flow.
Boundary conditions. For a 1-D problem, we need to specify equations other than Eq. 2 at the
left boundary and the right boundary. Usually, either a fixed pressure (mathematically called the
Dirichlet condition) or a fixed first derivative (the Neumann condition) are specified, as follows:
Fixed pressure:
p1n+1 = C1

(12)

pIMAXn+1 = C2

(13)

or,

Fixed first derivative:


p2 - p1
= C3
x

(14)

p IMAX - p IMAX -1
= C4
x

(15)

or,

where C1, C2, C3, and C4 are values specified by the problem. Although these values may change
with time, they are held constant during the timestep.
6
F.D.E. - Continuous Approach

We now will discuss how the solution is obtained for a timestep.

7
F.D.E. - Continuous Approach

Types and Methods of Solution of F.D.E.


The pressure solution - a matrix problem. We can now state all of the equations that are to be
solved simultaneously for a particular timestep. Let us take a case where the boundary conditions
are fixed pressure. For the following equations, the unknown pressures are on the left hand side
and the right hand side has known values.
The left boundary:
p1 = C1

(16)
The interior points, i = 2,...,IMAX-1:

ct ( x ) 2 n+1
c ( x )2
n+1
n+1
- pi-1 + 2 +

pi - pi+1 =

0.00633k t
0.00633k t

pin

(17)

The right boundary:


p IMAX = C 2

(18)

Eqs. 16-18 comprise a system of simultaneous equations with IMAX unknowns and IMAX
equations. All of these equations are linear with respect to the unknown pressures. That is, there
are no pressure squared, etc. All of the pressure terms have coefficients which do not depend on
pressure.
As an example, let us consider a problem where IMAX = 5. For this problem, we have
five unknown pressures and five equations. Three of these equations are for interior points,
represented by the finite difference equation, Eq. 2. The first and last equations are for the
boundary conditions.
This set of equations can be represented by a matrix equation which can simply be written
as
Ap =d

(19)
8
F.D.E. - Continuous Approach

where A is a coefficient matrix, and p and d are column vectors. The matrix equation, Eq. 19, can
be shown as

b1

a2

c1
b2
a3

c2
b3
a4

c3
b4
a5

p1
d1


p2
d2
p3 d3


c4 p4
d4


b5 p5
d5

(20)

The rows of the matrix represent equations and the columns represent unknowns. Only
the non-zero elements of the matrix are shown in Eq. 20. Notice that the non-zero elements
follow a diagonal trend, lying in three adjacent diagonals. This is called a tri-diagonal matrix and
is characteristic of the matrix form of Eq. 2. Since matrix A is mostly zeros for large problems, it
is not necessary to store all of its elements in the computer. The values of a, b, c, and d are stored
as arrays and are computed as follows, for a problem with fixed boundary pressures:
The left boundary:
b1 = 1
c1 = 0
d1 = C1
The interior points: i = 2, IMAX-1
ai = -1
bi = 2 + (c)/(0.00633k) ((x)2/t)
ci = -1
di = (c)/(0.00633k) ((x)2/t) pin
The right boundary:
aIMAX = 0
bIMAX = 1
dIMAX = C2
Notice that a1 and cIMAX are not used because they fall outside the matrix.
Tri-diagonal solution - Thomas algorithm. The tri-diagonal matrix of Eq. 20 is a form which
commonly occurs in engineering problems and has a very efficient solution procedure called the
9
F.D.E. - Continuous Approach

Thomas Algorithm. This algorithm is similar to Gaussian elimination in that it has a forward
sweep and a backward sweep. The algorithm can be summarized as follows:
Forward sweep:
w1 = b1
g1 = d1/w1
wi = bi - ai ci-1 / wi-1
gi = (di - ai gi-1) / wi
carried out with i increasing, and
Backward sweep:
pIMAX = gIMAX
pi = gi - ci pi+1 / wi
carried out with i decreasing.
After this computation is completed, we have now solved for the new pressures and are
ready to go to the next timestep.
Example 2.1 1-D Simulation
Problem. Solve the following initial/boundary value problem with the method just discussed:
permeability
viscosity
compressibility
length
porosity

= 10 md
= 10 cp
= 20 x 10-6 psi-1
= 400 ft
= 0.20

Initial condition:
p(x,0) = 1,000 psi
Boundary conditions:
p(0,t) =

0 psi

p(400,t) = 1,000 psi

10
F.D.E. - Continuous Approach

Model parameters:

x = 100 ft (IMAX = 5)
t = 5 days
Solution.
This problem is solved by writing a FORTRAN program. The following program is
specifically written to solve this problem and output the pressure results each timestep.
Boundary Conditions Example.
p1 = 0
p5 = 1,000

0
1

1 b2 1

1 b3 1

1 b4

b2
d2
d3
d4

= b3 = b4 = 2 +
= p2n
= p3n
= p4n

where:

p1
0

p2
d2
p3 d 3

1 p4
d4

1 p5
1000

= (c)/(0.00633k) ((x)2/t)

11
F.D.E. - Continuous Approach

c===================================================== 1dsim
c
Program for solving diffusivity equation with fixed
c
boundary pressures
DIMENSION a(40),b(40),c(40),d(40),p(40),pn(40)
WRITE(*,*) 'imax, delt'
READ (*,*) imax, delt
pinit = 1000.
xlength = 400.
c1 = 0.
c2 = 1000.
delx = xlength / (imax-1)
phi = 0.20
perm = 10.
visc = 10.
comp = 20.E-6
time = 80.
alpha = (phi * visc * comp) / (0.00633 * perm) * (delx**2 / delt)
c
... initial conditions
DO 10 i = 1, imax
p(i) = pinit
pn(i) = pinit
10
CONTINUE
c
... interior gridblocks
DO 20 i = 2, imax-1
a(i) = -1.
b(i) = 2. + alpha
c(i) = -1.
20
CONTINUE
c
... boundary conditions
b(1) = 1.
c(1) = 0.
d(1) = c1
a(imax) = 0.
b(imax) = 1.
d(imax) = c2
c
... taking timesteps
t
= 0
30
CONTINUE
t
= t + delt
DO 40 i = 2, imax-1
d(i) = alpha * pn(i)
40
CONTINUE
c
CALL thomas(a,b,c,d,p,imax)
WRITE(*,800) t, (p(i),i = 1,imax)
DO 50 i = 1, imax
pn(i) = p(i)
50
CONTINUE
IF ( t .LT. time ) GO TO 30
800
FORMAT( 200F8.1)
END

12
F.D.E. - Continuous Approach

c==================================================== thomas
SUBROUTINE thomas(a,b,c,d,p,n)
c
this is a solution of tridiagonal system of equations
c
a,b,c,d : coefficients of the equation,
c
a(i) * x(i-1) + b(i) * x(i) + c(i) * x(i+1) = d(i)
c
p = solution vector
c
n = number of unknowns
DIMENSION a(*),b(*),c(*),d(*),p(*),w(101),g(101)
w(1) = b(1)
g(1) = d(1) / w(1)
DO 1 i = 2,n
w(i) = b(i) - a(i) * c(i-1) / w(i-1)
g(i) = (d(i) - a(i) * g(i-1)) / w(i)
1
CONTINUE
p(n) = g(n)
DO 2 i = n-1,1,-1
p(i) = g(i) - c(i) * p(i+1) / w(i)
2
CONTINUE
RETURN
END

13
F.D.E. - Continuous Approach

The numerical results are shown in Fig. 3 Although results are only computed at discrete
points, it is customary to draw straight lines between points. The straight lines, rather than a
smoothed curve, emphasize the discrete nature of the solution and clearly shows where the
discrete points are. The solutions in Fig. 3 show that the early solution is transient but approaches
steady state at 80 days.

1000

p(x,t) (psi)

800

1000

t = 5 days

800
10
20
30

600

600

80

. t = 5 days
. t = 2.5 days
t = 1.25 days

400

400

. t = 0.625
days
.
t = 0.3125
days
. t = 0.15625
days

200

200

p(x,5) (psi)

100

200

300

400

X (ft)

100

200

300

400

X (ft)

Fig. 3 - Pressure profiles


for Example 1.
timestep sizes.

Fig. 4 - Comparison of pressure


profiles at t = 5 days for different

14
F.D.E. - Continuous Approach

Accuracy of solutions
Now the question occurs: "how accurate are the finite difference solutions". We can
compare with an exact analytical solution, if it is available. However, we do not have an exact
analytical solution for many problems. We need to develop a methodology for analyzing the
accuracy of finite difference solutions - at least to have confidence that they are sufficiently
accurate for the purposes of our objectives.
The accuracy of the solutions is related to the truncation error in our Taylor series
analysis. We could do a complicated analysis of the Taylor series approximations, but we would
be analyzing the accuracy of the finite difference equation (it's approximation to the partial
differential equation), not the accuracy of the solution.
A more practical approach is to vary the values of t and x and analyze the comparative
behavior of our solutions. Let us use Example 1 to illustrate this numerical experimentation.
First, we will vary the value of t and observe the results. t is usually much easier to change
than x. Fig. 4 shows such a comparison at t = 5 days. It can be seen that as t becomes smaller,
the solution converges.
The value of p at x = 100 ft and t = 5 days, p(100,5), is then plotted in Fig. 5 to see more
detail. As t approaches zero, p(100,5) seems to approach the correct analytical solution of
573.34 psi. Fig. 5 also shows other values for x and they all approach the exact solution as t
approaches zero. On the other hand, Fig. 6 shows the effect of x on the solution with various
values of t. It is seen that p(100,5) does not approach the correct solution as x approaches
zero unless t is sufficiently small. For this particular problem, we can conclude the small t is
much more important than small x. In general, however, we should realize that complete
numerical experiments may have to be carried out to have confidence in our results.
Fig. 7 shows our first solution of p(x,5) using t = 5 days and x = 100 ft, compared with
our improved values of t = 1.25 days and X = 25 ft. It is easy to see the improved accuracy
and smoothness of the solution. However, this solution is still higher than the analytical solution
at x = 100 ft (the analytical solution is 573.34 psi).
Fig. 8 shows a comparison of the two numerical solutions on a time plot. The same
general behavior is true as on the x profile plot - the smaller values of x and t give more
accurate results.
For this problem, we may not require great accuracy. We may decide from Figs. 5 and 2.6
that values of t = 1.25 days and x = 25 ft are sufficiently small to give good results for practical
purposes. This gives an error of about 35 psi for p(100,5) which seems high. However, if we
look at Fig. 7, it looks like these values give an acceptable result. (The error at x = 100 is about
15
F.D.E. - Continuous Approach

the highest in the x profile). This selection of t and x is a judgement, according to the
practicality for the problem being solved.
p(100,5) (psi)

700

700

675

x 6.25 ft

p(100,5) (psi)

t = 5 days

675

x = 12.5 ft

650

650

x = 12.5 ft

625

625

x = 50 ft

t = 1.25 days
600

600

x = 100 ft

t = 0.15625 days
575

575
550

t = 0.01 days

550

20

40

80

100

. x (ft)

. t (days)

Fig. 5 - Effect of timestep size on


pressures at x = 100 feet and t = 5 days

1000

60

Fig. 6 - Effect of grid spacing on


pressures at x = 100 feet and t = 5 days

p(x,5) (psi)

1000

p(100,t) (psi)

x=100 ft , t =5 days
800

800

600

600

x = 100 ft , t = 5 days
x = 25 ft ,t = 1.25 days

x = 25 ft , t = 1.25 days
400

400
Analytical Solution

200
0

100

200
X (ft)

200

300

400

Fig. 7 - Comparison of pressure


profiles at t = 5 days

Analytical Solution
0

20

40

Time (days)

60

Fig. 8 - Comparison of
vs. time at x = 100 feet

80

pressure

On large problems encountered in reservoir simulation, there is a cost involved in taking


small values of t and space grids (x, y, and z). It is also recognized that much of the field
16
F.D.E. - Continuous Approach

data is somewhat inaccurate and uncertain. Therefore, something less then complete accuracy
may be acceptable in order to reduce cost and simplify data preparation.
Although we have found practical values of t and x for this particular problem, we
should not expect these values to apply to other problems. The trial and error procedure for
determining practical values of x and t is called a sensitivity analysis and is commonly done for
practical problems when the question of accuracy arises. Most of the time the correct analytical
solution is not known, so converging results are taken to be converging on the correct solution.
It should also be pointed out that the best solution may not always be achieved by t
approaching zero. For certain other problems, such as water displacing oil (the Buckley-Leverett
problem), it is known that the best value of t depends on the value of x and the physical
properties of the problem6. Therefore, we should be cautious in accepting that small values of t
always give the best results.
Other Taylor Series Approximations.The following is a table that shows forward, backward,
and central difference expressions for first and second derivatives.
pi = p(x)
pi+1 = p(x+x)
pi+2 = p(x+2x)

Difference Expression
pi-3

pi-2

pi-1

Forward Difference
x p ' (x)
(x)2 p ''(x)
Backward Difference
x p ' (x)
(x)2 p ''(x)
Central Difference
2 x p ' (x)
(x)2 p ''(x)

-1

pi

pi+1

-1
1

1
-2

pi+2

+ O (x)
1
+ O (x)

(x)2 p "(x)
1
1
-2
-1
1

pi+3

-2

1
0
-2

+ (x)2

1
1

Higher Order Difference Expressions


17
F.D.E. - Continuous Approach

Forward Difference
2x p ' (x)
(x)2 p ''(x)
Backward Difference
2x p ' (x)
(x)2 p ''(x)
Central Difference
12x p ' (x)
12 (x)2 p ''(x)

-3
2

-1

1
4

-4
-5

3
2

1
-1

-8
16

0
-30

4
-5

-1
4

+ (x)2
-1
+ (x)2

8
16

-1
-1

+ (x)4

18
F.D.E. - Continuous Approach

Implicit vs. Explicit F.D.E.


2
p
p
=
2
x
t

(21)

2
p - 2 pi + pi+1
p
2
= i -1
+ ( x )
2
2
x
( x )

(22)

where

24

( x ) p
(x)=- 4(x*,t) (x-x x* x+x)
12 x
2

(23)

n+1
n
p - pi
p
= i
+ ( t)
t
t

(24)

where

t 2 p
( t)= - 2(x,t*) (t t * t + t)
2 x

(25)

Explicit FDE. The solution is only stable when (t) < (x)2/2.
1
1 n+1
n
( n - 2 pin + pi+1
) =
( pi - pin )
2 pi-1
t
( x )

(26)

Implicit FDE. The solution is unconditionally stable for any t.


19
F.D.E. - Continuous Approach

1
1 n+1
n+1
( n+1 - 2 pin+1 + pi+1
) =
( pi - pin )
2 pi-1
t
( x )

(27)

Crank-Nicolson Method (C-N). This is a half explicit/half implicit method


1 1
1 1
1 n+1
n
n+1
( n - 2 pin + pi+1
)+
( n+1 - 2 pin+1 + pi+1
) =
( pi - pin )
2 pi-1
2 pi-1
2 ( x )
2 ( x )
t

(28)

Truncation Error : ( (x)2 , (t)2 )


General Implicit Methods. This is also a mixed explicit/implicit method, but is more flexible
than the C-N method.

(1- )

1
1
1 n+1
n
n+1
( n - 2 pin + pi+1
)+
( n+1 - 2 pin+1 + pi+1
) =
( pi - pin )
2 pi-1
2 pi-1
t
( x )
( x )

Weighting factor :

(29)

(01)

= 1 ( Implicit)
= 0 ( Explicit)
= 1/2 ( C-N)
Truncation Error: ( (x)2 , (t) ) (generally)
Only the implicit method is unconditionally stable (for any timestep size). The explicit
method is stable only for sufficiently small timesteps, which are generally impractical. Although
the Crank-Nicholson method has higher order accuracy, it is on the borderline of instability and is
conditionally stable for practical purposes. Therefore, the implicit method is the standard in
reservoir simulation. If more accuracy is required, smaller timesteps are used.

20
F.D.E. - Continuous Approach

Stability and Convergence of Finite Difference Equations (Von Neumann


Analysis )
Consider the equation
2
p
p
=
x2
t

(21)

The
initial
conditions can be represented by a Fourier series

( x ,0) a m e imx
m1

(30)

But we can look at an arbitrary element m = s, and show that


(31)

p(x,0) = eisx
is representative of general behavior. At time t, we can represent the solution as
p(x,t) = eisx (t)
Since the solution is separable.

(32)

Time period operator, E.


We will represent one time period as an operator acting on the previous time period:
(t + t) = E(t)

(33)

Analytical solution.
A solution can be written in the form:
p(x, t) = eisx e- s

(34)

which means that

(t) = e- s

(35)

2t

21
F.D.E. - Continuous Approach

and can be expanded as,


2

p(x,t) = eisx [ 1 - s2 t +

( s2 t)
( 2 t)
- s
+ ... ]
2!
3!

(36)

but
2 (t+t)

e- s

= e- s t e- s t = E e- s

E = e- s

(37)

So
(38)

E analytical

( 2 t)
( 2 t)
= 1 - s t + s
- s
+ ...
2!
3!
2

(39)

Note that for any (positive) value of t, 0<E<1.


Explicit Difference Equation.
Now we will analyze the F.D.E.
t
n
n
n
n+1
[ pi+
- pin
1 - 2 pi + pi-1 ] = pi
2
( x )

(40)

Substituting our Fourier element eisx(t) for p gives


t
[ is(x + x ) (t) - 2 eisx (t) + eis(x - x ) (t)] = eisx [ (t + t ) - (t)] (41)
2 e
( x )
Cancelling eisx gives
t
[ eis x - 2 + e- is x ] (t) = (t + t ) - (t)
( x )2

(42)

eis x + e- is x = 2 cos(sx )

(43)

But,

22
F.D.E. - Continuous Approach

So,
2

t
[ cos(sx ) - 1] (t) = (t + t ) - (t)
( x )2

(44)

t
[ cos(sx ) - 1] ) (t)
( x )2

(45)

(t + t ) = (1 + 2

cos( sx ) 1 2 sin 2 ( s

(t + t) = (1 - 4

x
)
2

(46)

t
x
[ 2 (s
)]) (t)
2 sin
2
( x )

(47)

Then, the value of E is


E explicit = 1 - 4

t
x
[ 2 (s
)]
2 sin
2
( x )

(48)

For small values of x,


x
x
sin s s

2
2

(49)

lim sin (s 2 ) = (s 2 )(s 2 )


2

(50)

x 0

E explicit = 1 - 4

t
x x
(s
)(s
)
2
2
2
( x )

(51)

So,
E explicit = 1 - s2 t

(52)

23
F.D.E. - Continuous Approach

Which does converge to Eanalytical as t becomes small.


But since we can write the initial conditions as
p0 = eis
and after n timesteps

p(x,t) = En p(x,0)
pn = eisx (1 - 4

t
x n
[ 2 (s
)] )
2 sin
2
( x )

(53)

The quantity, E must be -1 E 1, otherwise changes in p will grow instead of decaying


and errors will grow instead of decaying. So, in order for the absolute value of E to be less than
1, the condition for stability is
t
1
<
2
2
( x )
We call this conditional stability. It is not practical for reservoir simulation. If we violate this
condition, the solution will oscillate with respect to x and t and may blow up.
Implicit Difference Equation. Following the same approach, we arrive at the following:

t
[ cos(sx ) - 1] (t + t ) = (t + t ) - (t)
( x )2

(54)

t
x
[ 2 (s
)] (t + t ) = (t + t) - (t)
2 sin
2
( x )

(55)

-4

(t + t) =

1
t
x
2
1+ 4
)]
2 [ sin (s
2
( x )

(t)

(56)

24
F.D.E. - Continuous Approach

So,
1

E implicit =
1+ 4

t
x
2
)]
2 [ sin (s
2
( x )

(57)

which indicates that the implicit difference equation is stable for any value of t, ( 0 < E < 1 ).
We call this unconditional stability. The implicit method will not oscillate or blow up.
For small values of x,
1

E =
1+ 4

t
x x
)(s
)
2 (s
2
2
( x )

1
1 + s2 t

(58)

which is equivalent to
E = 1 - s2 t + ( s2 t )2 - ( s2 t )3 + ...

(59)

and converges to
1 - s2 t = E analytical

(60)

for small x, t. So the implicit method becomes accurate for small values of x and t

25
F.D.E. - Continuous Approach

EXERCISES
PROBLEM NO.1
(a) Derive an O(x)2 F. D. representation for dp/dx at xN (right hand boundary) using
values at xN , xN-1 , and xN-2 .
(b) Use Taylors series and show the first truncated term.
PROBLEM NO.2
Our F. D. E. can be shown in dimensionless form as follows:

1
pD = t pD - 1
tD
2

Show all the steps in deriving this form, starting with the F. D. E.

Vc
a p = t p + qB
t
n+1 pt

Hint, use the following relationships:


x = y
pD =

0.00633 kh( pinitial - pi )


qB

tD =

0.00633 k t
ct x y

PROBLEM NO. 3
26
F.D.E. - Continuous Approach

For each of the following, use Taylor series to derive the indicated expression. Show the
first truncated term and state the order of the approximation(i.e. O(x)).
(a) a central difference equation for p/x which involves the points i-1 and i+1.
(b) a forward difference equation for p/x which involves the points i, i+1, i+2.
(c) a forward difference equation for p/x2 which involves the points i, i+1, i+2.

PROBLEM NO 4
Derive Eq. 2 using Taylors series. The Taylors series expansions are taken from the
reference point pin+1, so the space derivative will be centered and the time derivative will be
backward. Save the first truncated terms for both x and y.
PROBLEM NO 5
Analyze the accuracy of a 1-D simulator by the following:
(a) Run the 1-D program in Example 2.1, using various values of t and x. For each value of
x, find the limit of p(100,5) as the timestep approaches zero by extrapolating your results. Then
plot these limit values versus x. Note the significance of the timestep size.
(b) Run the 1-D program in Example 2.1, using various values of t and x. For each value of
t, find the limit of p(100,5) as t approaches zero by extrapolating your results. Then plot these
limit values versus t. Note the significance of the timestep size.
(c) Compare the sensitivity of results in parts a and b. Comment on these differences (Hint: look
at problem 4. Use this result to analyze the sensitivity.)
PROBLEM NO 6
Modify the 1-D simulator in Example 2.1 to calculate the flow rate (ft 3/dft2) on the left
boundary. Make each run to steady state. Plot this flow rate vs. time for IMAX = 5,10, and 20.
Note what timestep you use.
PROBLEM NO 7
Modify the 1-D simulator in Example 2.1 to have a closed right boundary (q = 0) instead
of a fixed pressure boundary. Calculate the flow rate (ft3/ft2) on the left boundary. Make each run
to 30 days. Plot the flow rate vs. time for IMAX = 5, 10, and 20. Note what timestep you use.
27
F.D.E. - Continuous Approach

PROBLEM NO 8
Modify the 1-D simulator in Example 2.1 to specify a slope of 1 on the left boundary and a
slope of 0 on the right boundary. Make each run until p1 becomes negative. Note what timestep
you use.
PROBLEM No. 9
Consider the following boundary value problem:
2
u u
=
x 2 t
I.C.: u(0<x<1, 0) = x
u(1<x<2, 0) = 2-x

B.C.: u(0, t) = 0
u(2, t) = 0
We want to solve this problem with an implicit F.D.E. but only use three grid points, at
x = 0, 1, and 2. We will use a timestep so that t = 0.5 . Of course, x = 1 .
(a)
(b)

Show the tri-diagonal matrix for this problem.


Solve for u(1, 0.5) and u(1, 1)

28
F.D.E. - Continuous Approach

You might also like