MATLAB Oil & Gas Production Optimization
MATLAB Oil & Gas Production Optimization
Artificial Big Data Deep Machine Reinforced Predictive Internet Process Process Process Value Chain
Intelligence Analysis Learning Learning Learning Analytics of Things Optimization Digitization Automation Integration
Well 4
Well 1
▪ Downhole-to-surface conversion is performed
over n-dimensional interpolating functions Well 2
Pad 1
using an accelerated nonlinear solver. To surface
Well 3 facilities
Well 2
2
Case 1. Maximize oil production while keeping gas production between 40
and 80 MMSCFD and water production at or below 1800 STB/day.
+-------------------------------------+
| Optimization Model Summary |
+-------------------------------------+
| Pres | Pad 01 | 1453.99 psia |
Pad 3 | | Pad 02 | 800.00 psia |
| | Pad 03 | 1153.41 psia |
Pad 2 Pressure = 1153.41 psia | | Pad 04 | 755.00 psia |
Oil = 368.2 stb/d
Pressure = 800 psia +-------------------------------------+
Gas = 13.07 mmscf/d
Oil = 1212.7 stb/d Water = 139.66 stb/d | Oil rate | 4625.61 BOPD |
Gas = 28.8 mmscf/d | Gas rate | 80.00 MMSCFD |
Water = 464.22 stb/d | Water rate | 1800.00 BWPD |
+-------------------------------------+
+--------------------------------------------------------+
| Per-pad / Per-well / Per-phase Optimization Results |
+--------+--------+------------+------------+------------+
| Pad | Well | Oil Rate | Gas Rate | Water Rate |
| (ID) | (ID) | (BOPD) | (MMSCFD) | (BWPD) |
+--------+--------+------------+------------+------------+
| 1 | 1 | 49.48 | 0.93 | 13.78 |
| 1 | 2 | 100.16 | 2.74 | 150.73 |
| 1 | 3 | 173.04 | 4.82 | 234.25 |
| 1 | 4 | 151.98 | 4.24 | 243.54 |
+--------+--------+------------+------------+------------+
| 2 | 1 | 158.71 | 4.45 | 53.85 |
| 2 | 2 | 258.41 | 7.25 | 103.04 |
| 2 | 3 | 181.22 | 5.98 | 98.69 |
Pad 4 | 2 | 4 | 322.54 | 5.66 | 114.54 |
| 2 | 5 | 291.84 | 5.46 | 94.10 |
Pressure = 755 psia +--------+--------+------------+------------+------------+
Pad 1 Oil = 2570 stb/d
| 3 | 1 | 137.35 | 3.08 | 45.24 |
Gas = 25.39 mmscf/d
Pressure = 1453.99 psia Water = 553.83 stb/d
| 3 | 2 | 69.89 | 3.00 | 23.34 |
Oil = 474.66 stb/d | 3 | 3 | 85.51 | 3.18 | 38.03 |
Gas = 12.73 mmscf/d | 3 | 4 | 75.45 | 3.81 | 33.05 |
Water = 642.3 stb/d +--------+--------+------------+------------+------------+
| 4 | 1 | 450.61 | 4.83 | 116.74 |
| 4 | 2 | 417.22 | 5.82 | 135.87 |
| 4 | 3 | 467.54 | 5.02 | 74.66 |
| 4 | 4 | 1234.65 | 9.72 | 226.56 |
+--------+--------+------------+------------+------------+
3
Case 2. Maximize gas production while keeping water production at or below
1000 STB/day.
+-------------------------------------+
| Optimization Model Summary |
+-------------------------------------+
| Pres | Pad 01 | 2988.38 psia |
Pad 3 | | Pad 02 | 800.01 psia |
| | Pad 03 | 680.03 psia |
Pad 2 Pressure = 680.03 psia | | Pad 04 | 2296.07 psia |
Oil = 601.64 stb/d
Pressure = 800.01 psia +-------------------------------------+
Gas = 21.35 mmscf/d
Oil = 1212.7 stb/d Water = 228.19 stb/d | Oil rate | 3054.18 BOPD |
Gas = 28.8 mmscf/d | Gas rate | 61.81 MMSCFD |
Water = 464.22 stb/d | Water rate | 1000.00 BWPD |
+-------------------------------------+
+--------------------------------------------------------+
| Per-pad / Per-well / Per-phase Optimization Results |
+--------+--------+------------+------------+------------+
| Pad | Well | Oil Rate | Gas Rate | Water Rate |
| (ID) | (ID) | (BOPD) | (MMSCFD) | (BWPD) |
+--------+--------+------------+------------+------------+
| 1 | 1 | 0.00 | 0.00 | 0.00 | <- Well shut-in
| 1 | 2 | 0.00 | 0.00 | 0.00 | <- Well shut-in
| 1 | 3 | 26.03 | 0.71 | 34.79 |
| 1 | 4 | 24.62 | 0.68 | 38.99 |
+--------+--------+------------+------------+------------+
| 2 | 1 | 158.71 | 4.45 | 53.85 |
| 2 | 2 | 258.41 | 7.25 | 103.04 |
| 2 | 3 | 181.21 | 5.98 | 98.69 |
Pad 4 | 2 | 4 | 322.54 | 5.66 | 114.54 |
| 2 | 5 | 291.84 | 5.46 | 94.10 |
Pressure = 2296.07 psia +--------+--------+------------+------------+------------+
Pad 1 Oil = 1189.2 stb/d
| 3 | 1 | 226.22 | 5.08 | 74.42 |
Gas = 10.27 mmscf/d
Pressure = 2988.38 psia Water = 233.79 stb/d
| 3 | 2 | 110.10 | 4.75 | 36.73 |
Oil = 50.65 stb/d | 3 | 3 | 147.72 | 5.53 | 65.58 |
Gas = 1.39 mmscf/d | 3 | 4 | 117.60 | 5.99 | 51.46 |
Water = 73.78 stb/d +--------+--------+------------+------------+------------+
| 4 | 1 | 74.82 | 0.79 | 19.24 |
| 4 | 2 | 77.24 | 1.08 | 25.01 |
| 4 | 3 | 97.77 | 1.04 | 15.55 |
| 4 | 4 | 939.36 | 7.36 | 173.99 |
+--------+--------+------------+------------+------------+
4
Case 3. Minimize water production while keeping gas production between 40
and 80 MMSCFD.
+-------------------------------------+
| Optimization Model Summary |
+-------------------------------------+
| Pres | Pad 01 | 3038.57 psia |
Pad 3 | | Pad 02 | 1130.70 psia |
| | Pad 03 | 680.00 psia |
Pad 2 Pressure = 680 psia | | Pad 04 | 4693.52 psia |
Oil = 601.64 stb/d
Pressure = 1130.7 psia +-------------------------------------+
Gas = 21.35 mmscf/d
Oil = 740.93 stb/d Water = 228.21 stb/d | Oil rate | 1412.91 BOPD |
Gas = 17.67 mmscf/d | Gas rate | 40.00 MMSCFD |
Water = 284.99 stb/d | Water rate | 553.38 BWPD |
+-------------------------------------+
+--------------------------------------------------------+
| Per-pad / Per-well / Per-phase Optimization Results |
+--------+--------+------------+------------+------------+
| Pad | Well | Oil Rate | Gas Rate | Water Rate |
| (ID) | (ID) | (BOPD) | (MMSCFD) | (BWPD) |
+--------+--------+------------+------------+------------+
| 1 | 1 | 0.00 | 0.00 | 0.00 | <- Well shut-in
| 1 | 2 | 0.00 | 0.00 | 0.00 | <- Well shut-in
| 1 | 3 | 0.00 | 0.00 | 0.00 | <- Well shut-in
| 1 | 4 | 19.33 | 0.53 | 30.56 |
+--------+--------+------------+------------+------------+
| 2 | 1 | 105.92 | 2.97 | 35.98 |
| 2 | 2 | 153.89 | 4.28 | 61.47 |
| 2 | 3 | 116.16 | 3.83 | 63.29 |
Pad 4 | 2 | 4 | 194.61 | 3.41 | 69.24 |
| 2 | 5 | 170.35 | 3.18 | 55.01 |
Pressure = 4693.52 psia +--------+--------+------------+------------+------------+
Pad 1 Oil = 51 stb/d
| 3 | 1 | 226.22 | 5.08 | 74.43 |
Gas = 0.44 mmscf/d
Pressure = 3038.57 psia Water = 9.63 stb/d
| 3 | 2 | 110.10 | 4.75 | 36.74 |
Oil = 19.33 stb/d | 3 | 3 | 147.72 | 5.53 | 65.58 |
Gas = 0.53 mmscf/d | 3 | 4 | 117.60 | 5.99 | 51.46 |
Water = 30.56 stb/d +--------+--------+------------+------------+------------+
| 4 | 1 | 0.00 | 0.00 | 0.00 | <- Well shut-in
| 4 | 2 | 0.00 | 0.00 | 0.00 | <- Well shut-in
| 4 | 3 | 0.00 | 0.00 | 0.00 | <- Well shut-in
| 4 | 4 | 51.00 | 0.44 | 9.63 |
+--------+--------+------------+------------+------------+
5
Agenda
▪ Key takeaways
6
Agenda
▪ Key takeaways
7
The surface-to-downhole conversion part of the model is critical to solve the
production optimization problem.
Function of
wellhead
Bottomhole
pressure
pressure
(P2)
P2 (P1)
𝑃1 = 𝑃0
VLPs
IPRs
𝑃1 < 𝑃0
Well
𝑃1
Reservoir
P0 P1 P0
Flow rates
𝑞𝑜 𝑞𝑤 𝑞𝑔
8
This case study considers production optimization of several multi-well pads
interconnected via pipes and manifolds.
Inflow Performance Relationship Pad 1
(IPR) Well 4
Well 3 Well 1 Well 2 Well 3 Well 4
Well 5 Well 2
Well 1 q11 = f11(p) q21 = f21(p) q31 = f31(p) q41 = f41(p)
Well 2
pressure
Flowing
Well 3
Set pressure Assuming equal pressure p = p1
Pad 2
Well 1 Pad 3 for all wells in the pad
Well 2
Pad 1
pressure
Flowing
10
We can solve the all-pads optimization problem following a
problem-based approach in MATLAB.
Downhole-to-surface
conversion
Problem-based
Model heuristics optimization Analysis of results
approach
Optimization scenario
11
Agenda
▪ Key takeaways
12
MathWorks Optimization Products video
▪ Optimization Toolbox
– Functions for finding parameters that minimize
or maximize objectives while satisfying constraints
video
.
▪ Global Optimization Toolbox
– Functions that search for global solutions
to problems that contain multiple maxima or minima
on smooth or nonsmooth problems (requires Optimization
Toolbox)
Faster ✓
Large Problems ✓
Better on: ✓
• Nonsmooth
• Noisy
• Stochastic
• Highly nonlinear
More “global” ✓
Custom data types ✓
14
Optimization Toolbox
Solving: Problem Types and Algorithms Global Optimization Toolbox
Objective Type
Constraint Type
Linear Quadratic Least Squares Smooth nonlinear Nonsmooth Multiobjective
None quadprog lsqcurvefit fminsearch fminsearch fgoalattain
lsqnonlin fminunc ga fminimax
paretosearch
gamultiobj
Discrete intlinprog ga
surrogateopt
16
Agenda
▪ Key takeaways
17
As a first step to solving the optimization problem, we use MATLAB
to calculate valid pressure range for each multi-well pad.
Nonlinear
Accelerated Solver
18
Second, we want to define totalized production rate functions for
each multi-well pad using well performance data.
function q = computeRates(pads, p)
% ...
% Loop through all wells and
% accumulates flow rates
% ...
end
Pad 1
q1 = F1(p) Pad 4
q4 = F4(p)
19
Third, we convert the totalized production function into an
optimization expression and define constraints.
p = optimvar(‘p’,numPads)
[qo,qg,qw] = fcn2optimexpr(@(p)
computeRates(pads,p))
prob = optimproblem()
Pad 1
q1 = F1(p) Pad 4
q4 = F4(p)
20
Agenda
▪ Key takeaways
22
MathWorks provides a comprehensive end-to-end solution for
<AI/Data Science/Tech Computing>
Develop
Access and Preprocess Operationalize
Analyze Data Algorithms
Explore Data Data Models
& Models
Dashboards
Operational • OSISoft PI
hadoop cloudera
Big Data
Technology
Apache Tableau
Spark databricks Spotfire PowerBI
Data Sources
Enterprise App
MATLAB Parallel Server
Web App
Data • AWS S3
stores • Azure BLOB
{ RESTful API }
• Avro
Files • Parquet
Training, simulation, optimization
Domain specific
MATLAB CI / CD MATLAB Web MATLAB
toolboxes
Platform
Azure
Signal Optimi- DevOps
Proc zation
Jenkins
Data exploration, preprocessing, algorithm development Sharing, deployment, integration
23
When it comes to operationalizing your <analytics/models> we
provide the broadest range of choices
Simulink
Compiler
Simulink
MATLAB
Coder MATLAB
Compiler
Products Compiler
MATLAB SDK
HTTP MATLAB
MATLAB Web Endpoint Production Server
App Server
24
Use MATLAB Web App Server, if you want to easily share
MATLAB Web Apps with your colleagues or collaborators
Develop the user Package MATLAB Deploy MATLAB Access and run
interface and callback app, data and Web Apps using MATLAB Web Apps
functions using associated files as the upload client directly from a browser
MATLAB App MATLAB Web Apps directly from the
Designer with one click browser
Create MATLAB Web Apps for sharing Manage the server infrastructure Easy access to MATLAB Web Apps
▪ Share your work as MATLAB Web Apps ▪ Secure and control access to MATLAB ▪ Save time by eliminating the steps to
with other engineers and scientists Web Apps install the application on your desktop
▪ Spend more time developing apps than ▪ Save time by eliminating the steps ▪ Access MATLAB Web Apps anywhere
managing distribution required for application distribution using a browser
25
Use MATLAB Production Server to operationalize your models or
algorithms as APIs that are integrated with your enterprise IT/OT
systems
Deploy AI / MLOps
▪ Deploy trained AI models for inference
▪ Models can be stored in a REDIS in-
memory database for high-speed
access
26
Agenda
▪ Key takeaways
27
Key Takeaways
▪ Optimization Toolbox can tackle very difficult problems with only a few steps
28
MATLAB can tackle very complex optimization problems and create
robust, deployable workflows
IPR
IPR data objects
VLP
VLP data objects
Connector Model Results
▪ Structure code
31