Click here to Skip to main content
15,868,141 members
Articles / Desktop Programming / WPF

Black-Oil MSV

Rate me:
Please Sign up or sign in to vote.
5.00/5 (6 votes)
21 Apr 2014GPL310 min read 33.5K   1.2K   7   20
This application integrates modification, simulation and visualization of Black-Oil model of hydrocarbon reservoirs

Download Source in VB.Net 2012

Image 1

Disclaimer

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

Introduction

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

Introduction 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 developers.

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

Introduction for Programmers

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.

Why MSV?

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

Features can be classified in two categories of Simulator Features and Code Features

Simulator Features:

  • Methodolgy
    • 3D-3Phase Black-Oil
    • Newtonian Fully-Implicit Formulism
    • Finite Difference Method
    • Time-Step Schedule\Correction
  • Model
    • Multi-Size, multi-neighbor, block-centered gridding
    • Grid rock types
    • Pressure & flow schedule
    • 3D-3Phase permeability (2Phase in user interface)
    • Capillary pressure hysteresis

Code Features:

  • Integrated modification, simulation and visualization
  • 3D visualization using WPF technology
  • Simultanious simulation\visualization
  • XML I/O for simulation object
  • Less than 1400 code lines for simulator core
  • All in VB.Net 2012

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.

Image 2

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.

Image 3

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

Image 4

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.

Image 5

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 reference book.

Image 6

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.

Image 7

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.

Image 8

Clicking on Regular button allows user to create their own regular model of custom size and refinement.

Image 9

PVT table can be edited in PVT panel.

Image 10

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.

Image 11

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

Image 12

In Rock Types tab user can edit Absolute and Relative values for rock type for 3D and 3Phase systems.

Image 13

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.

Image 14

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

Image 15

Schedules can be either Static or Dynamic (time-dependent).

Image 16

Dynamic values will be calculated by interpolating the values in table provided by user as shown below.

Image 17

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.

Image 18

On top left corner of the panel user can see time step and iteration statistics of simulation.

Image 19

In lower panel user can define the parameter and parameter boundaries for which the model will be visualized and colored.

Image 20

In log panel user can choose their custom time step and view the result and parameters in that time.

Image 21

The whole simulation structure and grids can be easily exported and saved to hard disk based on developers needs

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.

Recommendation

For programmers

  • 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.
This article was originally posted at http://www.petrocode.org/view.aspx?appid=80

License

This article, along with any associated source code and files, is licensed under The GNU General Public License (GPLv3)


Written By
Engineer
United Kingdom United Kingdom
I'm a Full-stack Software Developer with over a decade of experience at industrial and research projects having my main focus on Microsoft .Net stack.

Comments and Discussions

 
QuestionMissing Files Pin
Member 1474118019-Feb-20 21:45
Member 1474118019-Feb-20 21:45 
QuestionMissing source files Pin
Member 1134309322-Jan-19 1:25
Member 1134309322-Jan-19 1:25 
QuestionCode acess Pin
Member 1296818325-Jan-17 15:38
Member 1296818325-Jan-17 15:38 
QuestionNice work,Could your send the full project to me, please? Pin
Member 1194025115-Aug-16 22:39
Member 1194025115-Aug-16 22:39 
QuestionThe codes are missing.Could send me the missing file,please? Pin
Member 1194025115-Aug-16 22:12
Member 1194025115-Aug-16 22:12 
QuestionMissing files Pin
mvv2334-May-16 20:15
mvv2334-May-16 20:15 
QuestionMissing files Pin
michaeldjackson28-Dec-15 13:22
michaeldjackson28-Dec-15 13:22 
QuestionIMP assembly Pin
Richard Straub20-Nov-15 0:13
Richard Straub20-Nov-15 0:13 
QuestionI download does not contain all the code Pin
mkhoshkb10-Nov-15 9:37
mkhoshkb10-Nov-15 9:37 
AnswerRe: I download does not contain all the code Pin
Taylor Kobani11-Nov-15 8:37
Taylor Kobani11-Nov-15 8:37 
GeneralRe: I download does not contain all the code Pin
mkhoshkb30-Nov-15 5:29
mkhoshkb30-Nov-15 5:29 
GeneralRe: I download does not contain all the code Pin
Brantuo26-Feb-16 5:23
Brantuo26-Feb-16 5:23 
QuestionRe: I download does not contain all the code Pin
Richard Straub13-Nov-15 5:30
Richard Straub13-Nov-15 5:30 
QuestionTashakor! Pin
Member 113597667-Jan-15 12:02
Member 113597667-Jan-15 12:02 
AnswerRe: Tashakor! Pin
Taylor Kobani7-Jan-15 12:06
Taylor Kobani7-Jan-15 12:06 
QuestionVery Interested in the code Pin
terrydw3-Oct-14 7:03
terrydw3-Oct-14 7:03 
AnswerRe: Very Interested in the code Pin
Taylor Kobani3-Oct-14 23:02
Taylor Kobani3-Oct-14 23:02 
GeneralRe: Very Interested in the code Pin
terrydw4-Oct-14 9:37
terrydw4-Oct-14 9:37 
GeneralRe: Very Interested in the code Pin
Taylor Kobani5-Oct-14 19:13
Taylor Kobani5-Oct-14 19:13 
GeneralRe: Very Interested in the code Pin
Brantuo26-Feb-16 5:22
Brantuo26-Feb-16 5:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.