Download Source in VB.Net 2012
This package is not supposed to be used in serious projects of
any type by any means. User will be in charge for any potential loss or damage
arising from use of this package. For more information please refer to sections
15 and 16 of GNU general public license as published by The Free Software
Black-Oil MSV is a
.Net-based desktop application that integrates modification, simulation and
visualization of a black oil model of hydrocarbon reservoir using finite
difference fully implicit and IMPES formulations as formulated by Turgay
Ertekin, J.H. Abou-Kassem and G.R. King. in their book “Basic Applied Reservoir Simulation”.
for non-Petroleum Engineers
If you are not a petroleum engineer, you would
wonder what a petroleum reservoir simulator is and why petroleum engineers need
it. A petroleum reservoir simulator, nowadays, is referred to a computer
program that predicts the behavior of a hydrocarbon bearing formation
underground – known as petroleum reservoir - in a certain circumstance.
Petroleum reservoir engineers use simulators to enhance their knowledge of
reservoir and finally suggest an optimized production scenario which gives the
maximum economic performance. Black-Oil MSV is an open source petroleum reservoir
simulator which can be helpful to both petroleum engineers and software
for Petroleum Engineers
Petroleum engineers, especially the ones involved
with reservoir evaluation and characterization are mostly familiar with common
reservoir simulation tools such as SCHLUMGUERGER® ECLIPSE™ and CMG® IMEX™.
First of all it must be noted that Black-Oil MSV is not supposed to challenge
these robust industrial tools but it’s rather a laboratory where petroleum
engineer can study and evaluate various simulation approaches. Black-Oil MSV
source is written in VB.Net that is easy to read and understand for those who
have narrow knowledge of programming. The data structure is flexible and easy
to follow and modify. Visualization control is written clearly with least
complexity possible. Simulation core which is based on Ertekin formulation is written
in less than 1400 code lines. In addition, the Visual Studio facilities are
more than enough for debugging computational codes.
Not every ordinary programmer would find the
opportunity of writing codes for a petroleum reservoir simulator. That’s why an
introduction to this code is needed for software developers who don’t know what
a petroleum reservoir is and why and how it is being simulated. As previously
said, petroleum reservoir is a part of earth mostly thousands of feet
underground which contains hydrocarbons such as oil and gas. A petroleum
reservoir is naturally formed, that means it’s heterogeneous, so it exhibits
different behavior at different locations. So having in mind that it’s
heterogeneous, occurs thousands of feet underground and in any shape, we would conclude
that, a petroleum reservoir is an extremely mysterious object. On the
other hand petroleum reservoirs are among the richest and most valuable resources
of energy. Not only energy but a wide range of materials
are derived from oil. Just have a look at your keyboard, it’s mostly made up of
oil, your mouse, wire of mouse, most of the colors everywhere, your clothes and
many accessories we use, they are all derived from oil. The fact that petroleum reservoir is a complex natural system and at the same time holding the precious oil and gas resources, doubles the role and responsibility of a petroleum reservoir simulator. Actually, petroleum reservoir simulation can be classified as a heavy computational task which may even take days for ordinary computers. In contrast to this waste
of time, petroleum engineers are highly interested in trying various production
scenarios and investigating the result. So, the biggest challenge is to write
code in an optimized manner so that it takes least CPU time. At most of the
case, this computation is all about a huge matrix of equation which should be
solved. Some simulators provide parallel processing, some others reduce the
matrix complexity by some simplifying assumptions, there are also some which
utilize GPU processing capability to enhance speed. The second challenge for
programmers is visualization of reservoir parameters, either on 3D
representation of reservoir grids, or on 2D cross sections. You as programmer
would also be asked to develop highly interactive graphs. Finally, developers should design a user
interface that is easy to understand and straight-forward. This last feature is
a big lack in many industrial petroleum reservoir simulators. At most of the
time simulators do not read data in an organized manner and their output need
another application to be opened and have it visualized. They use obsolete
frameworks and technologies that lead to very rigid user interface. Black-Oil
MSV claims that it has the third challenge solved but solution to first and
second are up to future developers of the code.
MSV stands for Modification, Simulation and
Visualization. As naming applies, Black-Oil MSV integrates these features through
one single desktop application. Black-Oil MSV aims at providing a user
interface through which user can:
1. Modify all parameters needed for a simulation task such
as grid dimensions and locations, table of fluid behavior under reservoir
condition known as PVT, rock-fluid interactions and characteristics through
SCAL rock types, schedules of pressure and production for each grid and
simulation control parameters.
2. Simulate reservoir over specified period of time using
fully implicit or IMPES formulations.
3. Visualize reservoir parameters via 3D graph control while
simulation is in progress or when it’s accomplished.
Features can be classified in two categories of
Simulator Features and Code Features
- 3D-3Phase Black-Oil
- Newtonian Fully-Implicit Formulism
- Finite Difference Method
- Time-Step Schedule\Correction
- Multi-Size, multi-neighbor,
- Grid rock types
- Pressure &
- 3D-3Phase permeability
(2Phase in user interface)
- Capillary pressure
- Integrated modification, simulation and visualization
visualization using WPF technology
- XML I/O for simulation object
- Less than 1400
code lines for simulator core
- All in VB.Net
Using the Application
When Black-Oil MSV is executed, Main Window appears
as shown below. All user needs for simulating a reservoir is available through
Main Window. The simulation tree as
shown below consists of Model, PVT, RockType and Schedule which are essential
to any conventional simulation job.
Simulation page Consists
of Parameters and Run tab. Parameters tab includes System, Timing, Exactness,
Methodology and Options tabs. In System tab as below, user can choose the
system of units for the simulation job either metric or field. User may also choose
phases available in model. This does not necessarily affect the simulation
result but prevents simulator from performing additional calculations where the
corresponding phase parameters are zero.
In Timing tab user
determines the time-steps and finalization criteria of the simulator. Time
steps can be equal or read from a table as below. Simulation ends once it
reaches either Final Step or Finish Time
The calculations and
iterations should meet a pre-defined criteria as validation. In Exactness tab user
can specify these criteria. Solver MSE (Liniear Equation MSE) which specifies
the accuracy of solver can be specified. The maximum iteration determines the
maximum iteration number in fully implicit formulation for each time step.
Orthomin solver is an iterative method. The number of iteration for orthomin
are also determined. Developers may define their own solver for the simulator.
The iteration termination values are applied to fully implicit iteration. Once
calculated values are close enough to last iteration values the iteration
should stop and continue to next time step. Here user defines this criteria.
In methodology tab user
can specify formulation and calculation approaches. Currently fully implicit
and IMPES approaches are supported. Some parts of calculations require
derivations of a parameters with respect to saturation of phases and pressure.
Here user can define the epsilon by which the derivation is calculated. There
are several methods for averaging transmissibility which are explained in our
By clicking on Model user
will have access to model data including grids and their parameters. Here user
can define new grids either by editing the grid box or by clicking on Regular
button that creates regular grids for the model. Meanwhile user can observe the
final model in a WPF 3D control.
Grids are defined based
on their centers (not corners). Initial values for Sw,Sg and Po should be
specified. RockType and Schedules are determined according to their IDs.
Clicking on Regular button
allows user to create their own regular model of custom size and refinement.
PVT table can be edited
in PVT panel.
PVT table contains all
required parameters for a black-oil model simulation. User should take most
care in order to have appropriate values of correct unit based on defined
system of units.
By clicking on RockTypes
in tree view user can define and edit rock types. Clicking on New generates one
new rock type with unique ID which can be then used in Model section as earlier
In Rock Types tab user
can edit Absolute and Relative values for rock type for 3D and 3Phase systems.
As an instance in
water-oil tab user can determine relative permeability and capillary pressure
data. Wettability should be determined when the Pc is available for pc
hysteresis in imbibition and drainage processes.
In Schedule panel -
similar to Rock Types- user can create and edit schedule data. Each schedule
has its unique ID which can be applied to a grid under Schedule column in model
Schedules can be either
Static or Dynamic (time-dependent).
Dynamic values will be
calculated by interpolating the values in table provided by user as shown below.
Now that simulation Model
and Parameters are complete we can turn back to Simulation panel and open Run
tab. By clicking on play button, simulation starts and the alteration of the
specified parameter will be visualized in 3D graph.
On top left corner of the
panel user can see time step and iteration statistics of simulation.
In lower panel user can
define the parameter and parameter boundaries for which the model will be visualized and colored.
In log panel user can
choose their custom time step and view the result and parameters in that time.
The whole simulation
structure and grids can be easily exported and saved to hard disk based on
Developing the Code
Important Note: Before making any changes to the code please
study “Basic Applied Reservoir Simulation” written by Turgey Ertekin Et Al.
Black-Oil MSV parameters are mostly named based on their equivalent parameters
in that text. So, if you get familiar with concept there you’ll easily make
appropriate modifications in the code.
- Black-Oil MSV utilizes an Orthomin solver that works fine for smaller models. It’s recommended to use other algebraic solvers such as Bi-Conjugate method to enhance performance.
- The WPF visualization component is written very clean and clear so that developers can easily edit and upgrade its features. It’s recommended to improve the visualization components according to users need.
- For huge models it's necessary to save simulation history on hard drive and not in memory. It's also necessary to apply some optimization methods on visualization component.
- Interpolations are all linear. You can utilize much more stable algorithms with more smooth interpolation curves.
- Try using Parallel class ( new in .net framework) and a complying linear solver algorithm .I've personally tried this class and it could upgrade the performance by many times.
- Utilize multi-threading to enhance the user interface performance. This can be done by detaching the Run subroutine in Simulation module and calling it in a class instead.
- This code lacks export feature to excel. You can simply add such feature for Simulation object.
For petroleum engineers
- Currently there’s no
possibility to define wells separately. It can be simply done by defining well
path and applying the pressure/production schedule over the grid blocks on the path of each well.
- Currently there's no grid refinement algorithm. You can add such feature in Model panel. Or you would add dynamic grids that refines itself for regions of high variation.
- In addition to Fully Implicit and IMPES you would use SEQ method. Right now these formulations are applied to the whole model. One would choose to use a hybrid solution for different regions in the model.
- This application is also suitable for history matching tasks specially at core scale. You can simply add a history matching component under Component node of tree view.
- As far as each node in tree view (PVT, RockType, Schedule and Model) require data from a pre-processor, you would develop appropriate pre-processor application and link them to their tree nodes.