UNIVERSITY OF OKLAHOMA GRADUATE COLLEGE EVALUATION OF EQUIVALENT CIRCULATING DENSITY OF DRILLING FLUIDS UNDER HIGH PRESSURE-HIGH TEMPERATURE CONDITIONS A THESIS SUBMITTED TO THE GRADUATE FACULTY in partial fulfillment of the requirement for the degree of MASTER OF SCIENCE (Petroleum Engineering) By Oluseyi Harris Norman, Oklahoma 2004
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
UNIVERSITY OF OKLAHOMA
GRADUATE COLLEGE
EVALUATION OF EQUIVALENT CIRCULATING DENSITY OF DRILLING
FLUIDS UNDER HIGH PRESSURE-HIGH TEMPERATURE CONDITIONS
A THESIS
SUBMITTED TO THE GRADUATE FACULTY
in partial fulfillment of the requirement for the
degree of
MASTER OF SCIENCE
(Petroleum Engineering)
By
Oluseyi Harris
Norman, Oklahoma
2004
EVALUATION OF EQUIVALENT CIRCULATING DENSITY OF
DRILLING FLUIDS UNDER HIGH PRESSURE-HIGH TEMPERATURE
1. FORMULATION OF THE PROBLEM .........................................................1 1.1. Introduction ..........................................................................................1
1.2. Literature Review .................................................................................3
1.3. Objectives and Scope of Work...........................................................13
1.4. Study Organization ...........................................................................14
2.FUNDAMENTAL CONCEPTS FOR ESTIMATION OF EQUIVALENT STATIC AND CIRCULATING DENSITY ....................................................15 2.1 Equivalent Static density ......................................................................15
2.6.2 Temperature Dependent Yield point..............................................35
2.7 Bingham Plastic Pressure Loss Equations......................................36
3.DRILLING FLUID TEMPERATURE PROFILE ESTIMATION ...................40 3.1 Heat Transfer in the Wellbore ..............................................................41
4.DEVELOPMENT AND VALIDATION OF THE DYNAMIC DENSITY SIMULATOR AND MODELLING OF DYNAMIC DENSITY .......................69 4.1 Program Lay-Out.............................................................................70
4.2 DDS Program Execution .................................................................71
4.2.1 General Well Parameters Form ...................................................71
4.2.2 Mud Properties Form ...................................................................77
4.2.3 Formation Properties Form ..........................................................77
4.2.4 Heat Transfer Coefficients Form..................................................77
4.2.5 Results and Results Form ...........................................................80
4.3 Equations used in DDSimulator Program........................................82
APPENDIX ..................................................................................................119 Code for DDSimulator Program ...............................................................119
vii
LIST OF TABLES TABLE PAGE
4.1 : Well and mud circulating properties for a gulf coast well…………….85
4.2 : Simulated Well Conditions………………………………………………92
4.3 : Results of Well Simulation………………………………………………92
4.4 : Well simulation results for parameters detailed in Table 4.2 with
gG = 0.015 oF/ft……………………………….……………..……….…..96
4.5 : Well simulation results for parameters detailed in Table 4.2 with
gG = 0.025 oF/ft………………………………………………….….……96
4.6 : Well simulation results for parameters detailed in Table 4.2 with
inlet fluid temperature = 80 oF……………..……………….….….…….97
4.7 : Well simulation results for parameters detailed in Table 4.2 with
Ua = heat transfer coefficient across annulus/formation interface
(Btu/hr-ft2-oF)
TF = formation Temperature (oF)
The temperature in the formation is given by the following equation20.
( ) ( )t
trzTr
trzTrrr
FF
∂∂
=⎟⎠⎞
⎜⎝⎛
∂∂
∂∂ ,,1,,1
α (3.35)
where
α = formation transmissivity (kF/ρcF)
kF = formation conductivity
ρ = formation density
cF = formation heat transfer coeeficient
Note that heat flow in the formation is assumed to occur radially only. At the
boundary of the formation, heat exchange between the formation and annulus
is governed by Eq. 3.36. The equation is derived by performing a heat
balance about a sufficiently small control volume within the formation adjacent
to the annulus.
52
@ r = ra
( ) ( ) ( ) ( )⎥⎦⎤
⎢⎣⎡
∂∂
+−−r
trzTkrtzTtrzTtzUr aFFaaaFaa
,,2,,,,2 ππ
( )t
trzTcrr aFFa ∂
∂∆=
,,2 ρπ (3.36)
The first term on the left hand side of Eq. 3.36 represents the rate at which
heat is leaving the formation boundary by convection (q1 in Fig. 3.2b). The
second term on the left hand side of the equation represents the rate at which
heat enters the control volume by conduction (q2 in Fig. 3.2b). The right-hand
side of Eq. 3.36 represents the rate at which heat accumulates in or is lost
from the control volume at the formation boundary, leading to changes in
temperature.
3.3.2 Discretizing Heat Flow Equations for Finite difference Analysis
The solution of the equations governing heat transfer in the wellbore
and formation will be propagated across the formation and well bore using the
finite difference grid shown in Fig. 3.3. The solution will be advanced starting
at the outer boundary of the formation in the r-direction until the temperature
field is mapped for the entire formation cross-section at a particular time-step.
The temperature in the wellbore and formation are expressed as follows.
Tp(z, t) = Tp(i∆z, n∆t) = ( )nipT
Ta(z, t) = Ta(i∆z, n∆t) = ( )niaT
TF(z, r, t) = Ta(i∆z, j∆r, n∆t) = ( )njiFT ,
53
r
j = 0 j = 1 j = 2 i = 0
i = 1
i = 2
i = 3
z
FormatioWellbore
Figure 3.3- Finite Difference Grid
54
where,
i = depth coordinate j = radial coordinate n = time coordinate
Two discretization schemes were considered for the equations describing
heat flow in the wellbore (3.33 & 3.34). They were first discretized using
explicit finite differences as follows.
Eq. 3.33 can be expressed as
( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( )t
TTcr
zTT
cmTTTT
Urnip
nip
flp
nip
nip
fl
onip
nip
nia
nian
ipp ∆
++
∆
−=
⎥⎥⎦
⎤
⎢⎢⎣
⎡ +−
++
−−−
12111
222 ρππ
for i = 1,2,3,…,I-1,I n = 1,2,3,…N-1,N (3.37)
Parameters bearing coordinate n are known while parameters bearing
coordinate n+1, i.e. at the next time step, are not known. Equation 3.37 is
rearranged with the known parameters on right-hand side and the unknown
parameters on the left-hand side as follows.
( ) ( ) ( ) ( )nip
flp
ppfl
o
nia
flp
pnia
flp
pnip T
crz
UrzcmtT
crtU
Tcr
tUT
1211
−−+
⎟⎟⎟⎟
⎠
⎞
⎜⎜⎜⎜
⎝
⎛
∆
⎟⎠⎞
⎜⎝⎛ ∆−∆
+∆
+∆
=ρπ
π
ρρ
( ) nip
flp
ppfl
o
Tcrz
Urzcmt
⎟⎟⎟⎟⎟
⎠
⎞
⎜⎜⎜⎜⎜
⎝
⎛
∆
⎟⎟⎠
⎞⎜⎜⎝
⎛∆+∆
−+2
1ρπ
π
(3.38)
Equation 3.38 in essence, expresses the temperature at the particular
coordinate of interest as a weighted average of temperatures at spatial
coordinates located nearby in the pipe and annulus, at the previous time-step.
55
Stability Criterion- The coefficients of the known pipe and annulus
temperatures (i.e. in the present time-step) in Eq. 3.38 must be positive in
order to arrive at a stable solution of the equation. A negative coefficient
would not make physical sense, because it would be saying that the hotter
the temperature is at a coordinate near or at the particular coordinate of
interest for the present time-step, the colder the temperature will be at the
particular coordinate of interest at the next or future time-step. Therefore, the
coefficients must all be greater than or equal to zero. In fact, it is usually
desirable to avoid zero coefficients. Application of this rule to Eq. 3.38, results
in the following constraints.
⎟⎠⎞
⎜⎝⎛ ∆+
∆≤∆
ppfl
oflp
Urzcm
crzt
π
ρπ 2
(3.39)
(3.40) ppfl
oUrzcm π∆≥
The equation describing heat flow in the annulus (Eq. 3.34) is discretized as
follows.
( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( )⎥⎥⎦
⎤
⎢⎢⎣
⎡ +−
+−
⎥⎥⎦
⎤
⎢⎢⎣
⎡ +−
+ −−−−
222
222 1111
nip
nip
nia
nian
ipp
nia
nia
niF
niFn
iaa
TTTTUr
TTTTUr ππ
( ) ( ) ( ) ( ) ( )
tTT
crrzTT
cmnia
nia
flpa
nia
nia
fl
o
∆+
−+∆−
−=+
−1
221 ρπ
for i = 1,2,3,…,I-1,I n = 1,2,3,…N-1,N (3.41)
Equation 3.41 is rearranged, with known parameters on the right hand side of
the equation and unknown parameters on the left hand side as follows.
56
( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( )nip
flpa
ppnip
flpa
ppniF
flpa
aaniF
flpa
aania T
crrtUr
Tcrr
tUrT
crrtUrT
crrtUrT 2212222122
11 −
∆+
−
∆+
−∆
+−
∆=
−−+− ρρρρ
( ) ( )nia
flpa
ppaafl
o
Tcrrz
UrzUrzcmt1221 −
⎟⎟⎟⎟
⎠
⎞
⎜⎜⎜⎜
⎝
⎛
−∆
⎟⎠⎞
⎜⎝⎛ ∆+∆+∆
−+ρπ
ππ
( ) ( )nia
flpa
ppaafl
o
Tcrrz
UrzUrzcmt
⎟⎟⎟⎟
⎠
⎞
⎜⎜⎜⎜
⎝
⎛
−∆
⎟⎠⎞
⎜⎝⎛ ∆−∆−∆
+ 22ρπ
ππ (3.42)
Stability Criterion- Application of the rule of positive coefficients to Eq. 3.42
results in the following constraints.
( )
⎟⎠⎞
⎜⎝⎛ ∆+∆+
−∆≤∆
ppaafl
oflpa
UrzUrzcm
crrzt
ππ
ρπ 22
(3.43)
(3.44) ppaafl
oUrzUrzcm ππ ∆+∆≥
Boundary conditions in the Wellbore- The following boundary conditions are
applied to the wellbore.
@ i = 0 (pipe inlet) ( ) psnip TT = for all n.
@ i = imax (bottom-hole) ( ) ( )nia
nip TT = for all n.
where
Tps = temperature of fluid at pipe inlet
The second boundary condition states that at the bottom of the well, the pipe
and annulus fluid temperatures are equal. Note that Eq. 3.38 is solved from
57
the surface to the bottom in the direction of fluid flow, while Eq. 3.42 is solved
from bottom-hole to surface, also in the direction of fluid flow.
The explicit method detailed above was tested and found to be too
slow, that is, it took a longer time to converge on an answer. This was largely
due to the constraints placed on the time step. An alternative discretizing
scheme, the Crank-Nicolson method26, was then used. This scheme yields an
efficient, easy to use finite difference scheme which gives more accurate
solutions without constraints on the time step used.
Using the Crank-Nicolson scheme, Eq. 3.33 is discretized as follows.
( ) ( ) ( ) ( ) ( ) ( ) ( ) nip
nia
nipp
nip
nia
nipp TTUrTTUr −−+− +++ θπθπ 122 111
( ) ( )( )
( ) ( ) ( ) ( )t
TTcr
zTT
zTT
cmnip
nip
flp
nip
nip
nip
nip
fl
o
∆
−+
⎪⎭
⎪⎬⎫
⎪⎩
⎪⎨⎧
∆
−−+
∆
−=
+
−+
+
−
+
+
1211
11
11
21
2ρπθθ (3.45)
Eq. 3.45 is rearranged as
( ) ( ) ( ) ( ) 11
112
11 2
22
+
+
+++
− ∆+⎟
⎟⎠
⎞⎜⎜⎝
⎛+
∆+
∆− n
ipfl
o
nip
nipp
flpnip
fl
o
Tz
cmTUr
tcr
Tz
cmθθπ
ρπθ
( )( ) ( ) ( ) ( ) ( )( )nip
fl
o
nip
nipp
flpnip
fl
o
Tz
cmTUr
tcr
Tz
cm1
2
11
2121
2 +−−
∆−⎟
⎟⎠
⎞⎜⎜⎝
⎛−+
∆+−
∆= θθπ
ρπθ
( ) ( )( ) ( ) ( ) 11212 +++−+ nia
nipp
nia
nipp TUrTUr θπθπ (3.46)
Note that in Eq. 3.46, all the terms on the left hand side are unknowns while
all the terms on the right-hand side are known except the last one which is the
temperature in the annulus at the depth of interest during the current time
step. This problem is solved by taking an initial guess of the temperature
profile in the annulus. This guess is the temperature profile at the previous
58
time-step. Hence, the last term on the right-hand side of Eq. 3.46 will be a
known term.
The equation describing heat flow in the annulus (Eq. 3.34) is
discretized using the Crank-Nicolson method as follows.
( ) ( ) ( ) ( ) ( ) ( ) ( ) nia
niF
niaa
nia
niF
niaa TTUrTTUr −−+− +++
0,11
0,1 122 θπθπ (3.47)
( ) ( ) ( ) ( ) ( ) ( ) ( ) nip
nia
nipp
nip
nia
nipp TTUrTTUr −−−−− +++ θπθπ 122 111
( ) ( ) ( ) ( ) ( ) ( ) ( ) ( )⎪⎭
⎪⎬⎫
⎪⎩
⎪⎨⎧
∆−
−+∆−
−∆
−−= −+
+−
++
+
zTT
zTT
cmt
TTcrr
nia
nia
nia
nia
fl
onia
nia
flpa 21
211
11
11
122 θθρπ
Equation 3.47 is rearranged as
( ) ( ) ( ) ( ) ( ) ( ) 11
11122
11 2
222
++
++++− ∆
−⎟⎟⎠
⎞⎜⎜⎝
⎛++
∆
−+
∆nia
fl
o
nia
niaa
nipp
flpania
fl
o
Tz
cmTUrUr
tcrr
Tz
cmθθπθπ
ρπθ
( )( ) ( ) ( ) ( ) ( ) ( ) ( nia
niaa
nipp
flpania
fl
o
TUrUrt
crrT
zcm
⎟⎟⎠
⎞⎜⎜⎝
⎛−−−−
∆
−+−
∆−= − θπθπ
ρπθ 12121
21
22
1 )
( )( ) ( ) ( )( ) ( ) ( )( )niF
niaa
nip
nipp
nia
fl
o
TUrTUrTz
cm0,
11 12121
2θπθπθ −−−+−
∆− +
( ) ( ) ( ) ( ) 10,
111 22 ++++ ++ niF
niaa
nip
nipp TUrTUr θπθπ (3.48)
Note that all the terms on the left hand side of Eq. 3.48 are unknowns while
all the terms on the right hand side are known with the exception of the last
term. The sixth term is already known because the temperature profile in the
drill pipe at any given time-step is evaluated before the temperature profile in
the annulus. The problem of the last term is solved by making an initial guess
59
of the temperature profile in the immediate adjacent formation. The initial
guess is taken to be the temperature profile at the previous time step.
Boundary Conditions in the Wellbore - A heat balance is performed at the
bottom of the wellbore taking into account the bottom-hole boundary
condition. Figure 3.4 shows a diagram of the heat balance.
( )1max−ipT
( ) maxiT
imax
`
Figure 3.4- Heat Balance at Bottom-Hole
60
Note,
Timax = ( )maxipT = ( ) maxiaT
Since @ i = imax (Bottom-hole), ( )maxipT = ( ) maxiaT
Performing a heat balance about the bottom-hole volume element in the
wellbore yields the following equation.
( ) ( ) ( ) ( ) tTczrTTzUrTcmTcm flaiiFaaifl
o
ipfl
o
∂∂∆
=−∆
+−− 22
2 2maxmaxmax1max
ρππ (3.49)
Where T = Tp, Eq. 3.49 is discretized as follows.
( ) ( ) ( ) ( ) ( ) ( ) ( ) 1max
10max,max1max
1max
11max
1 ++
−
++
−−∆+−−+− n
ipniFaa
nip
nipfl
onip
nipfl
oTTzUrTTcmTTcm θπθθ
( ) ( ) ( ) ( ) ( )tTT
czrTTzUrnip
nip
flanip
niFaa ∆
−∆=−−∆+
+
max1
max2max0max, 2
1 ρπθπ (3.50)
Eq. 3.50 is rearranged as
( ) ( ) 1max
21
1max 2++
− ⎟⎟⎠
⎞⎜⎜⎝
⎛
∆
∆−−+ n
ipfla
fl
onipfl
oT
tzcr
cmTcmρπ
θθ
( )( ) ( ) ( ) ( ) 10max,max
2
1max 211 +
−∆−⎟
⎟⎠
⎞⎜⎜⎝
⎛
∆
∆−−−+−= n
iFaanip
flafl
onipfl
oTzUrT
tzcr
cmTcm θπρπ
θθ
( )( ) ( ) ( )( )niaaa
niaaa
niFaa TzUrTzUrTzUr max
1max0max, 11 θπθπθπ −∆−+∆+−∆− + (3.51)
Equation 3.46 in conjunction with Eq. 3.51, thus form a tridiagonal system of
equations. The system of equations is solved easily using the Thomas
algorithm26.
Where T = Ta, Eq. 3.49 is discretized as follows.
61
( ) ( ) ( ) ( ) ( ) ( ) ( ) 1max
10max,max1max
1max
11max
1 ++
−
++
−−∆+−−+− n
ianiFaa
nia
nipfl
onia
nipfl
oTTzUrTTcmTTcm θπθθ
( ) ( ) ( ) ( ) ( )t
TTczrTTzUr
nia
nia
flania
niFaa ∆
−∆=−−∆+
+max
1max2
max0max, 21 ρπθπ (3.52)
Eq. 3.52 is rearranged as follows
( ) ( ) ( )( )nipfl
onipfl
oniafl
o
aafla TcmTcmTcmzUr
tzcr
1max1
1max1
max
2
12 −
+
−
+ −+=⎟⎟⎠
⎞⎜⎜⎝
⎛+∆+
∆
∆θθθθπ
ρπ
( ) ( )( )niFaa
niFaa TzUrTzUr 0max,
10max, 1 θπθπ −∆+∆+ +
( ) ( ) ( )nia
flaaafl
oT
tzcr
zUrcm max
2
211 ⎟
⎟⎠
⎞⎜⎜⎝
⎛
∆
∆+−∆−−−+
ρπθπθ (3.53)
Equation 3.47 is solved in conjunction with Eq. 3.53 to yield the temperature
profile in the annulus.
Heat Flow Equations in the Formation
Equation 3.35 governs heat flow in the formation and is discretized
using the Taylor series approximation of derivatives in conjunction with the
Crank-Nicolson method of finite differences. The Crank-Nicolson method
results in an implicit set of linear algebraic equations which must be solved
simultaneously. However, this method has the advantage of being
unconditionally stable. There is no constraint set on the size of the time-step
to be used. Equation 3.35 is thus discretized as follows.
62
( ) ( ) ( ) ( ) ( )( )
( ) ( ) ( )( ) ⎟
⎟
⎠
⎞
⎜⎜
⎝
⎛
∆
+−+
∆
+−=
∆
− +−+
+++
−+
21,,
11,
2
11,
1,
11,,
1, 22
2 r
TTT
r
TTTt
TT njiF
njiF
njiF
njiF
njiF
njiF
njiF
njiF α
( ) ( ) ( ) ( )
⎟⎟
⎠
⎞
⎜⎜
⎝
⎛
∆
−
∆+
∆
−
∆+ −+
+−
++
rTT
rjrTT
rj
njiF
njiF
njiF
njiF
21
21
21,1,
11,
11,α (3.54)
Rearranging Eq. 3.54 so that unknowns are on the left-hand side,
( ) ( )( ) ( ) nji
njiF
rrnjiFr
nijiF
rr Taj
aTaTaj
a,
11,
1,
1, 24124 φααααα =⎟
⎠⎞⎜
⎝⎛ −−+++⎟
⎠⎞⎜
⎝⎛ − +
+++
− (3.55)
where,
( ) ( )( ) ( )njiF
rrnjiFr
nijiF
rrnji Ta
jaTaTa
ja
1,,,, 24124 +− ⎟⎠⎞⎜
⎝⎛ ++−+⎟
⎠⎞⎜
⎝⎛ +−= αααααφ
( )2rtar ∆
∆=
Formation Boundary Conditions- At the formation and annulus interface, the
boundary condition can be expressed as follows.
aaFaF
F TUTUr
Tk =+∂
∂− (3.56)
Equation 3.47 can be expressed as follows.
( ) ( ) ( ) ( )n
iaaniFa
niF
niF
F TUTUrTT
k =+∆
−− −
0,1,1,
2 (3.57)
Rearranging Eq. 3.57 for time-steps n and n+1, we obtain the following.
( ) ( ) ( ) ( )niF
F
niF
niaa
niF T
krTTUT 1,0,1,
2+
∆−=− (3.58)
( ) ( ) ( ) ( ) 11,
10,
111,
2 ++++− +
∆−= n
iFF
niF
niaa
niF T
krTTUT (3.59)
63
Note that there in Eqs. 3.49 and 3.50, there is a node j = -1. This is an
imaginary node located outside of the formation in the annulus. Near the
boundary, the equation describing internal heat flow in the formation (Eq.
3.35) is replaced with the following equation26.
2
2
2rT
tT FF
∂∂
=∂
∂ α (3.60)
This is done to avoid the apparent singularity which occurs at the node j = 0.
Equation 3.60 can be expressed as
( ) ( )t
TT njiF
njiF
∆
−+,
1,
( ) ( ) ( )( )
( ) ( ) ( )( ) ⎟
⎟
⎠
⎞
⎜⎜
⎝
⎛
∆
+−+
∆
+−= +−
++
++−
21,,
11,
2
11,
1,
11, 22
22
rTTT
rTTT n
jiFn
jiFn
jiFn
jiFn
jiFn
jiFα (3.61)
rearranging at node j = 0, we obtain
( ) ( )( ) ( ) ni
niFr
niFr
niFr TaTaTa 0,
11,
10,
11, 21 φααα =−++− +++
− (3.62)
where
( ) ( )( ) ( )niFr
niFr
niiFr
ni TaTaTa 1,0,,0, 21 ααφ +−+= − (3.63)
The temperatures at the imaginary node j = -1 are eliminated from Eqs. 3.62
and 3.63 by inserting Eqs. 3.58 and 3.59 to obtain
( ) ( ) ni
niFr
niFa
Frr TaTU
kraa 0,
11,
10, 2221 φααα =−⎟⎟
⎠
⎞⎜⎜⎝
⎛ ∆++ ++ (3.64)
64
where
( ) ( )niaa
Fr
niaa
Fr
ni TU
kraTU
kra ∆
+∆
= + 22 10, ααφ
( ) ( )niFr
niFa
Frr TaTU
kraa 1,0, 2221 ααα +⎟⎟
⎠
⎞⎜⎜⎝
⎛ ∆+−+ (3.65)
Equations 3.64 and 3.65 express the temperature in the formation at the
formation-annulus interface. Note that in Eq. 3.65, the first term on the right
hand side contains the annulus temperature for the future time step. This
does not create a problem because at the time when the temperature in the
formation is evaluated, the temperature in the wellbore for the future time-step
has already been evaluated. Hence, the temperature in the annulus for the
future time step is already known. At the outer boundary of the formation, a
sufficient radius of consideration is chosen at which the temperature
disturbance caused by the flow of fluid in the wellbore is no longer felt in the
formation. This length is generally taken to be 10 ft from the wellbore14. At this
outer boundary, the temperature conforms to the undisturbed geothermal
gradient.
@ j = J for all n (3.66) ( ) GGFSn
jiF TzigTT =∆+= **,
Equations 3.55, 3.64, and 3.66 thus form a complete set of linear algebraic
equations which describe the temperature at every node in the formation.
They can be expressed in matrix form as follows.
(3.67) [ ] Ψ=Ω T
This is done at each depth and at each time-step n as follows:
65
[ ]
⎥⎥⎥⎥⎥⎥⎥⎥
⎦
⎤
⎢⎢⎢⎢⎢⎢⎢⎢
⎣
⎡
=Ω
100000
00000001
KK
MM
MM
K
CBA
CBACBA
( )( )( )
( ) ⎪⎪⎪⎪
⎭
⎪⎪⎪⎪
⎬
⎫
⎪⎪⎪⎪
⎩
⎪⎪⎪⎪
⎨
⎧
=
+
+
+
+
1,
12,
11,
10,
nJiF
niF
niF
niF
T
TTT
T
M
M
⎪⎪⎪⎪
⎭
⎪⎪⎪⎪
⎬
⎫
⎪⎪⎪⎪
⎩
⎪⎪⎪⎪
⎨
⎧
=Ψ
−
G
nJi
ni
ni
ni
T1,
2,
1,
0,
φ
φφφ
M
where
⎟⎠⎞⎜
⎝⎛ −= 24
rr aj
aA αα ( )raB α+= 1 ⎟⎠⎞⎜
⎝⎛ −−= 24
rr aj
aC αα
Equation 3.56 is a tridiagonal system of linear algebraic equations, and can
thus be solved using the simple but efficient Thomas Algorithm.
Numerical Procedure-
The following is a summary of the steps taken in the numerical solution.
1. The initial conditions of the system are specified (time t = 0). The initial
temperature conditions in the formation conform to the geothermal
gradient. The initial temperature conditions in the wellbore also
66
conform to the formation geothermal gradient. This condition is chosen
because it is found that after sufficient time during a trip, the
temperature of the fluid in the wellbore is equal to temperature of the
formation.
2. The temperature profile in the drill pipe is evaluated first using Eqs.
3.46 and 3.51. It is first necessary to guess the temperature profile in
the annulus at the current time step in order to evaluate the drill-pipe.
The initial guess is taken to be the temperature profile in the annulus at
the previous time step.
3. Based on the newly evaluated drill-pipe temperature, the annular
temperature profile is evaluated using Eqs. 3.48 and 3.53. Note that it
is necessary to guess the temperature profile in the immediate
adjacent formation at the current time-step. The guess chosen is the
temperature profile in the previous time step.
4. The temperature profile in the formation is then evaluated at the
current time step based on the newly evaluated annulus profile. The
results of the procedure are then compared with the initial guesses. If
the error is insignificant, the next time step is evaluated. If there is
significant error, the whole procedure is repeated with the current
temperature profiles in the annulus and formation being used as the
guesses. This procedure is repeated until the calculations are
completed for the total circulation time.
67
3.4 Summary
The analytical and numerical methods for estimating the temperature
profile within the wellbore and formation have been described. It is assumed
that heat flow in the wellbore occurs rapidly in comparison to heat flow in the
formation. Heat flow in the wellbore occurs by bulk fluid flow, convection
across surface films on the pipe conduit and on the outer wall of the annulus,
and conduction through the pipe wall. Heat flow in the formation occurs by
conduction in the radial direction only. For the numerical method, the
equations governing heat flow in the wellbore and formation are solved using
the Crank-Nicolson method which results in a system of linear algebraic
equations. The numerical method is used in the development of the Dynamic
density Simulator.
68
Chapter 4
DEVELOPMENT AND VALIDATION OF THE DYNAMIC DENSITY SIMULATOR AND MODELLING OF DYNAMIC DENSITY Drilling operations are being conducted to deeper depths as the need
to supplement dwindling hydrocarbon resources forces exploration into more
unconventional environments. Deeper wells mean the drilling fluid will
encounter higher temperatures and pressures. As discussed in previous
chapters, it is not expected that the volumetric and rheological properties of
the fluid remain constant under these conditions. It is thus necessary to
predict these downhole conditions and their impact on the drilling fluid
behavior. This allows for precise drilling fluid selection and preparation, and
accurate estimation of the maximum allowable pump pressure.
The following chapter contains a description, development, and
validation of the Dynamic Density Simulator (DDS) and analysis of the results
of equivalent circulating density estimation under high-temperature/high-
pressure conditions. The DDS program is a predictive tool that will allow the
drilling engineer to predict the down-hole temperature/pressure conditions
that will be encountered and the resultant change in drilling fluid rheological
behavior. The simulator was written using Visual Basic for applications
automated through Microsoft Excel. The user interface is integrated with
Excel and initiated with a command button that is integrated into the main
69
worksheet menu. This format was chosen because it allows ease of use and
accessibility. It also allows manipulation of generated results with Excel
utilities such as worksheets and graphs. The following is a detailed
description and explanation of the program layout.
4.1 Program Lay-Out
The program interface is executed with a series of user forms, which
will accept data pertaining to the well bore, drilling fluid, and formation
parameters and return the temperature profiles in the wellbore and formation,
pressure losses in the wellbore and the ECD of the circulating fluid. The user
can navigate between forms and input data at leisure using the “back” and
“next” buttons. Once all the parameter values have been entered into the
program, the results are displayed on a “results” form. The following is the
sequence of forms used in the program.
1. “frmStart”- This is the starting form and the form that is displayed
when the program is initiated. On this form, the option is given to initiate a
new well profile.
2. “frmWellProps”- This form allows input of the well bore parameters. These
include the total vertical depth of the well, drill string dimensions such as
inner and outer drill pipe diameters, drill bit dimensions, and information
such as the inlet pipe temperature and the circulation rate.
3. “frmMudProps”- This form accepts the mud parameters such as
rheological data, volumetric and constituents data, and thermal data.
70
4. “frmFormationProps”- This form allows input of the thermal properties of
the surrounding formation.
5. “frmHeatTransfer”- This form allows input of the heat transfer coefficients.
6. “frmResults” - This form displays the frictional pressure losses and ECD
results.
Figure 4.1 shows a step-by-step sequence of data entry, computation and
results display.
4.2 DDS Program Execution
The first form that is displayed once the program is executed is the
program title page. From this form, a new well profile can be initiated. Figure
4.2 shows a screen capture of the title form. The form is initiated by clicking
on a command button that is integrated into Excel’s set of main menu
commands as shown in the screen capture in Fig. 4.3. The following
sequence of forms will be described as follows.
4.2.1 General Well Parameters Form
On this form, the dimensions and configuration of the drill-string are
specified. These include the dimensions of the drill-pipe, heavy-weight drill-
pipe and drill collars. The bit size, circulation rate, inlet pipe temperature and
total vertical depth are also specified. A screen capture of this form is shown
in Fig. 4.4.
71
START (Initiate Well
Profile)
INPUT WELL PARAMETERS
INPUT MUD PARAMETERS
INPUT FORMATION PARAMETERS
Drill String Configuration/Geometry
Bit Configuration
TVD, Circulation Rate, Inlet Pipe Temperature
EVALUATE WELLBORE TEMPERATURE PROFILE
CALCULATE BOTTOM-HOLE PRESSURE & ECD
DISPLAY
INPUT HEAT TRANSFER COEFFICIENTS
STOP
Reference Conditions
Thermal Properties
Density and Constituents
Rheological Properties
Figure 4.1- DDSimulator Program Flow
Chart
72
Figure 4.2- Title Form
73
DDSimulator Command
Button
Figure 4.3- DDSimulator Launch Command Button
74
Figure 4.4- Well Parameters Form
75
Figure 4.5- Mud Properties Form
76
4.2.2 Mud Properties Form
The properties of the drilling fluid are entered on this form. These
include the rheological properties such as plastic viscosity and yield strength,
the density and constituents, and the thermal properties such as thermal
conductivity and heat capacity. The density and rheological parameters are
obtained at certain reference temperature and pressure. These reference
conditions are also entered. Figure 4.5 shows a screen capture of the form.
4.2.3 Formation Properties Form
The properties of the formation are entered on this form. These
properties include the density, geothermal gradient, surface temperature, heat
conductivity, specific heat capacity, and maximum radius of interest. The
maximum radius of interest refers to the minimum radius at which the
formation no longer sees the temperature disturbance as a result of
introducing the drilling fluid into the well. This radius is usually about 10-ft
from the well-bore. Figure 4.6 shows a screen capture of the formation
properties form.
4.2.4 Heat Transfer Coefficients Form
The overall heat transfer coefficients for heat transfer across the
annulus-formation interface, and across the drill-pipe wall are entered on this
form. Figure 4.7 shows a screen capture of the heat transfer coefficients form.
77
Figure 4.6- Formation Properties Form
78
Figure 4.7- Heat Transfer Coefficients Form
79
4.2.5 Results and Results Form
Once all the system parameters have been specified, the simulator can
then evaluate the temperature profile inside the drill-pipe and annulus and the
resultant variation in density and rheological parameters. The frictional
pressure drop in the annulus and drill-pipe, the bottom-hole pressure and the
ECD are then determined. The results are presented on the result form and
temperature profile is presented graphically using the Excel graph feature.
The result form is shown in Fig. 4.8 and a sample temperature profile is
shown in Fig. 4.9.
Figure 4.8- Results Form
80
Figure 4.9- A Sample Temperature Profile Using Excel Graph Feature
81
4.3 Equations used in DDSimulator Program
The DDS program uses the numerical method to evaluate the
temperature profile in the wellbore and near formation environment. Taking
the temperature profile into account, the simulator computes equivalent
hydrostatic head and frictional pressure loss in the wellbore during circulation.
The equations used in the simulator are as follows:
4.3.1 Fluid Properties
The density of the fluid in the wellbore is computed using the
compositional method according to the following equation.
( )⎟⎟⎠
⎞⎜⎜⎝
⎛−+⎟⎟
⎠
⎞⎜⎜⎝
⎛−+
=111
,
2
1
2
1
122
w
ww
o
oo
mm
ffTp
ρρ
ρρ
ρρ (2.12)
The volumetric behavior of the oil component is calculated as follows:
(2.33) 222
22222 TFTEPDPCPTBAo +++++=ρ
where
A2 = 0.8807 B2 = 1.5235*10-9
C2 = 1.2806*10-6 D2 = 1.0719*10-10
E2 = -0.00036 F2 = -5.1670*10-8
The volumetric behavior of the water component is calculated as follows:
Circulation Rate- 252 gal/min Circulation Time- 56 min Fluid- Field Salt Water
Temperature
Figure 4.12- Temperature Profile For Gulf Coast Well
90
4.5 Dynamic Density Estimation
The effects of temperature and pressure on the equivalent circulating
density in a high temperature-high pressure well were simulated using the
DDSimulator. The properties of the first well that was simulated are detailed
in Table 4.2. The temperature profile for the well is shown in Fig. 4.13. The
temperature profile indicates that the temperature in the well-bore is higher
than the formation temperature for a large portion of the hole. As fluid moves
from the bottom of the hole upwards in the annulus, it looses heat to the pipe,
and for about 2000 ft up the annulus. It also gains heat from the formation.
Beyond this point, the annular temperature is higher than the formation
temperature. Thus, heat moves from the annulus into the formation as well as
into the drill-pipe. The rate of heat transfer across the pipe wall is very high
due to the high heat conductivity of steel and the high flow rate. Hence, the
temperature profiles in the annulus and drill pipe are very close.
The results of the ECD calculations are detailed in Table 4.3. The ECD
based on constant fluid properties (i.e. independent of the
temperature/pressure conditions) was evaluated for comparison. The bottom-
hole pressure taking into account the temperature-pressure dependence of
the fluid properties was 218 psi lower than the bottom-hole pressure obtained
using constant fluid properties. This is due to the volumetric behavior of the
drilling fluid. The decrease in the density of the fluid due to temperature is
more pronounced than the increase in density due to the pressure. Hence,
91
the bottom-hole pressure is less than one would expect if the density of the
drilling fluid remained constant.
General well Properties Well Depth (L) 17200 ft Outer Drill Pipe Radius (rp) 0.208333 ft Annulus Radius (ra) 0.354167 ft Circulation Rate 400 bbl/hr Circulation Time (hr) 5 hr
Inlet Mud Temperature (Tps) 120 oF Mud Properties Viscosity (µfl) (@ reference conditions) 50.82 lb/(ft-hour) Yield Value (@ reference conditions) 10 lbf/100ft2
Thermal Conductivity (kfl) 1 Btu/(ft-oF-hour) Specific Heat (cfl) 0.4 Btu/(lb-oF) Density (ρfl) (@ reference conditions) 16.8 lb/gal Oil Fraction 0.594 Water Fraction 0.066 Formation Properties
Thermal Conductivity (kF) 0.3 Btu/(ft-oF-hour) Specific Heat (cF) 0.21 Btu/(lb-oF) Density (ρF) 165 lb/ft3 Surface Earth Temperature (TFs) 70 oF
Geothermal Gradient (gG) 0.020 oF/ft
Temperature/Pressure
Dependent Constant Property Difference
Bottom Hole Pressure (psi) 22020 22238 -218
ECD (ppg) 24.6 24.9 -0.3
Table 4.3 Results of Well Simulation
Table 4.2 Simulated Well Conditions
92
Figure 4.14 shows a plot of the bottom-hole pressure versus depth. It
can be observed that there is a steady increase in pressure as the depth
increases with the final bottom-hole pressure obtained with constant fluid
density being higher than that obtained with a temperature/pressure
dependent fluid density. Figure 4.15 shows the temperature/pressure
dependent behavior of the fluid density. As depth increases the equivalent
circulating density continues to decrease as a result of the greater effect of
fluid expansion due to temperature, as opposed to compression due to the
Momentum Heat and Mass Transfer, John Wiley & Sons, 2001.
30. Dusinbere, G.M.:Heat Transfer Calculations by Finite Differences,
International Textbook Company, Scranton, Pennsylvania, 1961; pg 8-
23, 103-106.
118
APPENDIX Code for DDSimulator Program
119
Option Explicit 'This is a temperature profile object in which the methods to compute the pipe and annular 'temperature profiles are contained Dim Tax As WellProfile 'The following list conatins the depth coordinates at which temperature will be computed Dim Depth(200) As Double Private Sub ConstPropPressureDrop_Click() 'This sub computes the frictional pressure drop in the pipe and annulus with constant 'fluid properties Dim PlasticP As Double Dim PlasticA As Double Dim YieldP As Double Dim YieldA As Double Dim vP As Double Dim vA As Double Dim muP As Double Dim muA As Double Dim ReP As Double Dim ReA As Double Dim DPP As Double Dim DPA As Double Dim DppTotal As Double Dim DpaTotal As Double Dim i As Integer Dim imax As Integer imax = Tax.iTotal DppTotal = 0 DpaTotal = 0 'Compute Frictional Pressure Drop For i = 0 To imax If i > 0 Then 'compute plastic viscosity in cp PlasticP = Tax.RefMudPlasticViscosity PlasticA = Tax.RefMudPlasticViscosity 'Compute yield point in lbf/100ft^2 YieldP = Tax.RefMudYieldValue
120
YieldA = Tax.RefMudYieldValue 'Compute velocity in pipe and annulus vP = 4 * Tax.mRate / (7.48 * 3.142 * ((2 * Tax.rpi) ^ 2) * Tax.RefMudDensity) vA = 4 * Tax.mRate / (7.48 * 3.142 * (Tax.de ^ 2) * Tax.RefMudDensity) 'Compute apparent viscosity in pipe and annulus muP = PlasticP + (6.66 * YieldP * 2 * Tax.rp / vP) muA = PlasticA + (5 * YieldA * Tax.de / vA) 'Compute Reynold's # in pipe and annulus ReP = Tax.ReynoldsNum(Tax.RefMudDensity, vP, (2 * Tax.rp), muP) ReA = Tax.ReynoldsNum(Tax.RefMudDensity, vA, Tax.de, muA) 'Compute frictional pressure drop DPP = Tax.PressureDrop(ReP, (2 * Tax.rp), 0.01, Tax.DeltaZ, Tax.RefMudDensity, vP) DPA = Tax.PressureDrop(ReA, Tax.de, 0.03, Tax.DeltaZ, Tax.RefMudDensity, vA) DppTotal = DppTotal + DPP DpaTotal = DpaTotal + DPA End If Worksheets("AnnulusTemperature").Cells((i + 2), 12).Value = DppTotal Worksheets("AnnulusTemperature").Cells((i + 2), 13).Value = DpaTotal Next i End Sub Public Sub LoadProperties_Click() Set Tax = New WellProfile Tax.AnalyticalConstants End Sub Private Sub ComputeTempProf_Click() Dim i As Integer 'The "Interval" refers to the distance between depths at which temperature will be computed
121
Dim Interval As Double Interval = Tax.TVD / 200 For i = 0 To 200 Depth(i) = i * Interval Tax.AnalyticalComputeTemp Depth(i) Cells(i + 16, 8).Value = Tax.TPipe Cells(i + 16, 9).Value = Tax.TAnnulus If i < 300 Then End If Next i End Sub Private Sub NumericalTemperature_Click() 'Note that terms bearing an "N" at the end signify data at the time step that 'is currently being evaluated. Dim FormTemperature() As Double Dim PipeTemperature() As Double Dim AnnTemperature() As Double Dim FormTemperatureN() As Double Dim PipeTemperatureN() As Double Dim AnnTemperatureN() As Double 'These matrices store the pressure profile with the pipe and annulus Dim PipePressure() As Double Dim AnnPressure() As Double Dim PipePressureN() As Double Dim AnnPressureN() As Double 'Dim Uaaa() As Double 'Dim Uppp() As Double 'mud density in the pipe and annulus Dim rhoPipe() As Double Dim rhoAnnulus() As Double 'i - (depth), j - (radius), n - (time)
122
Dim i As Integer Dim j As Integer Dim n As Integer Dim imax As Integer Dim jMax As Integer Dim nMax As Integer 'This array is used to store the old pipe temperature values Dim store1() As Double Dim store2() As Double 'heat transfer coefficient for inner pipe surface Dim hi As Double 'error between guess and solution Dim err As Double Dim check1 As Double Dim check2 As Double Dim check3 As Double 'Terms used to evaluate the frictional pressure loss Dim PlasticP As Double Dim PlasticA As Double Dim YieldP As Double Dim YieldA As Double Dim vP As Double Dim vA As Double Dim muP As Double Dim muA As Double Dim ReP As Double Dim ReA As Double Dim DPP As Double Dim DPA As Double Dim DppTotal As Double Dim DpaTotal As Double imax = Tax.iTotal jMax = Tax.jTotal nMax = Tax.nTotal ReDim FormTemperature(imax, jMax) ReDim PipeTemperature(imax) ReDim AnnTemperature(imax) ReDim PipePressure(imax)
123
ReDim AnnPressure(imax) ReDim FormTemperatureN(imax, jMax) ReDim PipeTemperatureN(imax) ReDim AnnTemperatureN(imax) ReDim PipePressureN(imax) ReDim AnnPressureN(imax) ReDim rhoPipe(imax) ReDim rhoAnnulus(imax) 'ReDim Uaaa(iMax) 'ReDim Uppp(iMax) ReDim store1(imax) ReDim store2(imax) 'Worksheets.Add.Name = "PipeTemperature" 'Worksheets.Add.Name = "AnnulusTemperature" 'Worksheets.Add.Name = "FormationTemperature" 'Set initial conditions in the formation and annulus Tax.InitializeGrid FormTemperature(), PipeTemperature(), AnnTemperature(), PipePressure(), AnnPressure(), rhoPipe(), rhoAnnulus(), imax, jMax 'The following code computes temperature in the formation and wellbore For n = 1 To nMax 'Set initial guess for Ta(i,n+1), Ua(i,n+1), Tp(i,n+1), Up(i,n+1), Pp(i,n+1), and Pa(i,n+1) For i = 0 To imax AnnTemperatureN(i) = AnnTemperature(i) FormTemperatureN(i, 0) = FormTemperature(i, 0) 'PipePressureN(i) = PipePressure(i) AnnPressureN(i) = AnnPressure(i) 'rhoPipeN(i) = rhoPipe(i) 'rhoAnnulusN(i) = rhoAnnulus(i) Next i Do 'Evaluate the pipe Tax.EvaluatePipe FormTemperature(), FormTemperatureN(), PipeTemperature() _ , PipeTemperatureN(), PipePressure(), PipePressureN(), AnnTemperature() _
124
, AnnTemperatureN(), AnnPressure(), AnnPressureN(), imax 'Re-evaluate Pp(i,n+1) with the newly obtained Tp(i,n+1) For i = 0 To imax If i = 0 Then PipePressureN(i) = 14.7 Else rhoPipe(i - 1) = Tax.MudDensity(PipeTemperatureN(i - 1), PipePressureN(i - 1)) PipePressureN(i) = PipePressureN(i - 1) + 0.052 * rhoPipe(i - 1) * Tax.DeltaZ End If Next i 'Evaluate the Annulus Tax.EvaluateAnnulus FormTemperature(), FormTemperatureN(), PipeTemperature() _ , PipeTemperatureN(), AnnTemperature(), AnnTemperatureN(), PipePressure() _ , PipePressureN(), AnnPressure(), AnnPressureN(), imax, store1() 'Re-evaluate Pa(i,n+1) with the newly obtained Ta(i,n+1) For i = 0 To imax If i = 0 Then AnnPressureN(i) = 14.7 Else rhoAnnulus(i - 1) = Tax.MudDensity(AnnTemperatureN(i - 1), AnnPressureN(i - 1)) AnnPressureN(i) = AnnPressureN(i - 1) + 0.052 * rhoAnnulus(i - 1) * Tax.DeltaZ End If Next i 'Evaluate the formation Tax.EvaluateFormation FormTemperature(), FormTemperatureN(), AnnTemperature() _ , AnnTemperatureN(), AnnPressure(), AnnPressureN(), imax, jMax, store2() err = 0 'check for convergence
125
For i = 0 To imax check1 = ((AnnTemperatureN(i) - store1(i)) ^ 2) ^ (1 / 2) check2 = ((FormTemperatureN(i, 0) - store2(i)) ^ 2) ^ (1 / 2) check3 = ((PipeTemperatureN(imax) - AnnTemperatureN(imax)) ^ 2) ^ (1 / 2) If check1 > err Then err = check1 End If If check2 > err Then err = check2 End If If check3 > err Then 'err = check3 End If Next i Loop Until err <= 0.05 'update the temperature in the formation and wellbore For i = 0 To imax For j = 0 To jMax FormTemperature(i, j) = FormTemperatureN(i, j) Next j AnnTemperature(i) = AnnTemperatureN(i) PipeTemperature(i) = PipeTemperatureN(i) PipePressure(i) = PipePressureN(i) AnnPressure(i) = AnnPressureN(i) Next i 'Display results in formation For i = 0 To imax For j = 0 To jMax Worksheets("FormationTemperature").Cells((i + 2), (j + 2)).Value = FormTemperatureN(i, j) Next j Next i Next n 'Display results in wellbore For i = 0 To imax Worksheets("AnnulusTemperature").Cells((i + 2), 3).Value = AnnTemperatureN(i) Worksheets("AnnulusTemperature").Cells((i + 2), 2).Value = PipeTemperatureN(i)
126
Next i DppTotal = 0 DpaTotal = 0 'Compute Frictional Pressure Drop For i = 0 To imax If i > 0 Then 'compute plastic viscosity in cp PlasticP = Tax.MudPlasticViscosity(PipeTemperatureN(i), PipePressureN(i)) PlasticA = Tax.MudPlasticViscosity(AnnTemperatureN(i), AnnPressureN(i)) 'Compute yield point in lbf/100ft^2 YieldP = Tax.MudYieldValue(PipeTemperatureN(i), PipePressureN(i)) YieldA = Tax.MudYieldValue(AnnTemperatureN(i), AnnPressureN(i)) 'Compute velocity in pipe and annulus vP = 4 * Tax.mRate / (7.48 * 3.142 * ((2 * Tax.rpi) ^ 2) * rhoPipe(i - 1)) vA = 4 * Tax.mRate / (7.48 * 3.142 * (Tax.de ^ 2) * rhoAnnulus(i - 1)) 'Compute apparent viscosity in pipe and annulus muP = PlasticP + (6.66 * YieldP * 2 * Tax.rp / vP) muA = PlasticA + (5 * YieldA * Tax.de / vA) 'Compute Reynold's # in pipe and annulus ReP = Tax.ReynoldsNum(rhoPipe(i - 1), vP, (2 * Tax.rp), muP) ReA = Tax.ReynoldsNum(rhoAnnulus(i - 1), vA, Tax.de, muA) 'Compute frictional pressure drop DPP = Tax.PressureDrop(ReP, (2 * Tax.rp), 0.01, Tax.DeltaZ, rhoPipe(i - 1), vP) DPA = Tax.PressureDrop(ReA, Tax.de, 0.03, Tax.DeltaZ, rhoAnnulus(i - 1), vA) DppTotal = DppTotal + DPP DpaTotal = DpaTotal + DPA End If Worksheets("AnnulusTemperature").Cells((i + 2), 4).Value = rhoPipe(i) Worksheets("AnnulusTemperature").Cells((i + 2), 5).Value = rhoAnnulus(i) Worksheets("AnnulusTemperature").Cells((i + 2), 6).Value = PipePressureN(i)
127
Worksheets("AnnulusTemperature").Cells((i + 2), 7).Value = AnnPressureN(i) Worksheets("AnnulusTemperature").Cells((i + 2), 8).Value = DppTotal Worksheets("AnnulusTemperature").Cells((i + 2), 9).Value = DpaTotal Next i End Sub The following Code details the methods and characteristics of a well-bore profile object. Option Explicit 'Formation Properties Public kF As Double Public cF As Double Public FormationDensity As Double Public alpha As Double 'The maximum formation radius that will be considered (ft) 'a.k.a r-infinity Public rMax As Double 'Undisturbed formation temperature at the maximum depth considered Public Tmax As Double 'Mud Properties (densities in lb/gal) Public RefMudDensity As Double Public RefMudPlasticViscosity As Double Public RefMudYieldValue As Double Public OilFraction As Double Public WaterFraction As Double Public mRate As Double Public cfl As Double Public kfl As Double 'Reference mud conditions Public RefTemp As Double Public RefPress As Double 'annular radius Public ra As Double
128
'outer pipe radius Public rp As Double 'inner pipe radius Public rpi As Double 'heat conduction coefficient of pipewall Public kp As Double 'heat conduction coefficient of cement Public kcement As Double 'equivalent diameter of the annulus Public de As Double 'Heat Transfer coefficients across pipewall and across annulus/formation interface 'in Btu/(hour-ft2-oF) Public Ua As Double Public Up As Double Public time As Double Public beta As Double Public gG As Double Public TVD As Double Public Tdiff As Double Public TFs As Double Public Tps As Double 'Analytical parameters Public DTime As Double Public DTimeFunc As Double Public sigma As Double Public gammaOne As Double Public gammaTwo As Double Public COne As Double Public CTwo As Double 'Temperature in the annulus and pipe (oF) terms used in analytical analysis Public TAnnulus As Double Public TPipe As Double 'time, depth and radius intervals Public DeltaT As Double Public DeltaZ As Double Public DeltaR As Double 'terms used in numerical analysis- see class initialize for definitions Public ar As Double
129
Public az As Double 'Total number of depth, radial, and time steps Public iTotal As Double Public jTotal As Double Public nTotal As Double Private Sub Class_Initialize() mRate = Range("B20").Value cfl = Range("B11").Value kfl = Range("B10").Value kF = Range("B14").Value cF = Range("B15").Value FormationDensity = Range("B16").Value ra = Range("B5").Value rp = Range("B4").Value rpi = Range("B34").Value kp = Range("B25").Value Ua = Range("B24").Value Up = Range("B23").Value rMax = Range("B22").Value alpha = Range("B21").Value time = Val(Application.Worksheets("Sheet1").CirculationTime.Value) gG = Range("B18").Value TVD = Range("B3").Value TFs = Range("B17").Value Tps = Range("B7").Value kcement = 0.025 RefTemp = Range("B27").Value RefPress = Range("B28").Value RefMudDensity = Range("B29").Value RefMudPlasticViscosity = Range("B30").Value RefMudYieldValue = Range("B31").Value OilFraction = Range("B32").Value WaterFraction = Range("B33").Value de = 2 * (ra - rp) 'The following constants are declared for convenience beta = mRate * cfl / (2 * Pie * rpi * Up) Tdiff = TFs - Tps - beta * gG
130
'Tdiff = Tps - TFs + beta * gG Tmax = TFs + gG * TVD 'numerical intervals DeltaT = 0.05 DeltaZ = TVD / 200 DeltaR = rMax / 100 'terms used in numerical analysis ar = DeltaT / (DeltaR ^ 2) az = DeltaT / (DeltaZ ^ 2) 'compute iTotal If ((TVD / DeltaZ) - Int(TVD / DeltaZ)) < 0.5 Then iTotal = Int(TVD / DeltaZ) Else nTotal = Int(TVD / DeltaZ) + 1 End If 'compute jTotal If ((rMax / DeltaR) - Int(rMax / DeltaR)) < 0.5 Then jTotal = Int(rMax / DeltaR) Else jTotal = Int(rMax / DeltaR) + 1 End If 'compute nTotal If ((time / DeltaT) - Int(time / DeltaT)) < 0.5 Then nTotal = Int(time / DeltaT) Else nTotal = Int(time / DeltaT) + 1 End If End Sub Private Function ExpInt(X As Double) As Double Rem C Rem DOUBLE PRECISION FUNCTION EXPIN(X) Rem C Rem C Rem C EXPIN is the function which computes Rem C the exponential integral. Rem C Rem C E1(x)=SIGMA(x---->infinity)(exp(-t)/t)dt Rem C Rem C
131
Rem IMPLICIT REAL*8(A-H,O-Z) Rem COMMON AS,BS,S,ISTEP Rem C IF (X.LE.0) WRITE(10,10) X Dim Sign As Double Dim XX As Double Dim A1 As Double Dim A As Double Dim B As Double If (X <= 0#) Then Sign = -1# Else Sign = 1# Rem GoTo 2 End If XX = Abs(X) Rem C 10 FORMAT(//,2X,'X must be a positive number X= ',D19.8) If ((XX >= 0#) And (XX <= 1#)) Then GoTo 1 End If Rem C Rem C 1<=X<infinity. 5.1.56 Abramowitz & Stegun. Rem C A1 = XX ^ 4 A = A1 + 8.5733287401 * XX ^ 3 A = A + 18.059016973 * XX ^ 2 + 8.6347608925 * XX A = A + 0.2677737343 B = A1 + 9.5733223454 * XX ^ 3 B = B + 25.6329561486 * XX ^ 2 + 21.0996530827 * XX B = B + 3.9584969228 ExpInt = A / B / XX / Exp(XX) GoTo 2 Rem Return Rem C Rem C 0<=X<=1 5.1.53 Abramowitz & Stegun. Rem C 1 A = -0.57721566 + 0.99999193 * XX - 0.24991055 * XX ^ 2 A = A + 0.05519968 * XX ^ 3 - 0.00976004 * XX ^ 4 A = A + 0.00107857 * XX ^ 5
132
ExpInt = A - Log(XX) / Log(Exp(1#)) Rem Return Rem End Rem C 2 ExpInt = Sign * ExpInt End Function Public Function Pie() As Double 'This function computes Pi Pie = Application.WorksheetFunction.Pi End Function Public Function Absolute(X As Double) As Double 'This function returns the absolute value Absolute = Application.WorksheetFunction.Abs(X) End Function Public Function NatLg(X As Double) As Double NatLg = Application.WorksheetFunction.Ln(X) End Function '---------------------------TRIDIAGONAL ALGORITHM Public Sub ThomasAlgorithm(A() As Double, B() As Double, C() As Double, D() As Double, X() As Double, n As Integer) Dim i As Integer For i = 1 To n B(i) = B(i) - A(i) * C(i - 1) / B(i - 1) D(i) = D(i) - A(i) * D(i - 1) / B(i - 1) Next i ' Back Substitution X(n) = D(n) / B(n) For i = n - 1 To 0 Step -1 X(i) = (D(i) - C(i) * X(i + 1)) / B(i) Next i End Sub
133
Public Sub AnalyticalConstants() 'The following code will calculate the constants "sigma", "gammaOne", '"gammaTwo", "COne", and "CTwo" 'mRate = mass flow rate, cfl = fluid heat capacity, kF = formation 'conductivity, ra = annular radius, Ua = annular heat transfer coeff, 'aplha = k/(rho*cF), time = length of time of fluid circulation, 'beta = m*cfl/(2*Pi*rp*Up), gG = formatin temp grad. , TVD = Total 'vertical depth, Tdiff = (Tfs - Tps - beta*gG) 'Calculate dimensionless time "tD" 'DTime = (ra ^ 2) / (4 * alpha * time) DTime = (-1 * ra ^ 2) / (4 * alpha * time) 'Calculate dimensionless time function "f(tD)" DTimeFunc = 0.5 * ExpInt(DTime) / Exp(DTime) sigma = mRate * cfl * ((kF + ra * Ua * DTimeFunc) / (2 * Pie * ra * Ua * kF)) 'Compute "gammaOne" and "gammaTwo" gammaOne = (beta + ((beta ^ 2) + 4 * sigma * beta) ^ (1 / 2)) / (2 * sigma * beta) gammaTwo = (beta - ((beta ^ 2) + 4 * sigma * beta) ^ (1 / 2)) / (2 * sigma * beta) 'Compute "COne" and "CTwo" COne = (gG - (Exp(gammaTwo * TVD) * gammaTwo * Tdiff)) / (gammaTwo * Exp(gammaTwo * TVD) - gammaOne * Exp(gammaOne * TVD)) CTwo = (-1 * gG + (Exp(gammaOne * TVD) * gammaOne * Tdiff)) / (gammaTwo * Exp(gammaTwo * TVD) - gammaOne * Exp(gammaOne * TVD)) 'COne = (gG + (Exp(gammaTwo * TVD) * gammaTwo * Tdiff)) / (gammaTwo * Exp(gammaTwo * TVD) - gammaOne * Exp(gammaOne * TVD)) 'CTwo = (gG + (Exp(gammaOne * TVD) * gammaOne * Tdiff)) / (-gammaTwo * Exp(gammaTwo * TVD) + gammaOne * Exp(gammaOne * TVD)) End Sub Public Sub AnalyticalComputeTemp(z As Double) 'Computes temperature in the drill pipe and annulus at a particular depth TAnnulus = AnalyticalAnnularTemp(z) TPipe = AnalyticalPipeTemp(z)
134
End Sub Private Function AnalyticalAnnularTemp(Depth As Double) As Double 'Computes the temperature in the annulus at a particular depth AnalyticalAnnularTemp = (1 + beta * gammaOne) * COne * Exp(gammaOne * Depth) + (1 + beta * gammaTwo) * CTwo * Exp(gammaTwo * Depth) + gG * Depth + TFs End Function Private Function AnalyticalPipeTemp(Depth As Double) As Double 'Computes the temperature inside the drill pipe at a particular depth AnalyticalPipeTemp = COne * Exp(gammaOne * Depth) + CTwo * Exp(gammaTwo * Depth) + gG * Depth + TFs - beta * gG End Function Public Function ReynoldsNum(rho As Double, v As Double, D As Double, mu As Double) As Double 'Computes the Reynold's number 'density (rho) is in lb/gal, velocity (v) is in ft/hr, equivalent diameter (D) is in ft 'apparent viscosity (mu) is in lb/ft-hr ReynoldsNum = (7.48 * rho * v * D) / mu End Function Private Function NusseltNum(Re As Double, Pr As Double, D As Double, L As Double) As Double 'This function computes the Nusselt number 'Re & Pr - dimensionless 'D - ft 'L - ft If L = 0 Then L = DeltaZ / 2 End If If Re < 2300 And L / D < (8 / (Re / Pr)) Then 'Seider and Tate(1936) correlation - Laminar NusseltNum = 1.86 * (Re * Pr * (D / L)) ^ (1 / 3) ElseIf Re < 2300 And L / D > (8 / (Re / Pr)) Then
135
NusseltNum = 6.49 ElseIf ((2300 <= Re) And (Re <= 10000)) Then 'Hausen(1943) correlation - Transition NusseltNum = 0.116 * ((Re ^ (2 / 3)) - 125) * (Pr ^ (1 / 3)) * (1 + (D / L) ^ (2 / 3)) ElseIf Re > 10000 Then 'Seider & Tate(1936) correlation - Turbulent NusseltNum = 0.027 * (Re ^ 0.8) * (Pr ^ (1 / 3)) End If End Function Public Function FrictionFactor(Re, Roughness, Diameter) As Double 'The friction factor is computed using the Swamme and Jain correlation If Re < 2300 Then FrictionFactor = 64 / Re Else FrictionFactor = 1.325 / (NatLg((Roughness / Diameter) / 3.7) + (5.74 / (Re ^ 0.9))) ^ 2 End If End Function Public Function PressureDrop(Re As Double, Diameter As Double, Roughness As Double _ , L As Double, rho As Double, v As Double) As Double 'Re- Reynold's # 'D - diameter in question (ft) 'e - Pipe roughness (ft) Dim F As Double If Re < 2100 Then F = 64 / Re Else F = 1.325 / (NatLg((Roughness / Diameter) / 3.7) + (5.74 / (Re ^ 0.9))) ^ 2 'f = (0.79 * NatLg(Re) - 1.64) ^ (-2) End If PressureDrop = F * rho * (L / Diameter) * (v ^ 2) * 7.48 / (2 * 32.174 * (3600 ^ 2) * (12 ^ 2))
136
End Function Private Function WaterDensity(T As Double, P As Double) As Double 'This function computes the water density at the given temperature and pressure 'The correlation used in this function was obtained from Sorelle (1982) 'This function gives water density in lb/gal 'P - psi, T - oF WaterDensity = 8.63186 + (-3.31977 * 10 ^ -3) * T + (2.3717 * 10 ^ -5) * P End Function Private Function OilDensity(T As Double, P As Double) As Double 'This function computes the oil density at the given temperature and pressure 'The correlation used in this function was obtained from Politte (1985) 'This function gives density in (g/cm^3) 'P - psi, T - oF OilDensity = 0.8807 + 1.5235 * (10 ^ -9) * P * T + 1.2806 * (10 ^ -6) * P _ + 1.0719 * (10 ^ -10) * (P ^ 2) + (-0.00036) * T _ + (-5.167 * 10 ^ -8) * T ^ 2 End Function Private Function OilViscosity(T As Double, P As Double) As Double 'This function computes the oil phase viscosity at the given temperature and pressure in "cp" 'P - psi, T - oF Dim A As Double Dim B As Double Dim C As Double Dim D As Double Dim E As Double Dim F As Double Dim G As Double A = -23.1888 B = -0.00148 C = -0.9501 D = -1.9776 * 10 ^ -8 E = 3.3416 * 10 ^ -5 F = 14.6767 G = 10.9973
137
OilViscosity = P * ((T * P) ^ C) * 10 ^ (A + B * T + D * T * P + E * P + F * OilDensity(T, P) + G / OilDensity(T, P)) End Function Public Function MudDensity(T As Double, P As Double) As Double 'This function Computes the mud density in lb/gal at the given temperature 'and pressure using the compositional model 'P - psi, T - oF MudDensity = RefMudDensity / (1 + OilFraction * ((OilDensity(RefTemp, RefPress) / (OilDensity(T, P))) - 1) + WaterFraction * ((WaterDensity(RefTemp, RefPress) / WaterDensity(T, P)) - 1)) End Function Public Function MudPlasticViscosity(T As Double, P As Double) As Double 'This function computes the plastic viscosity of the mud at the given temperature and pressure 'in centipoise (cp) 'P - psi, T - oF MudPlasticViscosity = RefMudPlasticViscosity * OilViscosity(T, P) / OilViscosity(RefTemp, RefPress) End Function Public Function MudYieldValue(T As Double, P As Double) As Double 'This function computes the yield value at the given temperature and pressure 'in lbf/100ft^2 'P - psi, T - oF Dim A As Double Dim B As Double Dim C As Double A = -0.186 B = 145.054 C = -3410.322 If T >= 90 Then MudYieldValue = RefMudYieldValue * (A + B * (T ^ -1) + C * (T ^ -2)) / (A + B * (RefTemp ^ -1) + C * (RefTemp ^ -2)) Else MudYieldValue = RefMudYieldValue
138
End If End Function Public Function ConvectiveHeatTransCoeff(T As Double, P As Double, L As Double _ , D1 As Double, D2 As Double) As Double 'This function computes the heat transfer coefficient 'T - oF, P - psi, L - ft, D - ft Dim rho As Double Dim mu As Double Dim velocity As Double Dim Re As Double Dim Pr As Double Dim Nu As Double 'Compute fluid density in lb/gal 'rho = MudDensity(T, P) rho = RefMudDensity 'Compute fluid viscosity in lb/ft-hr 'mu = 2.42 * MudPlasticViscosity(T, P) mu = 2.42 * RefMudPlasticViscosity 'Compute fluid velocity in ft/hr velocity = 4 * mRate / (7.48 * 3.142 * (D1 ^ 2) * rho) 'Compute Reynold's # Re = ReynoldsNum(rho, velocity, D1, mu) 'Compute Prandtl # Pr = mu * cfl / kfl 'Compute Nusselt # Nu = NusseltNum(Re, Pr, D1, L) 'Compute heat transfer coefficient ConvectiveHeatTransCoeff = Nu * kfl / D2 End Function Public Sub InitializeGrid(FormTemp() As Double, PipeTemp() As Double, AnnTemp() As Double, PipePress() As Double, Annpress() As Double, rhoP() As Double, rhoA() As Double, imax As Integer, jMax As Integer)
139
Dim i As Integer Dim j As Integer Dim hi As Double 'Set initial conditions in the formation and annulus i.e. n = 0 PipePress(0) = 14.7 Annpress(0) = 14.7 For i = 0 To imax For j = 0 To jMax FormTemp(i, j) = TFs + gG * i * DeltaZ Next j PipeTemp(i) = TFs + gG * i * DeltaZ AnnTemp(i) = TFs + gG * i * DeltaZ 'Specific well initial conditions 'PipeTemp(i) = 134.7 + 0.0047 * i * DeltaZ 'AnnTemp(i) = 134.7 + 0.0047 * i * DeltaZ 'Set the initial hydrostatic pressure profile in the wellbore If i > 0 Then rhoP(i - 1) = MudDensity(PipeTemp(i - 1), PipePress(i - 1)) rhoA(i - 1) = MudDensity(AnnTemp(i - 1), Annpress(i - 1)) PipePress(i) = PipePress(i - 1) + 0.052 * rhoP(i - 1) * DeltaZ Annpress(i) = Annpress(i - 1) + 0.052 * rhoA(i - 1) * DeltaZ End If Next i End Sub Public Sub EvaluateFormation(FormTemp() As Double, FormTempN() As Double _ , AnnTemp() As Double, AnnTempN() As Double, Annpress() As Double, AnnpressN() As Double _ , imax As Integer, jMax As Integer, store() As Double) 'This sub evaluates temperature in the formation and at the formation boundary Dim A() As Double Dim B() As Double Dim C() As Double
140
Dim D() As Double Dim X() As Double Dim E() As Double Dim F As Double Dim G() As Double Dim H As Double Dim K() As Double Dim L As Double Dim Q As Double Dim Uaa As Double Dim i As Integer Dim j As Integer ReDim A(jMax) ReDim B(jMax) ReDim C(jMax) ReDim D(jMax) ReDim X(jMax) ReDim E(jMax) ReDim G(jMax) ReDim K(jMax) 'Store the old guess for Tf(i,0,n+1) For i = 0 To imax store(i) = FormTempN(i, 0) Next i F = 1 + alpha * ar L = 1 - alpha * ar H = 1 + 2 * alpha * ar Q = 1 - 2 * alpha * ar For i = 0 To imax Uaa = ConvectiveHeatTransCoeff(AnnTempN(i), AnnpressN(i), ((100 - i) * DeltaZ), de _ , de) 'This is for a specific cased hole with cement Uaa = ((1 / Uaa) _ + (Pie * (4.892 ^ 2) * NatLg(5.5 / 4.892) / (2 * Pie * kp * DeltaZ)) _
Next j ThomasAlgorithm A, B, C, D, X, jMax 'update the temperature in the formation grid For j = 0 To jMax FormTempN(i, j) = X(j) Next j Next i End Sub Public Sub EvaluateAnnulus(FormTemp() As Double, FormTempN() As Double _ , PipeTemp() As Double, PipeTempN() As Double, AnnTemp() As Double, AnnTempN() As Double _ , PipePress() As Double, PipePressN() As Double, Annpress() As Double _ , AnnpressN() As Double, imax As Integer, store() As Double) Dim A() As Double Dim B() As Double Dim C() As Double Dim D() As Double Dim X() As Double Dim E As Double Dim F As Double Dim G As Double Dim H As Double Dim L As Double Dim M As Double Dim i As Integer Dim UaaN As Double Dim UppN As Double Dim hoN As Double Dim hiN As Double Dim Uaa As Double Dim Upp As Double Dim ho As Double Dim hi As Double 'These parameters will be used to compute the bottom-hole
143
'annular temperature Dim Re As Double Dim mi As Double Dim fa As Double Dim so As Double Dim theta As Double ReDim A(imax) ReDim B(imax) ReDim C(imax) ReDim D(imax) ReDim X(imax) 'Store the old guess for Ta(i,n+1) For i = 0 To imax store(i) = AnnTempN(i) Next i E = mRate * cfl / (2 * DeltaZ) 'The following computes the bottom-hole annular temperature theta = 2 / 3 UaaN = ConvectiveHeatTransCoeff(AnnTempN(imax), AnnpressN(imax), ((200 - imax) * DeltaZ) _ , de, de) 'This is for a specific cased hole UaaN = ((1 / UaaN) _ + (Pie * (4.892 ^ 2) * NatLg(5.5 / 4.892) / (2 * Pie * kp * DeltaZ)) _ + (Pie * (4.892 ^ 2) * NatLg(6.108 / 5.5) / (2 * Pie * kcement * DeltaZ))) ^ (-1) 'UaaN = Ua Re = mRate * cfl mi = Pie * ra * UaaN * DeltaZ fa = 7.48 * MudDensity(AnnTemp(imax), Annpress(imax)) * Pie * (ra ^ 2) * DeltaZ * cfl _
144
/ (2 * DeltaT) 'fa = 7.48 * RefMudDensity * Pie * (ra ^ 2) * DeltaZ * cfl / (2 * DeltaT) so = Re * theta * PipeTempN(imax - 1) + Re * (1 - theta) * PipeTemp(imax - 1) _ + mi * theta * FormTempN(imax, 0) + mi * (1 - theta) * FormTemp(imax, 0) _ + (-Re * (1 - theta) - mi * (1 - theta) + fa) * AnnTemp(imax) AnnTempN(imax) = so / (Re * theta + mi * theta + fa) For i = 0 To (imax - 1) 'These are the heat transfer coefficients at the current time-step UaaN = ConvectiveHeatTransCoeff(AnnTempN(i), AnnpressN(i), ((200 - i) * DeltaZ) _ , de, de) 'This is for a specific cased hole UaaN = ((1 / UaaN) _ + (Pie * (4.892 ^ 2) * NatLg(5.5 / 4.892) / (2 * Pie * kp * DeltaZ)) _ + (Pie * (4.892 ^ 2) * NatLg(6.108 / 5.5) / (2 * Pie * kcement * DeltaZ))) ^ (-1) hoN = ConvectiveHeatTransCoeff(AnnTempN(i), AnnpressN(i), ((100 - i) * DeltaZ) _ , de, de) hiN = ConvectiveHeatTransCoeff(PipeTempN(i), PipePressN(i), (i * DeltaZ) _ , (2 * rpi), (2 * rpi)) UppN = ((1 / hiN) + (Pie * (rpi ^ 2) / (hoN * Pie * rp ^ 2)) _ + Pie * (rpi ^ 2) * NatLg(rp / rpi) / (2 * Pie * kp * DeltaZ)) ^ (-1) 'These are the heat transfer coefficients at the previous time-step Uaa = ConvectiveHeatTransCoeff(AnnTemp(i), Annpress(i) _ , ((200 - i) * DeltaZ), de, 2 * ra) 'This is for a specific cased hole Uaa = ((1 / Uaa) _ + (Pie * (4.892 ^ 2) * NatLg(5.5 / 4.892) / (2 * Pie * kp * DeltaZ)) _ + (Pie * (4.892 ^ 2) * NatLg(6.108 / 5.5) / (2 * Pie * kcement * DeltaZ))) ^ (-1)
145
ho = ConvectiveHeatTransCoeff(AnnTemp(i), Annpress(i) _ , ((100 - i) * DeltaZ), de, 2 * rp) hi = ConvectiveHeatTransCoeff(PipeTemp(i), PipePress(i), (i * DeltaZ), 2 * rpi _ , 2 * rpi) Upp = ((1 / hi) + (Pie * (rpi ^ 2) / (ho * Pie * rp ^ 2)) _ + Pie * (rpi ^ 2) * NatLg(rp / rpi) / (2 * Pie * kp * DeltaZ)) ^ (-1) 'Uaa = Ua 'UaaN = Ua 'Upp = Up 'UppN = Up F = 2 * Pie * ra * UaaN G = 2 * Pie * rp * UppN H = 7.48 * MudDensity(AnnTempN(i), AnnpressN(i)) * Pie _ * ((ra ^ 2) - (rp ^ 2)) * cfl / (DeltaT) 'H = 7.48 * RefMudDensity * Pie * ((ra ^ 2) - (rp ^ 2)) * cfl / (DeltaT) L = 2 * Pie * ra * Uaa M = 2 * Pie * rp * Upp Select Case i Case 0 A(i) = 0 B(i) = F * theta + G * theta + H C(i) = -E * theta D(i) = -E * (1 - theta) * (AnnTemp(i) - 2) _ + (H - L * (1 - theta) - M * (1 - theta)) * AnnTemp(i) _ + E * (1 - theta) * AnnTemp(i + 1) + L * (1 - theta) * FormTemp(i, 0) _ + M * (1 - theta) * PipeTemp(i) + F * theta * FormTempN(i, 0) _ + G * theta * PipeTempN(i) - E * theta * (AnnTempN(i) - 1)
146
Case (imax - 1) A(i) = E * theta B(i) = F * theta + G * theta + H C(i) = 0 D(i) = -E * (1 - theta) * AnnTemp(i - 1) _ + (H - L * (1 - theta) - M * (1 - theta)) * AnnTemp(i) _ + E * (1 - theta) * AnnTemp(i + 1) + L * (1 - theta) * FormTemp(i, 0) _ + M * (1 - theta) * PipeTemp(i) + F * theta * FormTempN(i, 0) _ + G * theta * PipeTempN(i) + E * theta * AnnTempN(imax) Case Else A(i) = E * theta B(i) = F * theta + G * theta + H C(i) = -E * theta D(i) = -E * (1 - theta) * AnnTemp(i - 1) _ + (H - L * (1 - theta) - M * (1 - theta)) * AnnTemp(i) _ + E * (1 - theta) * AnnTemp(i + 1) + L * (1 - theta) * FormTemp(i, 0) _ + M * (1 - theta) * PipeTemp(i) + F * theta * FormTempN(i, 0) _ + G * theta * PipeTempN(i) End Select Next i ThomasAlgorithm A, B, C, D, X, (imax - 1) 'Update annulus temperature in finite difference grid For i = 0 To (imax - 1) AnnTempN(i) = X(i) Next i End Sub Public Sub EvaluatePipe(FormTemp() As Double, FormTempN() As Double, PipeTemp() As Double _ , PipeTempN() As Double, PipePress() As Double, PipePressN() As Double _ , AnnTemp() As Double, AnnTempN() As Double, Annpress() As Double, AnnpressN() As Double _ , imax As Integer) Dim A() As Double Dim B() As Double Dim C() As Double Dim D() As Double Dim X() As Double
147
Dim E As Double Dim F As Double Dim G As Double Dim H As Double Dim L As Double Dim M As Double Dim mi As Double 'This parameter is used to weight the numerical solution ' at the bottom of the hole. A value of half gives the 'Crank-Nicholoson scheme Dim theta As Double Dim i As Integer Dim Uaa As Double Dim Upp As Double Dim ho As Double Dim hi As Double ReDim A(imax) ReDim B(imax) ReDim C(imax) ReDim D(imax) ReDim X(imax) theta = 2 / 3 E = mRate * cfl / (2 * DeltaZ) 'Store the old guess for Tp(i,n+1) 'For i = 0 To iMax ' store(i) = PipeTemp(i, n) 'Next i 'This sets the inflow pipe temperature PipeTempN(0) = Tps For i = 1 To imax ho = ConvectiveHeatTransCoeff(AnnTemp(i), Annpress(i), (i * DeltaZ), de, de)
148
hi = ConvectiveHeatTransCoeff(PipeTemp(i), PipePress(i), (i * DeltaZ), 2 * rpi _ , 2 * rpi) Upp = ((1 / hi) + (Pie * (rpi ^ 2) / (ho * Pie * rp ^ 2)) _ + Pie * (rpi ^ 2) * NatLg(rp / rpi) / (2 * Pie * kp * i * DeltaZ)) ^ (-1) 'Upp = Up F = 7.48 * MudDensity(PipeTempN(i), PipePressN(i)) * Pie * (rp ^ 2) * cfl _ / (DeltaT) 'F = 7.48 * RefMudDensity * Pie * (rp ^ 2) * cfl / (DeltaT) G = 2 * Pie * rp * Upp H = 2 * Pie * rp * Upp Select Case i Case 1 A(i - 1) = 0 B(i - 1) = F + G * theta C(i - 1) = E * theta D(i - 1) = E * (1 - theta) * PipeTemp(i - 1) + (F - H * (1 - theta)) * PipeTemp(i) _ - E * (1 - theta) * PipeTemp(i + 1) + H * (1 - theta) * AnnTemp(i) _ + G * theta * AnnTempN(i) + E * theta * PipeTempN(i - 1) Case imax Uaa = ConvectiveHeatTransCoeff(AnnTemp(i), Annpress(i) _ , ((200 - i) * DeltaZ), de, 2 * ra) 'This is for a specific cased hole Uaa = ((1 / Uaa) _ + (Pie * (4.892 ^ 2) * NatLg(5.5 / 4.892) / (2 * Pie * kp * DeltaZ)) _ + (Pie * (4.892 ^ 2) * NatLg(6.108 / 5.5) / (2 * Pie * kcement * DeltaZ))) ^ (-1) 'Uaa = Ua L = mRate * cfl
149
M = 7.48 * MudDensity(PipeTempN(i), PipePressN(i)) * Pie * (ra ^ 2) * DeltaZ _ * cfl / 2 * DeltaT 'M = 7.48 * RefMudDensity * Pie * (ra ^ 2) * DeltaZ * cfl / 2 * DeltaT mi = Pie * ra * Uaa * DeltaZ A(i - 1) = theta * L B(i - 1) = -theta * L - M C(i - 1) = 0 D(i - 1) = -(1 - theta) * L * PipeTemp(i - 1) + ((1 - theta) * L - M) _ * PipeTemp(i) - mi * theta * FormTempN(i, 0) _ - mi * (1 - theta) * FormTemp(i, 0) + mi * theta * AnnTempN(i) _ + mi * (1 - theta) * AnnTemp(i) Case Else A(i - 1) = -E * theta B(i - 1) = F + G * theta C(i - 1) = E * theta D(i - 1) = E * (1 - theta) * PipeTemp(i - 1) _ + (F - H * (1 - theta)) * PipeTemp(i) _ - E * (1 - theta) * PipeTemp(i + 1) _ + H * (1 - theta) * AnnTemp(i) + G * theta * AnnTempN(i) End Select Next i ThomasAlgorithm A, B, C, D, X, (imax - 1) 'Update pipe temperature in finite difference grid For i = 0 To (imax - 1) PipeTempN(i + 1) = X(i) Next i End Sub