Professional Documents
Culture Documents
Leslie Thompson
Spring 2009
Contents
1
2.6 Saturation and Pressure Initialization . . . . . . . . . . . . . . . 98
2.6.1 Initialization from Average Data . . . . . . . . . . . . . . 98
2.6.2 Initialization from Gridblock Data . . . . . . . . . . . . . 98
2.6.3 Initialization from GOC and WOC Data . . . . . . . . . . 98
2.7 Simulator Objects . . . . . . . . . . . . . . . . . . . . . . . . . . 99
2.7.1 UMFSparseMatrix Class . . . . . . . . . . . . . . . . . . . 99
2.7.2 RelativePermCapPressData Structure . . . . . . . . . . . 100
2.7.3 FlowEquationBuilder Class . . . . . . . . . . . . . . . . . 100
2.7.4 Simulator Class . . . . . . . . . . . . . . . . . . . . . . . . 102
2.8 Overview of a Simulator Run . . . . . . . . . . . . . . . . . . . . 103
2
A.5.2 Dranchuk and Abu Kassem[16] . . . . . . . . . . . . . . . 129
A.6 Gas Formation Volume Factor . . . . . . . . . . . . . . . . . . . . 130
A.7 Gas Viscosity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
A.7.1 Lee-Gonzalez[3] . . . . . . . . . . . . . . . . . . . . . . . . 130
A.7.2 Lucas[23] . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
A.8 Water Properties[41] . . . . . . . . . . . . . . . . . . . . . . . . . 131
A.8.1 Formation Volume Factor . . . . . . . . . . . . . . . . . . 131
A.8.2 Viscosity . . . . . . . . . . . . . . . . . . . . . . . . . . . 131
A.8.3 Density . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132
3
Chapter 1
1.1 Introduction
As used in this text, the term “Reservoir Simulation” refers to the modeling
of ‡uid ‡ow in petroleum reservoirs via a set of (partial di¤erential) equations
that (hopefully) capture the major physical features of the actual reservoir ‡ow.
The use of reservoir simulators allows us to approximately predict (at least
qualitatively) the behavior of the reservoir as it is produced under a variety
of di¤erent conditions without actually producing the real reservoir; in this
way, we can develop strategies to optimize production and/or recovery from a
reservoir before committing to an actual …eld implementation. Of course, the
quality of our predictions of reservoir behavior is completely dependent on our
knowledge of the geometry and rock and ‡uid properties of the reservoir that
we are modeling. In general, modern simulation studies do not seek a unique
answer to the predicted reservoir behavior; rather, they seek a range of possible
outcomes as determined by the degree of uncertainty in the input data. For
example, if simulation results from a set of equally probable reservoir system
descriptions (given the set of known data) indicate that drilling a new well at
a certain location will increase recovery, then it is assumed that a well at that
location in the real reservoir would most likely increase actual recovery.
Flow in the reservoir is assumed to be governed by a set of partial di¤er-
ential equations that describe conservation of mass, momentum and energy. In
this text, we will assume isothermal ‡ow in the reservoir (i.e., we will not con-
sider injection of ‡uids at temperatures signi…cantly di¤erent to the reservoir
temperature), so we will not consider conservation of energy. Further, we will
assume that the relationship between pressure drop and ‡ow rate is adequately
described by Darcy’s law, so our system of di¤erential equations will be re-
duced to a set of mass balance equations combined with Darcy’s law for phase
transport. In addition to the ‡ow equations, we will need to specify an initial
4
condition and appropriate boundary conditions. For very simple systems (i.e.,
‡ow of a slightly compressible, constant viscosity liquid), it may be possible to
solve the system of equations analytically; (in fact, the solutions used in the
analysis of pressure transient data for reservoir properties are developed this
way); however in general, the (approximate) solution of the system of equations
can only be obtained using numerical techniques. This text is focused on the
(implicit) numerical solution of the equations describing three-phase ‡ow of oil,
gas and water in a three dimensional reservoir. We discuss the formulation
for Cartesian coordinate systems in detail, and we outline the formulation for
cylindrical coordinate systems. We will assume that the PVT behavior of the
hydrocarbon ‡uid is well described by a “Beta” model, i.e., where there are
two distinct hydrocarbon species that can coexist and be transported in the
vapor or liquid phases. In the following we provide a detailed description of the
system under consideration and derive the set of equations that we will solve
numerically.
kz krm @pm g
vm = C1 + m (1.3)
m Bm @z 144gc
5
equations are respectively[34]
@ krw @pw
C1 kx +
@x B
w w @x
@ krw @pw
ky +
@y B
w w @y
@ krw @pw g
kz + w =
@z w Bw @z 144gc
Xnw
@ Sw e w;j (!
+ Q x j) (1.6)
@t Bw j=1
6
C1 = constant = 1:127 10 3 (5:615)
kx ; ky ; kz = Directional absolute permeabilities, md
kro ; krg ; krw = Relative permeabilities to oil (liquid), gas (vapor)
and water.
o; g ; w = Viscosities of oil (liquid), gas (vapor) and water, cp.
Bo ; B g ; B w = Formation volume factors for liquid, vapor and
water, bbl/STB or ft3 /scf.
pcgo = Capillary pressure of a gas/oil system (see Eq. 1.12)
pcow Capillary pressure of a oil/water system (see Eq. 1.11)
po ; p g ; p w = Pressures in the oil (liquid), gas (vapor) and water, psia
o; g ; w = Densities of oil (liquid), gas (vapor) and water, lbm/ft3 .
So ; S g ; S w = Saturations of oil (liquid), gas (vapor) and water.
rv = Volatility of oil in the vapor phase, STB oil/STB gas.
Rs = Solubility of gas in the liquid phase, STB gas/STB oil.
g = gravitational acceleration, 32.2 ft/sec2
gc = 32.2 lbm-ft/lbf-sec2
x; y; z = Positions in the coordinate axis directions, ft
e o;j ; Q
Q e g;j ; Qe w;j = Oil, gas and water volume removed per unit volume
per day from point ! x j ; scf/d/ft3
nw = Number of locations at which ‡uid is removed from
the reservoir.
(!
x j) = 1 at the point ! x j , 0 elsewhere.
With these de…nitions, the units on each side of the material balance equa-
tions are STB/bbl-day. Similarly, the equations for ‡ow in a cylindrical coordi-
nate system are written as
1 @ kro @po rv krg @pg
C1 rkr + +
r @r o B o @r g Bg @r
1 @ k kro @po rv krg @pg
+ +
r@ r B
o o @ g Bg @
@ kro @po g rv krg @pg g
kz + L + + V =
@z o Bo @z 144gc g Bg @z 144gc
@ So rv Sg
+ (1.7)
@t Bo Bg
7
1 @ krw @pw
C1 rkr +
r @r w B w @r
1 @ k krw @pw
+
r@ r w B w @
@ krw @pw g
kz + w =
@z w B w @z 144g c
@ Sw
(1.9)
@t Bw
(Note that Eqs. 1.7 - 1.9, we have not included source or sink functions; this
is because in this geometry, production and injection are usually included by
choosing appropriate boundary conditions.) In Eqs. 1.4 - 1.9, the phase pres-
sures, po , pg , pw and the phase saturations, So , Sg , and Sw are the dependent
variables. In addition to these material balance equations, the following “clo-
sure” relationships are also required.
The saturation constraint is given by
So + Sg + Sw = 1 (1.10)
8
1.2.1 Formulation in terms of mass concentrations
Consider a 1 ft3 pore volume of the reservoir containing hydrocarbon liquid,
(oil), hydrocarbon vapor, (gas), and water. Since we are considering a unit
pore volume, the volumes of oil, gas and water must be So , Sg , and Sw ft3
respectively. Suppose in the unit pore volume we have nL lbm of hydrocarbon
liquid, nV lbm of hydrocarbon vapor and nW lbm of water. Further, suppose
that the hydrocarbon liquid phase is composed of no;L lbm of “oil” component
and ng;L lbm of “gas”component and the hydrocarbon vapor phase is composed
of no;V lbm of “oil”component and ng;V lbm of “gas”component. Also, assume
that the total mass of oil and gas components in the unit pore volume are no
and ng lbm respectively. Since the total mass of oil and gas components in the
unit volume must be the sums of masses of each component in each hydrocarbon
phase, we must have
no = no;L + no;V (1.13)
and
ng = ng;L + ng;V (1.14)
If the in situ densities of the hydrocarbon liquid and vapor phases are L
and V lbm/ft3 , then
nL
So = ; (1.15)
L
nV
Sg = ; (1.16)
V
and
nW
Sw = ; (1.17)
W
If the densities of the “oil” and “gas” components at standard conditions are
3
osc and gsc lbm/ft respectively, then from the basic de…nitions of our PVT
properties, we have
nL
L nL osc
Bo = = ; (1.18)
no;L no;L L
osc
nV
V
nV gsc
Bg = = ; (1.19)
ng;V ng;V V
gsc
nW
W w;sc
Bw = = ; (1.20)
nW W
w;sc
no;V
osc
no;V gsc
rv = = ; (1.21)
ng;V ng;V osc
gsc
9
and
ng;L
gsc ng;L osc
Rs = = : (1.22)
no;L no;L gsc
osc
ng;L no;V
R s rv = ; (1.23)
ng;V no;L
Rs rv < 1: (1.24)
Since
nL = no;L + ng;L ; (1.25)
and
nV = no;V + ng;V ; (1.26)
using Eqs. 1.18 - 1.22 it is easy to derive the following expressions for the in
situ phase densities:
o;sc + g;sc Rs
L = ; (1.27)
Bo
g;sc + o;sc rv
V = ; (1.28)
Bg
We write Eqs. 1.13, 1.14, 1.25, 1.26, 1.21 and 1.22 in matrix form as
2 32 3 2 3
1 0 1 1 0 0 no;L 0
6 0 1 0 0 1 1 7 6 7 6 7
6 7 6 no;V 7 6 0 7
6 1 1 0 0 0 0 7 6 nL 7 6 no 7
6 76 7=6 7 (1.29)
6 0 0 0 1 1 0 7 6 7 6 7
6 7 6 ng;L 7 6 ng 7
4 0 gsc 0 0 r
osc v 0 5 4 n g;V
5 4 0 5
R
gsc s 0 0 osc 0 0 n V 0
and solve using symbolic algebra software[2] to obtain the following expressions:
gsc no osc ng rv
no;L = (1.30)
(1 R s rv ) gsc
osc ng gsc no Rs rv
no;V = (1.31)
(1 R s rv ) gsc
10
gsc no osc ng rv osc + gsc Rs
nL = (1.32)
(1 R s rv ) gsc osc
gsc no osc ng rv Rs
ng;L = (1.33)
(1 R s rv ) osc
osc ng gsc no Rs
ng;V = (1.34)
(1 Rs rv ) osc
and
osc ng gsc no Rs gsc + osc rv
nV = : (1.35)
(1 R s rv ) gsc osc
Substituting Eqs. 1.32, 1.35, 1.27 and 1.28 in Eqs. 1.15 and 1.16, we obtain
gsc no osc ng rv Bo
So = (1.36)
(1 R s rv ) gsc osc
osc ng gsc no Rs Bg
Sg = : (1.37)
(1 R s rv ) gsc osc
Sw = 1 So Sg (1.38)
or
gsc no osc ng rv Bo + osc ng gsc no Rs Bg
Sw = 1 (1.39)
(1 Rs rv ) gsc osc
If a liquid hydrocarbon phase is present, Eqs. 1.36 and 1.24 require that
So > 0 (1.40)
or
gsc no > osc ng rv ; (1.41)
similarly, presence of a gas phase is indicated if (Eqs. 1.37 and 1.24)
11
Note that phase saturations are now explicit functions of mass concentrations
of oil and gas components and pressure. In terms of our new set of independent
variables, our material balance equations in Cartesian coordinates become
@ @po @ (po + pcgo )
C1 kx o+ rv g +
@x @x @x
@ @po @ (po + pcgo )
ky o + rv g +
@y @y @y
@ @po g @ (po + pcgo ) g
kz o + L + rv g + V =
@z @z 144gc @z 144gc
nw
@no X e o;j (!
+ Q x j) (1.45)
o;sc @t j=1
@ @ (po
pcow )
C1 kx w +
@x @x
@ @ (po pcow )
ky w +
@y @y
@ @ (po pcow ) g
kz w + w =
@z @z 144gc
!
@ 1 gsc no osc ng rvBo + osc ng gsc no Rs Bg
@t Bw Bw (1 Rs rv ) gsc osc
nw
X
+ e w;j (!
Q x j) (1.47)
j=1
where
So rv Sg
no = osc + (1.48)
Bo Bg
Sg R s So
ng = gsc + (1.49)
Bg Bo
kro
o (1.50)
o Bo
12
krg
g (1.51)
g Bg
and
krw
w (1.52)
w Bw
Similarly, in cylindrical coordinates, the equations are
1 @ @po @pg
C1 rkr o + rv g +
r @r @r @r
1 @ k @po @pg
o + rv g +
r@ r @ @
@ @po g @pg g
kz o + L + rv g + V =
@z @z 144gc @z 144gc
@no
(1.53)
o;sc @t
1 @ @po @pg
C1 rkr Rs o + g +
r @r @r @r
1 @ k @po @pg
Rs o + g +
r@ r @ @
@ @po g @pg g
kz Rs o + L + g + V =
@z @z 144gc @z 144gc
@ng
(1.54)
g;sc @t
1 @ @pw
C1 rkr w +
r @r @r
1 @ k @pw
w +
r@ r @
@ @pw g
kz w + w =
@z @z 144gc
!
@ 1 gsc no osc ng rvBo + osc ng gsc no Rs Bg
(1.55)
@t Bw Bw (1 Rs rv ) gsc osc
Note that even if a phase disappears, the mass concentration of that phase
continues to exist; also, mass concentrations (like pressure) must be greater than
zero, but are not bounded between 0 and 1, and are not restricted by a saturation
constraint. However, even in this formulation, phase relative permeabilities will
cease to exist when that phase disappears; thus, di¢ culties may still arise when
we are crossing saturation boundaries.
13
Figure 1.1: Schematic of Rectangular Parallelpiped Reservoir
0=x 1
2
< x 21 < x 23 < ::: < xnx 3
2
< xn x 1
2
= Lx ; (1.56)
0=y 1
2
< y 12 < y 23 < ::: < yny 3
2
< yny 1
2
= Ly ; (1.57)
0=z 1
2
< z 21 < z 23 < ::: < znz 3
2
< znz 1
2
= Lz : (1.58)
The reservoir is now divided into subregions with vertices are at
x 1
2
; yj 1
2
; zk 1
2
; x 1
2
; yj+ 12 ; zk 1
2
; x 1
2
; yj 1
2
; zk+ 12 ;
x 1
2
; yj+ 21 ; zk+ 12 ; x + 12 ; yj 1
2
; zk 1
2
; x + 12 ; yj+ 12 ; zk 1
2
;
x + 12 ; yj 1
2
; zk+ 12 ; x + 21 ; yj+ 12 ; zk+ 12 ;
and whose centers are at (x ; yj ; zk ) ; for = 0; 1:::nx 1; j = 0; 1:::ny 1;
k = 0; 1:::nz 1: Note that
x + 12 + x 1
2
x = ; (1.59)
2
yj+ 12 + yj 1
2
yj = ; (1.60)
2
14
zk+ 12 + zk 1
2
zk = : (1.61)
2
n+1
We de…ne a sequence of times, tk k=0 at which we approximate our ‡ow equa-
tions as
0 = t0 < t1 < t2 < ::: < tn < tn+1 < ::: (1.62)
We illustrate the derivation of our …nite di¤erence approximations that hold
in the grid block centered at (x ; yj ; zk ) ; at time tn+1 , by integrating Eq. 1.45
over the volume of the grid block as follows:
8
>
>
x + 1 yj+ 1 zk+ 1
< Z 2 Z 2 Z 2 @ @po @ (po + pcgo )
C1 kx o + rv g
>
> @x @x @x
:x 1 yj 1 zk 1
2 2 2
We illustrate how this volume integral is evaluated by considering the …rst term
in Eq. 1.63. We change the order of integration and integrate analytically over
x …rst to obtain:
yj+ 1 zk+ 1 x 1
Z 2 Z 2 Z+ 2
@ @po @ (po + pcgo )
kx o + rv g dxdydz =
@x @x @x
yj 1 zk 1 x 1
2 2 2
yj+ 1 zk+ 1 2 3
Z 2 Z 2
x +1
x +1
4 kx @po 2 @ (po + pcgo ) 2
5 dydz
o + kx rv g
@x x 1
@x x 1
yj 1 zk 1 2 2
2 2
then we use the mean value theorem: we evaluate the integrand at the block
15
midpoint in the y and z directions, and integrate to obtain
(
@po @po
kx o kx o +
@x + 1 ;j;k @x 1
;j;k
2 2
)
@ (po + pcgo ) @ (po + pcgo )
kx rv g kx rv g y j zk
@x + 12 ;j;k @x 1
2 ;j;k
where we de…ne
x = x + 21 x 1
2
; (1.64)
yj = yj+ 12 yj 1
2
; (1.65)
zk = zk+ 12 zk 1
2
; (1.66)
and we have introduced the following simplifying notation. For a general func-
tion f (x; y; z; t), we de…ne
f n+1
;j;k f x ; yj ; zk ; tn+1 : (1.67)
h i
@po
so, for example, kx o @x is evaluated at the point x + 21 ; yj ; zk : Car-
+ 21 ;j;k
rying out the integration on Eq. 1.63, we obtain the following approximation
(( )
@po @po
C1 kx o kx o y j zk +
@x + 1 ;j;k @x 1
2 2 ;j;k
( )
@ (po + pcgo ) @ (po + pcgo )
kx rv g kx rv g y j zk +
@x + 12 ;j;k @x 1
2 ;j;k
( )
@po @po
ky o ky o x zk +
@y i;j+ 1 ;k @y i;j 1 ;k
2 2
( )
@ (po + pcgo ) @ (po + pcgo )
ky rv g ky rv g x zk +
@y i;j+ 12 ;k @y i;j 12 ;k
(
@po g
kz o + L
@z 144gc i;j;k+ 1
) 2
@po g
kz o + L x yj +
@z 144gc i;j;k 1
2
(
@ (po + pcgo ) g
kz rv g + V
@z 144gc i;j;k+ 1
) 2 )
@ (po + pcgo ) V g
kz rv g + x yj
@z 144gc i;j;k 1
2
!
@no eo
= +Q i;j;k
x y j zk (1.68)
o;sc @t ;j;k
16
Note that the last term in Eq. 1.68 only arises if there is a sink or source term
in block centered at (x ; yj ; zk ) and that we compute the integral on the right
side of Eq. 1.63 using the mean value theorem to evaluate the integrand at the
midpoint of the block.
We approximate spatial derivatives such as that in the x-direction as
@f f n+1
+1;j;k f n+1
;j;k
; (1.69)
@x x ;yj ;zk x + 21
+1
2
where
x + 21 = x +1 x; (1.70)
Similar equations apply for the other coordinate directions. Eq. 1.69 assumes
that a neighbor grid block exists at (x +1 ; yj ; zk ); in the case that no neighbor
grid block exists at (x +1 ; yj ; zk ), and the boundary is sealed at x + 21 ; yj ; zk ,
@f
= 0: (1.71)
@x x ;yj ;zk
+1
2
@f f n+1
;j;k
f n;j;k
; (1.72)
@t t
where
t = tn+1 tn (1.73)
We divide Eq. 1.68 by the bulk volume of the block,
Vi;j;k = x y j zk ; (1.74)
and apply the …nite di¤erence approximations to the spatial and time derivatives
to obtain:
12
X h i qoi;j;k
;j;k
Fo ;j;k = zo;` nn+1
o ;j;k nno ;j;k =0 (1.75)
o;sc t Vi;j;k
`=1
where qoi;j;k is the oil rate in scf/day from the block centered at (x ; yj ; zk ) ; and
n+1
zo;1 = Gx + 1 ;j;k o pn+1
o +1;j;k pn+1
o ;j;k (1.76)
2 + 1 ;j;k
2
n+1
zo;2 = Gx 1 ;j;k o 1 pn+1
o ;j;k pn+1
o 1;j;k (1.77)
2 ;j;k
2
17
zo;4 = Gx 1 ;j;k rvn+1 n+1
g pn+1
g ;j;k pn+1
g 1;j;k (1.79)
2 1 ;j;k 1 ;j;k
2 2
n+1
zo;5 = Gy ;j+ 1 ;k o pn+1
o pn+1
o ;j;k (1.80)
;j+1;k
2 ;j+ 1 ;k
2
n+1
zo;6 = Gy ;j 1 ;k o pn+1
o pn+1
o ;j 1;k (1.81)
2 1 ;k ;j;k
;j
2
0 n+1
1
V g
B n+1 ;j;k+ 1 C
zo;11 = Gz ;j;k+ 1 rvn+1 n+1
g @pg ;j;k+1 pn+1
g ;j;k +
2
zk+ 21 A
2 ;j;k+ 1
2
;j;k+ 1
2
144gc
0 (1.86)
1
n+1
V g
B n+1 ;j;k 1
C
zo;12 = Gz ;j;k 1 rvn+1 n+1
g @pg pn+1
g ;j;k + 2
zk 1 A
2 ;j;k 1
2
;j;k 1
2
;j;k 1
144gc 2
(1.87)
kx
C1 + 1 ;j;k
2
Gx + 1 ;j;k = ; (1.88)
2 x + 21 x 1
2
x +1 x
kx
C1 1 ;j;k
2
Gx 1 ;j;k = ; (1.89)
2 x + 12 x 1
2
x x 1
and the remaining terms involving Gy and Gz are analogous. Note that the
terms Gp ; p = x; y or z involve only geometric terms and rock properties.
The harmonic average permeability terms, e.g., kx 1 , are evaluated in the
+ ;j;k
2
standard manner; i.e.,
xi+1 xi
kx = x 1 xi xi+1 xi+ 21 : (1.90)
+ 1 ;j;k i+ 2
2
+
kx ;j;k kx +1;j;k
18
Finally,
n+1 n+1
m ;j;k + m ;j;k+1
n+1
m = ; for m = L; V (1.91)
;j;k+ 1
2
2
The …nite di¤erence equations for gas and water are similarly given by
12
X h i qgi;j;k
;j;k
Fg ;j;k = zg;` nn+1
g ;j;k nng ;j;k =0 (1.92)
g;sc t Vi;j;k
`=1
with qgi;j;k denoting the gas rate in scf/day from the block centered at (x ; yj ; zk ) ;
and
n+1
zg;3 = Gx + 1 ;j;k g 1 pn+1
g +1;j;k pn+1
g ;j;k (1.95)
2 + ;j;k
2
n+1
zg;4 = Gxi 1 ;j;k g 1 pn+1
g ;j;k pn+1
g 1;j;k (1.96)
2 i ;j;k
2
n+1
zg;7 = Gy ;j+ 1 ;k g pn+1
g pn+1
g ;j;k (1.99)
;j+1;k
2 ;j+ 1 ;k
2
n+1
zg;8 = Gy ;j 1 ;k g pn+1
g pn+1
g ;j 1;k (1.100)
2 1 ;k ;j;k
;j
2
0 n+1
1
L g
B n+1 ;j;k+ 1 C
zg;9 = Gz ;j;k+ 1 Rsn+1 n+1
o @po pn+1
o ;j;k +
2
zk+ 21 A
2 ;j;k+ 1
2
;j;k+ 1
2
;j;k+1 144gc
0 (1.101)
1
n+1
L g
n+1 n+1 B n+1 ;j;k 1
C
zg;10 = Gz ;j;k 1 Rs o @po pn+1
o ;j;k + 2
zk 1 A
2 ;j;k 1
2
;j;k 1
2
;j;k 1
144gc 2
0 1 (1.102)
n+1
V g
n+1 B n+1 ;j;k+ 1 C
zg;11 = Gz ;j;k+ 1 g @pg ;j;k+1 pn+1
g ;j;k +
2
zk+ 12 A (1.103)
2 ;j;k+ 1
2
144gc
0 n+1
1
V g
n+1 B n+1 ;j;k 1
C
zg;12 = Gz ;j;k 1 g @pg ;j;k pn+1
g ;j;k + 2
zk 1 A (1.104)
2 ;j;k 1
2
1
144gc 2
19
and
6
X h i qwi;j;k
;j;k n+1 n
Fw ;j;k = zw;` w ;j;k w =0 (1.105)
t ;j;k
Vi;j;k
`=1
where
Sw
w = (1.106)
Bw
n+1
zw;1 = Gx + 1 ;j;k w pn+1
w +1;j;k pn+1
w ;j;k (1.107)
2 + 1 ;j;k
2
n+1
zw;2 = Gx 1 ;j;k w pn+1
w ;j;k pn+1
w 1;j;k (1.108)
2 1 ;j;k
2
n+1
zw;3 = Gy ;j+ 1 ;k w pn+1
w pn+1
w ;j;k (1.109)
;j+1;k
2 ;j+ 1 ;k
2
n+1
zw;4 = Gy ;j 1 ;k w pn+1
w pn+1
w ;j 1;k
(1.110)
2 1 ;k ;j;k
;j
2
0 n+1 1
w g
;j;k+ 1
zw;5 = Gz ;j;k+ 1 n+1
w
@pn+1
w pn+1
w ;j;k +
2
zk+ 12 A (1.111)
2 ;j;k+ 1
2
;j;k+1 144gc
0 n+1 1
w 1
g
;j;k
zw;6 = Gz ;j;k 1
n+1
w
@pn+1
w pn+1
w ;j;k + 2
zk 1 A (1.112)
2 ;j;k 1
2
;j;k 1
144gc 2
rw = r 1
2
< r 12 < r 32 < ::: < rnr 3
2
< r nr 1
2
= re ; (1.113)
0= 1
2
< 1
2
< 3
2
< ::: < n 3
2
< n 1
2
=2 ; (1.114)
0=z 1
2
< z 21 < z 25 < ::: < znz 3
2
< znz 1
2
= Lz : (1.115)
The reservoir is now divided into subregions with vertices at
ri 1
2
; j 1
2
; zk 1
2
; ri 1
2
; j+ 12 ; zk 1
2
; ri 1
2
; j 1
2
; zk+ 12 ;
ri 1
2
; j+ 12 ; zk+ 21 ; ri+ 12 ; j 1
2
; zk 1
2
; ri+ 12 ; j+ 12 ; zk 1
2
;
ri+ 21 ; j 1
2
; zk+ 12 ; ri 1
2
; j+ 21 ; zk+ 12
20
Figure 1.2: Schematic of a Cylindrical Grid.
21
We illustrate the derivation of our …nite di¤erence approximations that hold
in the grid block centered at ri 12 ; j+ 21 ; zk+ 21 ; at time tn+1 , by integrating
Eq. 1.53 over the volume of the grid block as follows:
ri+ 1 1 z 1
Z 2 Zj+ 2 Zk+ 2
1 @ @po @pg
C1 rkr o + rv g +
r @r @r @r
ri 1 j 1 zk 1
2 2 2
1 @
k @po @pg
o + rv g +
r@
r @ @
@ @po g @pg g
kz o + L + rv g + V rdrd dz =
@z @z 144gc @z 144gc
ri+ 1 1 z 1
Z 2 Zj+ 2 Zk+ 2
@no
rdrd dz (1.116)
o;sc @t
ri 1 j 1 zk 1
2 2 2
kz o + L r j+
@z 144gc i;j;k 1 2
2
(
@ (po + pcgo ) g
kz rv g + V
@z 144gc i;j;k+ 1
2
) 9
@ (po + pcgo ) g ri+ 12 + ri 21 =
kz rv g + V r j
@z 144gc i;j;k 1 2 ;
2
!
@no ri+ 12 + ri 1
2
= r j zk (1.117)
o;sc @t i;j;k
2
22
where
r = r + 21 r 1
2
; (1.118)
j = j+ 12 j 1
2
; (1.119)
zk = zk+ 12 zk 1
2
; (1.120)
If we divide Eq. 1.117 by the gridblock volume, Vi;j;k ,
1 2
Vi;j;k = r +1 r2 1 j zk (1.121)
2 2 2
we can write Eq. 1.117 in the same form as Eqs. 1.75 - 1.87 provided we replace
the geometric terms Gx and Gy by Gr and G , where
r + 21 kr
2C1 + 1 ;j;k
2
Gr + 1 ;j;k = ; (1.122)
2
r2+ 1 r2 1
r +1 r
2 2
r 1 kr
2C1 2 1 ;j;k
2
Gr 1 ;j;k = ; (1.123)
2
r2+ 1 r2 1
r r 1
2 2
ri+ 1
kr ;j;k kr +1;j;k ln ri
2
1
2
kr = ri+ 1
(1.124)
+ 1 ;j;k
2 ri
kr ;j;k ln ri
2
+ kr +1;j;k ln ri 1
2
and
ri+ 1
2C1 ln ri
2
1
k
2 ;j+ 1 ;k
2
G ;j+ 1 ;k
= ; (1.125)
2
r2+ 1 r2 1 j+ 12 j 1
2
j+1 j
2 2
ri+ 1
2C1 ln ri
2
1
k 1 ;k
2 ;j
2
G ;j 1 ;k = ; (1.126)
2
r2+ 1 r2 1 j+ 12 j 1
2
j j 1
2 2
ri+ 1
kr ;j;k kr +1;j;k ln ri
2
1
2
k = ri+ 1
(1.127)
;j+ 1 ;k
2 ri
kr ;j;k ln ri
2
+ kr +1;j;k ln ri 1
2
By using the de…nitions of Eqs. 1.121 - 1.127, the discrete ‡ow equations,
Eqs. 1.75, 1.92 and 1.105 apply equally to Cartesian or cylindrical grids. In
23
fact, we can generalize our discretization to practically any discrete grid system
by appropriately modifying the equations for the geometric terms, Gx ; Gy and
Gz : Before closing this section, we note that it is customary to use the gridding
system suggested by MacDonald and Coats[24] in the radial direction. If the
wellbore radius is denoted by rw , and the external reservoir radius is denoted
by re , the radial grid is de…ned by the following equations:
1
re nr
= (1.128)
rw
i
ri = r i 1 = r0 for i = 1; 2; :::nr (1.129)
rw ln ( )
r0 = (1.130)
1
i
( 1) r0
ri+ 21 = for i = 1; 2; :::nr (1.131)
ln ( )
24
3
ft
Row Pressure, psia Bg , scf g; cp
0 100 0.000110 0.020
1 150 0.000106 0.021
2 200 0.000097 0.022
3 250 0.000089 0.023
4 300 0.000086 0.024
5 350 0.000079 0.025
The search technique we have described is general; for any table that has
an equal spacing x in the independent variable, the beginning index, j, of the
interval containing a user provided number x
^ is given by
x
^ x0
j = int (1.132)
x
where x0 is the value of the dependent variable in row 0, and int(y) returns the
(truncated) integer part of y. If the row index starts at 1, then the appropriate
formula is
x
^ x1
j = int +1 (1.133)
x
Equation 1.132 describes the fastest method of searching a table, however, it
only applies for tables that have equal step size in the independent variable.
Once the interval is found, we can estimate the required value(s) of the depen-
dent variables by linear interpolation using the following formula
y^ = yj0 (^
x xj ) + yj (1.134)
where
yj+1 yj
yj0 = : (1.135)
xj+1 xj
(In the following section on Object Oriented Design, we describe a table class
that performs table lookup and linear interpolation e¢ ciently.) If the provided
saturated tabular PVT data is not evenly spaced in pressure, an equivalent
even-spaced pressure table should be generated for use in the simulator. If
PVT properties are not measured, Appendix A presents some commonly used
correlations for estimating oil and water PVT properties; these should be used
to generate tables for input to the simulator.
PVT properties of undersaturated oil are dependent on both the pressure
and saturation pressure of the in situ oil mixture (see Figs. 1.3 and 1.4). In
order to compute the in situ saturation pressure, we determine the value of
solution gas-oil ratio if all of the gas component in the block were dissolved; i.e.,
we compute
ng osc
Rs (pbub ) = (1.136)
gsc no
then …nd the bubble point pressure by interpolating the provided saturated so-
lution gas-oil ratio versus pressure tables. As discussed previously, the most
25
e¢ cient way to do this is to create a table of solution gas-oil ratio versus satura-
tion pressure (from the provided PVT tables) that is equally spaced in solution
Gas-oil ratio.
Once the in situ saturation pressure has been determined, the desired un-
dersaturated oil PVT property is determined from
d#
# (p; psat ) = # (psat ; psat ) + (p psat ) (1.137)
dp undersaturated
where # (psat ; psat ) is the value of the (saturated) property at the saturation
pressure, d#
dp is the slope of the property with pressure at un-
undersaturated
dersaturated conditions, and p > psat . Note that gas properties cease to exist
above the bubble point; also water properties depend only on pressure and are
independent of saturation pressure.
where krw (Sw ) is the relative permeability to water at the water saturation of
interest (Sw ), Sorw is the residual oil saturation for oil in the presence of water,
krw (1 Sorw ) is the relative permeability to water at the residual oil saturation,
nw is an empirical water exponent, and SwD is a dimensionless water saturation
de…ned as
Sw Swi
SwD = (1.139)
1 Sorw Swi
for Swi Sw 1 Sor : Here Swi is the initial irreducible water saturation.
Similarly, the relative permeability to oil in a water wet rock is given by
no
krow (Sw ) = krow (Swi ) (1 SwD ) (1.140)
where krow (Sw ) is the relative permeability to oil at the water saturation of
interest (Sw ), krow (Swi ) is the relative permeability to oil at the irreducible
water saturation, and no is an empirical oil exponent. The equations for a gas
oil system are analogous; i.e.,
n g
krg (Sg ) = krg (1 Slc ) SgD (1.141)
26
Figure 1.3: Solution Gas-Oil Ratio as a function of pressure and saturation
pressure.
27
Figure 1.4: Oil Viscosity as a function of pressure and saturation pressure
28
where
Sg Sgc
SgD = (1.142)
1 Slc Sgc
and
Slc = Swi + Sorg (1.143)
Also the relative permeability to oil in an oil/gas system is
no
krog (Sg ) = krog (Sgc ) (1 SwD ) : (1.144)
(Note that the oil exponents, no ; in Eqs. 1.140 and 1.144 are unrelated and
distinct.)
As in the case of PVT properties, two-phase relative permeability properties
are stored and used in the simulator as tabulated data that are equally spaced
in saturation. (See the Table class in the following section.)
Stone Model I
Stone de…nes normalized saturations to oil (Son ), water (Swn ), and gas (Sgn ),
as follows
So Sor
Son = ; (1.148)
1 Swi Sor
where Sor is the residual oil saturation in the three-phase system and So Sor ;
Sw Swi
Swn = ; (1.149)
1 Swi Sor
29
for Sw Swi and
Sg
Sgn = =1 Son Swn : (1.150)
1 Swi Sor
The relative permeability to oil in the three-phase system is then determined
using the following formula:
where
krow (Sw )
w = (1.152)
krow (Swi ) (1 Swn )
and
krog (Sg )
g = (1.153)
krow (Swi ) (1 Sgn )
Note that it is assumed that
Stone Model II
This model does not require knowledge of the residual oil saturation in the
three-phase system. The equation is
kro (Sw ; Sg )
=
krow (Swi )
krow (Sw ) krog (Sg )
+ krw (Sw ) + krg (Sg ) (krw (Sw ) + krg (Sg ))
krow (Swi ) krow (Swi )
(1.155)
where the symbols are the same as in the Stone Model I, and kro (Sw ; Sg ) 0;
thus, if a negative value of kro is computed, it is truncated to 0.
30
1.6.1 Programming Speed versus Safety
We are faced with two choices in creating arrays in C++ - allocating memory to
pointers using new, or using std::vectors. Using pointers produces the fastest
code, but is inherently unsafe because use of a wrong index value could easily
overwrite memory anywhere in the system. Further, it is up to the user to
delete allocated memory after it has been used, or there will be “memory leaks”
during and after a run. In contrast, use of std::vectors is safe since the indices are
checked to ensure that they are within the array bounds; however, because of this
extra checking, std::vectors are much slower than pointers. Further advantages
of using std::vectors are that they can be easily resized and are automatically
deleted after a run, so there are no memory leaks. In a large reservoir simulator,
speed is critically important, however in developing a simulator, “safe arrays”
are invaluable in helping to debug the program.
31
BUG_MODE. Note that similar de…nitions can be made for multidimensional
arrays or arrays of di¤erent types. This is illustrated in the following.
32
return false;
}
}
return true;
}
}else{
pArray = NULL;
return true;
}
#endif
}
// delete 2-D array
template <class T >
void Delete2DFlexArray(T & pArray, int ncol)
{
int i;
#ifdef __DEBUG_MODE
if (pArray.size())
{
for (i = 0; i < ncol; i++)
{
pArray[i].clear();
}
pArray.clear();
}
#else
if (pArray)
{
for (i = 0; i < ncol; i++)
{
if (pArray[i])
{
delete [] pArray[i];
pArray[i] = NULL;
}
}
delete [] pArray;
pArray = NULL;
}
#endif
}
Note that the above destructor can be applied to any type 2-D ‡exible array.
33
// 3-D double array
bool CreateFlexArray(D3FLEXARRAY & pArray, int n0, int n1, int n2)
{
// creates array with dimensions n0 * n1 * n2
int i, j;
#ifdef __DEBUG_MODE
if (n0)
{
pArray.resize(n0);
for (i = 0; i < n0; i++)
{
pArray[i].resize(n1);
for(j = 0; j < n1; j++)
{
pArray[i][j].resize(n2);
}
}
}
return true;
#else
if (pArray)
{
throw "In CreateFlexArray - trying to create an already created D3FLEXARRAY \n";
}
if (n0)
{
pArray = new double ** [n0];
if (!pArray)
{
return false;
}else{
for (i = 0; i < n0; i++)
{
pArray[i] = new double *[n1];
if (!pArray[i])
{
return false;
}else{
for (j = 0; j < n1; j++)
{
pArray[i][j] = new double [n2];
if (!pArray[i][j])
{
return false;
}
}
34
}
}
return true;
}
}else{
pArray = NULL;
return true;
}
#endif
}
We delete 3-D arrays using:
// delete 3-D array
template <class T >
void Delete3DFlexArray(T & pArray, int n0, int n1)
{
int i, j;
#ifdef __DEBUG_MODE
if (pArray.size())
{
for (i = 0; i < n0; i++)
{
for (j = 0; j < n1; j++)
{
pArray[i][j].clear();
}
pArray[i].clear();
}
}
pArray.clear();
#else
if (pArray)
{
for (i = 0; i < n0; i++)
{
for (j = 0; j < n1; j++)
{
if (pArray[i][j])
{
delete [] pArray[i][j];
pArray[i][j] = NULL;
}
}
if (pArray[i])
{
delete [] pArray[i];
35
FiniteDifferenceGrid
# BlockPerm_0 : DFLEXARRAY
# BlockPerm_1 : DFLEXARRAY
# BlockPerm_2 : DFLEXARRAY
# BlockVolumes : DFLEXARRAY
# DZ : DFLEXARRAY
# FDTerm_0 : DFLEXARRAY
# FDTerm_1 : DFLEXARRAY
# FDTerm_2 : DFLEXARRAY
# nGrid_0 : int
# nGrid_1 : int
# nGrid_2 : int
# Porosity : DFLEXARRAY
# X0 : DFLEXARRAY* = NULL
# X0H : DFLEXARRAY* = NULL
# X1 : DFLEXARRAY* = NULL
# X1H : DFLEXARRAY* = NULL
# X2 : DFLEXARRAY* = NULL
# X2H : DFLEXARRAY* = NULL
+ <<Abstract>> ComputeGeometricTerms() : void
Figure 1.5: Main members and methods for a Finite Di¤erence Class
pArray[i] = NULL;
}
}
delete [] pArray;
}
#endif
}
Members
1. nGrid_0; nGrid_1; nGrid_2 (int) - the number of gridblocks in each
coordinate direction.
2. BlockV olumes (DFLEXARRAY) - the bulk volumes of each gridblock
(see Eq. 1.74 or 1.121). (ft3 ).
3. DZ (DFLEXARRAY) - array containing the heights of each gridblock;
(this is used in computation of the gravity terms - see for example, Eqs.
1.86 and 1.87).
36
4. BlockP erm_0, BlockP erm_1, BlockP erm_2 (DFLEXARRAY) - Ar-
rays containing the absolute permeabilities of each gridblock in each co-
ordinate direction (md).
5. F DT erm_0, F DT erm_1, F DT erm_2 (DFLEXARRAY) - Arrays con-
taining the geometric components of the interblock transmissibilities in
each coordinate direction (e.g., Eqs. 1.88, 1.89, 1.122, 1.123, 1.125, 1.126).
In the Cartesian coordinate system, F DT erm_0 is an array of size ((nGrid_0 + 1)
nGrid_1 nGrid_2), F DT erm_1 is dimensioned (nGrid_0 (nGrid_1 + 1)
nGrid_2) and F DT erm_2 is dimensioned (nGrid_0 nGrid_1
(nGrid_2 + 1)). The dimensions of the arrays in the cylindrical system
would be similar, except in the angular direction; if the reservoir is a
complete cylinder, the dimension of F DT erm_1 is (nGrid_0 nGrid_1
nGrid_2) since the block boundaries at = 0 and = 2 coincide.
6. P orosity (DFLEXARRAY) - array dimensioned nGrid_0 nGrid_1
nGrid_2 containing the porosities of each gridblock.
7. X0, X1, X2 (DFLEXARRAY) - Arrays containing the positions of the
gridblock centers in each coordinate direction.
8. X0H, X1H, X2H (DFLEXARRAY) - Arrays containing the positions of
the gridblock boundaries in each coordinate direction.
Functionality
Aside from o¤ering the user the ability to get any of the member arrays, this
class must provide an internal ability to compute all geometric terms based on
the coordinate system.
Members
1. n (int) - the number of gridblocks.
2. P (DFLEXARRAY) - array dimensioned n of block oil pressures.
37
GridblockVariables
# n : int = 0
+ BetaW : DFLEXARRAY
+ ng : DFLEXARRAY
+ no : DFLEXARRAY
+ P : DFLEXARRAY
+ PSat : DFLEXARRAY
+ Sg : DFLEXARRAY
+ Sw: DFLEXARRAY
+ EquateTo() : void
+ InputVariables() : void
+ OutputVariables() : void
+ Swap() : void
Figure 1.6: Members and Functionality of the Gridblock Variables class (struc-
ture).
Functionality
1. InputV ariables - given a std :: if stream object, read in values of all
arrays. This is used in initializing the simulator when we want to restart
from a previous run.
2. OutputV ariables - given a std :: of stream object, write values of all
arrays. Consider writing as binary …les for faster input/output.
3. EquateT o - given a (pointer to a) GridblockVariables object, equate all
elements of each array to the given object arrays.
38
Table
# noDependentVariables : int
# noValues : int
# X: DFLEXARRAY
# XStep : double
# YSlopes : D3FLEXARRAY
+ <<Virtual>> getInterpolatedValues() : bool
+ <<Virtual>> OutputTable() : void
+ <<Virtual>> ReturnPointerToIndependentVariable() : DFLEXARRAY*
+ <<Virtual>> ReturnPointerToTableColumn() : DFLEXARRAY*
# FillYSlopes() : void
- locate() : int
Members
1. noV alues (int) - the number of values (rows) in the table.
2. noDependentV ariables (int) - the number of columns (excluding the in-
dependent variable column) in the table.
3. X (DFLEXARRAY) - array dimensioned noV alues containing equally
spaced values of the independent variable.
4. XStep (double) - Size of the constant increment in the independent vari-
able array.
5. Y Slopes (D3FLEXARRAY) - three dimensional array (dimensioned 2
noDependentV ariables noV alues). Y Slopes[0][i][j] contains the value
of the ith dependent variable corresponding to X[j]; Y Slopes[1][i][j] con-
tains the …rst derivative of the ith dependent variable with respect to the
independent variable corresponding to X[j]:
Functionality
1. getInterpolatedV alues - given an array of user provided values of the in-
dependent variable, return interpolated values (and slopes). This function
is polymorphic.
2. OutputT able - given a std :: of stream object, write values of the table to
a …le. Consider writing as binary …les for faster input/output.
39
3. ReturnP ointerT oIndependentV ariable (DFLEXARRAY *) - sometimes
we need to work with the values in the independent variable array directly.
This function provides access to that array.
4. ReturnP ointerT oT ableColumn (DFLEXARRAY *) - sometimes we need
to work with a single column in the table of dependent variables; this
function provides access to that column.
5. F illSlopes - given the dependent variable tables, compute slopes of the
dependent variables with respect to the independent variable.
6. locate (int) - this function works with arbitrarily spaced tables of the
independent variable and is described below.
If our available tables are not equally spaced in the independent variable,
we must …rst create equally spaced tables by using conventional search and
interpolation routines on the input tables. The algorithm for doing this is as
follows:
1. Read in the given array of the independent variable (double * xactual) and
the dependent variables, (double **yactual), as well as the actual sizes of
the arrays. (xactual[nrows], yactual[ncolumns][nrows]). Store the actual
minimum and maximum values of the independent variable (double xmin,
double xmax).
2. Set a desired step size for the equally-spaced dependent variable array
(double xstep_desired).
3. Compute the actual number of values (int nV al) in the equally-spaced
arrays as
where int (x) returns the truncated integer part of the double precision
number x, ceil (x) returns the smallest double precision integer value that
is greater than or equal to x and fabs (x) returns the absolute value of x:
4. Compute the actual value of the constant step in the independent vari-
ables; double xstep = (xmax xmin)/(nV al 1).
5. Create arrays for the equal-spaced independent variables; double *x =
new double[nV al]. Also create arrays for the dependent variables and
the slopes of the dependent variables, e.g., double ** y = new double
*[ncolumns]; double ** yslope = new double *[ncolumns]; double *y[i]
= new double[nV al]; double *yslope[i] = new double[nV al].
6. Fill the array of independent variables; x[0] = xmin; x [i] = x [i 1] +
xstep for i = 1; 2:::nV al 1.
40
7. Fill the dependent variable and slope arrays by looking up and interpolat-
ing the input data set. The algorithm for searching the actual independent
variable array is described next.
In the following, we describe an algorithm (see Ref. [42]) to locate the index
l in a monotonically increasing or decreasing array x of size n, such that a given
value x^ is between x [l] and x [l + 1] :
1. Set lower and upper limits on the array indices: int jlow = 1; int jhi = n.
2. While jhi jlow > 1 do
3. Return l = jlow:
Having found the interval containing x [k] ; 0 < k < nV al, compute the
interpolated dependent variables and the slope using
y [i] [k] = yactual [i] [l] + yslope[i] [k] (x [k] xactual [l]) (1.158)
The algorithm for searching the equally space table and interpolating has
been described previously in Eqs. 1.132 - 1.135.
Members
1
1. Cw (double) - isothermal compressibility of water (psi ).
2. dM uodP (double) - derivative of oil viscosity with respect to pressure for
undersaturated oil. (cp/psi).
3. nP ress (int) - number of pressures at which PVT properties would be
evaluated.
4. P min, P max (double) - minimum and maximum values of pressures in
the pressure tables (psia).
41
PVTProperties
# Cw: double
# dMuodP : double
# nPress : int
# Pmax : double
# Pmin : double
# Pressures : DFLEXARRAY
# PSatVsRsTable : Table* = NULL
# Pstep : double
# PVTTable : Table* = NULL
# UndersatdCo : double
# UnderSaturatedIndices : IFLEXARRAY
# WaterTable : Table* = NULL
+ <<Virtual>> CreatePSatVsRsTable() : void
+ <<Virtual>> getFluidProperties() : bool
+ <<Virtual>> getSaturationPressure() : bool
Functionality
1. CreateP satV sRsT able - given arrays of saturated solution gas-oil ra-
tio versus pressure, create a table of saturation pressure versus (equally
spaced) solution gas-oil ratio data.
2. getF luidP roperties - given an array of input pressures and saturation
pressures (or oil and gas concentrations), compute PVT properties and
slopes of PVT properties.
3. getSaturationP ressure - given in situ solution gas-oil ratios (or in situ
oil and gas concentrations), return saturation pressures by interpolating
the P SatV sRsT able.
42
RelativePermeability
# Kr : DFLEXARRAY
# RelPermTable : Table* = NULL
+ <<Abstract>> CreateTable() : void
+ <<Virtual>> getRelativePermeability() : bool
+ <<Virtual>> OutputTables() : void
Figure 1.9: Members and Methods for the 2-phase Relative Permeability Class.
RelativePermeability Class
This (generic) class handles two-phase relative permeabilities. An overview of
the members and methods is shown in Fig. 1.9.
Members
1. RelP ermT able (Table *) - table of relative permeabilities versus phase
saturation.
2. Kr (DFLEXARRAY) - internal relative permeability table that is used if
we need results at only a single saturation.
Functionality
1. CreateT able (abstract) - function to create the 2-phase relative perme-
ability tables. This must be supplied in derived classes.
2. GetRelativeP ermeability - given phase saturation or an array of phase
saturations, return relative permeabilities and derivatives of relative per-
meability with respect to phase saturation.
3. OutputT ables - given a std :: of stream object, write values of all arrays.
Consider writing as binary …les for faster input/output.
Possible child classes include a TabularRelativePermeability Class (where
input data are provided in the form of relative permeability tables) and a Pow-
erLawRelativePermeability Class where the tables are generated from power-law
functions.
43
ThreePhaseRelativePermeabilityCapPress
# Krog : RelativePermeability* = NULL
# Krow: RelativePermeability* = NULL
# Pcgo : CapillaryPressure* = NULL
# Pcow: CapillaryPressure* = NULL
+ <<Virtual>> UpdateCapillaryPressure() : bool
+ <<Abstract>> updateProperties() : bool
# <<Virtual>> SetupRelativePermeability() : void
Figure 1.10: Members and Methods for the Three Phase Relative Permeability
Class.
CapillaryPressure Class
Like the 2-phase relative permeability class, more sophisticated simulators may
work with tabulated capillary pressure versus saturation data; in this case, a
Table pointer would be a class member. In our implementation, straight line
capillary pressure curves are employed. For these, it su¢ ces to have a slope and
intercept of the capillary pressure “curve” as members. The sole method for
this class would be a getCapillaryPressure function that would return capillary
pressures for a given input phase saturation array.
ThreePhaseRelativePermeabilityCapPress Class
This generic class typically interacts with two phase relative permeability and
capillary pressure objects to create three-phase data. An overview of the mem-
bers and methods is presented in Fig. 1.10.
Members
1. Krog, Krow (RelativePermeability *) - two-phase relative permeability
objects for gas-oil and oil-water systems respectively.
2. P cgo, P cow (CapillaryPressure *) - two-phase capillary pressures for gas-
oil and oil-water systems respectively.
Functionality
1. updateP roperties - given arrays of water and gas saturation, return rel-
ative permeabilities, capillary pressures and their partial derivatives with
respect to the phase saturations.
2. U pdateCapillaryP ressure - same as above, but only capillary pressures
are updated.
3. SetupRelativeP ermeability - a function to create required relative per-
meability and capillary pressure objects form an input data …le.
44
Miscellaneous
+ const_strip_comments() : int
+ InnerProduct() : double
+ locate() : int
+ Norm2() : double
+ InnerProduct() : double
+ Norm2() : double
Child classes of this generic class would include classes that implement the
Stone I and Stone II models[30], [31].
Functionality
1. strip_comments - input to the simulator is provided by a set of input data
…les; in order to facilitate reading and navigation through these …les, we
use commented data …les, such that lines beginning with “c ”or “C ”are
treated as comments and are ignored. This function reads the commented
data …les, removes the comments, and writes only the required data to a
text …le.
2. InnerP roduct - computes the inner product of two vectors of size n.
Pn
xi yi
x; y = i=1
n
45
Chapter 2
The discrete equations presented in the previous chapter are highly nonlinear, so
any solution method requires that the equations must be linearized. In this sec-
tion we develop the linearized equations for solution using Newton’s method. In
our implementation of the problem solution, we use the error oriented descent
restricted Newton step approach as described by P. Due‡hard[15]. For com-
pleteness, we present Due‡hard’s algorithm in Appendix B. Application of the
algorithm requires that we compute the derivatives of each of the ‡ow equations
with respect to the dependent variables in order to compute the Jacobian ma-
trix. To maximize e¢ ciency, we compute the Jacobian semi-analytically; that is,
we obtain analytical expressions for the required partial derivatives in terms of
derivatives of PVT properties with respect to pressure and relative permeabili-
ties with respect to saturation. In general, the derivatives of the PVT properties
and relative permeabilities cannot be e¢ ciently determined analytically, so we
resort to e¢ cient numerical di¤erentiation to complete the Jacobian.
Following standard procedure, we expand Eqs. 1.75, 1.92 and 1.105 about a
prior estimate of each of the dependent variables in the set
46
using truncated Taylor series[20] expansion to give
1
X n+1; 1
X n+1;
n+1;
@Fmi;j;k
@Fmi;j;k
0 = Fm + poi+`;j;k + poi;j+`;k +
i;j;k
@poi+`;j;k @poi;j+`;k
`= 1 `= 1;`6=0
1
X n+1; 1
X n+1;
@Fmi;j;k
@Fmi;j;k
poi;j;k+` + noi+`;j;k +
@poi;j;k+` @noi+`;j;k
`= 1;`6=0 `= 1
1
X n+1; 1
X n+1;
@Fmi;j;k
@Fmi;j;k
noi;j+`;k + noi;j;k+` +
@noi;j+`;k @noi;j;k+`
`= 1;`6=0 `= 1;`6=0
1
X n+1; 1
X n+1;
@Fmi;j;k
@Fmi;j;k
ngi+`;j;k + ngi;j+`;k +
@ngi+`;j;k @ngi;j+`;k
`= 1 `= 1;`6=0
1
X n+1;
@Fmi;j;k
ngi;j;k+` (2.1)
@ngi;j;k+`
`= 1;`6=0
for m = o; g or w. Here
+1
f f f (2.2)
where f is our last estimate of the variable, for
If we expand each ‡ow equation at each gridblock about the previous estimate
of the gridblock variables, write the resulting equations in matrix form
From the de…nition of total derivative [9] the following relationships must be
valid:
@Rs;sat @Rs;sat
dRs;sat = dno + dng
@no @ng
dRs;sat
= dpsat (2.4)
dpsat
47
From this we can write
dRs;sat @psat osc Rs;sat
= = : (2.5)
dpsat @ng gsc no ng
or
@psat Rs;sat
= dR
(2.6)
@ng ng dps;sat
sat
and similarly
@psat Rs;sat
= dRs;sat
(2.7)
@no no dpsat
Saturated Systems For saturated systems, kro = kro (Sw ; Sg ) and PVT
properties are uniquely dependent on pressure, so from the de…nitions of Eqs.
1.50 - 1.52, the partial derivatives of phase mobility with respect to our solution
variables are given by
Note that the above equations suggest that we must determine derivatives of
relative permeability with respect to saturation. This is straightforward for gas
(vapor) and water, since these relative permeabilities are uniquely dependent on
the corresponding phase saturations; thes derivatives can be obtained directly
from the slopes of the relative permeability tables. For the hydrocarbon liquid
48
phase, relative permeability depends on both gas and water saturations, so the
the form of the partial derivatives depends on the model used for three-phase
relative permeability.
From Eqs. 1.36 - 1.39, the partial derivatives of phase saturations with
respect to pressure and oil and gas concentrations are given by the following
expressions.
= +
@po Bo dp (1 R s rv ) gsc dp (1 Rs rv )
dRs drv
S o rv B g Sg B o
So dBo dp dp
= + (2.17)
Bo dp (1 Rs rv ) Bg
= +
@po Bg dp (1 R s rv ) osc dp (1 Rs rv )
drv dRs
Sg R s B o So B g
Sg dBg dp dp
= + (2.18)
Bg dp (1 Rs rv ) Bo
@Sg Bg
= (2.24)
@ng (1 R s rv ) gsc
@Sw rv B o B g
= (2.25)
@ng (1 Rs rv ) gsc
Finally from Eqs. 1.27 and 1.28,
d L gsc dRs dBo
L
= (2.26)
dpo Bo dpo Bo dpo
d V drv V dBg
= osc (2.27)
dpo Bg dpo Bg dpo
49
Undersaturated Systems Note that for undersaturated systems, PVT prop-
erties are functions of both pressure and saturation pressure (i.e., pressure and
composition), so the total derivative of a arbitrary PVT property, ; is given
by
@ @
d = dp + dpsat : (2.28)
@p psat @psat p
Thus, the partial derivative with respect to oil concentration is
@ @ @psat
= (2.29)
@no p;ng @psat p @no p;ng
@psat @
where @no is given by Eq. 2.7, and @psat is a saturated derivative,
p;ng p
i.e., the derivative of the property at saturated conditions. Similar formulas
apply for the derivative with respect to ng :
For undersaturated systems, Sg = g = 0; kro = kro (Sw ) ; and Eqs. 2.8 -
2.27 assume the following forms
!
@ o 1 dkro @Sw kro @ o @Bo
= 2 Bo + o
@po o Bo dSw @po ( o Bo ) @po p+ @po p+
sat sat
(2.30)
@ o @Bo
where @po + and @po + are derivatives of the properties above the bub-
psat psat
ble point.
@ g
=0 (2.31)
@po
!
@ o 1 @kro @Sw kro @ o @Bo
@psat
= 2 Bo + o
@no o Bo @Sw @no ( o Bo ) @psat
p p @no@psat
(2.32)
@ o @Bo
where @psat and @psat are derivatives of the saturated properties.
p p
@ g
=0 (2.33)
@no
!
@ o 1 @kro @Sw kro @ o @Bo @psat
= 2 Bo + o
@ng o Bo @Sw @ng ( o Bo )
@psat p @psat p @ng
(2.34)
@ g
=0 (2.35)
@ng
From Eqs. 1.36 - 1.39,
@So So @Bo
= (2.36)
@po Bo @p p+
sat
@Sg
=0 (2.37)
@po
50
@Sw @So
= (2.38)
@po @po
!
@So So @Bo @psat
= +
@no Bo @psat p @no
@rv @psat
gsc osc ng @psat @no Bo
p
+
(1 R s rv ) gsc osc
@Sg
=0 (2.40)
@no
@Sw @So
= (2.41)
@no @no
!
@So So @Bo @psat
=
@ng Bo @psat p @ng
@rv @psat
osc rv + n g @psat @ng Bo
p
+
(1 R s rv ) gsc osc
@Sg
=0 (2.43)
@ng
@Sw @So
= (2.44)
@ng @ng
Finally from Eqs. 1.27 and 1.28,
d L L @Bo
= (2.45)
dpo Bo @po p+
sat
d V
=0 (2.46)
dpo
51
d L L @Bo @psat gsc @Rs @psat
= + (2.47)
dno Bo @psat p @no Bo @psat p @n0
d V
=0 (2.48)
dno
d L L @Bo @psat gsc @Rs @psat
= + (2.49)
dng Bo @psat p @n g B o @psat p @ng
d V
=0 (2.50)
dng
In Eqs. 2.6 - 2.45, derivatives of the PVT properties with respect to pressure
below the saturation pressure and derivatives of phase relative permeability
with respect to saturation are determined numerically from the slopes of the
tabulated PVT and relative permeability data.
If we are dealing with retrograde condensate gases above the dew point,
equations analogous to Eqs. 2.30 - 2.45 must be derived.
(2.55)
52
Note that ( n+1
o for ‡ow from x 1 to x
n+1
o = 1;j;k
n+1
1 ;j;k
2 o for ‡ow from x to x 1
;j;k
( !
@zo;4 dpn+1
cgo @Sg
= Gx 1 ;j;k rvn+1 n+1
g 1+ 1;j;k 1;j;k
(2.59)
( !
@zo;8 dpn+1
cgo ;j @Sg ;j
= Gy ;j 1 ;k rvn+1 n+1
g 1+ 1;k 1;k
@poi;j 1;k 2 ;j 1 ;k
2
;j 1 ;k
2
dSg ;j 1;k
@poi;j 1;k
0 19
n+1
@ g drvn+1 =
y;g;j 1;j pn+1
g pn+1
g ;j 1;k
@rvn+1 ;j 1;k
+ n+1
g
;j 1;k
A
;j;k ;j 1;k @poi;j 1;k
;j 1;k dpoi;j 1;k
;
(2.60)
@zo;`
=0 (2.61)
@poi;j 1;k `6=6;8
12
X
@Fon+1;
i;j;k @zo;`
= (2.62)
@poi;j;k 1
@poi;j;k 1
`=1
where
0 0 1
n+1
@zo;10 1 zk 1 g@ L ;j;k
= Gz ;j;k 1
@ n+1
o
@1 1
A 2
@poi;j;k 1 2 ;j;k 1
2
2 144gc @poi;j;k 1
0 n+1
1 1
L g @ n+1
B n+1 ;j;k 1 C o ;j;k C
z;o;k 1;k @po ;j;k pn+1
o ;j;k + 2
zk 21 A 1
A (2.63)
1
144gc @poi;j;k 1
53
@zo;12
=
@poi;j;k 1
8 0 1
< n+1
@1 +
dpn+1
cgo ;j;k @Sg ;j;k 1 zk 12 g @ V ;j;k A
Gz ;j;k 1 rvn+1 n+1
g
1 1 1
0 n+1
1
V g
B n+1 ;j;k 1
C
z;g;k 1;k @pg pn+1
g ;j;k + 2
zk 1 A
;j;k 1
144gc 2
0 19
n+1
@ g drvn+1 =
@rvn+1 ;j;k 1
+ n+1
g
;j;k 1
A (2.64)
;j;k 1 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are given by Eqs. 2.91 -
2.127, provided we replace no by ng ; the sole exception to this rule is Eq. 2.115,
which is replaced by
X12
@Fon+1;
i;j;k @zo;`
= : (2.128)
@ngi;j;k @ngi;j;k
`=1
@zg;2
= Gx 1 ;j;k Rsn+11 ;j;k n+1
o 1
@poi 1;j;k 2 i
2 2
;j;k
0 11
n+1
@ o @Rsn+1
i 1 ;j;k
x;o;i 1;i pn+1
o ;j;k pn+1
o 1;j;k
@Rn+1 1;j;k
+ n+1
o
AA
si 1 ;j;k
@poi 1;j;k
1;j;k @poi 1;j;k
(2.130)
( !
@zg;4 n+1
dpn+1
cgo 1;j;k
@Sg 1;j;k
= Gx 1 ;j;k g 1 1+
@poi 1;j;k 2
2
;j;k dSg 1;j;k
@poi 1;j;k
9
n+1 =
@ g
x;g;i 1;i pn+1
g ;j;k pn+1
g 1;j;k
1;j;k
(2.131)
@poi 1;j;k
;
@zg;`
=0 (2.132)
@poi 1;j;k `6=2;4
12
X
@Fgn+1
i;j;k @zg;`
= (2.133)
@poi;j 1;k
@poi;j 1;k
`=1
62
where
@zg;6
= Gy ;j 1 ;k Rsn+1 1
n+1
o
@poi;j 1;k 2 i ;j 2 ;k 1 ;k
;j
2
0 11
n+1
@ o @Rsn+1
@Rn+1 i ;j 1;k AA
y;o;j 1;j pn+1
o pn+1
o ;j 1;k si ;j 1;k
;j 1;k
+ n+1
o
;j;k @poi;j 1;k
;j 1;k @poi;j 1;k
(2.134)
( !
@zg;8 n+1
dpn+1
cgo ;j 1;k
@Sg ;j 1;k
= Gy ;j 1 ;k g 1+
@poi;j 1;k 2 ;j 1 ;k
2
dSg ;j 1;k
@poi;j 1;k
9
n+1 =
@ g
y;g;j 1;j pn+1
g pn+1
g ;j 1;k
;j 1;k
(2.135)
;j;k @poi;j 1;k
;
@zg;`
=0 (2.136)
@poi;j 1;k `6=6;8
12
X
@Fgn+1;
i;j;k @zo;`
= (2.137)
@poi;j;k 1
@poi;j 1;k
`=1
where
0 0 1
n+1
@zg;10 1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n+1
g ;j 1;k
;j 1;k
(2.172)
;j;k @noi;j 1;k
;
68
@zg;`
=0 (2.173)
@noi;j 1;k `6=6;8
12
X
@Fgn+1;
i;j;k @zg;`
= (2.174)
@noi;j;k 1
@noi;j;k 1
`=1
where
@zg;10
=
@noi;j;k 1
0 n+1
1
L g @ n+1
B n+1 ;j;k 1
C n+1 o
z;o;k 1;k Gz 1 @po pn+1
o ;j;k + 2
zk 1AR
si ;j;k 1
;j;k 1
;j;k
2 ;j;k 1
144gc 2 @noi;j;k 1
(2.175)
@zg;12
=
@noi;j;k 1
(
n+1
dpn+1
@Sg ;j;k 1
cgo ;j;k 1
Gz ;j;k 1 g
2 ;j;k 1
2
dSg ;j;k 1 @noi;j;k 1
0 1 9
n+1
V g @ n+1 >
=
B n+1 n+1 ;j;k 1
2 C g ;j;k 1
z;g;k 1;k @pg ;j;k pg ;j;k 1 + zk 21 A (2.176)
144gc @noi;j;k 1
>
;
@zg;`
=0 (2.177)
@noi;j;k 1 `6=10;12
12
X
@Fgn+1
i;j;k @zg;`
= (2.178)
@noi+1;j;k @noi+1;j;k
`=1
where
n+1
@zg;1 @ o
= x;o;i+1;i Gx + 1 ;j;k
pn+1
o +1;j;k pn+1
o ;j;k Rsn+1
i+1 ;j;k
+1;j;k
(2.179)
@noi+1;j;k 2 @noi+1;j;k
@zg;3 n+1
dpn+1
cgo +1;j;k @Sg +1;j;k
= Gx + 1 ;j;k g 1
@noi+1;j;k 2 +
2
;j;k dSg +1;j;k @noi+1;j;k
1
n+1
@ g
+ x;g;i+1;i pn+1
g +1;j;k pn+1
g ;j;k
+1;j;k
A (2.180)
@noi+1;j;k
69
@zg;`
=0 (2.181)
@noi+1;j;k `6=1;3
12
X
@Fgn+1
i;j;k @zg;`
= (2.182)
@noi;j+1;k @noi;j+1;k
`=1
where
n+1
@zg;5 @ o
n+1 n+1
= y;o;j+1;j Gy ;j+ 1 ;k po pn+1
o ;j;k Rsi ;j+1;k
;j+1;k
(2.183)
@noi;j+1;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k 2
n+1 !
n+1
dpn+1
cow ;j;k @Sw ;j;k 1 zk 12 g @ w ;j;k
w 1 +
;j;k 1
2
dSw ;j;k @poi;j;k 2 144gc @poi;j;k
0 n+1 1 1
w 1
g @ n+1
w
;j;k
z;w;k;k 1
@pn+1
w pn+1
w ;j;k 1 +
2
zk 12 A ;j;k
A (2.228)
;j;k 144gc @poi;j;k
75
Turning to the partial derivatives with respect to no , we have
6
X
@Fwn+1
i;j;k @zw;`
= (2.229)
@noi 1;j;k
@noi 1;j;k
`=1
where
(
@zw;2 n+1
dpn+1
cow 1;j;k
@Sw 1;j;k
= Gx 1 ;j;k w
@noi 1;j;k 2 1 ;j;k
2
dSw 1;j;k
@noi 1;j;k
9
n+1 =
@ w
x;w;i 1;i pn+1
w ;j;k pn+1
w 1;j;k
1;j;k
(2.230)
@noi 1;j;k
;
@zw;`
=0 (2.231)
@noi 1;j;k `6=2
6
X
@Fwn+1
i;j;k @zw;`
= (2.232)
@noi;j 1;k
@noi;j 1;k
`=1
where
(
@zw;4 n+1
dpn+1
cow ;j 1;k
@Sw ;j 1;k
= Gy ;j 1 ;k w
@noi;j 1;k 2 ;j 1 ;k
2
dSw ;j 1;k
@noi;j 1;k
9
n+1 =
@ w
y;w;j 1;i pn+1
w pn+1
w ;j
;j 1;k
(2.233)
;j;k 1;k
@noi;j 1;k
;
@zw;`
=0 (2.234)
@noi;j 1;k `6=4
6
X
@Fwn+1;
i;j;k @zw;`
= (2.235)
@noi;j;k 1
@noi;j;k 1
`=1
where
(
@zw;6 n+1
dpn+1
cow ;j;k 1
@Sw ;j;k 1
= Gz ;j;k 1 w
@noi;j;k 1 2 ;j;k 1
2
dSw ;j;k 1
@noi;j;k 1
0 n+1 1 9
w 1
g @ n+1
w =
;j;k
z;w;k 1;k
@pn+1
w pn+1
w ;j;k + 2
zk 1 A ;j;k 1
(2.236)
;j;k 1
144gc 2 @noi;j;k 1
;
@zw;`
=0 (2.237)
@noi;j;k 1 `6=6
76
6
X
@Fwn+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;i+1 pn+1
w +1;j;k pn+1
w ;j;k
;j;k
(2.249)
@noi;j;k ;
(
@zw;2 n+1
dpn+1
cow ;j;k @Sw ;j;k
= Gx 1 ;j;k w 1
@noi;j;k 2
2
;j;k dSw ;j;k @noi;j;k
9
n+1 =
@ w
x;w;i;i 1 pn+1
w ;j;k pn+1
w 1;j;k
;j;k
(2.250)
@noi;j;k ;
(
@zw;3 n+1
dpn+1
cow ;j;k @Sw ;j;k
= Gy ;j+ 1 ;k w
@noi;j;k 2 ;j+ 1 ;k
2
dSw ;j;k @noi;j;k
9
n+1 =
@ w
+ y;w;j;j+1 pn+1
w pn+1
w ;j;k
;j;k
(2.251)
;j+1;k @noi;j;k ;
(
@zw;4 n+1
dpn+1
cow ;j;k @Sw ;j;k
= Gy ;j 1 ;k w
@noi;j;k 2 ;j 1 ;k
2
dSw ;j;k @noi;j;k
9
n+1 =
@ w
y;w;j;j 1 pn+1
w pn+1
w ;j
;j;k
(2.252)
;j;k 1;k
@noi;j;k ;
@zw;5 n+1
dpn+1
cow ;j;k @Sw ;j;k
= Gz ;j;k+ 1 w
@noi;j;k 2 ;j;k+ 1
2
dSw ;j;k @noi;j;k
0 n+1 1 1
w g @ n+1
w
;j;k+ 1
+ z;w;k;k+1
@pn+1
w pn+1
w ;j;k +
2
zk+ 12 A ;j;k
A (2.253)
;j;k+1 144gc @noi;j;k
78
@zw;6 n+1
dpn+1
cow ;j;k @Sw ;j;k
= Gz ;j;k 1 w
@noi;j;k 2 ;j;k 1
2
dSw ;j;k @noi;j;k
0 n+1 1 1
w 1
g @ n+1
w
;j;k
z;w;k;k 1
@pn+1
w pn+1
w ;j;k + 2
zk 1 A ;j;k
A (2.254)
;j;k 1
144gc 2 @noi;j;k
Undersaturated Systems
The derivative expressions that we have developed for the oil, water and
gas components in the previous sections implicitly assume that the reservoir
is saturated. For undersaturated reservoirs, some of these derivatives have to
be modi…ed: in particular, above the bubble point, all terms involving gas
transmissibility (or gas saturation) and its derivatives disappear, but new terms
appear because PVT properties are dependent on composition as well as pres-
sure. Derivitaves of phase transmissibilities below and above the bubble point
have been discussed previously. Here we present the derivative terms that must
be modi…ed above the bubble point.
Oil Equation
The only a¤ected terms in the oil equation are zo;9 (Eq. ??), and zo;10 (Eq. ??)
and only the derivatives with respect to oil and gas concentrations are a¤ected.
These are recorded as follows.
@zo;9
=
@noi;j;k+1
00 n+1
1
L g @ n+1
BB n+1 ;j;k+ 1 C o
z;o;k+1;k Gz ;j;k+ 1
@@po ;j;k+1 pn+1
o ;j;k + 2
zk+ 12 A ;j;k+1
+
2 144gc @noi;j;k+1
1
n+1 n+1
o zk+ 21 g @ L ;j;k+1
;j;k+1
A (2.255)
2 144gc @noi;j;k+1
n+1
@ L
;j;k+1
where @noi;j;k+1 is given by Eq. ??.
00 n+1
1
L g @ n+1
@zo;9 BB n+1 ;j;k+ 1 C o
= z;o;k;k+1 Gz ;j;k+ 1
@@po ;j;k+1 pn+1
o ;j;k + 2
z k+ 12 A
;j;k
79
@zo;10
=
@noi;j;k 1
00 n+1
1
L g @ n+1
BB n+1 ;j;k 1
C o
z;o;k 1;k Gz 1 @@po ;j;k pn+1
o ;j;k + 2
zk 1 A
;j;k 1
;j;k
2
1
144gc 2 @noi;j;k 1
1
n+1 n+1
o zk 1 g@ L ;j;k
;j;k 1 2 1
A (2.257)
2 144gc @noi;j;k 1
00 n+1
1
L g @ n+1
@zo;10 BB n+1 ;j;k 1
C o
= z;o;k;k 1 Gz 1 @@po pn+1
o ;j;k + 2
zk 1A
;j;k
@noi;j;k ;j;k
2 ;j;k 1
144gc 2 @noi;j;k
1
n+1 n+1
o zk 1 g@ L ;j;k
;j;k 2 A (2.258)
2 144gc @noi;j;k
Gas Equation
The a¤ected terms in the gas equation are zg;1 ; (Eq. 1.93), zg;2 ; (Eq. ??),
zg;5 ; (Eq. ??), zg;6 ; (Eq. ??), zg;9 ; (Eq. ??) and zg;10 ; (Eq. ??). The new
equations are as follows.
@zg;1
=
@noi+1;j;k
0
n+1
@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1
n+1
@Rsn+1 Rsn+1 n+1
o zk 1 g@ L ;j;k
+ n+1
o
i;j;k i;j;k ;j;k 2 A (2.270)
i;j;k @noi;j;k 2 144gc @noi;j;k
82
Water Equation
The terms in the water equation are the same as for saturated systems, pro-
vided we use appropriate de…nitions of the derivatives of the saturation terms
as de…ned previously.
(2.271)
qgi;j;k
= W I ;j;k n+1
gi;j;k pn+1
g ;j;k pn+1
well + Rsn+1 n+1
i;j;k oi;j;k
pn+1
o ;j;k pn+1
well
Vi;j;k
(2.272)
and
qwi;j;k
= W I ;j;k n+1
wi;j;k pn+1
w pn+1
well (2.273)
Vi;j;k ;j;k
where
5:615k 0 L0 ( ; !)
W I ;j;k = (2.274)
rb0 ( ; !)
141:2 ln 0 ( ; !)
+s xi yj zk
rw
with p
k 0 = 3 kx ky kz (2.275)
q
2 2 2
L0 ( ; !) = (L0x ) + L0y + (L0z ) (2.276)
r
0 k0
Lx = L sin cos ! (2.277)
kx
83
z
ω
x
84
s
k0
L0y = L sin sin ! (2.278)
ky
r
k0
L0z = L cos (2.279)
kz
q
0
rw ( ; !) = 02 (x) sin2 cos2 ! + r 02 (y) sin2 sin2 ! + r 02 (z) cos2
rw (2.280)
w w
s r !
0 rw k0 k0
rw (x) = + (2.281)
2 ky kz
r r !
0 rw k0 k0
rw (y) = + (2.282)
2 kx kz
s r !
0 rw k0 k0
rw (z) = + (2.283)
2 ky kx
q
rb0 ( ; !) = rb02 (x) sin2 cos2 ! + rb02 (y) sin2 sin2 ! + rb02 (z) cos2 (2.284)
s
0 e k0 k0
rb (x) = yj2 + zk2 (2.285)
4 ky kz
r
0 e k0 k0
rb (y) = x2i + zk2 (2.286)
4 kx kz
s
0 e k0 k0
rb (z) = x2i + yj2 (2.287)
4 kx ky
Here e is Euler’s constant 0:577: In Eq. 2.274, s is the dimensionless skin
factor associated with the given well segment; i.e., for single phase ‡ow of a ‡uid
with viscosity at at rate q bbl/d,
k 0 L0 ( ; !) pskin
s= (2.288)
141:2q
where pskin is the single phase skin pressure drop. Note that in our formulation
a particular reservoir gridblock may contain many di¤erent sources and/or sinks
corresponding to each (inclined, partially penetrating) perforated section along
the well path.
85
capillary pressure and because of this, it may be possible for one phase to ‡ow
from the well gridblock to the well while there is simultaneous ‡ow of another
phase from the well to the well gridblock. This introduces a question as to how
the phase transmissibility terms ( n+1
mi;j;k ; m = o; g or w) in Eqs. 2.271 - 2.273
should be evaluated. If ‡ow of a phase is from the gridblock to wellbore, the
phase mobilities are evaluated at the gridblock phase saturation. If ‡ow is in the
opposite direction, under the assumption that “upstream weighting” of phase
saturation most accurately describes the ‡ow phenomenon, phase mobilities
should be evaluated at the wellbore (sandface) saturation. The problem is that
sandface saturations are not routinely computed.
(2.292)
qgi;j;k
= W I ;j;k n+1
gwell pn+1
g pn+1 n+1
well + Rswell
n+1
owell pn+1
o pn+1
well
Vi;j;k ;j;k ;j;k
(2.293)
and
qwi;j;k
= W I ;j;k n+1
wwell pn+1
w pn+1
well (2.294)
Vi;j;k ;j;k
86
@ qoi;j;k n+1
= W I ;j;k owell +
@pn+1
o ;j;k Vi;j;k
!)
dpn+1 n+1
cgo ;j;k @Sg ;j;k
rvn+1 n+1
well gwell
1+ (2.295)
dSgn+1 n+1
;j;k @po ;j;k
( !
@ qgi;j;k n+1
dpn+1 n+1
cgo ;j;k @Sg ;j;k
= W I ;j;k gwell 1+ +
@pn+1
o ;j;k Vi;j;k dSgn+1 n+1
;j;k @po ;j;k
Rsn+1
well
n+1
owell (2.296)
and
!
@ qwi;j;k n+1
dpn+1 n+1
cow ;j;k @Sw ;j;k
= WI ;j;k wwell 1 : (2.297)
@pn+1
o ;j;k Vi;j;k n+1
dSw ;j;k @pn+1
o ;j;k
Similarly,
@ qgi;j;k n+1
dpn+1 n+1
cgo ;j;k @Sg ;j;k
= W I ;j;k gwell (2.299)
@nn+1
o ;j;k Vi;j;k dSgn+1 n+1
;j;k @no ;j;k
and
@ qwi;j;k n+1
dpn+1 n+1
cow ;j;k @Sw ;j;k
= W I ;j;k wwell : (2.300)
@nn+1
o ;j;k Vi;j;k n+1
dSw n+1
;j;k @no ;j;k
Finally,
@ qgi;j;k n+1
dpn+1 n+1
cgo ;j;k @Sg ;j;k
= W I ;j;k gwell (2.302)
@nn+1
g ;j;k Vi;j;k dSgn+1 n+1
;j;k @ng ;j;k
and
@ qwi;j;k n+1
dpn+1 n+1
cow ;j;k @Sw ;j;k
= W I ;j;k wwell : (2.303)
@nn+1
g ;j;k Vi;j;k n+1
dSw n+1
;j;k @ng ;j;k
87
Injection of a Single Phase
If a single phase (e.g., water or gas) is being injected into the reservoir, the
saturation of that phase at the sandface is assumed to be 1, and the phase
transmissibility terms are evaluated at the endpoint saturation. The transmis-
sibilities of the other phases at the sandface are set to zero and the expressions
derived above are valid.
Fluid Production
For ‡uid production from a gridblock, the transmissibility terms are dependent
on the gridblock variables, so the derivatives of the sink terms must re‡ect this
dependence. The derivatives of the sink (production) terms with respect to the
gridblock variables are as follows.
@ qoi;j;k n
n+1
= W I ;j;k oi;j;k +
@pn+1
o ;j;k Vi;j;k
n+1
@ oi;j;k
+ pn+1
o pn+1
well n+1
;j;k @po ;j;k
!
dpn+1 n+1
cgo ;j;k @Sg ;j;k
rvn+1 n+1
i;j;k gi;j;k
1+ +
dSgn+1 n+1
;j;k @po ;j;k
!)
n+1
@gi;j;k drvn+1
pn+1
g pn+1
well rvn+1 n+1 + n+1
gi;j;k
i;j;k
(2.304)
;j;k i;j;k
@po ;j;k dpn+1
o ;j;k
(
n+1
@ qoi;j;k @ oi;j;k
= W I ;j;k pn+1
o pn+1
well +
@nn+1
o ;j;k Vi;j;k ;j;k @nn+1
o ;j;k
dpn+1 n+1
cgo ;j;k @Sg ;j;k
rvn+1 n+1
gi;j;k +
i;j;k
dSgn+1 n+1
;j;k @no ;j;k
)
n+1
@ gi;j;k
pn+1
g ;j;k pn+1
well rvn+1 (2.305)
i;j;k
@nn+1
o ;j;k
(
n+1
@ qoi;j;k @ oi;j;k
= W I ;j;k pn+1
o p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o ;j;k
(
@ qwi;j;k n+1
dpn+1 n+1
cow ;j;k @Sw ;j;k
= W I ;j;k wi;j;k +
@nn+1
o ;j;k Vi;j;k n+1
dSw n+1
;j;k @no ;j;k
)
n+1
@ wi;j;k
pn+1
w ;j;k pn+1
well (2.311)
@nn+1
o ;j;k
89
(
@ qwi;j;k n+1
dpn+1 n+1
cow ;j;k @Sw ;j;k
= W I ;j;k wi;j;k +
@nn+1
g ;j;k Vi;j;k n+1
dSw n+1
;j;k @ng ;j;k
)
n+1
@ wi;j;k
pn+1
w pn+1
well (2.312)
;j;k @nn+1
g ;j;k
Mixed Production/Injection
In some cases it may be possible that one of the phases is injecting into the
reservoir while the other two are producing. For these cases we use a combina-
tion of the expressions that we derived before: for the phase that is injecting, we
evaluate transmissibility at the wellbore for the phase in question using the well-
bore saturation of that phase and using the expressions for partial derivatives
for injection of that phase. Computation of wellbore phase saturations in this
case is still an unresolved issue. For the producing phases, we compute trans-
missibilities at the gridblock and use the derivative expressions for a producing
well.
where ; ; and are constants, and qoi;j;k ; qgi;j;k ; and qwi;j;k are given by Eqs.
2.271 (or 2.292), 2.272 (or 2.293) and 2.273 (or 2.294) respectively. Thus, for
example, if qs is a total mass rate, then
= + Rsn+1
i;j;k
n+1
oi;j;k + rvn+1
i;j;k
+ n+1
gi;j;k + n+1
wi;j;k ; (2.314)
= pn+1
cgo ;j;k
n+1
gi;j;k rvn+1
i;j;k
+ pn+1
cow ;j;k
n+1
wi;j;k (2.315)
90
We can combine our rate expressions (i.e., Eqs. 2.271 (or 2.292), 2.272 (or
2.293) and 2.273 (or 2.294)) to obtain an expression for the ‡owing well pressure
associated with this rate as
qs
Vi;j;k W I + pn+1
o +
pn+1
;j;k ;j;k
well = : (2.316)
Each individual phase rate can be determined by using Eq. 2.316 in the appro-
priate phase rate expression. Of course, if the wellbore pressure is speci…ed, the
phase rates can be determined directly by inserting the speci…ed pressure into
the rate equations.
For completeness, we summarize simpli…cations to the expressions for some
of the most common producing conditions.
= 1; = = 0: (2.317)
and,
= 1; = = 0: (2.319)
and,
= 1; = = 0: (2.321)
and,
In all other cases, the complete expressions for the partial derivatives must
be used.
91
2.4 Boundary Conditions
In order to compute solutions to the ‡ow problem, we must specify conditions at
the reservoir boundaries. For the Cartesian coordinate system, these boundaries
are at x = 0, x = Lx , y = 0, y = Ly , z = 0 (i.e., the bottom of the reservoir)
and z = Lz : For the …nite di¤erence grid that we speci…ed in Eqs. 1.56 - 1.58,
we must specify conditions for gridblocks that have faces that fall on one or
more of these boundaries. This is easy to do if the faces are sealed (i.e., no-‡ow
boundaries), but requires considerably more work if there is any ‡ow across the
boundary, i.e., at speci…ed rate or pressure. Note that the following discussion
is applicable to each block on the reservoir boundary; since a boundary is made
up of many blocks, it is possible to have a reservoir boundary that is partially
sealed, partially at constant pressure and partially at speci…ed rate all at the
same time.
in Eqs. 1.75, 1.92 and 1.105 and in all their associated derivatives. This ensures
that pressures on the sealed reservoir boundary do not enter into the ‡ow equa-
tion. Note that this technique is general, and can be applied anywhere in the
reservoir, for example to simulate a sealing fault. Applying no-‡ow conditions
along the remaining reservoir boundaries is accomplished in the same manner.
= = 0; and = 1:
92
From Darcy’s law, the speci…ed rate at the boundary is expressed in discrete
form as
rvn+1 n+1
g pn+1
g0;j;k pn+1
1
;j;k
+
1 ;j;k 1 ;j;k 2
2 2
Rsn+1 n+1
o pn+1
o0;j;k pn+1
1
;j;k
+
1 ;j;k 1 ;j;k 2
2 2
n+1
g pn+1
g0;j;k pn+1
1
;j;k
+
1 ;j;k 2
2
n+1
w 1 pn+1
w0;j;k pn+1
1
;j;k
(2.325)
;j;k 2
2
Here pn+1
1 denotes the pressure at the boundary x = 0 - (note that capillary
2 ;j;k
pressure does not a¤ect the boundary pressure) - and we have approximated
the derivative of pressure at the boundary as
@p p0 p 1
2
(2.326)
dx x=0 x0 x 1
2
93
Equation 2.325 can be rearranged to solve for the boundary pressure as
pn+1
1
;j;k
=
2
+ rvn+11 n+1
g
1 ;j;k
+ + Rsn+11 n+1
o
1 ;j;k
+ n+1
w
1 ;j;k
;j;k ;j;k
2 2 2 2 2
+ rvn+1 n+1
g pn+1
g0;j;k +
1 ;j;k 1 ;j;k
2 2
+ Rsn+1 n+1
o pn+1
o0;j;k +
1 ;j;k 1 ;j;k
2 2
)
n+1 qs
w 1 pn+1
w0;j;k + (2.328)
2
;j;k Gx 1 ;j;k V0;j;k
2
This expression is substituted into the ‡ow equations (Eqs. 1.76 - 1.112) for
the blocks adjacent to the speci…ed rate boundary to obtain ‡ow equations that
include boundary ‡ow. For example, for our problem, Eq. 1.77 would assume
the form
n+1
zo;2 = Gx 1 ;j;k o 1 pn+1
o ;j;k
2 ;j;k
2
+ rvn+11 n+1
g 1 + + Rsn+11 n+1
o 1 + n+1
w 1
;j;k ;j;k ;j;k ;j;k ;j;k
2 2 2 2 2
+ rvn+1 n+1
g 1 pn+1
g0;j;k +
1 ;j;k ;j;k
2 2
+ Rsn+1 n+1
o 1 pn+1
o0;j;k +
1 ;j;k ;j;k
2 2
)!
n+1 qs
w 1 pn+1
w0;j;k + (2.329)
2
;j;k Gx 1 ;j;k V0;j;k
2
94
Note that treatment of conditions at other reservoir boundaries is analogous.
Finally, although we do not speci…cally address cylindrical coordinates in
this section, the preceding method is the most accurate way for prescribing ‡ow
across the boundary at the wellbore radius.
and the gridblocks are ordered from 0 to (nx ny nz ) 1, …rst in the x-direction,
then in the y-direction and …nally in the z-direction. Thus, the index I of the
gridblock at location (xi ; yj ; zk ) is given by
I = i + nx (j + kny ) (2.331)
Iu = l + 3 (i + nx (j + kny ))
= l + 3I (2.332)
95
lc = n modulo 3 (2.336)
In Eqs. 2.333 and 2.335, the result of the division is truncated to an integer
(without rounding), and the operation a modulo b is the remainder resulting
from the division. Here 8
< 0 = poi;j;k
lr = 1 = noi;j;k (2.337)
:
2 = ngi;j;k
and 8
< 0 Oil Flow
lc = 1 Gas Flow (2.338)
:
2 Water Flow
r = l + 3 (i + nx (j + kny )) (2.339)
96
An integer vector Ap dimensioned 3 nx ny nz + 1 such that Ap[0]
i 1
X
= 0; Ap[i] = number of nonzero coe¢ cients in column l; Ap[3 nx
l=0
ny nz ] = total number of nonzero coe¢ cients in the matrix nnz :
An integer vector Ai dimensioned nnz containing the row index of each
successive nonzero entry in the successive columns of the matrix.
A real vector Ax dimensioned nnz containing the values of each nonzero
coe¢ cient in the successive columns of the matrix.
Ap = 0 9 18 27 39 51 63 72 81 90 99
108 117 129 141 153 162 171 180 (2.341)
The …rst 19 entries of Ai (dimensioned 180) are
0 1 2 3 4 5 9 10 11 0 1 2 3 4 5 9 10 11 0
(2.342)
and the …rst 10 entries of Ax (dimensioned 180) are
A0;0 A1;0 A2;0 A3;0 A4;0 A5;0 A9;0 A10;0 A11;0 A0;1 (2.343)
where the …rst subscript index refers to the row of the entry, and the second
refers to the column.
We use UMFPACK[13] and GotoBLAS[18] to solve the matrix problem.
97
2.6 Saturation and Pressure Initialization
There are several options for initializing the simulator: We can initialize from
given average conditions; we can read in initial depths to gas-oil and water-oil
contacts or we can read in gridblock data from a previous run.
Sw = 1 So Sg (2.346)
Here, P V is the total reservoir pore volume in cubic feet. We initialize all
gridblocks to the average values then run the simulator with no sources or sinks
until all intergridblock ‡ow ceases. The …nal result from this run represents
the initial saturation/pressure distribution in the reservoir. This condition can
be saved by writing all gridblock variables to a …le which can be re-opened
and used as an initial condition for all future simulation runs. Alternatively,
the initial average saturations of oil and gas can be speci…ed, (along with the
average pressure) and the initialization run could be made as before.
98
UMFSparseMatrix
- Ai : IFLEXARRAY
- Ap : IFLEXARRAY
- Ax : DFLEXARRAY
- Control[UMFPACK_CONTROL] : double
- Info[UMFPACK_INFO] : double
- Numeric : void* = NULL
- Symbolic : void* = NULL
- W : DFLEXARRAY
- Wi : IFLEXARRAY
# n : int = 0
# nnz : int = 0
+ ScaleColumns() : void
+ <<Virtual>> Solve() : int
+ <<Virtual>> SolveMultiple() : int
+ <<Virtual>> SolveTranspose() : int
+ <<Virtual>> SolveTransposeMultiple() : int
+ zeroElements() : void
+ <<Virtual>> operator ()() : double&
Members
1. n (int) - number of rows in the matrix.
99
2. nnz (int) - number of non-zero elements in the matrix.
3. Ai (IFLEXARRAY) - Array (dimensioned nnz) containing row indices for
each non-zero entry.
4. Ap (IFLEXARRAY) - Array (dimensioned n + 1) containing the indices
of the …rst non-zero entry in each column.
5. Ax (DFLEXARRAY) - Array (dimensioned nnz) containing the non-zero
entries in the sparse matrix.
6. W (DFLEXARRAY) - Work array (dimensioned 6 n)
7. W i (IFLEXARRAY) - Work array (dimensioned n)
8. Symbolic (void *) - Used by UMFPACK.
9. N umeric (void *) - Used by UMFPACK.
10. Control, Inf o - UMFPACK arrays; see Ref. [14].
Functionality
1. operator()() - provides the functionality of being able to assign values to
the elements of the sparse matrix using statements similar to A(i; j) = x;
results in an error condition if the element is not a pre-designated non-zero
element.
2. Solve, SolveM ultiple, SolveT ranspose, SolveT ransposeM ultiple - front
ends for the UMFPACK solution routines.
Members
1. nBlocks (int) - number of reservoir gridblocks.
2. nEquations (int) - number of ‡ow equations (3 * nBlocks).
3. F (PVTProperties *) - provides PVT properties and derivatives.
100
RelativePermCapPressData
+ dKrgdSg : DFLEXARRAY
+ dKrgodSg : D2FLEXARRAY
+ dKrodSg : DFLEXARRAY
+ dKrodSw: DFLEXARRAY
+ dKrwdSw: DFLEXARRAY
+ dKrwodSw: D2FLEXARRAY
+ dPcgodSg : D2FLEXARRAY
+ dPcowdSw: D2FLEXARRAY
+ Krg : DFLEXARRAY
+ Krgo : D2FLEXARRAY
+ Kro : DFLEXARRAY
+ Krw: DFLEXARRAY
+ Krwo : D2FLEXARRAY
+ nData : int
+ Pcgo : D2FLEXARRAY
+ Pcow: D2FLEXARRAY
FlowEquationBuilder
# F : PVTProperties* = NULL
# g : FiniteDifferenceGrid*
# M: UMFSparseMatrix
# nBlocks : int
# nEquations : int = 0
# PVTProps : D2FLEXARRAY
# PVTSlopes : D2FLEXARRAY
# R : ThreePhaseRelativePermeabilityCapPress*
# RHS : DFLEXARRAY
# RPD : RelativePermCapPressData*
# Solution : DFLEXARRAY
# Tg : D2FLEXARRAY
# To : D2FLEXARRAY
# Tw: D2FLEXARRAY
# WaterProps : D2FLEXARRAY
# WaterSlopes : D2FLEXARRAY
+ ScaleJacobianMatrix() : void
+ SolveFlowEquations() : bool
+ UpdateFlowEquations() : bool
+ UpdateResidualEquations() : bool
Figure 2.4: Members and Functionality of the Flow Equation Builder Class
101
4. g (FiniteDi¤erenceGrid *) - provides geometric information, di¤erence op-
erators, block volumes, porosities, permeabilities, etc.
5. M (UMFSparseMatrix) - storage and solution methods for the sparse Ja-
cobian matrix.
Functionality
1. U pdateResidualEquations - computes the residual of the ‡ow equation
at the current solution guess; (see Eqs. 1.75, 1.92 and 1.105).
2. U pdateF lowEquations - computes the Jacobian matrix at the current
solution guess.
3. SolveF lowEquations - applies Newton iteration to solve the ‡ow problem
at the current timestep.
102
Simulator
# FEB : FlowEquationBuilder* = NULL
# Fluid : PVTProperties*
# GBVNewIteration : GridblockVariables* = NULL
# GBVOldIteration : GridblockVariables* = NULL
# GBVOldTstep : GridblockVariables* = NULL
# Grid : FiniteDifferenceGrid* = NULL
- h2oProps : DFLEXARRAY
- pvtProps : DFLEXARRAY
# RelPerm : ThreePhaseRelativePermeabilityCapPress* = NULL
+ DumpRestartData() : void
+ OutputResults() : void
+ RunSimulation() : void
+ SolveFlowProblem() : bool
+ UpdateGridblockVariables() : void
# Initialize() : void
# InitializeFromFluidContactData() : void
# ReadInitializiationData() : void
Functionality
1. Initialize - sets all gridblocks to initial values either using average data,
data from a previous run (ReadInitializationData), or gas-oil and water-
oil contact data (InitializeF ormF luidContactdata).
2. RunSimulation - sets the timestep and calls SolveF lowP roblem; respon-
sible for checking convergence, adjusting timesteps and outputting results.
3. SolveF lowP roblem - interacts with the F lowEquationBuilder object to
solve the problem using Newton’s method.
4. OutputResults - writes results from the timestep to a …le.
5. DumpRestartData - writes variables at all gridblocks to a …le that can
be later read in to initialize the simulator.
103
3. Read simulator data and create all simulator objects - i.e., the FiniteDif-
ferenceGrid object, the FlowEquationBuilder object, etc.
4. Initialize all gridblock variables; set the old time value to 0.
5. Set the initial timestep.
6. Set the current time value to the old time plus the current time step. If
the current time is greater than the required simulation time, stop.
7. Try to solve the ‡ow problem at the current timestep. If this fails, cut the
timestep to 70% of its original value and try again. Stop the simulation
if we make more than 5 consecutive timestep cuts, or if the timestep falls
below a threshold value.
8. If the solution is successful, output the results and update the values of
the gridblock variables at the old timestep to their current values. Update
the old time to the current time.
9. Set the new time step. (For simplicity we can use a geometric sequence of
timesteps, i.e.,
tn+1 = tn+1
where > 1:) Go to step 6.
104
Chapter 3
3.1 Introduction
Up to this point we have treated the well as a set of sources or sinks in the
reservoir simulator gridblocks without regard to ‡ow in the well. Note that in
addition to conducting ‡uids along a path to the surface, the physical wellbore
enables hydraulic contact (and potential ‡ow) between non-adjacent reservoir
gridblocks. We could try to incorporate the wellbore into the reservoir simulator
in a fully implicit formulation, however, this approach presents some serious
drawbacks: (i) the structure of the Jacobian matrix will depend on the path
of the well and the positions of the perforations. This means that the sparse
matrix structure will not be easily predictable, and will vary from case to case.
Writing a general program in this case would be di¢ cult. (ii) The elements of the
Jacobian matrix for reservoir ‡ow can be calculated e¢ ciently using analytical
formulae and table lookups; this is not the case for pipe ‡ow. In general, partial
derivatives of the equations governing pipe ‡ow must be determined numerically.
This would be extremely ine¢ cient in a fully coupled well/reservoir system. In
view of the stated drawbacks, we will model our wellbores separately, then
couple the reservoir and well systems externally. We will detail this coupling in
the following chapter.
In real wells, the well trajectory through the reservoir is often neither vertical
nor horizontal, and the well path will not in general run parallel to any of the
reservoir axes. Further, the well may be completed using advanced techniques
aimed at controlling the in‡ow of sand and coning of gas and water. The
resulting ‡ow in the wellbore may be much more complex than simple ‡ow
in a straight pipe with the well exchanging ‡uids with the reservoir along the
length of the wellbore. In this section, we focus on wells that can be viewed as
single pipes with perforations at various points along their lengths. Although
this system is very simple and can be modeled in an equally simple manner,
we will introduce pipe ‡ow modeling concepts that can be applied to much
more complicated well completions, so that reservoirs incorporating wells with
105
advanced completions could be modeled in a similar manner.
106
Reservoir Node
Heel Toe
Base Pipe
f g h i
4 5 6 7
a 0 b 1 c 2 d 3 e
Figure 3.2: Ordered nodes and arcs for the simple well.
m
_1 m
_2=m
_5 (3.2)
m
_2 m
_3=m
_6 (3.3)
m
_3=m
_7 (3.4)
Note that if the mass rates in arcs 4 - 7 are known, all arc rates are known. In
order to solve for the mass rates in arcs 4-7, we need 4 pressure loss equations;
these are:
pf p4 (m_ 4) p0 (m_ 0 ) pa = 0 (3.5)
pg p5 (m
_ 5) p1 (m
_ 1) p0 (m
_ 0) pa = 0 (3.6)
ph p6 (m
_ 6) p2 (m
_ 2) p1 (m
_ 1) p0 (m
_ 0) pa = 0 (3.7)
and
pi p7 (m
_ 7) p3 (m
_ 3) p2 (m
_ 2)
p1 (m
_ 1) p0 (m
_ 0) pa = 0 (3.8)
Equations 3.1 - 3.8 are 8 equations (4 of which are nonlinear) in the unknown
7
mass rates fm_ i gi=0 : The nonlinear equations can be solved using the restricted
step Newton algorithm of Due‡hard[15]; see Appendix C. The algorithm for
solving the system of equations is as follows:
107
1. Guess the mass rates in arcs 4-7; e.g., 1000 lbm/day.
2. Compute all remaining mass rates from Eqs. 3.1 - 3.4.
3. Compute the residuals of Eqs. 3.5 - 3.8, and compute the Newton cor-
7
rections for fm
_ i gi=4 : If the sizes of these corrections is su¢ ciently small
stop.
4. Update the mass rates in arcs 4 - 7 and go to step 2.
108
3.3.3 Speci…ed Heel Rate
The discussion we have presented so far implicitly assumed that the pressure was
speci…ed at the heel of the well. The problem changes slightly if rate is speci…ed
at the heel of the well. In this case, there is one less unknown mass rate and one
less pressure equation. For the system in Fig. 3.2, the pressure equations are
obtained by eliminating the outlet pressure from three of the equations, e.g., by
di¤erencing Eqs. 3.5 and 3.6, and 3.6 and 3.7 to obtain
pf pg + p5 (m
_ 5) p4 (m
_ 4) + p1 (m
_ 1) = 0 (3.9)
pg ph + p6 (m
_ 6) p5 (m
_ 5) + p2 (m
_ 2) = 0 (3.10)
and
pi p7 (m
_ 7) p3 (m
_ 3) p2 (m
_ 2)
p1 (m
_ 1) p0 (m
_ 0) pa = 0 (3.11)
Note that Eqs. 3.9 and 3.10 do not include the heel pressure (which is unspec-
i…ed) but we retain Eq. 3.8. We compute Eqs. 3.9 and 3.10 by starting at
the reservoir node “f”(or “g”), computing the pressure drop in the direction of
‡ow to the outlet node “a”, then working backward to the neighboring reservoir
node “g” (or “h”). For Eq. 3.8, we use the last available estimate of the well
heel pressure and work backwards to the reservoir node “i”. We have found
that this procedure facilitates convergence of the nonlinear equations.
To complete this section we describe modi…cations to the total mass rate
equations under di¤erent speci…ed rate conditions.
109
where NRES is the number of reservoir nodes that admit ‡ow to the network.
For our example network, we would write
m
_ 15
=
o;sc + GLR n (1 + W OR n) + W ORn w;sc
g;sc
m
_ 16
qo;sp eci…ed
o;sc + GLR o (1 + W OR o ) g;sc + W ORo w;sc
m_ 17
o;sc + GLRp (1 + W ORp ) g;sc + W ORp w;sc
m_ 18
(3.16)
o;sc + GLRq (1 + W ORq ) g;sc + W ORq w;sc
or
m_ i GLRi (1 + W ORi ) g;sc
m
_ g;i = (3.19)
o;sc + GLR i (1 + W ORi ) g;sc + W ORi w;sc
110
and our constraint equation assumes the form
NX
RES
m
_ i W ORi
= qw;sp eci…ed (3.24)
i=1 o;sc + GLR i (1 + W ORi ) g;sc + W ORi w;sc
m
_i=m
_ sp eci…ed (3.26)
i=1
The approach of solving the well model can be generalized to very complex
well completions; see Ref. [33].
For simplicity, we assume that there is no pressure drop in the perforations. Here
we summarize the basic equations for computing pressure drops in pipes[27].
The pressure gradient due to ‡uid ‡ow in a pipe is made up of three compo-
nents: the gravitational gradient (due to pipe inclination from the horizontal),
the frictional component resulting from shear resistance to ‡ow and the ac-
celeration component which results from velocity changes due to expansion or
contraction of the ‡uids (e.g., for ‡ow through nozzles or expansion …ttings).
For ‡ow in pipes with constant diameter, acceleration gradients are small, and
they will be neglected.
The gravitational gradient for a homogeneous mixture is given by
dp mix g
= sin psi/ft (3.27)
dL g 144gc
lbm
where mix is the homogeneous mixture density, f t3 , g is the acceleration due
ft 2 2
to gravity, 32.2 sec2 ;
144 converts f t to inch , gc is a units conversion factor
lbm f t
(32.2 lbf sec2 ), and (radian) is the angle of inclination of the pipe segment
from the horizontal in the direction of ‡ow. For a three-phase mixture, the
homogeneous mixture density is computed using
mix = o o + w w + (1 o w) g (3.28)
111
where o and w are the “no-slip”holdups of oil and water respectively. These
are de…ned as
qo
o = (3.29)
qt
and
qw
w = (3.30)
qt
where qo , qw and qg are the in situ volumetric rates of oil water and gas respec-
f t3
tively (all in the same units, e.g., day ), and
qt = qo + qw + qg : (3.31)
dp f mix v 2t
= psi/ft (3.32)
dL f 288gc D
where f is the Moody friction factor at average conditions in the pipe segment,
D is the pipe diameter (f t) and v t is the average mixture velocity in the segment
ft f t3
sec : For phase rates (qo , qw and qg ) in day ,
qt
vt = : (3.33)
D 2
86400 2
1488 mix v t D
NRe = ; (3.34)
mix
mix = o o + w w + (1 o w) g (3.35)
" 18:7
f = 1:74 2 log10 + p (3.36)
D NRe f
Note that this equation is nonlinear; it is easily solved using the following algo-
rithm.
112
3. Check whether jfguess fnew j < ; where is a small tolerance, e.g., 10 8 :
If the inequality is satis…ed, the required friction factor is fnew ; otherwise,
set fguess = fnew and go to step 2.
The algorithm for computing pressure drop in a pipe with a given rate is as
follows:
1. Starting with a known pressure at one end of the pipe, guess the pressure
at the other end. (To start we could set outlet pressure equal to inlet
pressure.)
2. Compute the average pressure in the segment
pin + pout
p= (3.37)
2
3. Compute PVT properties at the average pressure, and the in situ phase
‡ow rates.
4. Compute the Reynolds number and friction factor at average conditions.
Calculate the pressure gradient using
dp dp dp
= + (3.38)
dL total dL g dL f
dp
pout = pin L (3.39)
dL total
The design of the classes used to model the well is left as an exercise for the
reader.
113
Chapter 4
4.1 Introduction
At this point, we have described two independent models: the …rst for a reservoir
simulator that produces ‡uids via an arbitrarily located set of sinks, and the
second for a steady-state wellbore that exchanges ‡uid along its length with
an external source (i.e., the reservoir). We are now faced with the problem of
coupling the two disparate models at the points where they physically connect
(i.e., at the perforations). The …rst problem that we must address is the fact that
the geometries of the two systems need not match in any way; that is, wellbores
are usually made up of connected pipe joints which are typically about 40 ft
long that may meander in almost any direction; reservoir gridblocks can have
almost any dimensions depending on the …neness of the scale that we wish to
simulate and the faces of the gridblocks are aligned with the principal axes.
Our …rst problem is therefore: given the well trajectory as a sequence of spatial
coordinates, determine how the reservoir gridblocks dissect the well path and
break it into segments that …t exactly into each intercepted gridblock. During
this process, we must generate a mapping of wellbore arc indices to reservoir
gridblock indices and vice versa. Fig. 4.1 illustrates the problem for an arbitrary
horizontal well path through a two-dimensional grid. Clearly the reservoir grid
does not automatically coincide with the wellbore trajectory, so that parts of
a given 40-ft well segment will lie in one gridblock, while other parts will be
in completely di¤erent gridblocks. Further, it is possible that a single reservoir
gridblock may contain several pieces of di¤erent pipe segments. Note that in
3-dimensional problems, the well path is also three dimensional, so the path
may also intersect di¤erent vertical gridblocks.
Once the geometric mapping between well segments and reservoir gridblocks
has been obtained, we must devise a scheme to hydraulically connect the well
segments with the corresponding perforated gridblocks. To do this e¢ ciently,
114
Well path
x = xi 1
2
; x = xi+ 21 ;
y = yj 1
2
; y = yj+ 12 ;
z = zk 1
2
; z = zk+ 12 :
There are three possibilities: (A) the well segment lies totally within the grid-
block; (B) the well segment cuts a single face of the block; (C) the well segment
cuts two gridblock faces. (It is not physically possible for a straight line to
cut three faces of a rectangular parallelepiped gridblock.) The length of the
segment that is within the gridblock obviously depends on the number of cuts
and their coordinates. We can view the well path as a list of segment endpoint
coordinates, and our task is to subdivide this list into a new list of endpoint
115
yj+1/2 Xpe
B
Xpe
X ps
xi-1/2 xi+1/2
A
Xpe
X ps
yj-1/2 C
X ps
116
A. Determine the coordinates of the intersection point of the
line and the face. From basic analytic geometry[4], if a point
lies on the line connecting Xps and Xpe , we must have
x xps = t (xpe xps ) ; (4.3)
y yps = t (ype yps ) ; (4.4)
and
z zps = t (zpe zps ) ; (4.5)
where t is a parameter. If, for example, we know that the
line intersects the plane at x = xis 21 ; we can compute t from
xis 1
2
xps
t= (4.6)
xpe xps
and compute the y and z coordinates of the intercept
using Eqs. 4.4 and 4.5. Similar logic applies to the other
planes. Denote the coordinates of the intercept point by
XpInt :
B. Map the well sub-segment that lies between X ^ ps and XpInt
^
to the reservoir gridblock, and set Xps = XpInt :
iv. Continue
(c) Continue
2. Continue
At this stage we have a mapping of all the well sub-segments in the reservoir
gridblocks. We now recreate the well trajectory so that it re‡ects well segments
that …t exactly into reservoir gridblocks; there is now one to one correspondence
between well segments and reservoir gridblocks. We use the generated set of
well subsegments to set up sinks (or sources) in the reservoir using the methods
described in Chapter 2.
We assume that from the reservoir point of view, the pressure along a single pipe
subsegment is uniform and equal to the average pressure in that subsegment.
Fluid transfer between the reservoir gridblocks and the well subsegment is cal-
culated based on the average subsegment pressure; in this way we account for
varying ‡uid transfer along an actual pipe segment from areas with low or high
transmissibilities. We link the wellbore and reservoir simulators by requiring
that the pressures at their interfaces be the same, and solving both simulators
iteratively for the required rates. There are several possible methods for doing
this; here we describe an algorithm based on the method employed by Refs. [6]
and [5].
117
1. Initialize the simulator by setting a small mass ‡ow rate (e.g., 1000 lbm/d)
at each well subsegment. This is done to obtain initial estimates of the
interface pressures between the reservoir and the wellbore as well as the
‡owing gas-oil and water oil ratios, all of which are needed for the wellbore
model run.
2. Using the pressures and GORs and WORs from the simulator, run the
wellbore model to obtain the mass rates at each reservoir node. Compute
the di¤erences between the reservoir and network rates at the connecting
nodes using
v
unconnections
u X 2
=t (mReservoir;j mW ellbore;j ) (4.7)
j=1
This method is fast and simple, and usually converges to the correct solution.
Other methods of coupling the simulators are much more calculation intensive,
and are beyond the scope of this course. The design of the object code for the
interface is left as an exercise for the reader.
118
Bibliography
119
[13] Timothy A. Davis, Algorithm 832: UMFPACK v4.3— an unsymmetric-
pattern multifrontal method, ACM Transactions on Mathematical Software
(TOMS) 30 (2004), no. 2, 196–199.
[14] , UMFPACK version 5.4.0 user guide, Tech. report, Dept. of
Computer and Information Science and Engineering Univ. of Florida,
Gainesville, FL, May 2009.
[15] P. Deu‡hard, Newton methods for nonlinear problems - a¢ ne invariance
and adaptive algorithms, Springer Series in Computational Mathematics,
Springer-Verlag Berlin Heidelberg, 2004.
[16] P. M. Dranchuk and J. H. Abou-Kassem, Calculations of z-factors for nat-
ural gases using equations of state, Journal of Canadian Petroleum Tech-
nology 14 (1975), no. 3, 34.
[17] D.P. Bossler E.F. Johnson and V.O. Naumann, Calculation of relative per-
meability from displacement experiments, JPT (1959), 61–63.
[18] K. Goto, GotoBLAS (basic linear algebra subroutines),
http://www.tacc.utexas.edu/resources/software.
[19] K. R. Hall and L. Yarborough, A new EOS for z-factor calculations, Oil
and Gas Journal (1973), 82.
[20] Jr. J.E. Dennis and Robert B. Schnabel, Numerical methods for uncon-
strained optimization and nonlinear equations, Classics In Applied Mathe-
matics, SIAM, Philadelphia, 1996.
[21] T. Kartoatmdojo and Z. Schmidt, New correlations for crude oil physical
properties, paper SPE 23566, June 1991.
[22] E.F. Nelson K.M. Watson and G.B. Murphy, Characterization of petroleum
fractions, Ind. Eng. Chem. 27 (1935), 1460.
[23] K. Lucas, Die druckabhangigkeit der viskositat von ‡ussigkeiten - ein ee-
infache abschatzung (pressure dependence of viscosity of liquids - a simple
estimate), Chem. Eng. Tech. 53 (1981), 959.
[24] R.C. MacDonald and K.H. Coats, Methods for numerical simulation of
water and gas coning, SPEJ (1970), 425–436.
[25] S. Mochizuki, Well productivity for arbitrarily inclined well, SPE Reservoir
Simulation Symposium, 12-15 February 1995.
[26] D. W. Peaceman, Interpretation of well-block pressures in numerical reser-
voir simulation with nonsquare grid blocks and anisotropic permeability,
SPEJ (1983), 531–543, Paper SPE 10528.
[27] Ovadia Shoham, Mechanistic modeling of gas-liquid two-phase ‡ow in pipes,
Society of Petroleum Engineers, 2005.
120
[28] M. B. Standing, Volumetric and phase behavior of oil …eld hydrocarbon
systems, 9th ed., Society of Petroleum Engineers, Richardson, Texas, 1981.
[29] M.B. Standing and D.L. Katz, Density of natural gases, Transactions of
AIME 146 (1942), 140.
[30] H.L. Stone, Probablility model for estimating three-phase relative perme-
ability, Journal of Petroleum Technology (1970), 214.
[31] , Estimation of three-phase relative permeability and residual oil
data, Journal of Canadian Petroleum Technology 12 (1973), no. 4, 53.
[32] R.P. Sutton, Compressibility factors for high-molecular weight reservoir
gases, paper SPE 14265 presented at the 1985 SPE Annual Technical Con-
ference and Exhibition, 22-25 September 1985.
[33] Leslie Thompson and Kristian Brekke, Modeling of ‡ow in a near-wellbore
network, Proceedings of the ASME 2009 28th International Conference on
Ocean, O¤shore and Arctic Engineering, May 31st - June 5th 2009.
[34] Jamal H. Abou-Kassem Turgay Ertekin and Gregory R. King, Basic ap-
plied reservoir simulation, SPE Textbook Series Vol., Society of Petroleum
Engineers, Richardson, Texas, 2001.
[35] M. Vazquez and H. D. Beggs, Correlations for ‡uid physical property pre-
diction, Journal of Petroleum Technology (1980), 650.
[36] K.M. Watson and E.F. Nelson, Improved methods for approximating critical
and thermal properties of petroleum, Ind. Eng. Chem. 25 (1933), no. 8, 880.
[37] L. Weimann, Error based damped newton algorithm,
http://www.zib.de/Numerik/numsoft/NewtonLib, June 2006.
[38] , Error based quasi-newton algorithm,
http://www.zib.de/Numerik/numsoft/NewtonLib/qnerr/qnerr.c, June
2006.
[39] Curtis H. Whitson and Michael R. Brule, Phase behavior, Henry L. Doherty
Series, Society of Petroleum Engineers, Richardson, Texas, 2000.
[40] E. Wichert and K. Aziz, Calculate zs for sour gases, Hydrocarbon Process-
ing (1972), 119–122.
[41] Jr. William D. McCain, The properties of petroleum ‡uids, 2nd ed., Pen-
nWell Publishing Company, Tulsa, Oklahoma, 1990.
121
Appendix A
PVT Correlations
Here we summarize some of the most common correlations used by the oil
industry to generate black oil PVT properties in the absence of actual laboratory
data; a more complete set may be found in Appendix B of Ref. [7] and in Ref.
[39].
A.1.1 Standing[28]
The Standing correlation for computing solution gas-oil ratio (scf/STB) is
h p i1:2048
Rs = g + 1:4 100:0125AP I 0:00091T (A.2)
18:2
where g is the gas speci…c gravity (air = 1), p is the pressure in psia, AP I is
the stock tank oil API gravity (water = 10) and T is the system temperature
in o F.
5 psep
g100 = g 1 + 5:912 10 (AP I) T log (A.3)
114:7
122
where g is the separator gas speci…c gravity, AP I is the stock tank oil API
gravity, Tsep is the separator temperature in o F and psep is the separator pressure
in psia. Their correlation for solution gas-oil ratio is
C2 C3 AP I
Rs = C1 g100 p exp (A.4)
T + 460
where p is the pressure in psia and T is the system temperature in o F and
Coe¢ cient AP I 30 AP I > 30
C1 0.0362 0.0178
C2 1.0937 1.1870
C3 25.7245 23.931
where Bob is the oil formation volume factor at the saturation pressure, co is the
coe¢ cient of isothermal compressibility for the oil psi 1 ; pbub is the saturation
pressure, psia and p is the system pressure, psia.
123
A.2.1 Standing[28]
At pressures below the bubble point pressure, the Standing correlation is given
by
" #1:2
0:5
g
Bo = 0:9759 + 0:00012 Rs + 1:25T (A.8)
o
where g is the gas speci…c gravity (air = 1), o is the oil speci…c gravity (water
scf
= 1), Rs is the solution gas-oil ratio in ST B and T is the system temperature
o
in F.
AP I
Bo = 1 + C1 Rs + (T 60) (C2 + C3 Rs ) (A.9)
g100
where g100 is given by Eq. A.3, AP I is the oil API gravity (water = 10), Rs
scf o
is the solution gas-oil ratio in ST B and T is the system temperature in F and
Coe¢ cient AP I 30 AP I > 30
C1 4.677 10 4 4.670 10 4
C2 1.751 10 5 1.100 10 5
C3 -1.811 10 8 1.337 10 9
where
F = Rs0:755 0:25
g100 o
1:5
+ 0:45T (A.11)
and g100 is given by Eq. A.5, o is the oil speci…c gravity (water = 1), Rs is
scf o
the solution gas-oil ratio in ST B and T is the system temperature in F.
124
where o;bub is the viscosity at the saturation pressure, pbub , ddpo is the derivative
cp
of oil viscosity with respect to pressure above the saturation pressure ( psi ) and
p is the pressure of interest, psia, with p pbub: This is a deviation from the
standard PVT correlations which provide corrections from saturated to under-
saturated conditions. For the purpose of reservoir simulation we assume that
the above correction is adequate.
A.3.1 Standing[28],[39]
Whitson[39] recommends the following correlation due to Standing for deter-
mining “dead” oil viscosity i.e., viscosity of oil with no dissolved gas, when the
Watson characterization factor[36],[22], Kw is known,
oD 1
log = 2:17 (A.13)
8:24
o A3 Kw + 1:639A2 1:059
o
where
(2:87A1 1) o
A3 = 0:1285 (A.14)
2:87A1 o
T + 460
A2 = 1 + 0:554 log (A.15)
560
T + 460
A1 = 1 + 8:69 log (A.16)
560
gm
and o is the oil speci…c gravity (water = 1), o is the oil density ( cm3 ), and T
o
is the system temperature in F. The dead oil viscosity is converted to viscosity
at saturated conditions using[28]
a2
o = a1 oD (A.17)
where 4 7
7:4 10 Rs +2:2 10 Rss
a1 = 10 (A.18)
and
0:68 0:25 0:062
a2 = 5R + 3R + 3R (A.19)
108:62 10 s 101:1 10 s 103:74 10 s
scf
where Rs is the solution gas-oil ratio in ST B :
125
where
0:000845Rs 0:43+0:5165y
f = 0:2001 + 0:8428 10 oD (A.22)
and
0:00081Rs
y = 10 (A.23)
A.4.1 Sutton[32]
Given the speci…c gravity of the reservoir gas, g , its critical properties are
estimated from
Tc = 169:2 + 349:5 g 74 2g (A.26)
and
2
pc = 756:8 131 g 3:6 g (A.27)
A.4.2 Standing[28]
Standing provides two sets of correlations for hydrocarbon gases. For dry hy-
drocarbon gases, g < 0:75, the equations are
2
Tc = 168 + 325 g 12:5 g (A.28)
and
2
pc = 667 + 15 g 37:5 g (A.29)
For wet gases, the appropriate equations are
2
Tc = 187 + 330 g 71:5 g (A.30)
and
2
pc = 706 51:7 g 11:1 g (A.31)
126
A.4.3 Acid Gas Correction[40]
For sour hydrocarbon gases, the critical properties estimated using the equations
above must be adjusted to account for the presence of hydrogen sul…de and/or
carbon dioxide. This is a three step process; …rst, the speci…c gravity of the gas
without non-hydrocarbons () must be calculated using
where yH2 S ; yN2 and yCO2 are respectively the mole fractions of hydrogen sul…de,
nitrogen and carbon dioxide in the mixture and MH2 S (34.08), MN2 (28.0134),
MCO2 (44.01) and Mair (28.9625) are the molecular weights of hydrogen sul-
…de, nitrogen, carbon dioxide and air respectively. Hydrocarbon gas critical
properties (TcHC and pcHC )are calculated based on gHC using the previous
correlations. Non-hydrocarbon gas components are reincorporated into the
mixture using the following equations:
Tc = (1 yH2 S yN2 yCO2 ) TcHC + TcH2 S yH2 S + TcN2 yN2 + TcCO2 yCO2 ;
(A.33)
where where TcH2 S (672.32 o R); TcN2 (227.36 o R) and TcCO2 (547.78 o R) are
respectively the critical temperatures of hydrogen sul…de, nitrogen and carbon
dioxide.
pc = (1 yH2 S yN2 yCO2 ) pcHC + pcH2 S yH2 S + pcN2 yN2 + pcCO2 yCO2 ;
(A.34)
where where pcH2 S (1300. psia); pcN2 (493.1 psia) and pcCO2 (1071. psia)
are respectively the critical pressures of hydrogen sul…de, nitrogen and carbon
dioxide.
Finally, Aziz and Wichert introduced a temperature correction, ",
0:9 1:6 0:5 4
" = 120 (yH2 S + yCO2 ) (yH2 S + yCO2 ) + 15 yH 2S
yH 2S
(A.35)
The corrected critical properties are then calculated from the uncorrected values
using
Tcc = Tc " (A.36)
and
pc Tcc
pcc = (A.37)
Tc + yH2 S (1 yH2 S ) "
127
A.5.1 Hall and Yarborough[19]
The z-factor is computed from the reduced pressure and temperature as
2
exp 1:2 (1 t)
z = 0:06125pr t (A.38)
y
where
1
t= (A.39)
Tr
and y is the root of the equation
f (y) = a + b + c + d = 0 (A.40)
where
2
a= 0:06125pr t exp 1:2 (1 t) (A.41)
((( y + 1) y + 1) y + 1) y
b= 3 (A.42)
(1 y)
c= ((4:58t 9:76) t + 14:76) ty 2 (A.43)
2:18+2:82t
d = ((42:4t 242:2) t + 90:7) ty (A.44)
We solve Eq. A.40 using Newton’s method via
f (y o )
yn = yo (A.45)
f 0 (y o )
where
f 0 (y) = + + (A.46)
and
((((y 4) y + 4) y + 4) y + 1)
= 4 (A.47)
(1 y)
= ((9:16t 19:52) t + 29:52) ty (A.48)
1:18+2:82t
= (2:18 + 2:82t) ((42:4t 242:2) t + 90:7) ty (A.49)
As a …rst guess form the root, we use
2
y o = 0:06125pr t exp 1:2 (1 t) (A.50)
128
A.5.2 Dranchuk and Abu Kassem[16]
The Dranchuk and Abu Kassem implicit equation for gas z-factor is given by
where
A2 A3 A4 A5
= A1 + + 3 + 4 + 5 r (A.52)
Tr Tr Tr Tr
A7 A8 2
= A6 + + 2 r (A.53)
Tr Tr
A7 A8 5
= A9 + 2 r (A.54)
Tr Tr
2
2 r 2
= A10 1 + A11 r exp A11 r (A.55)
Tr3
and r is the reduced density given by
0:27pr
r = ; (A.56)
zTr
that is, z is the root of Eq. A.51. The coe¢ cients A1 A11 are given by
A1 = 0:3265 A7 = 0:7361
A2 = 1:07 A8 = 0:1844
A3 = 0:5339 A9 = 0:1056
A4 = 0:01569 A10 = 0:6134
A5 = 0:05165 A11 = 0:721
A6 = 0:5475
Equation A.51 is solved using Newton’s method. The derivative function
f 0 (z) is given by
d
f 0 (z) = (a + b + c) r 1 (A.57)
dz
where
A5 A6 r A4 A3
a=2 + 4 + 3 + A8 2 5A9 3r r2 (A.58)
Tr5 Tr Tr Tr
A7 2 5A9 3r r + A2
b= + A1 (A.59)
Tr
2 4 2
2A10 A11 r A11 r +1 r exp A11 r
c= (A.60)
Tr3
and
d r r
= (A.61)
dz z
The initial guess for the z-factor is z = 1:
129
A.6 Gas Formation Volume Factor
The gas formation volume factor is de…ned as the reservoir volume of gas re-
f t3
quired to yield a unit volume at standard conditions; units are scf : It is calcu-
lated from
0:0282z (T + 460)
Bg = (A.62)
p
where temperature is in o F and pressure is in psia. The z-factor is determined
using one of the previous correlations.
A.7.1 Lee-Gonzalez[3]
According to Whitson[39], this is the correlation most used by PVT laboratories
to report gas viscosity. The equations are
4 A3
g = A1 10 exp A2 g (A.63)
where
(9:379 + 0:01607Mg ) T 1:5
A1 = (A.64)
(209:2 + 19:26Mg + T )
986:4
A2 = 3:448 + 0:01009Mg + (A.65)
T
and
A3 = 2:447 0:2224A2 (A.66)
gm
where Mg is the molecular weight of the gas, g is the gas density in cm3 and
temperature, T is in o R:
A.7.2 Lucas[23]
The following viscosity correlation is valid in the range 1 < Tr < 40 and 0 <
pr < 100 :
g A1 p1:3088
r
=1+ 1 (A.67)
gsc A2 pA
r + 1 + A3 pr
5 A4
where
3 0:3286
1:245 10 exp 5:1726Tr
A1 = (A.68)
Tr
A2 = A1 (1:6553Tr 1:2723) (A.69)
37:7332
0:4489 exp 3:0578Tr
A3 = (A.70)
Tr
130
7:6351
1:7368 exp 2:2310Tr
A4 = (A.71)
Tr
A5 = 0:9425 exp 0:1853Tr0:4489 (A.72)
and
9 13
Vwp = ((1:95301 10 +1:72834 10 p)T +(3:58922e 7+2:25341 10 10 p))p:
(A.76)
Then
Bw = (1 + VwT )(1: + Vwp ): (A.77)
A.8.2 Viscosity
For a given water salinity, S (weight percent solids), we …rst calculate the water
viscosity (in centipoise) at atmospheric pressure, w;atm ; as follows:
w;atm = AT B (A.78)
131
and
6 5 4 2
B = (((1:5586 10 S 5:47119 10 )S 6:79461 10 )S+2:63951 10 )S 1:12166:
(A.80)
The viscosity (cp) at reservoir pressure is then computed using
w =C w;atm (A.81)
where
5 9
C = 0:9994 + p(4:0295 10 + 3:1062 10 p) (A.82)
and pressure is in psia.
A.8.3 Density
Water density at standard conditions ( lbm
f t3 ) is estimated using
3
wsc = 62:368 + (0:438603 + 1:60074 10 S)S (A.83)
where S is the salinity, (weight percent solids). The standard density is corrected
to reservoir conditions using the formation volume factor (see above) via
wsc
w = : (A.84)
Bw
132
Appendix B
Solution of Systems of
Nonlinear Equations Using
Error Oriented Descent
Our solution method for the system of nonlinear equations closely follows the
algorithm in Ref. [15] (page 148) and the code in Ref. [37]. Here we provide a
brief outline of the solution algorithm.
Given a system of n nonlinear equations F (x) ; our goal is to …nd the solu-
tion, xS ; such that
F (x) = 0 (B.1)
The L2 -norm of the vector x is de…ned as
r Pn
i=1 x2i
kxk2 = (B.2)
n
1. Evaluate F x0 :
2. Set a damping factor, 0 = 0:1; set a tolerance su¢ ciently above the
machine precision (e.g., =FLT_EPSILON); set a minimum allowable
dampening factor, min
3. For iteration index k = 0; 1; :::: do
F 0 xk xk = F xk (B.3)
133
where
xk = xk+1 xk (B.4)
xS = xk + xk (B.5)
where
k
xk 1
x
2 2
k = k k 1: (B.7)
k k 1
x x x
2 2
i. if k < min ; stop; the algorithm failed to converge.
(e) Compute the trial iterate
xk+1 = xk + k xk (B.8)
and
2
xk k
0 2
k = k+1
(B.11)
2 x (1 k) xk
2
(h) If k 1; set
0 0 1
k = k = min k; k (B.12)
2
i. if k < min ; stop; the algorithm failed to converge.
ii. Go to step (3e.)
Otherwise, let
0 0
k = min (1; k) (B.13)
0
(i) If k = k =1
134
k+1
i. If x < ; stop; the solution is
2
k+1
xS = xk+1 + x (B.14)
ii. if k < 12 , switch to the Quasi-Newton algorithm below.
0 0
Otherwise, if k 4 k, set k = k and go to step (e).
k+1
(j) Accept x as the new iterate and go to step (3) with k ! k + 1:
4. For k = 0; 1; 2:::::kmax
F 0 x0 v = F xk+1 (B.18)
(b) If k > 0
i. For i = 1; 2; :::k, compute
vT xi 1
= (B.19)
i 1
and set
v ! v+ xi (B.20)
135
(c) Compute
vT xk
k+1 = (B.21)
k
s
vT v
k = (B.22)
k
1
(d) If k > 2 stop; the algorithm failed to converge.
(e) Compute and store
v
xk+1 = (B.23)
1 k+1
2
k+1 = xk+1 (B.24)
2
p
(f) If k+1 stop. the solution is
136
Appendix C
C.1 Miscellaneous.h
/******************************************************************************\
*
* File: Miscellaneous.h
* Creation date: April 25, 2009 08:11
* Latest update: May 21, 2009 11:34
* Author: Leslie G. Thompson
* XXXX
* Purpose: Declaration of class ’Miscellaneous’
* CB version: ClassBuilder Version 2.9 (PR523)
*
\******************************************************************************/
#ifndef _MISCELLANEOUS_H
#define _MISCELLANEOUS_H
//@START_USER1
//@END_USER1
/*@NOTE_238
Collection of miscellaneous (static) functions
*/
/// Collection of miscellaneous (static) functions
class Miscellaneous
{
//@START_USER2
//@END_USER2
public:
/// Constructor method.
137
Miscellaneous();
/// Destructor method.
virtual ~Miscellaneous();
/// Sorts a vector in ascending or descending order using a bubble sort
/// algorithm - suitable for small vectors
static void BubbleSort(IFLEXARRAY& v, int size, bool Ascending = true);
/// function strips comments from a data file and returns number of lines of data
static int const_strip_comments(const char* name,
const char* filebak = "data.bak");
/// Computes the inner product of two vectors of size n
static double InnerProduct(DFLEXARRAY x, D2FLEXARRAY& y, int iCol, int n);
/// Computes the inner product of two vectors of size n
static double InnerProduct(DFLEXARRAY x, DFLEXARRAY& y, int n);
/// Based on "Numerical Recipes" by Press, Flannery, Teukolsky and Vetterling
/** (Cambridge University Press) p. 90 Given an array XX of length N and a given
value X, returns a value J such that X is between XX(J) and XX(J+1). XX must be
monotonic, either increasing or decreasing. -1 or N-1 is returned to indicate
that X is out of range. initialize upper and lower limits. if we are not yet
done, compute a midpoint and replace either the lower limit or upper limit as
appropriate. */
static int locate(DFLEXARRAY& xx, double x, int n);
/// Computes the 2-Norm of a given array of size n
static double Norm2(DFLEXARRAY& v, int n);
/// Computes the 2-Norm of a given array of size n
static double Norm2(D2FLEXARRAY& v, int iCol, int n);
/// Given an ASCII file, read and return the integer value in the last line
static int ReadLastLineOfFile(const char* InputFile);
/// Replaces a designated character in a character array with blank
static void RemoveCharacterFromString(char c, char* CharArray,
int ArrayLength);
};
#endif // ndef _MISCELLANEOUS_H
#ifdef CB_INLINES
#ifndef _MISCELLANEOUS_H_INLINES
#define _MISCELLANEOUS_H_INLINES
//@START_USER3
//@END_USER3
#endif // ndef _MISCELLANEOUS_H_INLINES
#endif // def CB_INLINES
C.2 Miscellaneous.cpp
/******************************************************************************\
*
138
* File: Miscellaneous.cpp
* Creation date: April 25, 2009 08:11
* Latest update: May 21, 2009 11:34
* Author: Leslie G. Thompson
\******************************************************************************/
//@START_USER1
//@END_USER1
#include "Miscellaneous.h"
//@START_USER2
#include <string.h>
//@END_USER2
/*@NOTE_243
Constructor method.
*/
Miscellaneous::Miscellaneous() //@INIT_243
{//@CODE_243
}//@CODE_243
/*@NOTE_239
Destructor method.
*/
Miscellaneous::~Miscellaneous()
{//@CODE_239
}//@CODE_239
/*@NOTE_3218
Sorts a vector in ascending or descending order using a bubble sort
algorithm - suitable for small vectors
*/
void Miscellaneous::BubbleSort(IFLEXARRAY& v, int size, bool Ascending)
{//@CODE_3218
int i, n;
n = size;
bool sorted = false;
while (!sorted)
{
sorted = true;
if (Ascending)
{
for (i = 0; i < n - 1; i++ )
{
if(v[i] > v[i+1] )
{
int temp = v[i];
v[i] = v[i+1];
v[i+1] = temp;
sorted = false;
}
139
}
// largest element is at the bottom
}else{
for (i = 0; i < n; i++ )
{
if(v[i] < v[i+1] )
{
int temp = v[i];
v[i] = v[i+1];
v[i+1] = temp;
sorted = false;
}
}
// smallest element is at the bottom
}
n = n - 1;
}
}//@CODE_3218
/*@NOTE_247
function strips comments from a data file and returns number of lines of data
*/
int Miscellaneous::const_strip_comments(const char* name, const char* filebak)
{//@CODE_247
// function strips comments from a data file and returns
// number of lines of data
// open input and output files
ifstream file1;
file1.open(name, ios_base::in);
ofstream file2;
file2.open(filebak, ios_base::out);
char ch[511]; // temporary data buffer
int count;
int nonBlank;
count = 0;
while (file1) { // read until end-of-file
file1.getline(ch, 511);
if(file1)
{
if (*ch != ’c’ && *ch != ’C’)
{ // write numeric data to DATA.BAK
int length = (int) strlen(ch);
nonBlank = 0;
for (int j = 0; j < length; j++)
{
// check to ensure that the line contains alphanumeric data
if (isalnum(int (ch[j])))
140
{
nonBlank++;
break;
}
}
if (nonBlank)
{
// remove commas from the line
RemoveCharacterFromString(’,’, ch, length);
file2 << ch << ’\n’;
count++;
}
} /* if ch */
}
} /* while ! file1 */
file1.close();
file2.close();
return count;
}//@CODE_247
/*@NOTE_1911
Computes the inner product of two vectors of size n
*/
double Miscellaneous::InnerProduct(DFLEXARRAY x, D2FLEXARRAY& y, int iCol,
int n)
{//@CODE_1911
double value = 0;
for (int i = 0; i < n; i++)
{
value += x[i] * y[iCol][i];
}
value /= n;
return value;
}//@CODE_1911
/*@NOTE_1916
Computes the inner product of two vectors of size n
*/
double Miscellaneous::InnerProduct(DFLEXARRAY x, DFLEXARRAY& y, int n)
{//@CODE_1916
double value = 0;
for (int i = 0; i < n; i++)
{
value += x[i] * y[i];
}
value /= n;
return value;
}//@CODE_1916
141
/*@NOTE_3386
Based on "Numerical Recipes" by Press, Flannery, Teukolsky and Vetterling
(Cambridge University Press) p. 90 Given an array XX of length N and a given
value X, returns a value J such that X is between XX(J) and XX(J+1). XX must be
monotonic, either increasing or decreasing. -1 or N-1 is returned to indicate
that X is out of range. initialize upper and lower limits. if we are not yet
done, compute a midpoint and replace either the lower limit or upper limit as
appropriate.
*/
int Miscellaneous::locate(DFLEXARRAY& xx, double x, int n)
{//@CODE_3386
/* Based on "Numerical Recipes" by Press, Flannery, Teukolsky and
* Vetterling (Cambridge University Press) p. 90 Given an array XX of
* length N and a given value X, returns a value J such that X is between
* XX(J) and XX(J+1). XX must be monotonic, either increasing or
* decreasing. -1 or N-1 is returned to indicate that X is out of range.
* initialize upper and lower limits. if we are not yet done, compute a
* midpoint and replace either the lower limit or upper limit as
* appropriate. */
int jl = 0;
int ju = n - 1;
while (ju - jl > 1)
{
int jm = (ju + jl) / 2;
if ((xx[n - 1] > xx[0]) == (x > xx[jm]))
{
jl = jm;
} else {
ju = jm;
}
}
/* repeat until the test condition is satisfied, then set the output and
* return */
return jl;
}//@CODE_3386
/*@NOTE_1908
Computes the 2-Norm of a given array of size n
*/
double Miscellaneous::Norm2(DFLEXARRAY& v, int n)
{//@CODE_1908
double value = 0;
int i;
for (i = 0; i < n; i++)
{
value += v[i] * v[i];
}
142
value = sqrt(value / n);
return value;
}//@CODE_1908
/*@NOTE_1921
Computes the 2-Norm of a given array of size n
*/
double Miscellaneous::Norm2(D2FLEXARRAY& v, int iCol, int n)
{//@CODE_1921
double value = 0;
int i;
for (i = 0; i < n; i++)
{
value += v[iCol][i] * v[iCol][i];
}
value = sqrt(value / n);
return value;
}//@CODE_1921
/*@NOTE_3516
Given an ASCII file, read and return the integer value in the last line
*/
int Miscellaneous::ReadLastLineOfFile(const char* InputFile)
{//@CODE_3516
int value;
ifstream fin(InputFile, ios_base::in);
char ch[512], chold[512]; // temporary data buffer
while (fin) { // read until end-of-file
fin.getline(ch, 512);
if (strlen(ch))
{
strcpy(chold, ch);
}
}
char *StopString;
value = strtol(chold, &StopString, 10);
fin.close();
return value;
}//@CODE_3516
/*@NOTE_775
Replaces a designated character in a character array with blank
*/
void Miscellaneous::RemoveCharacterFromString(char c, char* CharArray,
int ArrayLength)
{//@CODE_775
int i;
for(i = 0; i < ArrayLength; i++)
{
143
if(CharArray[i] == c)
{
CharArray[i] = ’ ’;
}
}
}//@CODE_775
144