-
Notifications
You must be signed in to change notification settings - Fork 0
/
VertCompletionObj.m
460 lines (391 loc) · 14.3 KB
/
VertCompletionObj.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
classdef VertCompletionObj < handle
%VertCompletionObj. Vertical Completion Object
% VertCompletionObj includes the information from the inflow performance
% relationships (IPR) in a vertical completion.
%
% Properties
% - IPRType : IPR model
% - Qsc : hydrocarbon flow rate @SC [Sm3/d]
% - Pws : reservoir pressure [kPa]
% - Pwf : bottom-hole pressure [kPa]
% - Twf : bottom-hole temperature [C]
% - JonesA : Jones' model laminar flow constant []
% - JonesB : Jones' model turbulent flow constant []
% - JonesType : Jones' model phase type
% - WellPIJ : well productivity index
% - WellPIType : well PI phase type
% - VogelQmax : Vogel's model maximum flow rate [Sm3/d]
% - FetchovitchQmax : Fetchovitch's model maximum flow rate [Sm3/d]
% - FetchovitchN : Fetchovitch's model n coefficient [-]
% - BackPressureC : backpressure model c coefficient []
% - BackPressureN : backpressure model n coefficient [-]
% - CalculationType : pressure or flow rate calculation
%
% Dependent properties
% - status : programming property (to be used in further versions)
%
% Methods
% - QCalculation
% Calculation of Qsc using the selected IPR model.
% - PwfCalculation
% Calculation of Pwf using the selected IPR model.
% - SolveCompletion
% Solve the completion depending on the selected model, calculating
% either Pwf or Qsc, according the complation data.
% -------------------------------------------------------------------------
% Development
% By: Ruben Ensalzado
% 2015
% Rev 00 151216 original release
% Rev 01 160109 remove Q, Tsc, Psc, Zwf properties
% fix bug in error notification for BadArguments error type
% include AOFPCalculation method
properties
IPRType
Qsc
Pws
Pwf
Twf
JonesA
JonesB
JonesType
WellPIJ
WellPIType
VogelQmax
FetchovitchQmax
FetchovitchN
BackPressureC
BackPressureN
CalculationType
end
properties (Dependent = true)
status
AOFP
end
methods (Hidden = true)
% -- initialization method --
function VC = VertCompletionObj
VC.IPRType = 'Well PI';
VC.CalculationType = 'pwf';
VC.JonesType = 'oil';
VC.WellPIType = 'oil';
end
end
methods
% -- error verification methods --
function set.IPRType(VC, uIPRType)
if strcmpi(uIPRType, 'well pi') || strcmpi(uIPRType, 'vogel') || ...
strcmpi(uIPRType, 'fetkovitch') || strcmpi(uIPRType, 'jones') || ...
strcmpi(uIPRType, 'backpressure equation')
VC.IPRType = uIPRType;
else
errrm = ['The available methods are:';...
'- Well PI ';...
'- Vogel ';...
'- Fetkovcitch ';...
'- Jones '; ...
'- BackPressure Equation '];
error('VerticalCompletionObject:BadArgument', ...
'%s \n\t%s \n\t%s \n\t%s \n\t%s \n\t%s \n', ...
errrm(1, :), errrm(2, :), errrm(3, :), ...
errrm(4, :), errrm(5, :), errrm(6, :))
end
end
function set.CalculationType(VC, uType)
if strcmpi(uType, 'pwf') || strcmpi(uType, 'q')
VC.CalculationType = uType;
else
errrm = ['The available calculations are:';...
'- pwf: bottom hole presssure ';...
'- q : fluid inflow '];
error('VerticalCompletionObject:BadArgument', ...
'%s \n\t%s \n\t%s \n', ...
errrm(1, :), errrm(2, :), errrm(3, :));
end
end
function set.WellPIType(VC, uWellPIType)
if strcmpi(uWellPIType, 'oil') || strcmpi(uWellPIType, 'gas')
VC.WellPIType = uWellPIType;
else
errrm = ['The available types are:';...
'- oil ';...
'- gas '];
error('VerticalCompletionObject:BadArgument', ...
'%s \n\t%s \n\t%s \n', ...
errrm(1, :), errrm(2, :), errrm(3, :));
end
end
function set.JonesType(VC, uJonesType)
if strcmpi(uJonesType, 'oil') || strcmpi(uJonesType, 'gas')
VC.JonesType = uJonesType;
else
errrm = ['The available types are:';...
'- oil ';...
'- gas '];
error('VerticalCompletionObject:BadArgument', ...
'%s \n\t%s \n\t%s \n', ...
errrm(1, :), errrm(2, :), errrm(3, :));
end
end
end
methods
% -- dependent properties --
function status = get.status(VC)
%Status. Independent property verification
req = zeros(5, 1);
req(1) = isempty(VC.Qsc);
req(2) = isempty(VC.Pws);
switch lower(VC.IPRType)
case 'well pi'
req(3) = isempty(VC.WellPIType);
req(4) = isempty(VC.WellPIJ);
case 'vogel'
req(3) = isempty(VC.VogelQmax);
case 'fetkovitch'
req(3) = isempty(VC.FetchovitchQmax);
req(4) = isempty(VC.FetchovitchN);
case 'jones'
req(3) = isempty(VC.JonesType);
req(4) = isempty(VC.JonesA);
req(5) = isempty(VC.JonesB);
case 'backpressure equation'
req(3) = isempty(VC.BackPressureC);
req(4) = isempty(VC.BackPressureN);
end
if all(~req)
status = true;
else
status = false;
end
end
function AOFP = get.AOFP(VC)
%AOFP. Absolute open flow performance
% Well performance when Pwf = 0.
CP0 = VC.CalculationType;
switch CP0
case 'q'
CP1 = VC.Pws;
CP2 = VC.Pwf;
case 'pwf'
CP1 = VC.Qsc;
CP2 = VC.Pwf;
end
VC.CalculationType = 'q';
VC.Pwf = 0;
VC.SolveCompletion
AOFP = VC.Qsc;
switch CP0
case 'q'
VC.CalculationType = 'q';
VC.Pws = CP1;
VC.Pwf = CP2;
case 'pwf'
VC.CalculationType = 'pwf';
VC.Qsc = CP1;
VC.Pwf = CP2;
end
end
end
methods
% -- calculation methods --
function CalculateQ(VC)
%CalculateFlowRate. Q calculation depending on the IPR model
switch lower(VC.IPRType)
case 'well pi'
VC.QWellPI
case 'vogel'
VC.QVogel
case 'fetkovitch'
VC.QFetkovitch
case 'jones'
VC.QJones
case 'backpressure equation'
VC.QBackPressure
end
if VC.Qsc < 0
VC.Qsc = 0;
lastwarn('Pwf may be greater than Pws; Q was set to zero!')
end
end
function CalculatePwf(VC)
%CalculateBottomHolePressure. Pwf calculation depending on the
%IPR model
switch lower(VC.IPRType)
case 'well pi'
VC.PwfWellPI
case 'vogel'
VC.PwfVogel
case 'fetkovitch'
VC.PwfFetkovitch
case 'jones'
VC.PwfJones
case 'backpressure equation'
VC.PwfBackPressure
end
if any(~isreal(VC.Pwf))
VC.Pwf = 0;
lastwarn('Pwf may be greater than Pws; Q was set to zero!')
end
end
function SolveCompletion(VC)
%SolveCompletion. Calculate Pwf or Qsc depeding on calculation
%method
switch lower(VC.CalculationType)
case 'pwf'
VC.CalculatePwf
case 'q'
VC.CalculateQ
end
end
end
methods (Hidden = true)
% -- IPR models : flow rate --
function QWellPI(VC)
%WellProductivityIndexFlowRate. Well PI IPR model
%Units
% J : Sm3/d.kPa or Sm3/d.kPa2
% Pws : kPa
% Pwf : kPa
% Qsc : Sm3/d
J = VC.WellPIJ;
switch lower(VC.WellPIType)
case 'oil'
VC.Qsc = J*(VC.Pws - VC.Pwf);
case 'gas'
VC.Qsc = J*(VC.Pws^2 - VC.Pwf^2);
end
end
function QVogel(VC)
%Vogel. (flow rate) Vogel IPR model
%Units
% qmax : Sm3/d
% Pws : kPa
% Pwf : kPa
% Qsc : Sm3/d
Pwf_Pws = VC.Pwf/VC.Pws;
qmax = VC.VogelQmax;
VC.Qsc = qmax*(1 - 0.2*(Pwf_Pws) - 0.8*(Pwf_Pws)^2);
end
function QFetkovitch(VC)
%Fetkovitch. (flow rate) Fetkovitch IPR model
%Units
% qmax : Sm3/d
% Pws : kPa
% Pwf : kPa
% Qsc : Sm3/d
Pwf_Pws = VC.Pwf/VC.Pws;
qmax = VC.FetchovitchQmax;
n = VC.FetchovitchN;
VC.Qsc = qmax*(1 - (Pwf_Pws)^2)^n;
end
function QJones(VC)
%Jones. (flow rate) Jones IPR model
%Units
% JonesA : kPa.d/Sm3 or kPa2.d/Sm3
% JonesB : kPa.d2/(Sm3)2 or kPa2.d2/(Sm3)2
% Pws : kPa
% Pwf : kPa
% Qsc : Sm3/d
C1 = VC.JonesB;
C2 = VC.JonesA;
switch lower(VC.JonesType)
case 'oil'
C3 = VC.Pws - VC.Pwf;
case 'gas'
C3 = VC.Pws^2 - VC.Pwf^2;
end
VC.Qsc = max(roots([C1 C2 C3]));
end
function QBackPressure(VC)
%BackPressure. (flow rate) Backpressure IPR model
%Units
% C : Sm3/(kPa)2n
% Pws : kPa
% Pwf : kPa
% Qsc : Sm3/d
C = VC.BackPressureC;
n = VC.BackPressureN;
VC.Qsc = C*(VC.Pws^2 - VC.Pwf^2)^n;
end
end
methods (Hidden = true)
% -- IPR models : bottom hole pressure --
function PwfWellPI(VC)
%WellProductivityIndex. (bottomhole pressure) Well PI IPR model
%Units
% J : Sm3/d.kPa or Sm3/d.kPa2
% q : Sm3/d
% Pws : kPa
% Pwf : kPa
J = VC.WellPIJ;
pws = VC.Pws;
q = VC.Qsc;
switch lower(VC.WellPIType)
case 'oil'
VC.Pwf = pws - q/J;
case 'gas'
VC.Pwf = sqrt(pws^2 - q/J);
end
end
function PwfVogel(VC)
%Vogel. (bottomhole pressure) Vogel IPR model
%Units
% qmax : Sm3/d
% q : Sm3/d
% Pws : kPa
% Pwf : kPa
pws = VC.Pws;
q = VC.Qsc;
qmax = VC.VogelQmax;
C1 = 0.8;
C2 = 0.2;
C3 = q/qmax - 1;
VC.Pwf = max(roots([C1 C2 C3]))*pws;
end
function PwfFetkovitch(VC)
%Fetkovitch. (bottomhole pressure) Fetkovitch IPR model
%Units
% qmax : Sm3/d
% q : Sm3/d
% Pws : kPa
% Pwf : kPa
pws = VC.Pws;
q = VC.Qsc;
qmax = VC.FetchovitchQmax;
n = VC.FetchovitchN;
VC.Pwf = pws*sqrt(1 - (q/qmax)^(1/n));
end
function PwfJones(VC)
%Jones. (bottomhole pressure) Jones IPR model
%Units
% JonesA : kPa.d/Sm3 or kPa2.d/Sm3
% JonesB : kPa.d2/(Sm3)2 or kPa2.d2/(Sm3)2
% q : Sm3/d
% Pws : kPa
% Pwf : kPa
A = VC.JonesB;
B = VC.JonesA;
pws = VC.Pws;
q = VC.Qsc;
switch lower(VC.JonesType)
case 'oil'
VC.Pwf = pws - A*q - B*q^2;
case 'gas'
VC.Pwf = sqrt(pws^2 - A*q - B*q^2);
end
end
function PwfBackPressure(VC)
%BackPressure. (flow rate) Backpressure IPR model
%Units
% C : Sm3/(kPa)2n
% q : Sm3/d
% Pws : kPa
% Pwf : kPa
pws = VC.Pws;
q = VC.Qsc;
C = VC.BackPressureC;
n = VC.BackPressureN;
VC.Pwf = sqrt(pws^2 - q^(1/n)/C);
end
end
end