Reservoir Simulation

Your Progress in this Chapter

0%

0 / 2 units completed

Chapter Overview

Reservoir Simulator 1D 2 Phases

Section 12.2 of 215 min1 code examples

Technical Overview and Mathematical Framework

In this section, we develop a comprehensive, fully implicit 1D two-phase reservoir simulator that models the transient, coupled flow of immiscible oil and water through a heterogeneous porous medium. The simulator is designed to capture the complex fluid-fluid and fluid-rock interactions that occur during waterflooding performance.

The mathematical framework couples the physics of multiphase porous media flow with operational engineering constraints.It incorporates highly nonlinear constitutive relationships—including fluid compressibilities, pressure-dependent viscosities, relative permeability curves, and capillary pressure effects—along with dynamic well control logic and an automated adaptive time-stepping engine.

Governing Flow Equations

The core of the simulator is governed by mass conservation equations for each fluid phase: water (w) and oil (o). In a 1D horizontal system, assuming Darcy flow, the partial differential equations(PDEs) are expressed as: Water Phase Mass Conservation:

x[αkkrwμwBwPwx]±qw=1βt(ϕSwBw)\frac{\partial }{\partial x} \left[ \alpha \frac{k \cdot k_ { rw }}{\mu_w B_w} \frac{\partial P_w}{\partial x} \right] \pm q_w = \frac{1}{\beta} \frac{\partial}{\partial t} \left( \frac{\phi S_w}{ B_w} \right)

Oil Phase Mass Conservation:

x[αkkroμoBoPox]±qo=1βt(ϕSoBo)\frac{\partial}{\partial x} \left[ \alpha \frac{ k \cdot k_{ ro} }{\mu_o B_o} \frac{\partial P_o} {\partial x} \right] \pm q_o = \frac{ 1} {\beta} \frac{\partial} {\partial t} \left( \frac{\phi S_o} { B_o} \right)

Where: P_o and P_w are the oil and water phase pressures respectively (\text{psi}).

S_o and S_w are the oil and water phase saturations, satisfying the algebraic constraint: S_o + S_w = 1.0.

k is the absolute rock permeability(\text{md}), and \phi is the rock porosity.

\alpha (1.127 \times 10^{ -3}) and \beta (5.615\ \text{ ft}^3/\text{bbl}) are conversion constants matching standard field units.

q_w, q_o represent volumetric source/sink well terms (\text{STB/day}).

Constitutive and Petrophysical Relationships

To close the system of equations, several empirical and thermodynamic relationships are explicitly modeled as functions of the primary state variables (P_o and S_w):

Phase Pressure Coupling (Capillary Pressure) The water phase pressure is dynamically linked to the oil phase pressure via the laboratory-measured imbibition capillary pressure function (P_{ cI}):

Pw=PoPcI(Sw)P_w = P_o - P_{ cI} (S_w)

The capillary pressure curve is scaled using an effective saturation profile(S_{ we}):

Swe=SwSwr1SwrSorS_{ we} = \frac{ S_w - S_{ wr} } { 1 - S_{ wr} -S_{ or} }
PcI(Sw)=Pe[(Swe)0.51]P_{ cI}(S_w) = P_e \cdot \left[ (S_{we})^{ -0.5}-1 \right]

where P_e is the entry capillary pressure, S_{ wr} is the residual water saturation, and S_{ or} is the residual oil saturation.

Relative Permeability(Modified Corey-Brooks Model) Multiphase fluid interference inside the pore throat structure is dictated by power-law relative permeability functions:

krw(Sw)=krw0(Swe)nwk_{ rw}(S_w) = k_{ rw0} \cdot(S_{ we})^{ n_w}
kro(So)=kro0(1(1So)Swr1SwrSor)nok_{ ro}(S_o) = k_{ ro0} \cdot \left(1 - \frac{(1 - S_o) - S_{wr}}{ 1 - S_{ wr} -S_{ or} }\right)^{n_o}

Fluid PVT Behavior (Compressibility and Viscosity) Fluid volumes and flows scale dynamically with local pressure fields to model slightly compressible behaviors:

Bo(Po)=Bo0eco(2000Po)andBw(Pw)=Bw0ecw(2500Pw)B_o(P_o) = B_{ o0} \cdot e^{c_o(2000 - P_o)} \quad \text{and} \quad B_w(P_w) = B_{ w0} \cdot e^{c_w(2500 - P_w)}
μo(Po)=μo0ebo(Po2000)andμw(Pw)=μw0ebw(Pw2500)\mu_o(P_o) = \mu_{o0} \cdot e^{b_o(P_o - 2000)} \quad \text{and} \quad \mu_w(P_w) = \mu_{w0} \cdot e^{b_w(P_w - 2500)}

Spatial Discretization &Transmissibilities

The continuous governing equations are discretized in space using a block-centered finite volume formulation.For fluid flow between block i and block i+1, the inter-block absolute permeability is resolved using a harmonic mean:

ki+1/2=Harmmean(ki,ki+1)=21ki+1ki+1k_{i+1/2} = \text{Harmmean}(k_i, k_{i+1}) = \cfrac{2}{\cfrac{1}{k_i} + \cfrac{1}{k_{i+1}}}

To ensure numerical stability and avoid unphysical oscillations across displacement fronts, the phase fluid mobilities (k_{r}/(\mu B)) are evaluated using Single-Point Upstream Weighting. The properties are chosen entirely from the cell possessing the higher phase pressure:

(krwμwBw)i+1/2={(krwμwBw)iifPw,i>Pw,i+1(krwμwBw)i+1ifPw,i+1>Pw,i\left(\cfrac{k_{rw}}{\mu_w B_w} \right)_{i+1/2} = \begin{cases} \left(\cfrac{k_{rw}}{\mu_w B_w} \right)_i & \text{if} P_{w, i} > P_{w,i+1} \\ \left(\cfrac{k_{rw}}{\mu_w B_w} \right)_{i+1} & \text{if} P_{w, i+1} > P_{ w,i} \end{cases}

Wellbore Boundary Equations and Operational Controls Wells represent external localized source/sink boundary constraints modeled via a radial inflow Peaceman formulation. The equivalent well block radius (r_e) and baseline Well Index (WI) are evaluated as:

re=0.14Δx2+Δy2r_e = 0.14\sqrt{\Delta x^2 + \Delta y^2}
WI=2παkΔzln(re/rw)WI = \frac{2\pi \alpha \cdot k \cdot \Delta z}{\ln(r_e / r_w)}

The individual phase flow rates produced or injected in a grid block are functions of the drawdown between the cell pressure and the wellbore's bottomhole flowing pressure (P_{wf}):

Qw=WIkrwμwBw(PwfPw)Q_w = WI \cdot \frac{k_{rw}}{\mu_w B_w} \cdot(P_{ wf} - P_w)
Qo=WIkroμoBo(PwfPo)Q_o = WI \cdot \frac{k_{ro}}{\mu_o B_o} \cdot(P_{ wf} - P_o)

Dynamic Constraint Swapping

Wells operate on dual-modifier switching scripts. They enforce target surface volume constraints as long as the system remains within safe pressure limits:

Producer: Operates at a target production rate Q_{ target}. If the calculated P_{ wf} drops below the mechanical limit P_{ min} (1500\ \text{psi}), the control loop automatically switches to variable-rate, fixed-BHP mode (P_{ wf} = P_{ min}).

Injector: Operates at a target injection rate Q_{ target}. If the injection pressure exceeds a formation fracturing threshold P_{ max} (4500\ \text{psi}), the solver seamlessly overrides the control variables to fixed-pressure boundaries (P_{wf} = P_{max}).

Numerical Solution and Post-Processing Applying backward Euler finite differences (Full_Implicit) in time yields a highly non-linear algebraic system of discrete residual equations at each time level (n+1). The total mathematical system vector is assembled explicitly via a custom packing scheme:

R(x)=[RoilRwaterRwellborebalanceRoperationalcontrols]=0\vec{R}(\vec{x}) = \begin{bmatrix} \vec{R_{oil}} \\ \vec{R_{water}} \\ \vec{R_{wellbore-balance}} \\ \vec{R_{operational-controls}} \end{bmatrix} = \vec{0}

This combined system is solved iteratively using the high-performance Fsolve method, which is part of the Solver class inside SepalSolver—a proprietary scientific computing and mathematical library developed by CypherCrescent. To maximize computational throughput, the simulator pairs SepalSolver's root-finding capabilities with an automated adaptive time-stepping loop. If the non-linear solver encounters a convergence failure or an operational constraint violation, the engine automatically cuts the time step size (\Delta t) by 75\% and retries the step. Conversely, when convergence is achieved rapidly (\text{Iterations} < 4), the engine safely scales up \Delta t by 25\% for subsequent steps. Finally, the localized state data histories collected are processed dynamically to output diagnostic performance graphs (tracking fractional water cuts, bottomhole pressures, and overall volumetric sweep efficiency) while compiling a high-speed animated GIF visualizing the propagation of the transient water saturation shock front over time.

Example 1C#

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
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
Code is ready to run
OutputFrom the book
======================================================================
           Starting simulation for Rate = 200 STB/day

Time: 
0.00 days

Producer BHP: 
3000.00 psi

Injector BHP: 
3000.00 psi

Pressure: 
3000.00, 3000.00, 3000.00, 3000.00, 3000.00, 3000.00, 3000.00, 3000.00, 
3000.00, 3000.00, 3000.00, 3000.00, 3000.00, 3000.00, 3000.00, 3000.00, 
3000.00, 3000.00, 3000.00, 3000.00, 3000.00, 3000.00, 3000.00, 3000.00, 
3000.00

Saturation:
0.20, 0.20, 0.20, 0.20, 0.20, 0.20, 0.20, 0.20, 
0.20, 0.20, 0.20, 0.20, 0.20, 0.20, 0.20, 0.20, 
0.20, 0.20, 0.20, 0.20, 0.20, 0.20, 0.20, 0.20, 
0.20



================================================
           Rejected (Non-Convergence)
================================================
================================================
           Rejected (Non-Convergence)
================================================
================================================
           Rejected (Non-Convergence)
================================================
================================================
           Rejected (Non-Convergence)
================================================
================================================
           Rejected (Non-Convergence)
================================================
================================================
           Rejected (Non-Convergence)
================================================
================================================
           Rejected (Non-Convergence)
================================================
================================================
           Rejected (Non-Convergence)
================================================
================================================
           Rejected (Non-Convergence)
================================================
================================================
           Rejected (Non-Convergence)
================================================
================================================
           Rejected (Non-Convergence)
================================================
================================================
           Rejected (Non-Convergence)
================================================
================================================
           Rejected (Non-Convergence)
================================================
================================================
           Rejected (Non-Convergence)
================================================
================================================
           Rejected (Non-Convergence)
================================================
================================================
           Rejected (Non-Convergence)
================================================
================================================
           Rejected (Non-Convergence)
================================================
================================================
           Rejected (Non-Convergence)
================================================

Showing the first 80 of 7,998 lines.