0% found this document useful (0 votes)
97 views30 pages

MATLAB Oil & Gas Production Optimization

Uploaded by

Bel Mec
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
97 views30 pages

MATLAB Oil & Gas Production Optimization

Uploaded by

Bel Mec
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Oil & Gas Production Optimization in MATLAB

Leverage MATLAB’s powerful solvers for tackling


nonlinear optimization problems
Oscar Molina, PhD
Sr. Applications Engineer
MathWorks
March 2024

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

© 2024 The MathWorks, Inc.


1
For this analysis we will consider a four-pad multi-well production
system producing oil, gas, and water simultaneously.
Well 4
Well 3
▪ Inflow Performance Relationship (IPR) and Well 5 Well 2
Well 1
Vertical Lift Performance (VLP) data for each Well 2
Well 3
well are supplied via external simulation files. Well 1
Pad 2
Pad 3

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

▪ The goal of this use case is to establish a multi- Well 4


Well 4
purpose, robust, and maintainable production Pad 4

optimization workflow in MATLAB. Well 1 Well 3

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

▪ Outline and define production optimization problem

▪ Introduction to the Optimization Toolbox

▪ Prepare and set up optimization problem


– Improving mathematical model with heuristics
– Problem-based optimization workflow in MATLAB

▪ Deploying optimization models

▪ Key takeaways
6
Agenda

▪ Outline and define production optimization problem

▪ Introduction to the Optimization Toolbox

▪ Set up and solve optimization problem with MATLAB


– Improve mathematical model with heuristics
– Problem-based optimization workflow in MATLAB

▪ Deploying optimization models

▪ 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 4 Total production rates


Oil rate Well 1
q1 = f11(p1) + f21(p1) + f31(p1) + f41(p1) = F1(p1)

Well 2
Pad 1
pressure
Flowing

Each pad has its own lumped production function


To surface
Well 3 facilities Multi-pad system

Pad 1 Pad 2 Pad 3 Pad 4


Gas rate Well 4
Well 4 q1 = F1(p1) q2 = F2(p2) q3 = F3(p3) q4 = F4(p4)
Pad 4
pressure
Flowing

Pressure on each pad is


Well 1 Well 3 independent from one another

Well 2 Total system production

Water rate qt = F1(p1) + F2(p2) + F3(p3) + F4(p4)

q = <oil rate, gas rate, water rate>


9
This case study considers production optimization of several multi-well pads
interconnected via pipes and manifolds.

General all-pads problem ▪ Straightforward problem formulation


– Supply pressure vector (input), get total rate vector (output)
qt = F(p) = ∑ Fi(pi) – Meant to answer direct questions like “how much will we
produce if p = <p1, p2, p3, … , pk>?”

▪ Inverse-problem formulation is quite difficult


– Tightly coupled problem; N-degrees of freedom
– Extremely challenging to answer “is there any p for which q
equals…?”

▪ Optimization problem setup


– Seeks to solve questions like “what pressures do we need in
order to maximize oil production while keeping water production
between x and y?”

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

▪ Outline and define production optimization problem

▪ Introduction to MATLAB optimization products

▪ Set up and solve optimization problem with MATLAB


– Improve mathematical model with heuristics
– Problem-based optimization workflow in MATLAB

▪ Deploying optimization models

▪ Key takeaways
12
MathWorks Optimization Products video

▪ Optimization Toolbox
– Functions for finding parameters that minimize
or maximize objectives while satisfying constraints

Objective with single minimum

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)

Objective with multiple minima


13
Optimization toolboxes support different problem types

Optimization Global Optimization


Toolbox 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

▪ Linear programming ▪ Nonlinear optimization


– Simplex and interior-point – Nelder-Mead simplex
▪ Mixed-integer linear programming – Interior-point, SQP, trust-region
– Branch-and-cut – MultiStart & GlobalSearch
– Pattern (direct) search
▪ Quadratic programming
– Genetic algorithm
– Interior-point, active-set, trust-region
– Simulated annealing
▪ Second-order cone programming – Particle swarm
– Interior-point
– Surrogate optimization
▪ Least-squares and nonlinear equations ▪ Mixed-integer nonlinear
– Interior-point, trust-region, Levenberg-
optimization
Marquardt
– Genetic algorithm
▪ Multiobjective optimization – Surrogate optimization
– Weighted and goal-attainment
– Genetic algorithm
– Paretosearch Optimization Decision Table
15
Solve many types of optimization problems with MATLAB Optimization Toolbox
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

Bound quadprog lsqcurvefit fmincon fminbnd ga fgoalattain


lsqnonlin surrogatopt fminimax
lsqnonneg patternsearch paretosearch
lsqlin particleswarm gamultiobj
simulannealbnd

Linear linprog quadprog lsqlin fmincon ga fgoalattain


patternsearch fminimax
surrogatept paretosearch
gamultiobj

Second-Order Cone coneprog coneprog

General smooth fmincon fmincon fmincon fmincon ga fgoalattain


patternsearch fminimax
surrogateopt paretosearch
gamultiobj

General nonsmooth ga ga ga ga ga paretosearch


patternsearch patternsearch patternsearch patternsearch patternsearch gamultiobj
surrogateopt

Discrete intlinprog ga
surrogateopt

16
Agenda

▪ Outline and define production optimization problem

▪ Introduction to MATLAB optimization products

▪ Set up and solve optimization problem with MATLAB


– Improve mathematical model with heuristics
– Problem-based optimization workflow in MATLAB

▪ Deploying optimization models

▪ 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.

Downhole-to-surface conversion Pad 2


800 ≤ p ≤ 2220 Pad 3
(psia)
680 ≤ p ≤ 2444
(psia)
Inflow Performance Vertical Lift
Relationship Performance
(IPR) (VLP)

Nonlinear
Accelerated Solver

Well performance Pad 1


data (surface) 630 ≤ p ≤ 3039 Pad 4
(psia)
755 ≤ p ≤ 4694
(psia)

18
Second, we want to define totalized production rate functions for
each multi-well pad using well performance data.

Totalized production Pad 2


Pad 3
q2 = F2(p)
q3 = F3(p)

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.

Optimization problem set up Pad 2


Pad 3
q2 = F2(p)
q3 = F3(p)

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

▪ Outline and define production optimization problem

▪ Introduction to MATLAB optimization products

▪ Prepare and set up optimization problem


– Improve mathematical model with heuristics
– Problem-based optimization workflow in MATLAB

▪ Deploying optimization models

▪ 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

Streaming • Apache Kafka Qlik


data • Azure EventHub

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

App Server Production Server


MATLAB

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

Embedded Hardware Desktop and Web Deployment Enterprise Systems

Micro Java MATLAB


MATLAB Docker Excel Hadoop/ C/C++ ++ Python .NET Production
C, C++ HDL PLC CUDA .exe Web App Container Add-in Spark service DLL JAR py DLL Server
Deployed
Simulation

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

MATLAB MATLAB MATLAB Web App Server Browser


MATLAB
App Designer Compiler Runtime

MATLAB/Simulink IT System End User


User Administrator (Scientist, Engineer)

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

Process streaming analytics for IIoT


▪ Stream data from operational systems
through streaming services such as
Apache Kafka or Azure EventHub into
MATLAB analytics for anomaly
detection, condition based monitoring
or predictive maintenance

Host Microservices APIs


▪ Share MATLAB algorithms and
functions as microservice APIs in your
corporate service fabric

26
Agenda

▪ Outline and define production optimization problem

▪ Introduction to MATLAB optimization products

▪ Prepare and set up optimization problem


– Improve mathematical model with heuristics
– Problem-based optimization workflow in MATLAB

▪ Deploying optimization models

▪ Key takeaways
27
Key Takeaways

▪ MATLAB helps streamline processing data from external sources

▪ Optimization Toolbox can tackle very difficult problems with only a few steps

▪ Users can create and deploy custom optimization workflows as standalone


applications (.exe), libraries (Python, Java, .NET, etc.), and microservices.

▪ MathWorks Training is highly recommended for efficient use of our tools.

28
MATLAB can tackle very complex optimization problems and create
robust, deployable workflows
IPR
IPR data objects

Cost Optimization Scenario


function problem analysis

VLP
VLP data objects
Connector Model Results

Standalone End users


app
29
Optimization Techniques in MATLAB
Recommended Training

After this 1-day course you will be able to:

▪ Run optimization problems in MATLAB

▪ Specify objective functions and constraints

▪ Choose solvers and algorithms

▪ Evaluate results and improving performance

▪ Use global and multiobjective optimization


methods

See detailed course outline


30
MATLAB Programming Techniques
Recommended Training

After this 2-day course you will be able to:

▪ Manage data efficiently

▪ Utilize development tools

▪ Structure code

▪ Create robust applications

▪ Verify application behavior

See detailed course outline

31

You might also like