1. MATLAB Reservoir Simulation Toolbox
(MRST)
by
Rupak
Department of Chemical Engineering
Indian Institute of Technology Guwahati
2. The MATLAB Reservoir Simulation Toolbox
A free open-source software for petroleum reservoir:
reading
running simulation
visualization
MRST is not a primarily a simulator:
developed as a research tool by researcher at SINTEF Digital.
can be downloaded and used under GNU General Public License (GPL).
To download, visit: www.sintef.no/mrst/
MRST offers black-oil and compositional model capable of simulating industry-standard problems.
Graphical user interfaces for post-processing simulation results.
April 24, 2025 CL 644: Reservoir Simulation 2
4. Core Functionality & Add-on Modules
April 24, 2025 CL 644: Reservoir Simulation 4
Core Module
data structures for creating and manipulating grids.
petro-physical data
drive mechanism: gravity, boundary conditions, source terms, and wells
Automatic differentiations.
Add-on modules
discretization : TPFA, MPFA, mimetic etc.
flow equations and solvers
workflow tools: coarsening, upscaling, flow diagnostics, visualization
analysis of large-scale CO2 storage in saline aquifers.
special models like geomechanics and fractured reservoirs
5. Overview of Functionality
Grid generation and coarsening
April 24, 2025 Flow Visualization Lab 5
upr: used to generates the 2D or 3D
Voronoi grid.
coarsegrid: data structures and
simple coarsening
agglom: to create an adapted coarse
partition.
libgeometry: to compute geometric
quantities like cell volumes, areas ,
centroids etc.
opm_gridprocessing: contains
functionality for reading and
processing the GRID section of
ECLIPSE input data.
triangle: to create triangular grid
6. Overview of Functionality
Discretization and solvers for incompressible flow:
April 24, 2025 Flow Visualization Lab 6
incomp: incompressible, two phase
flow. This module implements two point
flux approximations (TPFA) and
implicit/explicit transport solver.
mimetic, mfpa, ntpfa, vem implements
consistent discretization.
adjoint: Implements strategies for
production optimization for
incompressible, two-phase flow
7. Overview of Functionality
Implicit solvers based on Automatic Differentiation:
April 24, 2025 Flow Visualization Lab 7
The automatic differentiation-object oriented (AD-OO) frame work offers fully implicit simulators from
industry-standard input decks, including computations of adjoints
8. Overview of Functionality
Workflow tools:
April 24, 2025 Flow Visualization Lab 8
co2lab: comprehensive tools for large-
scale CO2 storage saline aquifers
diagnostics: flow diagnostics,
mrst-gui: interactive visualization
optimization: solution of optimal control
problems based on AD-OO
enkf and remso: third-party modules for
EnKF (Ensemble Kalman filter) and
multiple-shooting optimization
9. Overview of Functionality
Upscaling and multiscale methods
April 24, 2025 Flow Visualization Lab 9
msrsb is state-of-the art multiscale
solver.
msfem: implements multiscale finite
elements method on unstructured grids.
msfvm: Implements the operator
formulation of the multiscale finite-
volume method for incompressible flow
on structured and unstructured grids.
hfm: implements msrsb this for fracture
models
upscaling: flow-based single-phase
upscaling.
steady-state: multiphase upscaling based
on steady state assumptions.
10. Overview of Functionality
Fractured Media
April 24, 2025 Flow Visualization Lab 10
dfm: discrete fracture models, hfm: hierarchical/embedded fracture models
11. Downloading and Installing
April 24, 2025 CL 644: Reservoir Simulation 11
Download official release from SINTEF Digital official website and extract
mrst-2021b containing all parts of software.
Since MRST is a secondary software you need to activate the software in
MATLAB
You have to run startup.m script to activate MRST
MRST Package Welcome Message
12. Exploring Functionality and Getting Help
April 24, 2025 CL 644: Reservoir Simulation 12
To find out what a specific function does, you ca type help function_Name in the
command window
13. Example of Automatic Differentiation (AD)
April 24, 2025 CL 644: Reservoir Simulation 13
We want to compute z = f(x,y) = x3
y and its partial derivatives for the values x=1 and y = 2.
z = f(x,y) = x3
y
𝜕𝑧
𝜕𝑥
=3 𝑥 2 𝑦
𝜕 𝑧
𝜕 𝑦
=𝑥 3
z | x=1,y=2 = 2
𝜕𝑧
𝜕𝑥
| x=1,y =2=6
𝜕 𝑧
𝜕 𝑦
| x=1,y =2=1
Manual
Independent variables: x, y
Dependent variable: z
[x,y] = initVariablesADI(1,2);
Independent variables Initialized value of IV
𝜕𝑥
𝜕𝑥
|1,2
𝜕 𝑥
𝜕 𝑦
|1,2
𝜕 𝑦
𝜕 𝑥
|1,2
𝜕 𝑦
𝜕 𝑦
|1,2 𝜕𝑧
𝜕𝑥
|1,2
𝜕 𝑧
𝜕 𝑦
|1,2
14. Basic Data Structures in a Model
April 24, 2025 CL 644: Reservoir Simulation 14
Fluid properties:
fluid = initSingleFluid('mu' , 1*centi*poise , ...
'rho', 1014*kilogram/meter^3);
fluid = initSimpleFluid('mu' , [ 1, 10]*centi*poise , ...
'rho', [1014, 859]*kilogram/meter^3, ...
'n' , [ 2, 2]);
fluid = initCoreyFluid('mu' , [ 1, 10]*centi*poise , ...
'rho', [1014, 859]*kilogram/meter^3, ...
'n' , [ 2, 2] , ...
'sr' , [ 0.2, 0.2] , ...
'kwm', [ 0.85, 0.60]);
Single-Phase Flow
Two-Phase Flow
• Corey model with exponent ‘n’
• Zero residual saturation
• krw=, kro=
Two-Phase Flow
• Corey model with exponent ‘n’
• With residual saturation
• krw=, kro=
15. Basic Data Structures in a Model
April 24, 2025 CL 644: Reservoir Simulation 15
Reservoir states:
state = initResSol(G, p0,s0);
state = initResSol(G, W, p0,s0);
• p0 = Initial pressure
• s0 = Initial saturation
• When there are wells in the reservoir
• Additional field ‘wellsol’
• wellSol = initWellSol(W, pw0);
𝑠0=
{ 1, 𝐹𝑜𝑟 𝑠𝑖𝑛𝑔𝑙𝑒− h
𝑝 𝑎𝑠𝑒
[𝑠𝑤 0𝑠𝑜 0], 𝐹𝑜𝑟 𝑡𝑤𝑜− h
𝑝 𝑎𝑠𝑒 𝑓𝑙𝑜𝑤
16. Basic Data Structures in a Model
April 24, 2025 CL 644: Reservoir Simulation 16
Fluid sources:
src = addSource(src, cells, rates, ‘sat’, sat)
src = an empty array (src==[])
rates = volumetric flow rates of sources
sat = fluid composition of injected fluids with rate > 0
Example:
src==[]
src = addSource(src, 1,1,[], 100*m3/day, ‘sat’, 1)
Boundary conditions:
bc = addBC(bc, faces, type, values, ‘sat’, sat)
bc = an empty array (bc==[])
faces = faces for which the conditions are set
type = type of boundary condition: pressure or flux
values = pressure of flux value for the given conditions
17. Basic Data Structures in a Model
April 24, 2025 CL 644: Reservoir Simulation 17
Boundary conditions:
bc = pside(bc, G, ‘side’,p)
bc = fluxside(bc, G, ‘side’,flux)
Side argument is a string which one out of the following six alias groups:
• West/Xmin/Left
• East/Xmax/Right
• South/Ymin/Back
• North/Ymax/Front
• Upper/Zmin/Top
• Lower/Zmax/Bottom
18. Basic Data Structures in a Model
April 24, 2025 CL 644: Reservoir Simulation 18
Wells:
W = addWell(W, G, rock, cellInx)
W = verticalWell(W, G, rock, I, J, K, 'pn1', pv1, ...)
W = verticalWell(W , G, rock, I, J, K, 'Type', 'rate/bhp', ...
'InnerProduct', well_ip, ...
'Val’,rate/bhp value, 'Radius’, radious of well, ...
'Name', ‘I/P', 'Comp_i', [1, 0],'Sign',1);
I,J,K=Location of well
Type = String specifying the well control: rate or bhp
InnerProduct = Method of consistent discretizations
Val = Target value of well control
Radius =Welbore radius in meters
Name = String giving the name of the well
Comp_i = Fluid composition for injection well
Sign = Well type: Production (sign=-1)/Injection (sign=1)
19. Example:
April 24, 2025 CL 644: Reservoir Simulation 19
Problem 1: Quarter five-spot problem
- Flow equations: - .( )=q
∇ 𝐾∇𝑝
- Single-phase incompressible flow
- 2D cartesian grid covering 500× 500 m2
- Two source term at diagonally opposite corners
- Permeability = 100 mD and Porosity = 0.25
- Fluid = Water
Problem 2: Boundary conditions
- The reservoir is 50 m thick and is restricted to a 1 × 1 km2
area.
- The permeability is uniform and anisotropic, with a diagonal (1,000, 300, 10) mD tensor
- the porosity is uniform and equal 0.2
- the reservoir is represented as a 20×20×5 rectangular grid
- Neumann conditions with total inflow of 100 m3
/day on the east boundary
- Dirichlet conditions with fixed pressure of 25 bar on the west boundary
20. Grids:
April 24, 2025 CL 644: Reservoir Simulation 20
MRST Module: gridProcessing
Features:
a common data structures and infrastructures for all types of grids
all grids are assumed to be unstructured
nbo grid generator
several grid factory routines for : regular cartesian grids, rectilinear grids, triangular grids etc.
Regular Cartesian Grid Rectilinear Grid Triangular Grid
21. Grids:
April 24, 2025 CL 644: Reservoir Simulation 21
Basic files and their functions:
cartGrid - Construct 2d or 3d Cartesian grid in physical space
tensorGrid - Construct Cartesian grid with variable physical cell sizes
tetrahedralGrid - Construct valid grid definition from points and tetrahedron list
triangleGrid - Construct valid grid definition from points and triangle list
computeGeometry - Add geometry information (centroids, volumes, areas) to a grid
22. Parameters:
April 24, 2025 CL 644: Reservoir Simulation 22
MRST Module: params
Features:
Data structures for petrophysical properties
Routines for setting and manipulating : boundary conditions, source/sink, well models etc.
Basic files and their functions: Rock
makeRock - Create rock structure from given permeabilty and porosity values
grdecl2Rock - Extract rock properties from input deck
permeabilityConverter - Add tensor permeability to GRDECL struct
permTensor - Expand permeability tensor to full format.
poreVolume - Compute pore volumes of individual cells in grid.
*GRDECL: Grid section of an ECLIPSE deck
23. Rock Modelling: Example
April 24, 2025 CL 644: Reservoir Simulation 23
Homogeneous modelling:
Square 10 × 10 grid model with a uniform porosity of 0.2 and isotropic permeability
equal 200 mD
The permeability is uniform and anisotropic, with a diagonal (1,000, 100, 10) mD
tensor the porosity is uniform and equal 0.2
Heterogeneous modelling:
Generate φ as a Gaussian field and then compute K from the Carman–Kozeny relation
24. Upscaling
April 24, 2025 CL 644: Reservoir Simulation 24
• Also called homogenization
• Replace number of heterogeneous fine grid blocks with one equivalent coarse homogeneous grid
block
• Properties of fine scale model are approximated by that of a coarse model
• It’s an averaging procedure
• Additive properties
Porosity
Fluid saturations
• Non-additive properties: Permeability
25. Why Upscaling?
April 24, 2025 CL 644: Reservoir Simulation 25
• First level upscaling :
Laboratory data interpretation at the scale of reservoir.
• Second level upscaling:
Scales properties of a fine grid to a coarse grid
Scale up of geological grid to simulator grid for numerical simulation
• Other example:
Consideration of first-hand-data distribution.
Reservoir engineers usually apply a finer local grid in well-denser-area as well as in wellbore
around, and apply a coarser grid in well-thinner-area.