Docsity

Finite Difference Equations, Continuous Approach - Lecture Notes |, Study notes of Engineering

Toggle sidebar
bg1
CHAPTER 2
Finite Difference Equations,
Continuous Approach
z Introduction
z Finite Difference Equation for the Diffusivity Equation (1-D)
z Types and Methods of Solution of F.D.E.
z Accuracy of Solutions
z Implicit vs. Explicit F.D.E.
z Stability of Convergence of Finite Difference Equation
(Von Neumann Analysis)
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c

Partial preview of the text

Download Finite Difference Equations, Continuous Approach - Lecture Notes | and more Study notes Engineering in PDF only on Docsity!

CHAPTER 2

Finite Difference Equations,

Continuous Approach

z Introduction

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

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

z Accuracy of Solutions

z Implicit vs. Explicit F.D.E.

z Stability of Convergence of Finite Difference Equation

(Von Neumann Analysis)

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.

t

x

t

p p p P(x+ āˆ† x)

x x+ āˆ† x

P(x)

x

P

Fig. 1 - Finite difference template, Fig. 2 - Illustration of Taylor showing pressures involved in the finite series analysis. difference equation.

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 pi^0 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)+ x 2!

p (x)+ x 3!

p (x)+ + x n!

p (x)+

2 3 n (^) n āˆ† āˆ†

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 , e (^) t , (the remaining terms which are not included). This truncation error is

t

n+1 (^) n e =

p(x ) x (n + 1)!

1 (4)

and is equal to

t

n+1 (^) n e =

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

(0 x)

≤ ≤

1 (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 p i-1 rather than p(x- āˆ† x). We can expand our Taylor series in either direction as follows:

i+1 i

(^2 ) 2

3 3

4 p (^) = p + x (^4) p x

x 2!

p x

x 3!

p x

x 4!

p x

( )^ ( ) 3 ( )^4

i-1 i

2 2

3 3

4 p (^) = p - x (^4) p x

x 2!

p x

x 3!

p x

x 4!

p x

( ) 2 ( ) 3 ( )^4

Notice that the right-hand side now uses partial derivatives (evaluated at x (^) i ) since p is a function of both x and t , p(x,t).

We have a couple of choices of approximations to āˆ‚ p/ āˆ‚ x :

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

i

0 p = pinitial i = 1,.., IMAX (11)

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:

p 1 n+1^ = C 1 (12)

or,

pIMAXn+1^ = C 2 (13)

Fixed first derivative:

2 1 3

p - p x

= C

or,

IMAX IMAX - 4

p - p x

= C

where C 1 , C 2 , C 3 , and C 4 are values specified by the problem. Although these values may change with time, they are held constant during the timestep.

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

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:

p 1 = (^) C 1

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

- p^ + 2 +

c 0.00633k

x t

p (^) - p (^) =

c 0.00633k

x t i-1n+1^ t in+1 i+1n+1 pin

āŽ›^2

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

A p = d (19)

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

Forward sweep:

w 1 = b 1 g 1 = d 1 /w 1 wi = bi - a (^) i c (^) i-1 / wi- gi = (di - a (^) i gi-1 ) / wi

carried out with i increasing, and

Backward sweep:

pIMAX = gIMAX

pi = gi - c (^) i 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 = 10 md viscosity = 10 cp compressibility = 20 x 10 -6^ psi - length = 400 ft porosity = 0.

Initial condition:

p(x,0) = 1,000 psi

Boundary conditions:

p(0,t) = 0 psi

p(400,t) = 1,000 psi

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.

p 1 = 0

p 5 = 1,

1 0 1 1 1 1 1 1 0 1

0

1000

2 3 4

1 2 3 4 5

2 3 4

āˆ’ āˆ’ āˆ’ āˆ’ āˆ’ āˆ’

āŽ›

āŽ

āŽœ āŽœ āŽœ āŽœ āŽœ āŽœ

āŽž

āŽ 

āŽŸ āŽŸ āŽŸ āŽŸ āŽŸ āŽŸ

āŽ›

āŽ

āŽœ āŽœ āŽœ āŽœ āŽœ āŽœ

āŽž

āŽ 

āŽŸ āŽŸ āŽŸ āŽŸ āŽŸ āŽŸ

=

āŽ›

āŽ

āŽœ āŽœ āŽœ āŽœ āŽœ āŽœ

āŽž

āŽ 

āŽŸ āŽŸ āŽŸ āŽŸ āŽŸ āŽŸ b b b

p p p p p

d d d

b 2 = b 3 = b 4 = 2 + α

d 2 = α p 2 n

d 3 = α p 3 n

d 4 = α p 4 n

where: α = ( φμ c)/(0.00633k) (( āˆ† x)^2 / āˆ† t)

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,- p(i) = g(i) - c(i) * p(i+1) / w(i) 2 CONTINUE RETURN END

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.

0 100 200 300 400 X (ft)

0

200

400

600

800

1000 p(x,t) (psi)

t = 5 days 10 (^2030) 80

0 100 200 300 400 X (ft)

0

200

400

600

800

1000 p(x,5) (psi)

.āˆ† t = 5 days .āˆ† t = 2.5 days āˆ† t = 1.25 days .āˆ† t = 0. .āˆ† t = 0. .āˆ† t = 0.

Fig. 3 - Pressure profiles Fig. 4 - Comparison of pressure for Example 1. profiles at t = 5 days for different timestep sizes.

about the highest in the x profile). This selection of āˆ†t and āˆ†x is a judgement, according to the practicality for the problem being solved.

0 1 2 3 4 5 .āˆ† t (days)

550

575

600

625

650

675

700 p(100,5) (psi)

āˆ†x = 12.5 ft

0 20 40 60 80 100 .āˆ† x (ft)

550

575

600

625

650

675

700 p(100,5) (psi)

āˆ†t = 5 days

āˆ†t = 1.25 days

āˆ†t = 0.15625 days āˆ†t = 0.01 days

āˆ† x = 6. 25 ft

āˆ†x = 100 ft

āˆ†x = 50 ft

Fig. 5 - Effect of timestep size on Fig. 6 - Effect of grid spacing on pressures at x = 100 feet and t = 5 days pressures at x = 100 feet and t = 5 days

0 100 200 300 400 X (ft)

0

200

400

600

800

1000 p(x,5) (psi)

āˆ†x = 25 ft , āˆ†t = 1.25 days

āˆ†x=100 ft , āˆ†t =5 days

Analytical Solution

0 20 40 60 80 Time (days)

0

200

400

600

800

1000 p(100,t) (psi)

āˆ†x = 100 ft , āˆ†t = 5 days

āˆ†x = 25 ft ,āˆ†t = 1.25 days

Analytical Solution

Fig. 7 - Comparison of pressure Fig. 8 - Comparison of pressure profiles at t = 5 days vs. time at x = 100 feet

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

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 problem^6. 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+2āˆ†x) z z z

Difference Expression pi-3 pi-2 pi-1 pi pi+1 pi+2 pi+

Forward Difference

āˆ† x p ' (x) -1 1

( āˆ† x)^2 p ''(x) 1 -2 1

Backward Difference

āˆ† x p ' (x) -1 1 + O ( āˆ† x)

( āˆ† x)2 p ''(x) 1 -2 1

Central Difference

2 āˆ† x p ' (x) -1 0 1 + Ο ( āˆ† x)^2

( āˆ† x)^2 p ''(x) 1 -2 1

Higher Order Difference Expressions

Implicit vs. Explicit F.D.E.

2 2

p x

p t

+ ( x ) ( x)

p -^2 _p+p

x_

p (^2) 2

i- 1 i i+ 1 2

2 āˆ† āˆ‚ āˆ†

where

(x,t) (x- x x x+ x) x

p 12

( x) ( x)=- 4

(^24) (^2) āˆ† ≤ ≤ āˆ† āˆ‚

+ ( t) t

_p -p

t_

p n i

n+ 1 i (^) āˆ† āˆ‚ āˆ†

where

(x,t ) (t t t+ t) x

p 2

t ( t)=- 2

2 ≤ ≤ āˆ† āˆ‚

Explicit FDE. The solution is only stable when ( āˆ† t) < ( āˆ† x)^2 /2.

( x )

( p - 2 p + p ) =

t 2 i-1n in i+1n ( p^ in+1 -^ p )in āˆ† āˆ†

Implicit FDE. The solution is unconditionally stable for any āˆ† t.

( x )

( p - 2 p + p ) =

t 2 i-1n+1 in+1 i+1n+1 ( p^ in+1 -^ p )in āˆ† āˆ†^

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

( x )

( p - 2 p + p ) +

( x )

( p - 2 p + p ) =

t 2 i-1n in i+1n 2 i-1n+1 in+1 i+1n+1 ( p^ in+1 -^ p )in āˆ† āˆ† āˆ†

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.

( x )

( p - 2 p + p ) +

( x )

( p - 2 p + p ) =

t

σ 2 i-1n in i+1n σ 2 i-1n+1 in+1 i+1n+1 ( p in+1 - p )in

Weighting factor : ( 0 ≤ σ ≤ 1 )

σ = 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.