Complete First is a book to prepare this level for Cambridge exam. It's a complete book since is goes through all the parts of the exam.Descripción completa
Maynard Ferguson's Chameleon - Big Band Score and PartsFull description
Maynard Ferguson's Chameleon - Big Band Score and Parts
Descrição completa
Album GismontiDescrição completa
Descripción: arrangement of anterior teeth
Petroleum Experts
User Manual
IPM OpenServer January 2011
OpenServer Communication Protocols to use IPM tools using external commands by Petroleum Experts Limited
OpenServer is designed to provide an Open Architecture for all the Petroleum Experts IPM products. This will allow the programs to be directly accessed and be driven by other third party programs. Applications for OpenServer are in Connections to: • Third Party Reservoir Simulator. • Process Simulators. • Economics Packages. • Data Base. • Field Control System. • In House and Proprietary Applications. Specifically, the OpenServer allows other programs (such as Excel or programs written in Visual Basic) to access public functions in Petroleum Experts programs. An external program, in an automated procedure, can then access the Petroleum Experts products. As of IPM 7.0 OpenServer is a separately licenced product.
1 Basic Functions ................................................................................................................................... 4 2 Calling................................................................................................................................... Public Functions 5
8
Part 2 Support
10
Part 3 Using OpenServer
1 Tag Strings ................................................................................................................................... 10 2 Automation ................................................................................................................................... 11 Exam ple Macro .......................................................................................................................................................... 11 Macro Fram ew .......................................................................................................................................................... ork 14 DoCm d .......................................................................................................................................................... 15 DoSet Sub Com .......................................................................................................................................................... m and 16 DoCom m andAsync .......................................................................................................................................................... 16 DoGet Sub Com .......................................................................................................................................................... m and 17
3 Batch ................................................................................................................................... File 18 Running a Batch .......................................................................................................................................................... File 18 Form atting Com .......................................................................................................................................................... m ands 19 DoCom m and .......................................................................................................................................................... 20 SetValue .......................................................................................................................................................... 20 GetValue and .......................................................................................................................................................... GetValPrint 21
5 Multiple ................................................................................................................................... Values for Arrays 25 Multiple DoGet .......................................................................................................................................................... Values 25 Multiple DoSet.......................................................................................................................................................... Values 26 Using More than .......................................................................................................................................................... One Multiple Array 26
6 Units ................................................................................................................................... 27 7 Start/Shutdown ................................................................................................................................... Commands 29
32
Part 4 GAP and the OpenServer
1 Introduction ................................................................................................................................... and Variable Lists 32 Ctrl + Right m ouse .......................................................................................................................................................... click 33 Execute OpenServer .......................................................................................................................................................... Statem ent 34
January, 2011
Contents
II
Specific Units .......................................................................................................................................................... Handling Com m ands 35 Literal Constants .......................................................................................................................................................... 36 Date Handling.......................................................................................................................................................... w ithin GAP 37 OpenServer "Wild .......................................................................................................................................................... Cards" 38 Variables at Top .......................................................................................................................................................... Level 39 Variables at MOD .......................................................................................................................................................... Level 41 Model Options ......................................................................................................................................................... 41 Solver Setup and......................................................................................................................................... Calculation Log 46 Prediction Setup ......................................................................................................................................... 48 Model Equipment ......................................................................................................................................................... List 52 Variables at Node .......................................................................................................................................................... Level 53 General fields ......................................................................................................................................................... found in nodes of any type 53 Fields specific ......................................................................................................................................................... to tanks 55 Fields Specific ......................................................................................................................................................... to Wells 57 Fields specific to ......................................................................................................................................... all w ell models 58 Fields specific to ......................................................................................................................................... w ells modelled using VLP/IPR intersection 60 Fields specific to w ells modeled using Performance Curves / Interpolated Performance ......................................................................................................................................... Curves 65 Fields specific to ......................................................................................................................................... Stand-Alone Inflow s 67 Fields specific to ......................................................................................................................................... Stand-Alone Outflow s 67 Equipment Control......................................................................................................................................... Section 68 PROSPER Online ......................................................................................................................................... Models 69 Fields specific ......................................................................................................................................................... to pipelines 70 Pipeline Model Selection ......................................................................................................................................... 70 GAP Internal Correlation ......................................................................................................................................... Pipeline Models 70 GAP Lift Curves Pipeline ......................................................................................................................................... Models 74 GAP PROSPER Online ......................................................................................................................................... Pipeline Models 75 Fields specific ......................................................................................................................................................... to joints 76 Fields specific ......................................................................................................................................................... to pump/compressor nodes 76 Fields Common to......................................................................................................................................... Pumps and Compressors 77 Fields Specific to......................................................................................................................................... Compressors 78 Fields specific ......................................................................................................................................................... to separator / injection manifold nodes 79 Com position Records .......................................................................................................................................................... 80 Compositional ......................................................................................................................................................... Model Setup 80 Fluid Composition ......................................................................................................................................................... Setup - Wells 80 Fluid Composition ......................................................................................................................................................... Results 82 Enabling / Disabling .......................................................................................................................................................... Options 82 Scheduling .......................................................................................................................................................... 84 Schedule Count ......................................................................................................................................................... 84 Date ......................................................................................................................................................... 84 Event type......................................................................................................................................................... 85 Constraint ......................................................................................................................................................... Type 86 Constraint ......................................................................................................................................................... Value 86 Schedule Reset ......................................................................................................................................................... 86 Apply Schedule ......................................................................................................................................................... To 87 Constraints .......................................................................................................................................................... 87 Constraint ......................................................................................................................................................... Level and Type 87 Binding Constraints ......................................................................................................................................................... 89 Constraints......................................................................................................................................................... and Potential Calculations 90 Obtaining the .......................................................................................................................................................... Results 91 Solver Results ......................................................................................................................................................... 91 Prediction Results ......................................................................................................................................................... 92 Total System ......................................................................................................................................................... Results 94 Snapshot Results ......................................................................................................................................................... 94
3 GAP ................................................................................................................................... Internal Script 131
134
Part 5 MBAL and the OpenServer
1 Finding ................................................................................................................................... a Variable Text String 134 2 Date ................................................................................................................................... Handling within MBAL 135 3 Commands ................................................................................................................................... 135 General .......................................................................................................................................................... 136 Material Balance .......................................................................................................................................................... Com m ands 136 Monte Carlo .......................................................................................................................................................... 138 1D Model .......................................................................................................................................................... 138 Decline Curve .......................................................................................................................................................... 138 Multi-Layer .......................................................................................................................................................... 138 Production Allocation .......................................................................................................................................................... 138 Tight Gas .......................................................................................................................................................... 139 PVT .......................................................................................................................................................... 139
4 OpenServer ................................................................................................................................... Code Examples 140 DoGet, DoSet.......................................................................................................................................................... and DoCm d Exam ple 140 List Variables .......................................................................................................................................................... 141 Material Balance .......................................................................................................................................................... Step-by-Step Prediction 142 Production Allocation .......................................................................................................................................................... Step-by-Step Prediction 144
5 Direct................................................................................................................................... Access OPENSERVER 145 Overview .......................................................................................................................................................... 145 Sum m ary .......................................................................................................................................................... 146 High Level Exam .......................................................................................................................................................... ple 147 Low Level Exam .......................................................................................................................................................... ple 155 Datablock Variable .......................................................................................................................................................... Nam es 170
6 Variable ................................................................................................................................... Text Strings 173 1D Model .......................................................................................................................................................... 173 Monte Carlo .......................................................................................................................................................... 174 Decline Curve .......................................................................................................................................................... 175 Multi-Layer Tool .......................................................................................................................................................... 175 PVT .......................................................................................................................................................... 177 Material Balance .......................................................................................................................................................... 179 Production Allocation .......................................................................................................................................................... 185 Tight Gas .......................................................................................................................................................... 186 Relative Perm .......................................................................................................................................................... eability Curves 186
189
Part 6 PROSPER and the OpenServer
1 General ................................................................................................................................... Comments 189 Getting the strings .......................................................................................................................................................... through Ctrl+Right Click 190 List of variables .......................................................................................................................................................... in PROSPER file (NEW!!!) 190
OpenServer User's Manual
January, 2011
IV
V
OpenServer
Evaluate OpenServer .......................................................................................................................................................... Statem ent Section (NEW!!!!) 195 Setting the Units .......................................................................................................................................................... and Validation Lim its 196 Counting num .......................................................................................................................................................... ber of entry data points or calculated results 198
2 Options ................................................................................................................................... Summary Data 199 3 PVT Data ................................................................................................................................... Section 202 INPUT - Input.......................................................................................................................................................... Data 202 MATCH - PVT.......................................................................................................................................................... Match Data 204 TABLE - Setting .......................................................................................................................................................... data to the PVT Lookup Tables 205 CORREL – Correlation .......................................................................................................................................................... Matching Param eters 206 Black Oil -......................................................................................................................................................... Oil 206 Black Oil -......................................................................................................................................................... Gas 208 Black Oil -......................................................................................................................................................... Retrograde Condensate 208 CALC - Calculation .......................................................................................................................................................... Results 209 EOS - Equation .......................................................................................................................................................... of State Data 211 DLL - External .......................................................................................................................................................... PVT DLL Data 214 EMULSION - Em .......................................................................................................................................................... ulsion Data 215 VISC - Viscosity .......................................................................................................................................................... Data 215 HYD - Hydrates .......................................................................................................................................................... Form ation Data 216
4 INPUT ................................................................................................................................... Data Section 216 IPR Data .......................................................................................................................................................... 217 Overview......................................................................................................................................................... 217 Single Branch ......................................................................................................................................................... Data 217 Common Parameters ......................................................................................................................................... 217 Model Selection ......................................................................................................................................... and PVT Screen 218 Test/PI Entered Models ......................................................................................................................................... 219 MultiRate Models......................................................................................................................................... 220 Darcy-based Models ......................................................................................................................................... 221 External Entry Model ......................................................................................................................................... Parameters 223 Multi-layer (no friction ......................................................................................................................................... dP loss) Table 223 Horizontal Well w ......................................................................................................................................... ith dP Friction Loss Table, Including Coning Screen 224 Multi-layer w ith dP ......................................................................................................................................... Friction Loss Table 226 Skin Aide Model......................................................................................................................................... Parameters 228 Tw o-term Model......................................................................................................................................... Parameters 231 Fracture Model ......................................................................................................................................... 231 SPOT ......................................................................................................................................... 232 Mechanical Skin......................................................................................................................................... Parameters 238 Deviation Skin-Specific ......................................................................................................................................... Parameters 239 Gravel Pack-Specific ......................................................................................................................................... Parameters 240 Relative Permeability ......................................................................................................................................... Screen 241 Gas Coning Parameters ......................................................................................................................................... for Oil 241 Multi-lateral ......................................................................................................................................................... Well Data 242 Netw ork items ......................................................................................................................................... 242 Branch, Layer and ......................................................................................................................................... Segment Details 248 Calculation Control ......................................................................................................................................... Data 249 Visualisation Data ......................................................................................................................................... 249 Multilateral Results ......................................................................................................................................... 250 Equipm ent Data .......................................................................................................................................................... 251 Overview......................................................................................................................................................... 251 DEVN – Deviation ......................................................................................................................................................... Survey Equipment 252 TEMP – Flow ......................................................................................................................................................... ing Temperature Survey 252 GEO – Geothermal ......................................................................................................................................................... Gradient 253 SURF – Surface ......................................................................................................................................................... Equipment 253 TURF – Surface ......................................................................................................................................................... Equipment (Enthalpy Balance) 254
January, 2011
Contents
VI
DOWN – Dow ......................................................................................................................................................... n Hole Equipment 255 TOWN – Dow ......................................................................................................................................................... n Hole Equipment (Enthalpy Balance) 256 SHC – Fluid ......................................................................................................................................................... Properties – Average Heat Capacities 256 ENV – Surface ......................................................................................................................................................... Environment Data (Enthalpy Balance / Rough Approx.) 257 DRILL – Drilling ......................................................................................................................................................... Data (Enthalpy Balance) 257 LITHO – Lithology ......................................................................................................................................................... (Enthalpy Balance) 259 DB – Databases ......................................................................................................................................................... (Enthalpy Balance) 259 Artificial Lift .......................................................................................................................................................... Data Section 260 Gas Lift (Continuous) ......................................................................................................................................................... 261 Electircal ......................................................................................................................................................... Submersible Pump 262 Hydraulic ......................................................................................................................................................... Drive Dow nhole PUmp 263 Progressive ......................................................................................................................................................... Cavity Pump 263 Coil Tubing ......................................................................................................................................................... Gas Lift 263 Jet Pump ......................................................................................................................................................... 264 Multiphase ......................................................................................................................................................... Pump 264 Sucker Rod ......................................................................................................................................................... Pump 264 Gas Lift (Intermittent) ......................................................................................................................................................... 265
1 OpenServer ................................................................................................................................... VBA Template 484 2 GAP ................................................................................................................................... Examples 484 Basic Code Structure .......................................................................................................................................................... 484 Exam ple 1 – GAP .......................................................................................................................................................... Open Server Exam ple A 487 Exam ple 2 – GAP .......................................................................................................................................................... Open Server Exam ple B 489 Exam ple 3 – GAP .......................................................................................................................................................... Open Server Exam ple C 500 Exam ple 4 – GAP .......................................................................................................................................................... Open Server Exam ple D 500
spreadsheet. Data Import/Export The OpenServer can be used for transferring data to or from a database and PETEX programs. The client program can use any technique to access the values in the database (e.g. ODBC, DAO, and SQL) and then transfer them with OpenServer. For example, production data may be stored in an Access database, a VBA macro can be written in Access to query the data from the database and then use OpenServer to set the data in MBAL for instance. An example is available in the installed MBAL examples – OPENSERV.MDB. Enhanced Prediction Runs in GAP Using OpenServer with GAP provides the ability to control field development strategies during the prediction by performing a task such as well drilling and completing from using OpenServer to dynamically monitor an overall facilities rate constraint. This means that wells will now be drilled and completed based on the overall model response, rather than driving well drilling scheduling from a scheduled date perspective. Please see the GAP OpenServer Example D.GAR file that also contains the completed drilling queue macro. Running PETEX programs with other engineering software applications OpenServer can be used to run the PETEX programs in conjunction with other software applications and exchange data between them. For example, a visual basic program or batch file could be used to successively: - Run a process simulator to calculate a feed separator pressure - Set the separator pressure in GAP - Optimize the production system in GAP - Pass the GAP rates onto the process simulator -Run the process simulator, etc. It is important to note that dynamic links to industry standards process and numerical reservoir simulators are now available through RESOLVE.
The code for these commands has already been setup in the OpenServer template provided with the software installation. This OpenServer template is called OpenServer Template.xls and can be found at the following location: - C:\Program Files\Petroleum Experts\IPM 6.0\Samples\openserver\Template. The OpenServer template can be used as a starting point when building an Excel based OpenServer utility. Also, the variety of OpenServer example files that have been constructed for each IPM tool can also be modified to meet individual needs. Note: Unfortunately, VBA was designed for use with simple functions that take only a few seconds. If a function is called that takes more than one minute to complete, a timeout error in Excel may occur depending on operating system, Excel version, setup etc. This is where the DoSlowCmd would be required to replace the DoCmd sub fuction. The DoSlowCmd will also be required if the license server has high traffic where the speed of communication from the local PC to obtain a license has been reduced.
1.2
Calling Public Functions There are two methods of calling public functions. The following sections summarizes how to call the functions, syntax examples are also provided. Automation The OpenServer is an Automation server. This means that the public functions can be called from any program that can act as an Automation client. There are many programs that can act as an Automation client and can therefore be used to call the public functions in the PETEX programs. These include: - Any VBA macro. These macros are available in Excel, Access and many other Microsoft products. - Visual Basic programs can be written to act as an Automation client and therefore call the public functions. - C++ programs can also be written to act as an Automation client and therefore call the public functions. Many other products can act as Automation clients and will be illustrated in their
OpenServer User's Manual
Technical Overview
6
individual documentation. Batch File To avoid dependence on Automation, it is also possible to call the public functions in the PETEX programs using a simple batch file. The functions required are typed into a text file. A program is supplied by Petroleum Experts (PXBATCH) which will interpret the text file and call the functions in the PETEX programs. It also writes the output of the DoGet function to another text file which can be viewed afterwards.
Support The main strength of the OpenServer is that users are now free to develop their own applications which utilise the public functions within PETEX products. However this does mean that a user of the OpenServer will require more computing knowledge than a user of the standard PETEX programs. This is particularly the case where a user writes a client application in VBA or Visual Basic. The user is expected to have (or be trained in) the requisite computing skills to write these client applications. Petroleum Experts will not be able to undertake to train users in these computing skills. The boundary of the PETEX products and the user’s applications needs to be defined with respect to support provided by Petroleum Experts of the OpenServer feature. Firstly, as with normal support, a maintenance agreement between the user and Petroleum Experts must be in place. Unfortunately, Petroleum Experts will not be able to undertake development of VBA macros, batch files or other OpenServer clients for a particular user. The strength of the feature is to allow the user to implement these client applications without any further input by Petroleum Experts. Similarly Petroleum Experts will be unable to assist in fixing bugs in users VBA macros, batch files or any other OpenServer client. Petroleum Experts will undertake to support any user who can demonstrate (through a simple fragment of a batch file or VBA macro etc) that a public function call to a PETEX product fails to work correctly.
Using OpenServer This chapter describes in detail how to access the public function in PETEX programs. The TagStrings section describes how each data item is defined in the PETEX programs using a variable text string. The Automation section describes how to call the public functions using Automation. We first describe the framework needed to use the OpenServer, then each function is described in detail. The Batch File section describes how to call the public functions using a batch file system. We describe the framework and then describe each function in detail. This section does not deal with specific issues relating to particular products e.g. GAP or MBAL. To use the public function for a particular PETEX program, the tools must be installed on the local hard disk with access to a valid security authentication e.g. security key or HARDLOCK. When the public functions are being called (either using Automation or a batch file), the appropriate PETEX product must be running. However, it does not need to be visible on the screen (i.e. it can be minimized). Commands are available to start each of the programs. Alternatively one can start the programs manually before running a macro/ batch file.
- MB – In the material balance tool - PRED – In the prediction section - STARTTIME – Start time All tag strings are case insensitive (i.e. it does not matter if lower or upper case characters are used). For specific details of the tag strings for each PETEX program, refer to the program specific sections below. It is also possible to capture the OpenServer string details directly from the given IPM tool using a Ctrl + Right-Click keyboard and mouse work-flow. Please note, it is not possible to capture an OpenServer string using the above keyboard and mouse work-flow for a calculation button. For a list of IPM OpenServer command strings, please review the corresponding OpenServer command reference information.
3.2
Automation This section describes how to access the public functions using Automation. This is a Microsoft Windows standard (formally known as OLE Automation). This method requires software which can act as an Automation client to call the public functions. Probably the most commonly used example of such an Automation client that is used in the engineering industry is the VBA macro language within Excel. We will therefore demonstrate how the public functions are called by such macros – the same rules should extend to other Automation clients. Rather than describing the functions in isolation, an example of an Excel VBA macro is presented that uses all the available public functions. Each function within this example will be described including macro error handling. It is important to note that the OpenServer template already contains the necessary macro communication error handling already built in.
3.2.1 Example Macro This example performs a simple set of operations in the MBAL program. These include: - Open the OIL.MBI file - Change the original oil in place to a new value - Run a prediction - Get the first oil rate and display it in the Excel spreadsheet. This macro is available in the installed MBAL examples, OPENSERV.XLS, located in OpenServer User's Manual
Using OpenServer
12
the directory C:\Program Files\Petroleum Experts\IPM 7.0\Samples\openserver\MBAL The macro is split into a number of subroutines and functions: - The main subroutine is called DoAll(). - There are five other subroutines and functions which allow calls to be made to the PETEX public functions. Option Explicit Dim Server As Object Dim AppName As String Sub DoAll() Connect 'establishes Excel communication link to IPM AppName = "MBAL" DoSlowCmd "MBAL.OPENFILE=C:\PETEX\SAMPLES\OIL.MBI" 'See below for an alternative "file open" approach DoSet "MBAL.MB.TANK.OOIP", "250.0" 'set the tank OOIP value DoSlowCmd "MBAL.MB.RUNPREDICTION" 'run the prediction Range("C11") = DoGet("MBAL.MB.TRES[2][0][0]. OILRATE") 'retrieve the first oil rate Disconnect 'Closes the server object connection to IPM MsgBox "Macro completed" End Sub Alternative File Open Approach Ü If the MBAL file name was placed at a certain cell reference in Excel, then the following File | Open approach could be used: "MBAL.OpenFile(""" + Range ("E12") + """)" OpenServer Template Error Handling Code The following code is part of the OpenServer template and manages error handling between the application and macro: Sub DoCmd(Cmd) Dim lErr As Long lErr = Server.DoCommand(Cmd) If lErr > 0 Then MsgBox Server.GetErrorDescription(lErr) Set Server = Nothing End End If End Sub
Sub DoSet(Sv, Val) Dim lErr As Long lErr = Server.SetValue(Sv, Val) lErr = Server.GetLastError(AppName) If lErr > 0 Then MsgBox Server.GetErrorDescription(lErr) Set Server = Nothing End End If End Sub Function DoGet(Gv As String) As String Dim lErr As Long DoGet = Server.GetValue(Gv) lErr = Server.GetLastError(AppName) If lErr > 0 Then MsgBox Server. GetErrorDescription(AppName) Set Server = Nothing End End If End Function Sub DoSlowCmd(Cmd) Dim StartTime As Single Dim EndTime As Single Dim CurrentTime As Single Dim lErr As Long Dim bLoop As Boolean lErr = Server.DoCommandAsync(Cmd) If lErr > 0 Then MsgBox Server.GetErrorDescription(lErr) Set Server = Nothing End End If While Server.IsBusy(AppName) > 0 StartTime = Timer EndTime = StartTime + 2 Do CurrentTime = Timer DoEvents bLoop = True Rem Check first for the case where we have Rem gone over midnight and the number of Rem seconds will go back to zero If CurrentTime < StartTime Then bLoop = False OpenServer User's Manual
Using OpenServer
14
Rem Now check for the 2 second pause finishing ElseIf CurrentTime > EndTime Then bLoop = False End If Loop While bLoop Wend lErr = Server.GetLastError(AppName) If lErr > 0 Then MsgBox Server.GetErrorDescription(lErr) Set Server = Nothing End End If End Sub Function DoGAPFunc(Gv As String) As String AppName = “GAP” DoSlowCmd Gv DoGAPFunc = DoGet("GAP.LASTCMDRET") End Function
functions from any or all of the PETEX programs, i.e., Ser ver . DoCommand( Command1) Ser ver . DoCommand( Command2) Ser ver . Get Val ue( Var 1) Once the public functions in the macro have completed, the server object connection can be closed using: Set Ser ver = Not hi ng This line can be replaced by the Disconnect function that has been implemented in the OpenServer template. The line then simply becomes: Di sconnect These can be seen in the DoAll() subroutine above.
3.2.3 DoCmd The DoCmd function is used to perform calculations and other functions such as file opening and saving in the PETEX programs. Only a subset of the commands available using the user interface are available. The commands that are not supported are those that require some graphical interaction such as graphical history matching in MBAL. In the above example, DoCmd is used twice. The first time it is used to open the Oil. MBI data file. The second time it is used for running a prediction. The text string after the DoCmd statement describes the command to be performed. The text string always starts with the name of the program in which the calculation is to be done. The rest of the text string describes the command – check the following sections describing each PETEX program for a list of possible calculations. There is no output to the PXR file for this command. If there is any error, a message will be written to PXBATCH.LOG. Note that the abbreviation dc can be used in the batch file instead of DoCmd. Note: As previously mentioned, VBA was designed for use with simple functions that take only a few seconds. If a function is called that takes more than one minute to complete, a timeout error in Excel may occur depending on operating system, Excel version, setup etc. If this happens, the DoSlowCmd should be used instead of the DoCmd. OpenServer User's Manual
Using OpenServer
16
3.2.4 DoSet Sub Command The DoSet command is used to set the value of a data item. It should be possible to change most of the values that can normally be accessed via the user interface. Each variable is identified by the unique text string that can be captured using a Ctrl + RightMouse Click keyboard and mouse action. In the above example, the DoSet function is used in the DoAll() subroutine to change the value of the initial oil in place to 250.0. The variable to be changed is determined by the first input text string. The new value for the variable is passed in the second input text string. This function expects the value to be in the units currently displayed in the user interface. It is the responsibility of the user writing the macro to ensure that the second text string contains a valid number if the data item is numerical. Unlike the DoCmd public function, the DoSet function does not return an error number. As can be seen in the example macro subroutine DoSet(), the GetLastError() public function must be called to check if any error occurred. This will return zero if the last public function call was successful or an error number if not. It is recommended that the DoSet() macro subroutine shown in the example macro and provided in the OpenServer Template.xls file is used for all applications as it already has error handling built in. Please also see the main on-line help of PROSPER, as it contains a listing of OpenServer variables and commands.
get the calculated value before the calculation is finished! So the VBA still needs some way of knowing when the calculation has finished. Therefore it is usually necessary to append some VBA code after a call to DoCommandAsync which loops until the calculation is finished. The inserted code uses another function called IsBusy() to check if the calculation is finished. This VBA code to do this is in the macro subroutine DoSlowCmd() in the example macro. The code loops round until the IsBusy function returns a value greater than zero. The only input argument is the name of the PETEX program in which the calculation was called. Within the loop the code will wait 2 seconds before looping again. It also calls the VBA function, DoEvents, which will allow other windows program to work whilst the VBA is waiting for the calculation to finish. It is recommended that the DoSlowCmd macro subroutine shown in the example macro and provided in the OpenServer Template.xls file is used for all applications as it already has error handling built in as well as the code to wait for the function to finish.
3.2.6 DoGet Sub Command The DoGet function is used to get the value of a data item or result. It should be possible to query most of the values that can normally be accessed via the user interface. Each variable is identified by a unique text string. In the above example, the DoGet function is used in the DoAll() subroutine to get the value of the first oil rate in the prediction tank results. The variable to be retrieved is determined by the input text string. The return value of the function call is another text string containing the value of the data item. If the value is numerical data, the return text string will contain the formatted number and avoids having different functions for different data types. The value will be returned in the units currently displayed in the user interface. As with the DoSet function, the GetLastError function must be used to check for errors in the SetValue function. Note that in the macro subroutine DoGet, we use a different function to get the actual error message using GetLastErrorMessage. This function returns the error message corresponding to the last public function call for the application specified by the input argument. If the last public function call was successful, it will return a blank error message. It is recommended that the DoGet macro subroutine shown in the example macro and provided in the OpenServer Template.xls file is used for all applications as it already has error handling built in.
OpenServer User's Manual
Using OpenServer
3.3
18
Batch File This section describes how to access the public functions using a batch file. Each command is typed into an ASCII file. A program is supplied by Petroleum Experts which reads this ASCII file and calls the public functions in the PETEX programs and writes the output to another ASCII file.
3.3.1 Running a Batch File The first step to calling the public functions from the batch file is to create the batch file itself. This is a simple ASCII file which can be created using NOTEPAD.EXE. The only point to note is that when the batch file is saved it should have the file extension PXB e.g. TEST.PXB. Each public function to be called should be listed on a separate line. Comment lines can be entered by starting the line with a # character e.g. # This is my first batch file # 1st January 2009 The details of how to list the public functions are shown in the following sections. Once the batch file has been created and the functions listed in the file, we can run the batch file: Steps: 1. Run the latest version of the PETEX program that is going to be used e.g. MBAL and GAP 2. Copy the file PXBATCH.EXE into the same directory as the PXB batch file (this file can be found in the latest installation of the PETEX CD (C:/Program Files/Petroeum Experts/IPM 7) 3. Run the PXBATCH program with the PXB file name as an argument For example, if the batch file is called TEST.PXB, run PXBATCH –b TEST. PXBATCH will call each public function in turn and two files will be created by PXBATCH. The first is called PXBATCH.LOG and will contain any error messages from the batch run so it is important to examine the file after every batch run to check for errors. The second file will have the same file stem as the batch file but will have the extension PXR. In the above case, the second output file will be called TEST.PXR. This file will contain any output from the public functions.
An example batch will be presented which shows calls to all the public functions in the PETEX products. Then each function used in the example batch file will be described in turn. The example batch file is as follows (this file is available in the installed MBAL examples, MBALTEST.PXB).:# Example batch file PRINT Example batch file output PRINT docommand MBAL.OpenFile("C:\PETEX\SAMPLES\OIL.MBI") setvalue MBAL.MB.TANK.OOIP 250.0 docommand MBAL.MB.RUNPREDICTION getvalprint MBAL.MB.TANK.OOIP PRINT "First oil rate =" PRINTTAB PRINTTAB getvalue MBAL.MB.TRES[2][0][0].OILRATE PRINT " bbls/day" PRINT PRINT End of example batch file output The output PXR file from the above batch file is as follows: 250 ! MBAL.MB.TANK.OOIP First oil rate = 16516.8 bbls/day End of example batch file output
3.3.2 Formatting Commands There are two commands, PRINT and PRINTTAB that can be used to format and write text to the output PXR file. The PRINT statement can be used in two ways: - If some text is appended to the PRINT statement, the text will be printed out to the PXR file. If desired the text might be enclosed in quotations. - If the PRINT command is used without any text, it will move the output onto the next line in the PXR file. For example, consider the last three lines of the example batch file. The first of these PRINT statements prints the text “ bbls/day”. The second PRINT statement moves the next output onto the next line. The third PRINT statement displays the text “End of example batch file output” on the next line of the PXR file. Note that if the second PRINT statement was not included, the output PXR file would look like: …. . bbl s/ dayEnd of exampl e bat ch f i l e out put OpenServer User's Manual
Using OpenServer
20
The second formatting command is PRINTTAB. This command simply writes a tab character to the PXR file.
3.3.3 DoCommand The DoCmd function is used to perform calculations and other functions such as file opening and saving in the PETEX programs. Only a subset of the commands available using the user interface are available. The commands that are not supported are those that require some graphical interaction such as graphical history matching in MBAL. In the above example, DoCmd is used twice. The first time it is used to open the Oil. MBI data file. The second time it is used for running a prediction. The text string after the DoCmd statement describes the command to be performed. The text string always starts with the name of the program in which the calculation is to be done. The rest of the text string describes the command – check the following sections describing each PETEX program for a list of possible calculations. There is no output to the PXR file for this command. If there is any error, a message will be written to PXBATCH.LOG. Note that the abbreviation dc can be used in the batch file instead of DoCmd. Note: As previously mentioned, VBA was designed for use with simple functions that take only a few seconds. If a function is called that takes more than one minute to complete, a timeout error in Excel may occur depending on operating system, Excel version, setup etc. If this happens, the DoSlowCmd should be used instead of the DoCmd.
3.3.4 SetValue This function is used to set the value of a data item. It should be possible to change most of the values that can normally be accessed via the user interface. In the example we use SetValue once to change the original oil in place to 250.0. The first text string after SetValue defines the variable to be changed. The second text string defines the new value of the variable. This function expects the value to be in the units currently displayed in the user interface. There is no output to the PXR file for this command. If there is any error, a message will be written to PXBATCH.LOG. Note that the abbreviation sv can be used in the batch file instead of SetValue.
3.3.5 GetValue and GetValPrint These two functions are both used to get the value of a data item and print it to the PXR output file. The only difference between the two functions is the format of the output to the PXR file. GetValPrint is used once in the example batch file to get the value of the original oil in place – this is to verify that the preceding SetValue worked correctly. The text string after GetValPrint defines the variable to be written to the output PXR file. If the function works correctly, the variable is written to the PXR file followed by the variable text string, separated by an exclamation mark. It also moves the output onto the next line so any further Print functions will start on the next line. This format can be seen in the example PXR file above. GetValue is also used once in the example batch file to output the first oil rate in the prediction tank results. The function is called as for GetValPrint. The only difference is that this function simply writes the value of the variable to the output PXR file without any formatting. This means that other Print commands will be needed to format the output – as shown in the example batch file. Note that the abbreviation gvp can be used in the batch file instead of GetValPrint. The abbreviation gv can be used instead of GetValue.
3.4
Arrays and List Variables Many of the variables in the programs have single values, such as a single reservoir pressure in PROSPER. However some of the variables are arrays such as a multi-tank system in MBAL. For this case, an index in the tag string must be specified. Arrays in the programs can be variable or of a fixed size. For example, if we have three tanks in an MBAL model then we access the OOIP of the first tank using the following tag string :MBAL.MB.TANK[0].OOIP Note that the index is zero based. By this, we mean that the 1st item has an index of 0, the 2nd item will then have an index of 1, etc. In some cases, one can identify an item in an array using the label of the item rather than an index. For example if the label of the 1st tank is Lower05, the OOIP can be accessed using the following tag string: MBAL.MB.TANK[{Lower05}].OOIP
OpenServer User's Manual
Using OpenServer
22
One must place {} brackets around the label so the program will not interpret the label as a numerical index. NOTE: The label is the only part of a tag string which is case sensitive. If there is only one item in the list, then the index is optional. For example, if there is only one tank, the following tag string can be used: MBAL.MB.TANK.OOIP There are also some variables that are arrays with two or more dimensions. These variables will require two or more indices in the tag string. For example, consider the prediction results for the material balance tool in MBAL. These have three indices where the first index indicates the result type, the second index is the tank and the third index is the row. A tag string for a result may look like: MBAL.MB[0].TRES[0][0][3].GASSAT
3.4.1 Special Array Operations There are a number of special features that can only be used with arrays.
3.4.1.1 COUNT The COUNT feature returns the number of items that exist in an array. This feature only works for arrays that have a variable size. For example, the number of tanks in an MBAL model can be found using the command: Range("C11") = DoGet("MBAL.MB.TANK.COUNT") This command can also be used in multi-dimensional arrays to count the number of tank prediction results for instance using the command: Range("C11") = DoGet("MBAL.MB.TRES[2][3].COUNT")
3.4.1.2 NDIM The NDIM feature can only be used for fixed length arrays. It is used to find the number of dimensions in the array.
Consider a variable which is a three-dimensional array (this is not an actual variable). An item in the array may be accessed as follows: Range("C11") = DoGet("MBAL.MB.TANK.PV[1][5][9]") One can find the number of dimensions by calling the following function: Range("C11") = DoGet("MBAL.MB.TANK.PV.NDIM") This function will return the value 3.
3.4.1.3 DIMSIZE The DIMSIZE feature can only be used for fixed length arrays. It is used to find the fixed number of items for a given dimension of the array. Consider a variable which is a three-dimensional array (this is not an actual variable). Now, this array has 3 items in the 1st dimension, 8 in the 2nd dimension and 20 in the 3rd dimension. So the maximum indices we can access would be (remembering that the indices are zero based): Range("C11") = DoGet("MBAL.MB.TANK.PV[2][7][19]") One can find the fixed number of items in the second dimensions by calling the following function: Range("C11") = DoGet("MBAL.MB.TANK.PV.DIMSIZE[1]") This function will return the value 8. Similarly, DIMSIZE[0] will return 3 and DIMSIZE[2] will return 20.
3.4.1.4 RESET The RESET feature can only be used for arrays with a variable number of items. It is used to delete all the items in the array and thus reduce the number of items in the array to zero. For example, to delete all the items in the tank production history for an MBAL model, use the command: DoSet "MBAL.MB.TANK.PRODHIST.RESET", ""
OpenServer User's Manual
Using OpenServer
24
3.4.1.5 SORT The SORT feature can only be used for arrays with a variable number of items. It is used to sort all the items in the array in order. The method of sorting is the same as used in the corresponding dialog of the program. For example, the tank production history for an MBAL model is sorted by the date of each item in the array. To sort the production history, use the command: DoSet "MBAL.MB.TANK.PRODHIST.SORT", ""
3.4.1.6 ADD The ADD feature can only be used for arrays with a variable number of items. It is used to add a new item to the end of an array. For example, to add two rows to an empty table of tank production history for an MBAL model, use the commands: DoSet DoSet DoSet DoSet DoSet DoSet DoSet DoSet
3.4.1.7 DELETE The DELETE feature can only be used for arrays with a variable number of items. It is used to delete a particular item in the list and it will reduce the number of items in the list by one. For example, the following command will delete the 4th row in the production history table of an MBAL model: DoSet "MBAL.MB.TANK.PRODHIST[3].DELETE", ""
3.4.1.8 INSERT The INSERT feature can only be used for arrays with a variable number of items and it is used to insert a new item at a particular position in the list. All the items at and above the position to insert will be moved up one position in the list, so the new item can be inserted. For example, the following command will insert a new row in the production history table of an MBAL model. The new row will become the 7th row: DoSet DoSet DoSet DoSet DoSet
Multiple Values for Arrays This section describes how the DoSet / DoGet functions are used to retrieve and set more than one item in an array.
3.5.1 Multiple DoGet Values Consider a situation where one wishes to extract tank pressures from a 5-tank MBAL model. The following fragment of VBA code could be used: Range("C1") Range("C2") Range("C3") Range("C4") Range("C5")
A quicker method is to get all the pressures in one DoGet call, and there are two options to achieve the objective: - Get the pressures for all the available tanks: Range("C1") = DoGet(" MBAL.MB.TANK[$].PRESS") - Get the pressures for tank index zero through to tank index four: Range ("C1") = DoGet("MBAL.MB.TANK[0,1,2,3,4].PRESS") The above example using multiple DoGet calls will return all the tank pressures in the model.
OpenServer User's Manual
Using OpenServer
26
The values will be returned in a single text variable separated by the ‘|’ character e.g. 5132.0|4893.0|4598.3|4882.0|4976.6 There are several other variations which can be used to extract data from multiple tanks using the following syntax: - Return the pressure for tank 0,1,2 and 4: Range("C1") = DoGet("MBAL .MB.TANK[0:2,4].PRESS") - Return the pressure for tank 1 and 3: Range("C1") = DoGet("MBAL. MB.TANK[1,3].PRESS")
3.5.2 Multiple DoSet Values The DoSet function can use multiple tag names in a similar manner to the DoGet function as previously described. All the different forms of the variable tag names used by the DoGet can be used for the DoSet function. For the DoSet function, a text variable is passed to the function which contains a list of the values to set, separated by the ‘|’ character. For example, the following string can be used to set multiple OOIP's in a multi-tank system to tank 1, 4 and 5: DoSet " MBAL. MB. TANK[ 1, 4, 5] . OOI P" , " 250. 0| 129. 0| 349. 0" The above command will set the OOIP of tank index 1 to 250.0, tank index 4 to 129.0 and tank index 5 to 349.0. There is an extra feature available with the DoSet function, where all tanks specified in the indices array [1,4,5] can have the same OOIP assigned using the following DoSet command: DoSet " MBAL. MB. TANK[ 1, 4, 5] . OOI P" , " 250. 0" The above technique can be used to set many items in a list to the same value.
tank. We have already seen how we could access more than one production history record or more than one tank e.g. : MBAL.MB.TANK[2].PRODHIST[3 :7].CUMOIL MBAL.MB.TANK[$].PRODHIST[4].CUMOIL However we can also have multiple indices for both the production history records and the tank in the same tag name. For example : DoSet "MBAL.MB.TANK[1,2].PRODHIST[4:6]", "11.2|14.5|16.3| 5.2|6.1|7.5" The above command sets indices 4, 5 and 6 of the production history for both tanks 1 and 2. The data in the values to set is ordered such that the index to the right varies first. In other words the order is: MBAL.MB.TANK[1].PRODHIST[4].CUMOIL MBAL.MB.TANK[1].PRODHIST[5].CUMOIL MBAL.MB.TANK[1].PRODHIST[6].CUMOIL MBAL.MB.TANK[2].PRODHIST[4].CUMOIL MBAL.MB.TANK[2].PRODHIST[5].CUMOIL MBAL.MB.TANK[2].PRODHIST[6].CUMOIL As before, this method will work equally well for the DoGet function. The example shown above has two arrays. However, it is possible to use multiple indices for any number of arrays in a tag string e.g. : MBAL.MB.WELL[1:3].IPR[4,7].CONEMATCH[$][3,5:8].PRESS
3.6
Units Units are handled the same way in all the IPM programs. Use of Units in OpenServer: By default, when a variable is accessed from the OpenServer using the DoGet function, the value returned is in the same units as defined for the current model. For example, if a GAP model has degrees Celcius selected for the surface temperature variable of pipes, and the value entered for pipe ‘pipe3’ is 10 degrees C, then performing a DoGet on the tag “GAP.MOD[0].PIPE[{pipe3}].TMPSUR” will return 10.
the tag with UNITMAX. Minimum and maximum values of a variable with the same tag can be changed by using the DoSet function as per the following example: DoSet “MBAL.MB.TANK[0].PRESS.UNITMAX”, “15000.0”
3.7
Start/Shutdown Commands To use the OpenServer to communicate with a particular IPM program, the IPM program must be running. The program can be started manually e.g. using the Start menu. Alternatively there are two special commands that can be used to start an IPM program and to shut down an IPM program. To start an IPM program, use the command:DoCmd “GAP.START()” This will start the GAP program that was last installed on the working PC. Other IPM programs can be started using the same syntax by replacing “GAP” with the appropriate program name i.e., MBAL, PVTp, PROSPER, REVEAL, and RESOLVE. To start an IPM program installed in a particular directory, use the command:DoCmd “GAP.START(“C:\PETEXPROGS”)” This will start the GAP program that has been installed in the directory C: \PETEXPROGS. Another method to start a particular program is to use the command SHELL. SHELL is a Visual Basic command to run a particular executable. For example, to start GAP, the command line will be SHELL (“C:\Program Files\Petroleum Experts\IPM 7\GAP.exe”) It is also possible to start a given IPM program with the users own timeout period. This is particularly useful if the IPM executable and licenses are located on a network where it takes a long period of time to access them. In such cases, the classic timeout period might be too short. To start an IPM program with this timeout option, use the command:
OpenServer User's Manual
Using OpenServer
30
DoCmd "GAP.STARTASYNC()" It will be possible to check whether the program is ready to use by using the following command: DoGet "GAP.ISREADY" This will return 0 : if the program is not ready 1 : if the program is ready 2 : if the program has not yet started or has been unable to find a license. The ISREADY command can also be used with the other applications of IPM. To shut down an IPM program, use the command: DoCmd “GAP.SHUTDOWN” This will shutdown the GAP program. It will close the program without asking if the current data is to be saved, thus it is necessary to make sure the appropriate command has been used to save the data file prior to using the SHUTDOWN command. Other IPM programs can be shut down using the same syntax by replacing “GAP” with the appropriate program name (MBAL, PVTP, PROSPER, REVEAL, RESOLVE).
OpenServer provides GAP with a completely open architecture that enables access to modify and control any data item within a given GAP model from any client application capable of supporting Automation. OpenServer functionality with GAP provides complete freedom with regard to importing, exporting or reporting data to and from virtually any data source. OpenServer also provides the added ability to execute field development decisions during a GAP prediction from dynamically monitoring results at any level of a given production system. For example, well drilling schedules can be developed from using OpenServer to monitor an overall plant capacity, then perform drilling and completion tasks to open new wells to maintain a given plant capacity. GAP has also made a set of OpenServer commands available, which in addition to providing a ‘batch’ mode of working, can also be used to interfaceGAP to other applications such as process simulators, external optimizers or reservoir simulators. GAP has also been given a new prediction mode, the step-by-step mode, which allows users, via OpenServer, to customize GAP prediction runs. This section lists the variables available to the OpenServer from GAP. Most variables in GAP are accessed using a tag string consisting of several levels (sections), each level identifying a record (structure). All variables from GAP begin with the string “GAP”. This is to allow OpenServer to differentiate between the different Petroleum Experts products, and the remaining part of the string identifies the OpenServer variable. EXAMPLE: if we wish to access the surface temperature of the pipe with label ‘pipe3’ in the currently loaded GAP model, we would use the string GAP.MOD[0].PIPE[{pipe3}]. TMPSUR. The first section of the string is “GAP”, which identifies the Petroleum Experts product taken into account. This level is further defined as Top Level. The next section is “MOD[0]”, which identifies the currently loaded GAP model. This level is further defined as MOD Level. The next section is “PIPE[{pipe3}]”, which identifies the pipe element with label “pipe3”. This level is further defined as Node Level. -
The final section is “TMPSUR”, the name of the field in the pipe record that contains the surface temperature.
only part of them will be used in specific string. It is important to notice that all the elements of an OpenServer string expressed inbetween brackets and curly brackets are case sensitive. All the other elements of the OpenServer strings are not case sensitive.
4.1.1 Ctrl + Right mouse click Most GAP dialogues and fields support the “Ctrl+Right click” feature, or by simply right clicking in the given variable field. This feature enables to automatically obtain the OpenServer string related to a certain variable. To get the OpenServer tag of a variable, hold the Control key down and right click on the variable field (or simply right click in the variable field). GAP display an information box containing the OpenServer tag of the variable related to the field with, in some cases, a list of possible keywords (see literal constants below) and the current value of this variable. For example, if we consider the previous example, and want to access the surface temperature of the pipe with the ‘pipe3’ label, the following screen will be displayed, specifying the access string previously described.
OpenServer User's Manual
GAP and the OpenServer
34
The OpenServer variable accessed through this screen can be directly copied on the clipboard by clicking on the “Copy” button in the screen. The OpenServer variable can then be directly pasted into the macro code for instance.
4.1.2 Execute OpenServer Statement This option is available from the main GAP menu bar, using the following path: Edit / Execute OpenServer Statement. The following screen is then displayed and allows monitoring of specific data from OpenServer commands.
A particular string can be entered by hand or copied from the clipboard. Then, the “Eval ” button will do the requested operation of: - DoGet (i.e. obtain the current value of the variable considered) - DoSet (i.e. set the value of the variable considered) - DoCommand (i.e. execute a GAP calculation for instance). Global Element Changes using OpenServer This can be used for instance to change the value of a specific variable for all the wells of a system simultaneously. To act on all elements of a specific type (i.e. all the wells, all the pipelines, etc…), it is possible to replace the label of the element by a $ sign. For instance, the string GAP.MOD[{PROD}].WELL[$].IPR[0].PI will link to the productivity indexes of all the wells of the system, and can be used to change the productivity indexes of all the wells of the system in one operation.
Selected Items Only Using the select feature in GAP (blue arrow from the main tool bar) enables specific elements to be manually selected and doing so will place a blue circle around the selected element. Selecting several wells, then executing the following OpenServer statement (GAP.MOD [{PROD}].WELL[$].IPR[0].PI), only the selected well PI's will be changed.
4.1.3 Specific Units Handling Commands The Unit System in GAP can either be changed directly through Units section or through Preferences (File| Preferences). To specify input and output Units for the opened GAP model the following commands can be used: DoSet ("GAP.InputUnitSystem", "OilField") DoSet ("GAP.InputUnitSystem", 0) DoSet ("GAP.OutputUnitSystem", "OilField") DoSet ("GAP.OutputUnitSystem", 0) The argument can either be specified as a string or as a number; the following options are available: 0 - "OilField" 1 - "NorwegianSI" 2 - "CanadianSI" 3 - "GermanSI" 4 - "FrenchSI" 5 - "LatinSI"
Preferences option allows the user to specify the DEFAULT input and output Unit System that will be used as a reference. If in this case GAP file is opened or reloaded it will be automatically converted into the specified DEFAULT Unit System. The following OpenServer commands are available: DoSet ("GAP.Preferences.DefaultInputUnitSystem", "OilField") DoSet ("GAP.Preferences.DefaultOutputUnitSystem", "OilField”)
OpenServer User's Manual
GAP and the OpenServer
36
EXAMPLE The following example of code will define default Units System and reloads the GAP file, to ensure that the file is successfully converted into the units specified: ‘set default Unit System DoSet ("GAP.Preferences.DefaultInputUnitSystem", "CanadianSI") DoSet ("GAP.Preferences.DefaultOutputUnitSystem", "CanadianSI”) DoSet ("GAP.Preferences.AlwaysUseDefaultUnitSystems", 1) ‘reload GAP file DoGAPFunc ("GAP.OPENFILE(""file_path"")")
4.1.4 Literal Constants In previous releases (i.e. previous to GAP version 5.0), variables such as the WELLTYPE were defined using numerical indexes (0 - Oil naturally flowing, 1 – Gaslifted, 2 – ESP lifted, etc…). The use of numerical indexes has two main drawbacks: They make the OpenServer script code more difficult to read. One has to remember what well types 0, 1, 2, 3, ...n correspond to. The GAP internal values for these variables may have to change in the future, making existing scripts incompatible. Since version 5.0, GAP uses keywords rather than numerical indexes to represent such variables. For instance, the well type is now defined as OilProducerNoLift for a naturally flowing oil well, OilProducerGL for a gas lifted oil well, OilProducerESP for an ESP lifted oil well, etc. If we use the “Right Click” option in order to obtain the OpenServer access string defining the well type from the GAP well Summary screen, the screen obtained displays the access string as well as the literal constants available for each variable.
This means that DoGet(“GAP.MOD[{PROD}].WELL[{welllabel}].WELLTYPE”) will return “OilProducerNoLift” instead of 0. This may make some existing scripts created before the GAP version 5.0 incompatible with this release of GAP. The DoSet command supports both literal and numerical constants. recommend to use literal constants instead of numerical constants.
We highly
To eliminate the short term incompatibility issue of existing scripts when considering a DoGet command, a new OpenServer variable called OpenServerUseKeywords has been added. It allows the script to switch on or off the use of literal constants (see OpenServerUseKeywords below). The default value for this variable is 1 which means that GAP will use literal constants whenever possible. It is highly recommended that new OpenServer scripts use literal constants, and that existing scripts are upgraded as soon as possible. This will hugely reduce the amount of maintenance required on these scripts in the future. In the following descriptions, the variables using literal constants will be marked by an asterisk *.
4.1.5 Date Handling within GAP By default, the dates in GAP are refered to using a numerical constant format, with the reference being 01/01/1900, which corresponds to day1 and a value of 1 for the date numerical constant. As soon as a DATE OpenServer keyword is used, it will refer to that type of numerical OpenServer User's Manual
GAP and the OpenServer
38
format. If the suffix DATESTR is added after the suffix DATE, i.e. DATE.DATESTR, then the date will be converted automatically from a numerical format to a day/month/year format, or month/day/year, depending on the regional settings of the machine. If the suffix DATETIMESTR is added after the suffix date, then the date will be converted automatically from a numerical format to a day/month/year hrs/min/sec format. If the suffix TIMESTR is added after the suffix date, then the date will be converted automatically from a numerical format to a hrs/min/sec format. NOTE: In some cases when the date is retrieved from GAP into the Excel spreadsheet using DATE keyword, and then internal Excel conversion is used to translate it from numerical into dd/mm/yyyy format day and month numbers can be flipped with erroneous date in result. To avoid this CDate() VBA command can be used for date conversion.
The OpenServer string will then become: GAP.MOD[{PROD}].EQUIP[{@Letter?}]. Label @Digit#: will match any equipment name with a maximum of two characters starting by the digit specified The OpenServer string will then become: GAP.MOD[{PROD}].EQUIP[{@Digit#}].Label @AlphaCharacter!: will match any equipment name with a maximum of two characters starting by the alpha character specified The OpenServer string will then become: GAP.MOD[{PROD}].EQUIP [{@AlphaCharacter!}].Label Examples: If the GAP model considered has 5 wells with the following labels: W1, W2, W3, Well4 and Well5 and the following OpenServer string is used: DoGet("GAP.MOD[{PROD}].EQUIP[{@W?}].Label") then the following elements will be returned: W1|W2|W3 For instance, if the GAP model considered has 5 wells with the following labels: W1, W2, W3, Well4 and Well5 and the following OpenServer string is used: DoGet("GAP.MOD[{PROD}].EQUIP[{@W*}].Label") then the following elements will be returned: W1|W2|W3|Well4|Well5
4.1.7 Variables at Top Level Variable Name Description EnableNetworkVali Works with a DoSet structure, as illustrated below: dation DoSet "GAP.EnableNetworkValidation", 0 This variable can be set to either 0 or 1. In the case it is setup to 0, the validation process of GAP will be deactivated. In the case it is setup to 1, the validation process of GAP is activated. This is the default setup. The purpose of this variable is to enable speeding up OpenServer routines by avoiding the validation process of the GAP network. This is to be used with caution as for instance if the validation process is deactivated and one of the nodes is masked, the elements upstream of the masked node will not be considered in the calculation but will not be masked either. This can lead to erroneous answers when using OpenServer routines that check the status of some of the nodes in the network.
OpenServer User's Manual
GAP and the OpenServer
40
FNA
Contains the floating point value used by GAP to indicate the variable value is undefined. Example: when a DoGet function returns FNA, the variable targeted by the DoGet function is not defined. FNAT A test value which should be used to test whether a variable is defined or not. Example: a variable is defined if the variable value < FNAT LASTCMDRET Contains the returned value of last command. LASTERROR Contains the error code of the last error. MOD[i] Defines the GAP model to be considered. If the GAP model loaded is a single file, use MOD[0]. If the GAP model loaded has associated injection systems, one can use MOD[{PROD}] or MOD[0] for the production system, MOD [{WINJ}] or MOD[1] for the water injection system, and MOD[{GINJ}] or MOD[2] for the gas injection system. PREDCURDATE OBSOLETE: Contains current prediction step date when running a prediction. This variable contains the date at the start of the timestep, before any calculations have been done. This variable is kept for backward compatibility only and should therefore not be used in any new scripts. PREDCURSTEPD Contains the step date at the end of the current prediction step, ATE after the calculation has been done. It therefore corresponds to the date of the beginning of the next time-step. eg. A = DOGET (“GAP.PREDCURSTEPDATE”) PREDPREVSTEP Contains the step date at the beginning of the current prediction DATE step, before any calculation is done. It is the equivalent of the PREDCURDATE variable used in previous versions. PREDCURSTEPN Contains the current prediction time-step number. O PREDSTEPLENG Contains current prediction step duration when running a TH prediction. eg. b = DOGET (“GAP.PREDSTEPLENGTH”) OpenServerUseKe Switches on and off the use of literal constants (see Literal ywords Constants paragraph above). The values characterizing this variable are defined as follows: 0 – use numerical indexes 1 – use literal constant (default value) Example: the DoSet("GAP.OpenServerUseKeywords"), 0 command will switch off the use of literal constants and keep only the use of numerical indexes.
Alternatively, this OpenServer variable can be set when the program starts by creating and setting the KEY_CURRENT_USER\Software\Petroleum Experts\GAP\ OpenServer\UseKeywords dword value to 0 or 1. OpenServerCaseS Makes GAP OpenServer statement case sensitive for ensitive OpenServer tag labels i.e. for labels between { …}. The values returned for this variable are defined as follow: 0 – not case sensitive (default value) 1 – case sensitive Alternatively, this OpenServer variable can be set when the program starts by creating and setting the KEY_CURRENT_USER\Software\Petroleum Experts\GAP\ OpenServer\CaseSensitive dword value to 0 or 1.
4.1.8 Variables at MOD Level All of the data contained in the currently loaded GAP model (or models, if associated injection systems are present) is accessed through the MOD variable. This variable requires an index i.e., MOD[0], MOD[1], MOD[2] or MOD[3] to select the particular model. The use of literal constants is highly recommended (see Literal_Constants). This means that the model method can be changed to a gas injection system using the following string, rather than having to use a numeric index: DoSet ("GAP.MOD[{PROD}].SysType"), "GasInjection" Since GAP can have four models, i.e., a production model and three associated injection models, the fields of the variables at MOD level will be divided in three categories: - Model Options - Solver and Prediction Setup - System Constraints Setup - Model Equipment List
4.1.8.1 Model Options Variable Name ActualLayout. UseIPRdP
OpenServer User's Manual
Description Contains the IPR dP shift status in the Actual/Production Validation section. The values characterising this variable are defined as follows: 0 - No IPR dP shift is taken into account 1- The IPR dP shift facility is activated.
GAP and the OpenServer
ASSOCFLAG
BGCORR
BOCORR
COMPMODE *
CORRNAME[i] *
Currency CurrShort DefaultGasLiftFlui dID DefaultTaxRegim eID DefaultWatInjFluid ID EmulsionCorrecti onList[i].Label EmulsionCorrecti
42
Describes the type of GAP model considered. The values characterising this variable are defined as follows: 0 - No associated models 1 - Associated water injection model 2 - Associated gas injection model 3 - Associated water and gas injection models Example: the GAP.MOD[0].ASSOCFLAG string will link to the index characterising the type of field model considered. Contains the gas process correction factor. Can be used to reconcile surface rates as calculated by GAP Black Oil process versus surface rates as calculated by some other process. Contains the oil process correction factor. Can be used to reconcile surface rates as calculated by GAPs Black Oil process versus surface rates as calculated by some other process. Contains the system settings regarding fluid composition. This variable can be characterised as follows: NONE – The system does not take into account any fluid composition, at the exception of H2S, CO2 and N2 impurities. TRACKING – The system is set to track the fluid composition at each system node. FULL – The system is a fully compositional system. BOLumpDelump - The system is set to track the fluid composition at each system node and can be set to use a lumped composition or full composition. Black oil correlations are used for all pressure loss calculations. Array [40] of correlation names. Enables to determine the flow correlation associated with each correlation index. Example: the DoGet(“GAP.MOD[{PROD}].CORRNAME[1]”) command will return the Beggs and Brill flow correlation name. It is highly recommended to use literal constants to set and retrieve multiphase flow correlation data. Refers to the currency used for revenue calculations. Refers to the label os the currency used for revenue calculations. Contains the FluidList index of the default fluid used for gas lifting purposes. Contains the Tax Regime list index of the default tax regime setup used for optimisation calculations. Contains the FluidList index of the default fluid used for water injection purposes. Contains the label of the emulsion correction model considered. The index refers to the row index of the emulsion model considered in the emulsion correction list. Contains the value of the first match parameter used in the emulsion
viscosity model. Contains the value of the second match parameter used in the emulsion viscosity model. Contains the value of the third match parameter used in the emulsion viscosity model. Contains the value of the fourth match parameter used in the emulsion viscosity model. Contains the value of the fifth match parameter used in the emulsion viscosity model.
Contains the value of the maximum left water cut used to match the emulsion viscosity model. Contains the value of the maximum rigth water cut used to match the emulsion viscosity model. Contains the multiplier used to convert from the default currency (i.e. US Dollars) to the currency chosen for revenue calculations. FILENAME Contains the file name of the model and its corresponding path. FlashOptions.EoS Contains the type of equation of state model used to characterise * the fluids in the model. Two equation of state models are available using the following literal constants: PR – Peng Robinson SRK – Soave Redlich Kwong FlashOptions. Contains the type of optimisation mode used to characterize the OPTMODE * fluid. Three optimisation mode are available using the following literal constants: LOW – Low optimisation mode MEDIUM – Medium optimisation mode OFF – No optimisation mode FlashOptions. Refers to the type of separator calculation used in the model. SEPCALCMODE Three type of separator calculations are available, using the * following literal constants: NOSEPTRAIN – The model will not be using a specific separator train SEPTRAIN – The model will be using a specific separator train KVALUES – The model will be using K values FlashOptions. Refers to the set of separator pressures used when the model SEPPRES[i] selected uses a specific separator train. Up to ten values of separator pressures can be entered, using the
OpenServer User's Manual
GAP and the OpenServer
44
index following the main string name. FlashOptions. Refers to the set of separator temperatures used when the model SEPTEMP[i] selected uses a specific separator train. Up to ten values of separator temperatures can be entered, using the index following the main string name. FlashOptions. Refers to the use of volume shift for fluid characterization purposes. VOLUMESHIFTM Two status are available using the following numerical constants: ODE 0 – The fluid has not been characterized using volume shift 1 – The fluid has been characterized using volume shift FluidList[i].CGR Refers to the CGR of the ith fluid of the fluid list. FluidList[i]. GasGravity FluidList[i].GOR
Refers to the gas gravity of the ith fluid of the fluid list.
Refers to the GOR of the ith fluid of the fluid list. FluidList[i].Label Contains the label of the injection fluid considered. The index refers to the row index of the fluid considered in the fluid list. FluidList[i]. Refers to the oil gravity of the ith fluid of the fluid list. OilGravity FluidList[i]. Refers to the CO2 content of the ith fluid of the fluid list. PctCO2 FluidList[i]. Refers to the H2S content of the ith fluid of the fluid list. PctH2S FluidList[i].PctN2 Refers to the N2 content of the ith fluid of the fluid list. FluidList[i].Type * Contains the type of fluid considered. Four type of fluids are available using the following literal constants: OIL GAS WATER OTHER FluidList[i].Watsal Refers to the water salinity of the ith fluid of the fluid list. FluidList[i].WCT FluidList[i].WGR
Refers to the water cut of the ith fluid of the fluid list. Refers to the WGR of the ith fluid of the fluid list.
GasRevenueMod Refers to the type of gas revenue considered for production e* optimisation purposes. Two types of gas revenue can be taken into account using the following literal constants: VOLUME GROSSHEATINGVALUE GINJNAME Contains the file name of the associated gas injection system. ISDIRTY Enables to determine if the model has been modified since its last saved version. The values characterising this variable are defined as follows:
0 - The model has not been modified since its last version. 1 - The model has been modified since its last version. OptMethod Contains the type of optimisation method used in the model. The numerical indexes characterising this variable are defined as follows: 0 - Production 1 - Revenue 2 - Oil Rate Only 3 - Gas Rate Only 4 - Water Rate Only Predict Contains the prediction method used in the model. The values characterising this variable are defined as follows: (previously 0 - Only the pressure drops are calculated in the system ISPANDT) pipelines 1 - Both pressure drops and temperature are calculated in the system pipelines PredMode * Contains the status of the model in terms of prediction: OFF - The prediction mode of GAP is not activated. ON - The prediction mode of GAP is activated. SYSLOG Contains the text comments linked to the system. These comments will be displayed in GAP in the Options / System Summary screen. SYSTITLE Contains the system title. This title will be displayed in GAP in the Options / System Summary screen. SYSTYPE * Contains the type of system considered. Three type of systems are listed using the following literal constants: - Production - WaterInjection - GasInjection - GasLIftInjection Example: DoSet ("GAP.MOD[{PROD}].SysType"), "gasliftinjection" The above DoSet function would set the method to be able to construct a gas lift injection network, etc. TaxRegimeList[i]. Refers to the cost of diluent in the ith tax regime of the tax regime CostDiluent list. TaxRegimeList[i]. Refers to the cost of injected gas in the ith tax regime of the tax CostInjGas regime list. TaxRegimeList[i]. Refers to the cost of power in the ith tax regime of the tax regime list. CostPower TaxRegimeList[i]. Refers to the cost of power fluid in the ith tax regime of the tax CostPowerFluid regime list. TaxRegimeList[i]. Refers to the cost of water processing in the ith tax regime of the tax CostWater regime list.
OpenServer User's Manual
GAP and the OpenServer
46
TaxRegimeList[i]. Contains the name of the tax regime considered. Name The index refers to the row index of the tax regime considered in the tax regime list. TaxRegimeList[i]. Refers to the gas price in the ith tax regime of the tax regime list. RevenueGas TaxRegimeList[i]. Refers to the oil price in the ith tax regime of the tax regime list. RevenueOil WINJNAME Contains the filename of the associated water injection system.
4.1.8.1.1 Solver Setup and Calculation Log Variable Name GASAV [i]
OptPotCnst - The solver run will be optimised and will respect only the potential constraints Returns the status of the last solver run. This values characterising this variable are as follows: 0 - the last solver run did not experience any error #0 - the last solver run did experience an error. Returns a text string describing the last solver run error.
SolverStatusList[i].LastError
All these OpenServer variables refer to solver status and results. The index i refers to the index of the sensitivity case considered. The values of this index range from 0 to 9, depending on the number of sensitivity cases considered. These OpenServer variables are not available using the Ctrl + Rigth Click option. Returns the number of sensitivity cases used during the solver run. Returns the CPU time used by the solver to run the case considered. Expressed in seconds. Returns the total time used by the solver to run the case considered. Expressed in milliseconds. Returns the last error associated with the ith
SolverStatusList[i]. MaxMassBalanceDiff
sensitivity case of the solver. Returns the maximum mass balance difference associated with the ith sensitivity case of the
pressure balance difference associated with the ith sensitivity case of the solver. Returns the number of iterations associated with the ith sensitivity case of the solver.
SolverStatusList[i].OptNumIteration Returns the number of optimisation iterations associated with the ith sensitivity case of the solver optimiser. SolverStatusList[i].OptBestGuess Returns the optimiser best guess associated with the ith sensitivity case of the solver. OpenServer User's Manual
Returns the status of the last solver run for the ith solver sensitivity. The values characterising this variable are as follows: 0 - the last solver run did not experience any error #0 - the last solver run did experience an error. Returns a text string describing the last solver run error for the ith solver sensitivity case. Returns the amount of constraints violated during the ith Solver run. Returns the type of equipment to which the jth violated constraint message of the ith Solver run
refers to. SolverStatusList[i]. Returns the ID of the system equipment to which ViolatedConstraint[j].EquipUniqueID the jth violated constraint message of the ith Solver run refers to. SolverStatusList[i]. Returns the label of the system equipment to ViolatedConstraint[j].EquipLabel which the jth violated constraint message of the ith Solver run refers to. SolverStatusList[i]. ViolatedConstraint[j].Binding
Returns the binding status of the jth violated constraint message of the ith Solver run. Returns 0 if the constraint is not binding and 1 if the constraint is binding. Returns the calculated value of the jth violated constraint message of the ith Solver run.
Contains the ith date of the DCQ schedule in a numerical constant format. This date is expressed in days and time and the reference used is the 01/01/1900 00:00:00 (i.e. correspond to day 1). Contains the ith date of the DCQ schedule in a day/month/ year format. Contains the ith date of the DCQ schedule in a day/month/ year hrs/min/sec format. Contains the ith time of the DCQ schedule in a hrs/min/sec format. Contains the value of the DCQ schedule at the ith date. Enables to select whether swing factors have to be used in the DCQ driven production prediction or not. The values associated to this variable are the following: 0 – Swing factors are not used 1 – Swing factors are used Enables to select whether to calculate or not the model potential during the prediction. The values associated to this variable are the following: 0 - The model potential is not calculated 1 - The model potential is calculated Contains the length of the prediction period in days. Example: the DoSet(“GAP.MOD[0].PREDINFO.PERIOD), 1000 command will set a prediction period of 1000 days starting from the prediction start date specified. Contains the prediction starting date in a numerical constant format. This date is expressed in days and time and the reference used is the 01/01/1900 00:00:00 (i.e. correspond to day 1). Example:the DoSet(“GAP.MOD[{PROD}].PREDINFO. START.DATESTR”),36525 command sets the prediction starting date to the 01/01/2000 00:00:00. Contains the prediction starting date in a day/month/year format. Contains the prediction starting date in a day/month/year hrs/min/sec format. Contains the prediction starting date in a day/month/year hrs/min/sec format. Contains the prediction ending date in a numerical date format. This date is expressed in days and the reference used is
PredTimeStep[i] variables The following OpenServer variables refer to solver and optimiser status and results during a prediction run. The index i refers to the prediction step index or date (in between curly brackets) considered. The first timestep is always referred as using the index 0. NOTE: These variables are accessible after prediction run has accomplished, therefore the name or number of prediction runs should also be specified in the tag string. Example: To obtain variable for ith time step of Last Prediction Run following command can be used: DoGet("GAP.MOD[{PROD}].PREDRES[{Last Prediction Run}].PredTimeStep[i].variable") PredTimeStep[i]. Returns the status of the last solver run associated with the SolverStatus.Status i+1th prediction time-step.
The values characterising this variable are as follows: 0 - the last solver run did not experience any error #0 - the last solver run did experience an error. Returns a text string describing the last solver run error associated with the i+1th prediction time-step. Returns the last error associated with the i+1th prediction time-step. Returns the maximum flow balance difference associated with the i+1th prediction time-step. Returns the maximum pressure balance associated with the i+1th prediction timestep.
difference
Returns the number of iterations associated with the i+1th prediction time-step.. Returns the number of optimisation iterations associated with the i+1th prediction time-step.. Returns the optimiser best guess associated with the i+1th prediction time-step.
For more information on macro code structure to perform a prediction, please see Basic_Code_Structure.
OpenServer User's Manual
GAP and the OpenServer
52
4.1.8.2 Model Equipment List As described previously, OpenServer strings at the MOD level enable to define the overall model and calculation procedures setup. In order to access the parameters related to one specific element of the model i.e., a well, reservoir, etc., it will be necessary to specify the element using an element tag at the MOD level. The MOD variable contains the ‘node lists’, i.e. the lists of wells, tanks etc., that are defined in the GAP model. Each list contains nodes of the same type, such as TANK, WELL, PIPE and so on. The EQUIP list contains all the elements defined in the GAP model regardless of their type The name of the list taken into account as well as either the numerical index (i.e. TANK [3]) or the element label of the element considered (i.e. TANK[{T1}]) needs to be added to the MOD section of the string to be able to access the element. This will enable to pass from the MOD level to the NODE level of the OpenServer string. The element lists used in GAP are defined as follows: Variable Name EQUIP[i]
deleted from the model. Example: EquipAddDel["EQUIP"] is incremented each time any node is added or deleted from the model. Some scripts are ‘caching’ the number of nodes of a given type and their respective labels in memory to speed up the execution of the script. By checking of the values of this array, a script will be able to detect if nodes have been added to or deleted from the model since the information was last cached.
4.1.9 Variables at Node Level The node lists used at the MOD level enables to specify a certain element of the model. At the Node level, the following keywords are used to access the different node variables. The Scheduling and Constrainst OpenServer access strings will be described as separate sections (Scheduling andConstraints_and_Potential_Calculations).
4.1.9.1 General fields found in nodes of any type Variable Name COMMENT COUNT
Description Refers to the comment field of the node.
Contains the number of nodes of the same type present in the GAP model. ISBYPASSED Contains the status of the node relative to node bypass as set by the user. Read-Only variable. If the value returned is: - 0: the node is not bypassed - 1: the node is bypassed ISDISABLED Contains the status of the node relative to node disabling as set by the user. Read-Only variable. If the value returned is: - 0: the node is not disabled - 1: the node is disabled ISMASKED Contains the status of the node relative to node masking as set by the user (i.e. if a node is not masked by the user but greyed-out by the software: ISMASKED will return 0 and MASKFLAG will be # 0). If the value returned is: - 0: the node is not masked OpenServer User's Manual
Example: The GAP.MOD[0].EQUIP[1].TYPE string will enable to specify the type of the second node of the overall equipment list. If it is a well, it will return WELL for instance. Contains a number referring to the type of node considered when considering the overall EQUIP list. Contains an READ-ONLY identifier which will be unique for each node and will never change, whatever modifications are done to the system. The value of this unique ID can be used similarly to the node index number to define the node in any OpenServer string. This tag is applied to inline elements, pumps and compressors (all elements that are placed in between two joints). This allows to determine the name of the joint upstream the element itself. Example: GAP.Mod[0].Pump[0].EndA will give the name of the joint upstream the pump This tag is applied to inline elements, pumps and compressors (all elements that are placed in between two joints). This allows to determine the name of the joint downstream the element itself
4.1.9.2 Fields specific to tanks All the following variables will need to be preceded by the following OpenServer string structure: GAP.MOD[i].TANK[j] Where the index i refers to the type of model considered (i.e. refers to the Variables at MOD level, MOD[i] section) and the index j refers to the name or numerical index of the element considered (i.e. refers to the Model Equipement List, see Model_Equipment_List). Variable Name FILE
Description Contains the name and path of the MBAL data file associated to the tank. MAINSUBTANK.File When considering a multiple tank model, this will return the path of the MBAL file corresponding to this tank model. MBINUMTANKSINFIL This will return the number of tanks included in the model E considered. It will return 1 for a single tank model and a value higher than 1 for a multiple tank model. Model Contains the type of tank model used to model the reservoir. The values returned can be: - 0: Material Balance model - 1: Decline Curves NUMPROD Number of production data points entered (decline curve tanks). PRODDATA[i][j] Refers to the production data array [20][2] (decline curve tanks). OpenServer User's Manual
GAP and the OpenServer
56
The following numerical indexes are used: - i: Refers to the input row considered - j: Refers to the input parameter considered (0 for reservoir pressure, 1 for cumulative production) TANKID Contains the name of the MBAL tank. TANKTYPE * Refers to the type of tank considered. The keyword values used are: OIL, GAS, CONDENSATE TCURGASPROD Contains the current cumulative gas production (decline curve tank). TCUROILPROD Contains the current cumulative oil production (decline curve tank). TCURRESPRED Returns the Current Pressure for the tank based on the current Oil/Gas Production. (Decline Curve Tanks) TINJGASFIX Refers to the fixed gas injection rate associated to the reservoir. TINJGWR Contains the injected Gas to Water ratio used to maintain a reservoir target pressure. TINJWATFIX Refers to the fixed water injection rate associated to the reservoir. TMAXGAS Contains the maximum gas injection constraint (apply to tank in injection system). TMAXLIQ Contains the maximum liquid injection constraint (apply to tank in injection system). TRECYCGAS Contains the required fraction of gas recycling. TRECYCGASPMFIX Contains the amount of sales gas to subtract from production before recycling. TRECYCWAT Contains the required fraction of water recycling. TTARGPRES Contains the target pressure associated with the tank. TVOIDREPGAS Contains the fraction of gas voidage replacement required. TVOIDREPWAT Contains the fraction of water voidage replacement required. SubTankNumber Refers to the Index of the tank in the MBAL data file (apply to multiple tank models). PRODHISTORYSTAR Start of production history for the tank T.DATESTR PRODHISTORYEND. End of production history for the tank DATESTR Example: To access the MBAL tank ID of a node with label t1, one could use the command DoGet(“GAP.MOD[0].TANK[{t1}].TANKID”) or equivalently DoGet(“GAP. MOD[0].EQUIP[{t1}].MBALNUM”). Remark: These OpenServer variables are also available for both groups preceded by the following OpenServer string structure: GAP.MOD[i].GROUP[j] and group members preceded by the following OpenServer string structure: GAP.MOD[i].GROUP[j]. MEMBER[k].
4.1.9.3 Fields Specific to Wells The following codes may be used to get the information about the Relative Permeability Curves for Fractional Flow information when the option is set to USE REL PERM 1 or USE REL PERM 2. i : 1 to 2
the value of i in the below mentioned strings varies from 1 to 2. i = 1 denotes the data for REL PERM 1 and i=2 denotes the data for REL PERM 2. FRACFLOWi.RESSAT.Krw Residual Saturation for water FRACFLOWi.ENDPOINT. End Point Relative Permeability for Water Krw FRACFLOWi.EXPON.Krw Corey Exponent for Water FRACFLOWi.RESSAT.Kro Residual Saturation for Oil FRACFLOWi.ENDPOINT. End Point Relative Permeability for Oil Kro FRACFLOWi.EXPON.Kro Corey Exponent for Oil FRACFLOWi.RESSAT.Krg Residual Saturation for Gas FRACFLOWi.ENDPOINT. End Point Relative Permeability for Gas Krg FRACFLOWi.EXPON.Krg Corey Exponent for Gas for example the following code may be used to extract the Residual Saturation of Water for USE REL PERM 1 option that is defined for IPR Layer 0 for Well W1 to cell (10,2) Cells(10, 2) = DoGet("GAP.MOD[{PROD}].WELL[{W1}].IPR[0].FRACFLOW1. RESSAT.Krw") The following codes may be used to get the information about the Relative Permeability Curves for Fractional Flow information when the option is set to FROM TABLE 1 or FROM TABLE 2. i : 1 to 2
the value of i in the below mentioned strings varies from 1 to 2. i = 1 denotes the data for TABLE 1 and i=2 denotes the data for TABLE 2. j : 0 to 99 the value of j in the below mentioned strings varies from 0 to 99 to represent the data point number FRACFLOWi.FFTABLE[j]. Time TIME FRACFLOWi.FFTABLE[j]. Water Cut WATCUT FRACFLOWi.FFTABLE[j]. GOR GOR
OpenServer User's Manual
GAP and the OpenServer
58
FRACFLOWi.FFTABLE[j]. Pressure PRESS FRACFLOWi.FFTABLE[j]. Cumulative Production CUMOIL for example the following code may be used to extract the Water Cut for data point number 1 set in TABLE 1 option that is defined for IPR Layer 0 for Well W1 to cell (10,3) Cells(10, 3) = Doget("GAP.MOD[{PROD}].WELL[{Well1}].IPR[0].FRACFLOW1. FFTABLE[0].WATCUT") 4.1.9.3.1 Fields specific to all well models All the following variables will need to be preceded by the following OpenServer string structure: GAP.MOD[i].WELL[j] Where the index i refers to the type of model considered at the MOD level i.e., MOD[i] section and the index j refers to the name or numerical index of the element considered i.e., EQUIP[i] section. Variable Name File PowerFluidMode *
TypeWell *
Description Well Summary Section Contains the name and path of the PROSPER file associated with the well considered. Contains the type of power fluid system used (i.e. Oil Producer well with diluent injection). The following keywords are used: - ClosedLoop - Commingled Contains the type of well considered. The following keywords are used: - CondensateProducer - GasInjector - GasProducer - OilProducerDILUENT - OilProducerESP - OilProducerGL - OilProducerHSP - OilProducerJETPUMP - OilProducerNoLift - OilProducerPCP - WaterInjector - WaterProducer
Contains the type of well model used. The following numerical indexes are used: - 0: VLP/IPR Intersection - 1: Performance Curve - 2: PC interpolation - 3: Outflow Only VLP - 4: Outflow Only PROSPER Sets the rate type of well model used. The following numerical indexes are used: - 0: Use Volumes - 1: Use Mass Downtime Section Contains the downtime value associated with the well considered. dP Control Section Contains the status of the artificial lift control parameter. The following keywords are used: - CALCULATED: The artificial lift system is controlled by the optimiser. - FIXEDVALUE: The artificial lift system is not controlled by the optimiser. Contains the value of the artificial lift parameter used or calculated from allocation result. Depending of the type of artificial lift consider, this parameter will refer to: - Power Fluid Rate (Diluent Injection Well, HSP Lifted Well, Jet Pump Lifted Well) - ESP Frequency (ESP Lifted Well) - Pump Speed (PCP Lifted Well) Contains the maximum value the artifial lift parameter can take when controlled by the optimiser. The type of artificial lift parameters considered are listed in the AlqValue row. ! Does not include gas lifted systems (see MAXQINJ). Contains the minimum value the artifial lift parameter can take when controlled by the optimiser. The type of artificial lift parameters considered are listed in the AlqValue row. ! Does not work in gas lifted system (see MINQINJ). Contains the status of the wellhead choke control. The following keywords are used: - CALCULATED: The wellhead choke (i.e. and therefore the corresponding pressure drop) is
controlled by the GAP optimiser accordingly to the constraints set on the model. - FIXEDVALUE: A fixed dP is applied at the wellhead. - NONE: The wellhead choke cannot be controlled by the optimiser. Contains the value of the wellhead choke generated pressure drop or the value of the chosen fixed pressure drop at the wellhead. Contains the label of the injection fluid considered. Contains the maximum gas lift gas available. Contains the amount of gas lift gas injected in the system. Contains the minimum gas lift gas available. Refers to the type of power fluid circulation mode used. The following keywords are used: - Commingled - ClosedLoop
4.1.9.3.2 Fields specific to wells modelled using VLP/IPR intersection Variable Name VLP/IPR Intersection Model CurEditLayer IPR[i]
Used together with a DoCmd structure, will disable the ith layer of the well. See IPR[i].MASK() IPR[i].ENABLE() Used together with a DoCmd structure, will enable the ith layer of the well IPR[i].GasGravity Contains the gas specific gravity for the layer fluid IPR[i].GOR Contains the current GOR of the layer fluid IPR[i].IPRType * Contains the type of IPR model used to characterize the inflow performance of the well. The following keywords are used: - Lookup: A P vs. rate table is used to define the well IPR. - PI: A Productivity index is used to define the well IPR (oil wells only). - Cn: A C and n relationship is used to define the well IPR (gas wells only). - Forcheimer: A Forcheimer relationship is used to define the well IPR (gas wells only). - Forcheimer Pseudo Pressure (gas wells only) IPR[i].ISLAYERVALID Check the validity of the IPR dataset. The following numerical indexes are used: - 0: The IPR dataset considered is not valid. - 1: The IPR dataset considered is valid IPR[i].Label Contains the label of IPR considered IPR[i].LayerType * Contains the type of layer considered. The following keywords are used: - CONDENSATE - GAS - OIL IPR[i].MASK() Used together with a DoCmd structure, will mask the ith layer of the well. Example: If used as such, the DoCmd(“GAP.MOD[0].Well[{Well 1}].IPR[0].MASK()”) command will mask the 0th layer production until otherwise specified by the end user or the scheduling IPR[i].MASKFLAG() Contains the status of layer considered. The following numerical indexes are used: - 0: The IPR considered is included in the system. - #0: The IPR considered is not included in the system IPR[i].MGasRate[j] Contains an array (i.e. 20 values maximum) of gas rates used for IPR matching IPR[i].MGOR Contains the layer test GOR (with PI correction for mobility activated and Vogel correction for GOR options activated) IPR[i].MLiqRate[j] Contains an array (i.e. 20 values maximum) of oil rates used for IPR matching IPR[i].MNUMPOINTS Contains the number of IPR match point used IPR[i].MPB Contains the layer test bubble point pressure IPR[i].MPRES[j] Contains an array (i.e. 20 values maximum) of pressures used OpenServer User's Manual
GAP and the OpenServer
62
for IPR matching Contains the layer test pressure (with PI correction for mobility activated) IPR[i].MWCT Contains the layer test water cut (with PI correction for mobility activated) IPR[i].MWGR Contains the layer test WGR (with PI correction for mobility activated) IPR[i].N Contains the N value used for gas wells IPRs IPR[i].NonDarcyCoeff Contains the non-Darcy coefficient used for gas IPRs IPR[i].OffsetPressure Contains the value of the IPR offset pressure if any IPR[i].OilGravity Contains the oil specific gravity for the layer fluid IPR[i].PctCO2 Contains the CO2 mole percentage for the layer fluid IPR[i].PctH2S Contains the H2S mole percentage for the layer fluid IPR[i].PctN2 Contains the N2 mole percentage for the layer fluid IPR[i].PERMCORRN Contains the value of the permeability compaction correction exponent IPR[i].PI Contains the Productivity Index value of the layer considered IPR[i].PICorrRelPerm Contains the status of the PI correction for mobility. The following numerical indexes are used: - 0: The PI correction for mobility is not activated. - 1: The PI correction for mobility is activated. IPR[i].PRODDATA[i][j] Contains an array of production data values. Used only when the MBAL tank is modeled using decline curve. The following numerical indexes are used: - i: Refers to the input row considered. - j: Refers to the parameters considered (i.e 0 for cumulative production, 1 for GOR / CGR and 2 for Water Cut / WGR) IPR[i]. Refers to the type of interpolation used in the model when using ProdDataInterpolation a decline curve MBAL tank. Mode* The following keywords are used: - CumProd: Interpolate on Cumulative Production - ResPres: Interpolate on Reservoir Pressure IPR[i].RELPERM1. Contains the gas relative permeability exponent value described EXGAS in the Rel Perm1 relative permeability dataset. Remark: In all similar variables described below, if RELPERM2 is used, then it will refer to the Rel Perm 2 relative permeability dataset. Remark2: In previous versions, the string RELPERM.EXGAS was used. In terms of backward compatibility, this type of string will refer to the Rel Perm 1 relative permeability dataset IPR[i].RELPERM1. Contains the oil relative permeability exponent value described EXOIL in the Rel Perm1 relative permeability dataset IPR[i].RELPERM1. Contains the water relative permeability exponent value EXWAT described in the Rel Perm1 relative permeability dataset IPR[i].RELPERM1. Contains the gas residual saturation value described in the Rel IPR[i].MResPres
Perm1 relative permeability dataset Contains the oil residual saturation value described in the Rel Perm1 relative permeability dataset Contains the water residual saturation value described in the Rel Perm1 relative permeability dataset Contains the relative permeability to gas endpoint described in the Rel Perm1 relative permeability dataset Contains the relative permeability to oil endpoint described in the Rel Perm1 relative permeability dataset Contains the relative permeability to water endpoint described in the Rel Perm1 relative permeability dataset Refers to the set of relative permeabilities used in the layer considered. The following numerical indexes are used: - 0: From Tank Model - 1: From RelPerm1 set of relative permeabilities. - 2: From RelPerm2 set of relative permeabilities IPR[i].RelPermType2 Refers to the set of relative permeabilities used in the layer considered for mobility correction. The following numerical indexes are used: - 0: From Tank Model - 1: From RelPerm1 set of relative permeabilities - 2: From RelPerm2 set of relative permeabilities IPR[i].ResPres Contains the current Reservoir Pressure of the layer considered IPR[i].ResTemp Contains the Reservoir Temperature of the layer considered IPR[i].Tank Enables to determine the tank connected to the layer considered. Example: If used as such, the DoGet(“GAP.MOD[0].Well[{Well 1}].IPR[0].Tank”) command will return a 8 number digit which is an internal index for the node considered. If a .Label is added at the end of the string (i.e. GAP.MOD[0]. Well[{Well 1}].IPR[0].Tank.Label), it will return the label of the tank considered IPR[i].TCURPROD Contains the current reservoir cumulative production when using a decline curve MBAL model IPR[i]. Contains the current reservoir cumulative gas production when TCURGASPROD using a decline curve MBAL model IPR[i].UNMASK() Used together with a DoCmd structure, will unmask the ith layer of the well IPR[i]. Contains the status of the use offset pressure option. UseOffsetPressure The following numerical indexes are used: - 0: The offset IPR pressure option is not activated. - 1: The offset IPR pressure option is activated IPR[i]. Relates to the impurities dataset (i.e. Mole percentages of H2S, UseTankImpurities CO2, H2S and water salinity) considered. The following numerical indexes are used: OpenServer User's Manual
GAP and the OpenServer
64
-
0: The impurities dataset used is the one defined in the IPR section. - 1: The impurities dataset used is the one defined in the tank PVT IPR[i].VogelCorrectionContains the status of the Vogel Correction for GOR option. The following numerical indexes are used: - 0: The Vogel correction option is activated. - 1: The Vogel correction option is not activated IPR[i].WaterCut Contains the current water cut of the layer considered IPR[i].WaterSalinity Contains the water salinity of the layer considered IPR[i].WGR Contains the WGR of the layer fluid IPR[i].XFLOWIIPI Contains the layer crossflow injectivity index VLP Section AllowLeftVLPIPRInters Contains the status of the the type of VLP intersection. ection The following indexes are used: - 0: Left Hand side VLP/IPR intersection is not considered - 1: Left Hand side VLP/IPR intersection is considered ForceVLPIPRIntersect Contains the status of the the type of intersection considered. ion The following indexes are used: - 0: Left Hand side VLP/IPR intersection is not considered - 1: Left Hand side VLP/IPR intersection is forced SafeVLPIPRIntersecti Contains the status of the the type of intersection considered. on The following indexes are used: - 0: The safe VLP/IPR intersection routine is not activated - 1: The safe VLP/IPR intersection routine is activated TurnOffIfUnstable Contains the status of the the type of intersection considered. The following indexes are used: - 0: The Turn off well if unstable VLP/IPR intersection routine is not activated - 1: The Turn off well if unstable VLP/IPR intersection routine is activated adn the well will be switched off if a negative VLP slope is detected intersecting the IPR VLPFile Contains the name and path of the VLP file used to describe the outflow performance of the well CMNUMPOINTS CVALID
IPR[i].TConeData. Anisotropy
Coning Section Contains the number of coning match points considered Contains the status of the coning input data set. The following numerical indexes are used: - 0: The dataset required for coning calculation is not valid - 1: The dataset required for coning calculation is valid Contains the reservoir vertical anisotropy value
Contains the value of the coning model exponent Contains the value of the coning model F2 parameter Contains the value of the coning model F3 parameter Contains the depth of the tank GOC Contains the Liquid Rates corresponding to the ith test measurement used in the coning calculation Contains the GOR corresponding to the ith test measurement used in the coning calculation Contains the depth of the GOC at the test prevailing date Contains the reservoir pressure at the test prevailing date Contains the water cut at the test prevailing date Contains the reservoir permeability value Contains the status of the coning calculation in the layer considered. The following numerical indexes are used: - 0: The coning calculation is not activated. - 1: The coning calculation is activated
Example: To access the file name of the VLP File associated with a well labelled w1, one could use the string “GAP.MOD[0].WELL[{w1}].VLPFILE”, or, equivalently, “GAP. MOD[0].EQUIP[{w1}].VLPFILE”. 4.1.9.3.3 Fields specific to wells modeled using Performance Curves / Interpolated Performance Curves Variable Name Performance Curve Model GenType
Description
Well Summary Section Refers to the origin of the PC considered. The following numerical indexes are used: - 0: The PC are generated from PROSPER - 1: The PC are generated from a VLP / IPR model
From PROSPER IType
OpenServer User's Manual
PC Data Section Refers to the parameter used to describe the amount of gas considered for each PC dataset.
GAP and the OpenServer
66
The following numerical indexes are used: - 0: Gas Lift Gas Injection Rate - 1: Gas Liquid Ratio MANIPRES[i] Contains the manifold pressure at which the ith set of PC data refers to. PCDATA[i][j][k] Contains the different parameters of the PC dataset. The first index [i] refers to the dataset row and is only valid if more than one dataset has been entered at one specific manifold pressure, as it can be the case with gas lifted wells for instance. The second index [j] refers to the parameter considered. The following numerical indexes are used: - 0: Either Oil Rate or Liquid Rate depending of the PType choice. - 1: Water Cut - 2: GOR - 3: Flowing Bottom Hole Pressure - 4: Oil Gravity or Condensate Gravity - 5: Gas Gravity - 6: Gas Lift Gas Injected or Gas Liquid Ratio depending of the IType choice. - 7: Temperature - 8: H2S mol. percentage - 9: CO2 mol. percentage - 10: N2 mol. percentage - 11: Gas Rate - 12: Water to Gas Ratio - 13: Water Salinity - 14: Condensate to Gas Ratio
PType
The third index [k] refers to the dataset considered. Up to 5 PC datasets taken at 5 different manifold pressures can be entered for naturally flowing wells and 3 for gas lifted wells. Refers to the type of rate considered when describing an oil producer PC data: The following numerical indexes are used: - 0: Liquid Rates - 1: Oil Rates
Similar to the From PROSPER PC Well model VLP Section Similar to the VLP/IPR Well model 4.1.9.3.4 Fields specific to Stand-Alone Inflows All the following variables will need to be preceded by the following OpenServer string structure: GAP.MOD[i].INFLOW[j] Where the index i refers to the type of model i.e., refers to the Variables at MOD level, MOD[i] section) and the index j refers to the name or numerical index of the element. Variable Name Stand – Alone Inflow Model Inflow Model
IsInjector IsProducer
RateType
Description
Well Summary Section Refers to the type of inflow model used. The following numerical indexes are used: - 0: GAP Internal Model Refers to the type of inflow considered: Injector Refers to the type of inflow considered: Producer Coning Section Similar to the VLP/IPR Well model Downtime Section Similar to the VLP/IPR Well model IPR Section Similar to the VLP/IPR Well model Sets the rate type of the inflow model used. The following numerical indexes are used: - 0: Use Volumes - 1: Use Mass
4.1.9.3.5 Fields specific to Stand-Alone Outflows All the following variables will need to be preceded by the following OpenServer string structure: GAP.MOD[i].WELL[j]
OpenServer User's Manual
GAP and the OpenServer
68
Where the index i refers to the type of model considered (i.e. refers to the Variables at MOD level, MOD[i] section) and the index j refers to the name or numerical index of the element considered (i.e. refers to the Model Equipement List, EQUIP[i] section). Variable Name Description Stand – Alone Ouflow Model Outflow VLP Model Well Summary Section Similar to the VLP/IPR Well model VLP Section Similar to the VLP/IPR Well model Outflow PROSPER Model
RateType
PROSPER Data Section See PROSPER_Online_Models Sets the rate type of well model used. The following numerical indexes are used: - 0: Use Volumes - 1: Use Mass
4.1.9.3.6 Equipment Control Section (i.e. Previously Actual and Production Validation sections)
Variable Name
Description Equipment Control Section DPControlMeasured Contains the measured value (i.e. test value) of the well control parameter (i.e. pressure drop through the wellhead choke or gas lift gas injection rate for instance). DPControlValue Contains the current value (i.e. used by the solver during nonoptimised runs) of the well control parameter (i.e. pressure drop through the wellhead choke or gas lift gas injection rate for instance). DPControlOptimised Contains the value of the well control parameter (i.e. pressure drop through the wellhead choke or gas lift gas injection rate for instance) obtained after an optimised run.
Contains the estimated GOR. Depending on the type of well considered this keyword will refer to: - Total GOR (For oil wells) - Separator GOR (For retrograde condensate wells) Contains the estimated rate. Depending on the type of well considered and the type of rate selected, this keyword will refer to: - Oil Rate (For oil wells) - Liquid Rate (For oil wells) - Water Rate (For water wells) - Gas Rate (For gas and retrograde condensate wells) Contains the estimated WC. Contains the estimated WGR. Contains the IPR pressure offset (i.e. IPR pressure shift) used in the well considered. Contains the difference between estimated and measured rate. The rate it is described in the EstimatedLiqRate keyword. Contains the artificial lift associated variable value. Depending on the type of well considered this keyword will refer to: - ESP Frequency (For ESP lifted wells) - Gas Lift Gas Injection Rate (For gas lifted wells) - Power Fluid Rate (For HSP / Jet Pump lifted wells) - Diluent Injection Rate (For Diluent Injected wells) - Motor RPM (For PCP lifted wells). Contains the measured CGR. Contains the measured GOR. The variable it refers to is described in the EstimatedGOR keyword. Contains the measured manifold pressure. Contains the measured rate. The rate it refers is described in the EstimatedLiqRate keyword. Contains the measured reservoir pressure. Contains the measured water cut. Contains the measured WGR.
4.1.9.3.7 PROSPER Online Models When using the PROSPER Online option of GAP, the PROSPER variables available through OpenServer within PROSPER will also be available from GAP. The strings used for these variables are similar to the strings used within PROSPER, replacing the PROSPER prefix by a GAP.MOD[i].EQUIP[j].PrpData prefix.
OpenServer User's Manual
GAP and the OpenServer
70
The general string structure for accessing PROSPER Online variables through GAP OpenServer will therefore be the following: GAP.MOD[i].EQUIP[j].PrpData.k Where the index i refers to the type of model considered (i.e. refers to the Variables at MOD level, MOD[i] section), the index j refers to the name or numerical index of the element considered (i.e. refers to the Model Equipement List, EQUIP[i] section) and the index k refers to the PROSPER OpenServer string associated with the parameter considered. Example: To access the solution GOR input within the PROSPER Online section of a well labeled Well1, the following string can be used: GAP.MOD[0].WELL[{Well1}].PrpData.PVT.Input.Solgor As described previously, this string is exactly similar to the one that is used to refer to the solution GOR in a PROSPER model i.e., PROSPER.PVT.Input.Solgor, except that the PROSPER prefix has been replaced by the GAP prefix.
4.1.9.4 Fields specific to pipelines All the following variables will need to be preceded by the following OpenServer string structure: GAP.MOD[i].PIPE[j] Where the index i refers to the type of model considered such as production, injection, etc., and the index j refers to the name or numerical index of the element considered.
4.1.9.4.1 Pipeline Model Selection Variable Name PipeModel
Description Refers to the type of pipeline model used. Determined using the following values: - 0: GAP Internal Correlations - 1: Lift Curves - 2: PROSPER online
4.1.9.4.2 GAP Internal Correlation Pipeline Models Variable Name
Pipeline Environment Description Contains the pipe Gas Heat capacity. Contains the pipe Oil Heat capacity. Contains the pipe Water Heat capacity. Contains the pipe Overall Heat Transfer Coefficient. Contains the Surface Temperature. Pipeline Data Description Contains the Pipe section j type code. The following codes are used: - 1: Line Pipe - 2: Choke - 3: Coated - 4: Flexible - 5: Fitting - 6: User Contains the Pipe section j depth (Enthalpy balance only). Contains the Pipe section j ID. Contains the Pipe section j insulation type code (Enthalpy balance only). Contains the K value associated to the pipe section (User Pipe Type only) Contains the Pipe section j length. Contains the Pipe section j OD (Enthalpy balance only). Contains the Pipe section j roughness. Contains the Pipe section j thickness (Enthalpy balance only). Contains the Pipe section j True Vertical Depth. Defines the format of the pipeline depth. The following codes are used: – 0: TVD – 1: Elevation Change SYNTAX: DoSet ” GAP.MOD[{PROD}]. PipeDescInputFormat”, 0
EmptyPipe
OpenServer User's Manual
NOTE: The command changes pipeline description for ALL pipelines in the network. The Elevation Change option is implemented for reporting purposes and pipeline depth in GAP file is stored in TVD format. Hence, the values input into pipeline description table through OpenServer code should always be in TVD format. Enables to determine the pipeline status. The following values can be returned: - 0: The pipe is a pipe linking two joints and having pipeline data associated.
GAP and the OpenServer
72
-
ENDA
ENDB PIPERATEMULT PIPESTEPCH PseudoPipe
1: The pipe is empty (i.e. either it is linking a joint and an element and is therefore a pseudo-pipe, either it is linking two joints but has no corresponding pipeline data entered). Enables to determine the node connected to the inlet end of the pipe. Example: If used as such, the DoGet(“GAP.MOD[0].Pipe[1]. ENDA”) command will return a 8 number digit which is an internal index for the node considered. If a .Label is added at the end of the string (i.e. GAP.MOD[0]. Pipe[1].ENDA.Label), it will return the label of the considered node. Enables to determine the node connected to the outlet end of the pipe. Contains the Pipeline rate multiplier value. Contains the Maximum Step Length used by the correlations. Enables to determine the pipeline status. The following values can be returned: - 0: The pipe is a normal pipe (i.e. it is linking two joints) - 1: The pipe is a pseudopipe (i.e. it is linking a joint and an element such as a well for instance, and has no data associated)
the flow correlation. The index relates to the set of data selected. Up to 10 sets of measured data can be entered for the same pipeline section. The ‘var’ section relates to the variable to consider. The following variable names are used when proceeding to a pipeline matching calculation: - InPres: Upstream pressure - OutPres: Downstream pressure - InTemp: Upstream temperature - Qliq: Liquid rate - Qoil: Oil rate - Qgas: Gas rate (gas and condensate systems only) - Qginj: Gas lift gas injection rate - WCT: Water Cut - GOR: Gas Oil Ratio - OilGravity: Oil gravity - GasGravity: Gas gravity - CGR: Condensate to Gas ratio (gas and condensate systems only) - WGR: Water to Gas ratio (gas and condensate systems only) Contains the type of rate used to input the measured data. The following numerical indexes are used: - 0: Liquid Rate - 1: Oil Rate Contains the type of pipeline used for matching purposes. The following numerical indexes are used: - 0: Oil - 1: Oil + Gas Lift Gas - 3: Dry Gas - 4: Retrograde Condensate - 5: Water - ANNULAR - TUBING Pipeline Constraints Setup Contains the maximum C factor constraint applied on the pipe. Contains the maximum pressure constraint applied on the pipe. Contains the maximum velocity constraint applied on the pipe.
GAP and the OpenServer
74
4.1.9.4.3 GAP Lift Curves Pipeline Models GAP UnderModel
Description Contains the sub-model used when using the GAP Lift curve modelling facilities for pipelines. The different sub-models are described using the following numerical indexes: - 0: External - 1: GAP Internal Correlations - 2: PROSPER Online - 3: PROSPER file
External Model VLPFile
Lift Curves Contains the name and path of the file used to describe the pipeline lift performance curves. Pipeline Constraints Setup Similar to the GAP internal correlations pipeline model.
Contains the fluid CO2 mole percentage in the pipe section considered. Contains the fluid N2 mole percentage in the pipe section considered. Pipeline Environment Description Pipeline Data Description Correlations and Matching Procedure Pipeline Constraints Setup Similar to the GAP internal correlations pipeline model.
PROSPER Online Lift Curves Similar to the GAP Lift Curves / External Model. PROSPER Data Refer to the section 5.2.7.7.7 of the present manual. Pipeline Constraints Setup Similar to the GAP Internal Correlations Model. PROSPER File File
PROSPER File Contains the name and path of the PROSPER file used to describe the pipeline section. Lift Curves Similar to the GAP Lift Curves / GAP Internal Correlations Model Pipeline Constraints Setup Similar to the GAP Internal Correlations Model.
4.1.9.4.4 GAP PROSPER Online Pipeline Models Variable Name
Description PROSPER Data See PROSPER_Online_Models Pipeline Constraints Setup Similar to the GAP Internal Correlations Model.
OpenServer User's Manual
GAP and the OpenServer
76
Example: To access the overall heat transfer coefficient of a pipeline modeled with GAP Internal Correlations with label p1, one could use the string GAP.MOD[0].PIPE [{p1}].HTCSUR. 4.1.9.5 Fields specific to joints All the following variables will need to be preceded by the following OpenServer string structure: GAP.MOD[i].JOINT [j] Where the index i refers to the type of model considered at the MOD level i.e., MOD[i] and the index j refers to the name or numerical index of the element considered i.e., EQUIP[i] section. Variable Name MAXPCO2 MAXPH2S MAXPN2 MAXQGAS MAXQLIQ MAXQOIL MAXQWAT MAXSOG MINQGAS MINQLIQ ABMAXPWF
Description Contains the maximum mole percentage of CO2 constraint applied on the joint. Contains the maximum mole percentage of H2S constraint applied on the joint. Contains the maximum mole percentage of N2 constraint applied on the joint. Contains the maximum gas rate constraint applied on the joint. Contains the maximum liquid rate constraint applied on the joint. Contains the maximum oil rate constraint applied on the joint. Contains the maximum water rate constraint applied on the joint. Contains the maximum oil specific gravity constraint applied on the joint. Contains the minimum gas rate constraint applied on the joint. Contains the minimum liquid rate constraint applied on the joint. Contains the maximum flowing pressure constraint applied on the node.
Example: To access the maximum gas rate constraint applied on the node N1, one could use the string GAP.MOD[0].JOINT[{N1}].MAXQGAS.
4.1.9.6 Fields specific to pump/compressor nodes All the following variables will need to be preceded by the following OpenServer string structure:
GAP.MOD[i].PUMP[j] for a pump GAP.MOD[i].COMP[j] for a compressor Where the index i refers to the type of model considered at the MOD level i.e., MOD[i] section and the index j refers to the name or numerical index of the element considered i.e., EQUIP[i] section.
4.1.9.6.1 Fields Common to Pumps and Compressors Variable Name ACTSPEED
CalcData[i][j]
DESSPEED
DPControl *
MAXSPEED MDRateType
MINSPEED NumStage OPTSPEED
OpenServer User's Manual
Description Contains the Actual speed (or frequency) of the pump/compressor for use with affinity laws or if speed/frequency is a sensitivity variable. Enables to specify the data used to calculate the pump / compressor performance using the Input | Calculate Performance screen. The i index enables to specify which row is selected, the j index enables to specify which column is selected. See the MDRateType variable below to know how to specify the data entry format. Contains the Design speed (or frequency) of the pump/compressor for use with affinity laws or if speed/frequency is a sensitivity variable. Refers to the type pressure control used to drive the pump/ compressor. The following status are available: - FIXED VALUE: the pressure drop through the pump/ compressor is fixed by the user. - CALCULATED: the pressure drop through the pump/ compressor can be modified by the GAP optimiser to obtain the optimum performance of the system. Contains the pump/compressor maximum speed limit. Enables to specify in which format the data for the Input | Calculate Performance screen is specified. The following options are available: - 0: Liquid Rate, WCT, GOR - 1: Oil Rate, WCT, GOR - 2: Gas Rate, WGR, CGR - 3: Oil, Water and Gas rates - 4: Water rate Contains the pump/compressor minimum speed limit. Contains the number of stages considered for the pump/ compressor. Returns the pump/compressor optimum calculated speed.
GAP and the OpenServer
StageData[i]. UseSep
StageData[i]. SepData[j]
UseAff
INJTEMP
78
Contains the status of the internal separation for the pump/ compressor. The index refers to the stage considered: - 0: Before compression process - 1: After compression process The following indexes are describing the separation status: - 0: No Internal Separation - 1: Existing Internal Separation capacity Contains the fraction of fluid removed by the internal separation process if any. The index refers to the stage considered: - 0: Before compression process - 1: After compression process The following indexes are describing the fluid phases considered: - 0: Percentage of Water removed. - 1: Percentage of Oil removed. - 2: Percentage of Gas removed. Contains the use affinity laws facility status. The following numerical indexes are used: - 0: Do not use affinity laws. - 1: Use affinity laws to scale the element performance for speed/frequency. Contains the injection (inlet) temperature - only for injection systems.
4.1.9.6.2 Fields Specific to Compressors Variable Name SubType *
Refers to the status of the cooling process for the compressor. The index refers to the stage considered: - 0: Before compression process - 1: After compression process The following indexes are describing the separation status: - 0: No Cooling - 1: A Cooling process exists Contains the description of the cooling process if any. The index refers to the stage considered: - 0: Before compression process - 1: After compression process The following indexes are describing the fluid phases considered: - 0: Cooler Temperature. - 1: Cooler Efficiency. Contains the use polytropic head facility status. The following numerical indexes are used: - 0: Do not use the polytropic head facility. Assumes the head in the performance data used is based on an isentropic cycle. - 1: Do use the polytropic head facility. Assumes the head in the performance data used is based on a polytropic cycle.
StageData[i]. CoolData[j]
UsePoly
Example: To access the design speed of a node with label c1, one could use the string GAP.MOD[0].COMP[{c1}].DESSPEED.
4.1.9.7 Fields specific to separator / injection manifold nodes All the following variables will need to be preceded by the following OpenServer string structure: GAP.MOD[i].SEP[j] Where the index i refers to the type of model considered (i.e. refers to the Variables at MOD level, MOD[i] section) and the index j refers to the name or numerical index of the element considered (i.e. refers to the Model Equipement List, EQUIP[i] section). Variable Name SubType *
OpenServer User's Manual
Description Contains the type of separation node considered: The following keywords are used: - GASINJMAN: Gas Injection Manifold
GAP and the OpenServer
InjFluidLabel
SolverPres[j]
Temperature
80
- PRODSEP: Production Separator - WATINJMAN: Water Injection Manifold Contains the fluid label that refers to the type of fluid used for injection purposes. The properties of these fluids can be found under the FluidListSection string. Contains an array of pressures to be used in allocation calculations. Up to 10 pressure values can be entered. If the system is gaslifted, only one pressure value can be assigned to the separator, and therefore only [0] is used. Contains the temperature of the injected fluid.
Example: To set the manifold pressure used for the Solve Network calculation to 200 psig for instance, the following command will be used: DoSet(“GAP.MOD[0].SEP [{Sep1}].SolverPres[0]”),200
4.1.10 Composition Records 4.1.10.1Compositional Model Setup The type of compositional model and associated calculations can be setup in the Options / System Options / Method section. The COMPMODE string can be used directly at the MOD level to setup directly these options via OpenServer. When either the Compositional Tracking, Fully Compositional or Black Oil Lumping Delumping Calculation options are selected, the EOS model used in GAP needs to be setup, as well as emulsion models if needed (see Model_Options).
at MOD level, MOD[i] section), the index j refers to the name or numerical index of the well considered (i.e. refers to the Model Equipement List, EQUIP[i] section) and the index k refers to the layer considered in case of multilayer wells. In case the composition considered does not refer to a well fluid composition but to a specific fluid from the GAP fluid list, the OpenServer strings associated to this fluid list are defined in the section 3.2.6.1, the following string will then been used: GAP.MOD[i].FluidList[j].Composition Variable Name
Description
In every variable described below, the indes [i] refers to the row of the composition table considered. Each component described in the fluid composition table will have a specific table row assigned using the NAME string described below. BICOEFF[i][j] Refers to the binary interaction coefficients used. The first index refers to the composition table row index of the first component considered. The second index refers to the composition table row index of the second component considered. MOLEPCT[i] Array [30] of mole percentages. MW[i] Array [30] of molecular weights. NAME[i] Array [30] of component names. Valid values for this variable could be for instance: - N2 - CO2 - NC4 - PS-1 ; PS-2 ; PS-3 for the pseudo-components considered. NUMCOMP Contains the total number of components used to describe the fluid composition in the well layer considered. OMEGA[i] Array [30] of accentric factors (i.e. Ù factors). OMEGAA[i] Array [30] of Ù A factors. OMEGAB[i] Array [30] of Ù B factors. PARACHOR Array [30] of parachors. [i] PCRIT[i] Array [30] of critical pressures. SPGRAV[i] Array [30] of specific gravities. TBOIL[i] Array [30] of boiling points. TCRIT[i] Array [30] of critical temperatures. VCRIT[i] Array [30] of critical volume. VSHFT[i] Array [30] of volume shifts. Example: To access the mole percentage of the first component of the input OpenServer User's Manual
GAP and the OpenServer
82
composition for the first layer of a well labeled w1, the string would be “GAP.MOD[0]. WELL[{w1}].IPR[0].Composition.MOLEPCT[0]”.
4.1.10.3Fluid Composition Results Whether the compositional tracking, fully compositional or black oil lumping delumping calculation option is chosen, the fluid composition will be defined in every system node using a composition table similar to the one used to define the fluid composition and described previously. The strings used to obtain these results are similar to the one described above, at the exception that the type of calculation considered should be specified in the OpenServer string as described below. To obtain the results from the Solver Calculation, the following type of string can be used: GAP.MOD[i].EQUIP[j].SolverResults[k].Composition.NAME[l] Where the index i refers to the type of model considered (i.e. refers to the Variables at MOD level, MOD[i] section), the index j refers to the name or numerical index of the node considered (i.e. refers to the Model Equipement List, EQUIP[i] section) and the index k refers to the solver sensitivity considered. The index l refers to the row index or the component name of the component considered. To obtain the results from the Prediction Calculation, the following type of string can be used: GAP.MOD[i].EQUIP[j]. PREDRES[{01/01/2000}].Composition.NAME[k] Where the index i refers to the type of model considered (i.e. refers to the Variables at MOD level, MOD[i] section), the index j refers to the name or numerical index of the node considered (i.e. refers to the Model Equipement List, EQUIP[i] section) and the index k refers to the row index of the component considered. Example: To access the mole percentage of the first component of the solver result composition for a node labeled N1, the string to use would be “GAP.MOD[0].NODE [{N1}].SolverResults[0].Composition.MOLEPCT[0]”. The above string is exactly the same when using the Black Oil Lumping Delumping compositional calculation option.
4.1.11 Enabling / Disabling Options This section provides various OpenServer Commands for Enabling or Disabling various elements in GAP.
Will Disable the Prediction Script double quotes flag (under Predictions tab of GAP)
OpenServer User's Manual
Will Enable the System Validation flag (under Options tab of GAP) Will allow checking whether the System Validation flag is enabled or disabled.
Will Enable the Automatic Masking flag (under Options tab of GAP) Will allow checking whether the Automatic Masking flag is enabled or disabled.
Will Enable the Label Validation flag (under Options tab of GAP) Will allow checking whether the Label Validation flag is enabled or disabled.
Will Enable the PROSPER Well Type Validation flag (under Options tab of GAP) Will allow checking whether the PROSPER Well Type Validation flag is enabled or disabled.
Will Enable the Disable Prediction Script flag (under Predictions tab of GAP) Will allow checking whether the Disable Prediction Script flag is enabled or disabled.
Will Enable the Prediction Script double quotes flag (under Predictions tab of GAP) Will allow checking whether the Prediction Script double quotes flag is enabled or disabled.
GAP and the OpenServer
84
4.1.12 Scheduling The user can set the schedule of any model element for the prediction run. All the schedule events will need to be preceded by the following OpenServer string structure: GAP.MOD[i].EQUIP[j].SCHEDULE[k] If the schedule event refers to the entire system, i.e., production network or associated injection network for instance, the following OpenServer string structure can be used: GAP.MOD[i].SCHEDULE[k] Where the index i refers to the type of model considered (i.e. refers to the Variables at MOD level, MOD[i] section), the index j refers to the name or numerical index of the network element considered (i.e. refers to the Model Equipement List, EQUIP[i] section) and the index k refers to the row of the schedule event considered in the schedule event list.. For each record in the schedule, the following fields are considered: - Date - Event type - Constraint type (or OpenServer variable) - Constraint value
4.1.12.1Schedule Count The total number of schedule rows assigned to an element can be derived using the following string: GAP.MOD[i].EQUIP[j].SCHEDULE.COUNT
4.1.12.2Date The variable string for the date in the ith model, jth equipment and kth record in the schedule is the following: GAP.MOD[i].EQUIP[j].SCHEDULE[k].DATE The above string refers to the date of the scheduled event as a number, and not as a day/month/year format date.
To refer to the date as a day/month/year format, the following string can be used: GAP.MOD[i].EQUIP[j].SCHEDULE[k].DATE.DATESTR
4.1.12.3Event type The variable string for the event type in the ith model and jth record in the schedule is: GAP.MOD[i].EQUIP[j].SCHEDULE[k].TYPE This variable is a read only variable. The existing types of event and their availability, depends of the type of element considered. A list of associated keywords are described below: Event Type Bypass Change constraints Change Diameter Change Downtime Change Fixed Rate Fixed rate (Gas) Fixed rate (Gas) - off Fixed rate (Wat) Fixed rate (Wat) - off Gas recycling Gas recycling - off Gas recycling (Prd – Amount) Gas recycling (Prd – Amount) - off Mask Pressure target Pressure target - off Start well Stop well Stop well, no X-flow Unbypass Unmask Voidage Replacement (Gas) Voidage Replacement (Gas) - off Voidage Replacement (Wat) Voidage Replacement (Wat) - off
4.1.12.4Constraint Type When the type of event considered refers to the modification of a model constraint, the constraint to modify needs to be specified. The string referring to the type of constraint in the ith model and kth record in the schedule is: GAP.MOD[i]. EQUIP[j].SCHEDULE[k].LPAR[0] See Constraint_Level_and_Type for further description of constraint names.
4.1.12.5Constraint Value When the event type considered refers to the setup of a model parameter value or the modification of one of the model constraints, the following string will be used: GAP.MOD[i]. EQUIP[j].SCHEDULE[k].CVAL[0] When retrieving a value of a scheduled element, the previous string will return both value and the unit in which it is expressed. Example: To setup the maximum liquid constraint to 5000STB/d on the 01/01/2005 in a well labeled W1, the following set of strings will be used: DoSet “GAP.MOD[0]. EQUIP[{W1}].SCHEDULE[0].DATE.DATESTR”, “01/01/2005” DoSet “GAP.MOD[0]. EQUIP[{W1}].SCHEDULE[0].LPAR[0]”, “MAXQLIQ” DoSet “GAP.MOD[0]. EQUIP[{W1}].SCHEDULE[0].CVAL[0]”, 5000
4.1.12.6Schedule Reset The existing GAP schedule can be reset, either at the production system level, associated injection system level or at the element level using the following strings: At system level: GAP.MOD[i].SCHEDULE.RESET At equipment level: GAP.MOD[i].EQUIP[j].SCHEDULE.RESET Note that these should be used with a Doset for example:
At system level: Doset (“GAP.MOD[{PROD}].SCHEDULE.RESET”), 1 At Equipment level: Doset (“GAP.MOD[{PROD}].EQUIP[{Separator}].SCHEDULE. RESET”), 1 4.1.12.7Apply Schedule To The OpenServer commands to access the "Apply Schedule To" section are : DoCmd ("Gap.APPLYSCHEDULETO({20/04/2012})") DoCmd ("GAP.CLEARAPPLIEDSCHEDULE()")
4.1.13 Constraints 4.1.13.1Constraint Level and Type The following listed constraints are available within GAP. The availability of these constraints on the system element considered such as a well, joint, separator, etc., will depend of the nature of the element. The string defining the constraint type should always be preceded by a prefix describing the system level and element on which this constraint should be applied: - MOD Level Constraints (i.e. System Constraints) : The constraint name should be preceded in the OpenServer string by a GAP.MOD[{PROD}] prefix. Example: To set the value of the maximum gas rate constraint applied to the system to 1000MMSCF/d, the following string could be used: DoSet (“GAP.MOD[0].MAXQGAS”),1000 -
NODE Level Constraints : The constraint name should be preceded in the OpenServer string by a GAP.MOD[{PROD}].NODETYPE prefix.
Example: To set the value of the maximum gas rate constraint applied to the well “WELL 1” to 100MMSCF/d, the following string could be used: DoSet (“GAP.MOD[0].WELL[{WELL 1}].MAXQGAS”),100 The well abandonment constraints can be set for each well layer independently using the following structure: GAP.MOD[0].WELL[{WELL 1}].IPR[i].ABMAXGOR The constraint list is as follows: OpenServer User's Manual
GAP and the OpenServer
Variable Name ABMAXGOR ABMAXWC ABMAXWGR ABMINGAS ABMINLIQ
Description Well Abandonment Constraints Type Contains the well maximum GOR before abandonment Contains the well maximum WC before abandonment Contains the well maximum WGR before abandonment Contains the well minimum gas rate before abandonment Contains the well minimum liquid rate before abandonment General Constraints Type Contains the maximum well artificial lift parameter: - For ESP lifted wells: refers to the ESP frequency - For PCP lifted wells: refers to the pump speed - For HSP lifted wells: refers to the power fluid rate - For Jet Pump lifted wells: refers to the power fluid rate - For Diluent Injection wells: refers to the diluent injection rate Contains the minimum well artificial lift parameter (see above) Contains the maximum ESP frequency Contains the minimum ESP frequency Contains the maximum C factor (pipeline only) Contains the well maximum applied drawdown Contains the maximum gas injection rate Contains the maximum gross heating value Contains the maximum mole percentage of CO2 Contains the maximum mole percentage of H2S Contains the maximum mole percentage of N2 Contains the maximum power Contains the maximum power fluid rate, at separator or node level only. Contains the line maximum pressure (pipeline only) Contains the maximum flowing bottom hole pressure Contains the maximum gas rate Contains the maximum liquid rate Contains the maximum oil rate Contains the maximum total gas rate Contains the maximum water rate
MAXSOG Contains the maximum gas specific gravity MAXSPECGROSSHEATIN Contains the maximum specific gross heating value G MAXVELOCITY Contains the maximum fluid velocity (pipeline only) MINGINJ MINGINJNC MINPWF MINQGAS MINQLIQ
Contains the minimum gas injection rate Contains the minimum no-close gas injection rate Contains the minimum flowing bottom hole pressure Contains the minimum gas rate Contains the minimum liquid rate
MotPowMax MotPowMin
Contains the maximum motor power Contains the minimum motor power
Contains the well optimisation weigth Contains the maximum PCP speed Contains the minimum PCP speed Contains an array of minimum and maximum pump rate as a factor of the pump control parameter. Valid for ESP lifted, PCP lifted, HSP lifted and Jet Pump lifted wells only. The following numerical indexes are used: - i: Defines the colum index 0: Refers to the Pump contol parameter column. (See the AlqValueMax constraint for pump control parameter list) 1: Refers to the Minimum Pump Rate Column 2: Refers to the Maximum Pump Rate Column - j: Defines the row index (j values from 0 to 19, 20 columns maximum) Contains the well shut in priority factor
SHUTINPRI
4.1.13.2Binding Constraints Some of the constraints described above can be setup to be either binding or unbinding constraints. To access the binding section of each constraint, the constraint original OS string should be followed by the BINDING keyword. The following numerical indexes are used to define the status of the constraint regarding to the binding option: 0 : the constraint is set to non-binding 1 : the constraint is set to binding
OpenServer User's Manual
GAP and the OpenServer
90
Example: To access the binding status of the well “WELL 1” maximum liquid constraint, the following string can be used: DoGet (“GAP.MOD[0].WELL[{WELL 1}].MAXQLIQBINDING”)
4.1.13.3Constraints and Potential Calculations By definition, the potential calculation enables to calculate the system potential, i.e., calculating the system production without taking into account any imposed constraints. However, it is possible to tune the potential status of each constraint to maintain a binding status during the potential calculation. To access the potential section of each constraint, the constraint original OS string should be followed by the POTENTIAL keyword, except for the specific constraints listed below. The following numerical indexes are used to define the status of the constraint regarding to the potential calculation: 0 : the constraint is not kept active during the potential calculation 1 : the constraint is kept active during the potential calculation By default, GAP will keep the constraints that cannot physically be neglected, such as the separator handling capacities for instance. Example: To keep the liquid constraint of the well “WELL 1” active during the potential calculation, the following string can be used: DoSet (“GAP.MOD[0].WELL[{WELL 1}].MAXQLIQPOTENTIAL”),1 Variable Name ABMAXPWFPOTENTIAL MAXGLPOTENTIAL MINGLNCPOTENTIAL MINGLPOTENTIAL MXDRWDWNPOTENTIAL
OtherConstraintPotential[i]
Description Contains the maximum flowing bottom hole pressure constraint potential status Contains the maximum gas injection constraint potential status Contains the minimum no close gas injection constraint potential status Contains the minimum gas injection constraint potential status Contains the maximum drawdown constraint potential status Contains the potential status of the following constraints, depending of the i index value: - 0: Maximum pump control parameter - 1: Minimum pump control parameter
(See the AlqValueMax constraint for pump control parameter list) - 2: Minimum motor power - 3: Maximum motor power
4.1.14 Obtaining the Results 4.1.14.1Solver Results All the Solver results can be obtained for each node and element in the network using the following string: GAP.MOD[i].EQUIP[j].SolverResults[k].l Where the index i refers to the type of model considered (i.e. refers to the Variables at MOD level, MOD[i] section), the index j refers to the name or numerical index of the network element considered (i.e. refers to the Model Equipement List, EQUIP[i] section) and the index k refers to the index of the Solve Network sensitivity case considered. l refers to the model parameter considered. The following keywords are used: Parameter Keyword CO2 H2S N2
Description Mol percentage of CO2 in the fluid considered Mol percentage of H2S in the fluid considered Mol percentage of N2 in the fluid considered
Produced CGR Well drawdown Well flowing bottom hole pressure Produced GOR Gross heating value of the fluid stream considered Hydrocarbon mass rate produced Hydrocarbon molar rate produced Net heating value of the fluid stream produced Optimum pressure drop calculated Pressure at the system node considered Produced gas rate Produced liquid rate Produced oil rate Produced water rate Reservoir pressure
Specific gas gravity produced Specific gross heating value of the fluid considered Specific net heating value of the fluid stream considered Specific oil gravity produced Flowing temperature at the system node considered Total mass rate produced Produced water cut Produced water to gas ratio Water salinity produced
Pipeline and Well Status Flags IsBottleNecked IsReversedFlow IsUnstable
IsChokedByOptimiser IsUnstable
Pipeline Status Flags Returns 0 if the pipe is not bottlenecking, 1 if it is. Returns 0 if the pipe is not in reverse flow, 1 if it is. Returns 0 if the pipe is in stable flow, 1 if it is not. Well Status Flags Returns 0 if the well is not choked by the optimiser, 1 if it is. Returns 0 if the well is in stable flow, 1 if it is not.
If the element considered is a well, the following string can be used to access the solver results for a specific layer: GAP.MOD[i].WELL[j].IPR[k].SolverResults[l].m Example: To retrieve the oil rate produced at the node labeled Manifold, the following string can be used: GAP.MOD[0].EQUIP[{Manifold}].SolverResults[0].Qoil In case the compositional tracking or full composition calculation options are used, the composition related solver results can be obtained as defined in Fluid_Composition_Results.
at MOD level, MOD[i] section), the index j refers to the name or numerical index of the network element considered (i.e. refers to the Model Equipment List, EQUIP[i] section) and the index k refers to the date of the prediction time-step considered. l refers to the model parameter considered. The integer k in the above mentioned command will vary from 0 to one less than the number of prediction results. The command to check the number of prediction results is GAP.MOD[i].EQUIP[j].PREDRES.DATES.COUNT Similar keywords to the one used for the Solver results are used for prediction results, except for the following parameters: Parameter Keyword AVGGASRATE AVGLIQRATE AVGOILRATE AVGWATRATE DATES[i]
Description Average gas rate produced Average liquid rate produced Average oil rate produced Average water rate produced Refers to the date of the ith prediction time-step.
DATES[i].DATESTR
Will refer to the date using an integer format. Refers to the date of the ith prediction time-step.
DATES[i]. DATETIMESTR
Will refer to the date using a day/month/year format. Refers to the date of the ith prediction time-step.
DATES[i].TIMESTR
Will refer to the date using a day/month/year hrs/min/ sec format. Refers to the date of the ith prediction time-step.
Will refer to the date using a day/month/year hrs/min/ sec format. Well downtime Instantaneous gas rate Instantaneous liquid rate Instantaneous oil rate Bottom hole flowing pressure Revenue generated up to the node considered Instantaneous water rate
If the element considered is a well, the following string can be used to access the solver results for a specific layer: GAP.MOD[i].WELL[j].LAYERPREDRES[k][l].m Where the index i refers to the type of model considered (i.e. refers to the Variables at MOD level, MOD[i] section), the index j refers to the name or numerical index of the OpenServer User's Manual
GAP and the OpenServer
94
well considered (i.e. refers to the Model Equipment List, EQUIP[i] section), the index k refers to the layer considered (i.e. it can either be the layer numerical index or the layer name expressed between {}) and the index l refers to the prediction time-step considered. The index m refers to the model parameter considered. The keywords used here are similar to those used for the Production Prediction results. Example: To retrieve the average oil rate produced by the layer labeled Oil of the well labeled Well1 on the 01/01/2000, the following string can be used: GAP.MOD[0].WELL[{Well1}].LAYERPREDRES[{Oil}][{01/01/2000}].AVGOILRATE
4.1.14.3Total System Results The Solve Network total system results can be obtained directly from the MOD level using the following string structure: GAP.MOD[i].SystemTotal[j].k Where the index i refers to the type of model considered (i.e. refers to the Variables at MOD level, MOD[i] section), the index j refers to solver sensitivity case considered and the index k refers to the model parameter considered. The keywords used for the model parameters are similar to the one described for the Solve Network results.
4.1.14.4Snapshot Results The following table summarizes the OpenServer commands to re-load snapshot data: OpenServer string GAP.PREDSNAPSHOT.TIME.COUNT GAP.PREDSNAPSHOT.LOAD (snapshot_number) GAP.PREDSNAPSHOT.LOAD (“snapshot_date”) GAP.PREDSNAPSHOT.UNLOAD()
Description Returns the number of snapshots saved during prediction run Loads the snapshot that corresponds to the specified number starting from 0 Loads the snapshot that corresponds to the specified date Unloads the snapshot and return to the initial system settings
Please see Section 2.8.6 of the GAP User Guide for information on how to save prediction snapshot data.
4.1.15 SubFlowSheets GAP offers the possibility of organizing the system into different flow sheets, this option is useful when organizing large models. It is possible to use the OpenServer functionality to retrieve and modify variables being located in the flow sheets. The following syntax can be used to access the number of wells located in the flow sheet with the index i: GAP.MOD[{PROD}].FLOWSHEET[i].WELL.COUNT The following syntax can be used to access the label of the well j located in the flow sheet i: GAP.MOD[{PROD}].FLOWSHEET[i].WELL[j].LABEL Adding the FLOWSHEET[index] or FLOWSHEET[{name of the flow sheet}] structure to the OpenServer string identifies which flow sheet the given variable is located The above is valid for any variable and any equipment element.
4.2
GAP OpenServer Functions This section describes the functions available to the OpenServer from GAP. All functions in GAP have the form: function_name (function_arguments) Even if a function does not require any arguments, the brackets are still required. The recommended way to execute these functions from Visual Basic is to use the DoGAPFunc subroutine as shown below. This subroutine works properly with any GAP function, and correctly deals with the case where a function takes an appreciable amount of time to execute. Some functions may return a value. The GAP functions can be applied at four different levels: - Functions applicable at the Network or Top level The function action will be applied to the entire GAP network considered i.e., the production, gas and water injection systems. In the DoGAPFunc subroutine, the function name and arguments will be preceded by a GAP prefix. Example: The function PREDINIT() in GAP is a network level function and performs prediction initialization and returns the number of time-steps to be performed during the
OpenServer User's Manual
GAP and the OpenServer
96
prediction. The code to call this in Visual Basic would be: NSTEPS = DoGAPFunc( “GAP.PREDINIT()” ) Upon execution, NSTEPS would be set to the number of prediction time-steps. NSTEPS must also be declared in the macro as an Integer. -
Functions applicable at the Model level The function action will be applied to one of the models included in the GAP network considered i.e., the production, gas and water injection systems. In the DoGAPFunc subroutine, the function name and arguments will be preceded by a GAP.MOD[i] prefix, where the i index relates to the GAP model considered and is either expressed using the model numerical index or using the model label between the braces{}.
-
Functions applicable at the Node level The function action will be applied to one of the node of one of the models included in the GAP network considered i.e., the production, gas and water injection systems. In the DoGAPFunc subroutine, the function name and arguments will be preceded by a GAP.MOD[i].EQUIP[j] prefix, where the i index relates to the GAP model considered and the j index refers to the node considered.
-
Functions applicable at the IPR level The function action will be applied to one of the well IPR in the GAP network considered. In the DoGAPFunc subroutine, the function name and arguments will be preceded by a GAP.MOD[i].EQUIP[j].IPR[k] prefix, where the i index relates to the GAP model considered, the j index refers to the node considered and the k index refers to the layer considered.
Sample Macros: Please also review the prediction set-up sample code in the provided "GAP Prediction Template.xls" located in: C:/Program Files/Petroleum Experts/IPM 7/Samples/ OpenServer/Template/. Please also review the GAP OpenServer examples. The files are in the form of *.GAR files (archived GAP files). To open a GAR file, from the main menu of GAP select File | Archive | Extract. Included in the GAR file is the macro that is used to run the predictions and the code structure can be used as a reference to develop custom macros, and to be modified to suit individual needs.
Remark: Non compulsory function arguments will be individualized using a blue font colour. Function Name Network Level Functions CALCCOMPDP (comp)
Description
Calculates the outlet conditions of the compressor given the inlet conditions. CALCPIPEDP (pipe) Calculates the dP in the pipe given the upstream flowing conditions. CALCPUMPDP (pump) Calculates the outlet conditions of the pump given the inlet conditions. COPYITEM (EquipDest,EquipSrc) Copies data from a source node to a destination node. DELITEM (equip) Deletes a specified node from the system. ISMEMBEROFGROUP(group) Enables to check if the node considered is member of a specific group. LINKITEMS (equip1, equip2, linklabel) Creates a link between two specified nodes. NEWFILE () Clears any currently loaded GAP file. NEWITEM (type, label, iposcode, equip, Creates a new node in the system specified. model) OPENFILE (filename) Opens the GAP file specified. PCCALC (equip, PcCurve) Allows access to well modelled using PC curve option. PCGMAX (equip, PcCurve) Calculates the maximum gas lift gas for a particular performance curve at a specified manifold pressure. PCGSOLV (equip, PcCurve) Calculates the gas lift gas required to meet a particular target value for a particular performance curve at a specified manifold pressure. PCPSOLV (equip, PcCurve) Calculates the manifold pressure required to meet a particular target value for a particular performance curve. PREDDOSTEP (optimise, potential) Performs a production prediction time-step. PREDDOSOLVER (timestepsize, Performs a solve network in prediction optimise, potential, model) mode. PREDEND (dorest, optimise, potential) Stops a production prediction calculation. PREDINIT (ignore internal timesteps, Performs production prediction initialisation. ignore internal scheduling) PURGEALLRESULTS (model) Deletes all the solver and prediction results of the GAP model considered. PURGEPREDLOG (model) Deletes the prediction calculation log.
Specific Snapshot Commands PREDSNAPSHOT.TIME.COUNT
98
Deletes all the prediction results of the GAP model considered. Deletes the prediction snapshots. Deletes the solve network calculation log Deletes all the solve network results of the GAP model considered. Calculates a set of performance curve for the specified well based on the PC curve input data. Resets any previously entered solve network input data (i.e. separator pressure, injection manifold pressure, gas lift gas available…). Saves the currently loaded GAP modle to the file specified. Closes GAP. Perfoms a solver calculation within GAP. See Start and Shutdown section See Start and Shutdown section Specifies the target IPR layer in a multilayer IPR model Example: GAP.MOD[i].WELL[j]. GENIPRLAYER to n-1 where 'n' is the layer number corresponding to the layer the IPR will be generated Transfers the IPR from PROSPER to the well node Example: GAP.MOD[i].WELL[j]. TRANSFERPROSPERIPR Deletes the link between the two node specified. Validates all the network input dataset. Imports the specified VLP file into the corresponding node. Calculates the VLP/IPR intersection for the well specified. Generates performance curve data from the VLP/IPR data. Calculates the well performance given specific flowing conditions. Used to validate the model performance.
during prediction run. EXAMPLE DoGet ("GAP.PREDSNAPSHOT.TIME. COUNT") Returns date for snapshot of the specified number (if exist). The date is returned in general format i.e. in days since 01/01/1990. EXAMPLE DoGet ("GAP.PREDSNAPSHOT.TIME [X]") If snapshot number X corresponds to 01/01/2010 the value of 40179 will be returned. Returns date for snapshot of the specified number (if exist). The date is returned as a string in DD/MM/YYYY format. EXAMPLE DoGet ("GAP.PREDSNAPSHOT.TIME [X].DateStr") If snapshot number X corresponds to 01/01/2010 the string "01/01/2010" will be returned. Returns dates for all the snapshots in the specified number interval in the format of the string separated by "|" symbol. Dates are returned in general format. EXAMPLE DoGet ("GAP.PREDSNAPSHOT.TIME [0:3]") If snapshots 0-3 corresponds to dates 01/01/2010, 01/02/2010, 01/03/2010, 01/04/2010 the following string will be returned "40179|40210|40238|40269". Returns dates for all the snapshots in the specified number interval in the format of the string separated by "|" symbol. Dates are returned in DD/MM/YYYY format. For snapshots 0-3 in this case the following string will be returned "01/01/2010| 01/02/2010|01/03/2010|01/04/2010" Loads the snapshot that corresponds to the specified number (if exist) onto the screen. EXAMPLE DoCmd ("GAP.PREDSNAPSHOT. LOAD(X)")
GAP and the OpenServer
PREDSNAPSHOT.LOAD (snapshot_date)
PREDSNAPSHOT.LOAD("Original")
PREDSNAPSHOT.UNLOAD()
100
Loads the snapshot that corresponds to the specified date (if exist) onto the screen. The date should be specified in DD/MM/YYYY format in curly brackets. EXAMPLE DoCmd ("GAP.PREDSNAPSHOT. LOAD({01/01/2010})") Unloads prediction snapshot and returns original system settings that were specified before the predictions run. EXAMPLE DoCmd ("GAP.PREDSNAPSHOT. LOAD("Original")") Unloads prediction snapshot and returns original system settings that were specified before the predictions run. EXAMPLE DoCmd ("GAP.PREDSNAPSHOT. UNLOAD()")
Model Level Functions MOD[i].CopyControls(from, to, SkipFNAs Copy any column of the equipment control ) screen into another column of this screen. MOD[i].ResetControls(column) Resets any column of the equipment control screen. MOD[i].RESETSCHEDULE (type, Resets any scheduling associated with the equiptype) element specified. MOD[i]..VALIDATE (solverorpred) Validates the specified model input dataset. Node Level Functions GROUP[i].ADDMEMBER (equip) GROUP[i].REMOVEALLMEMBERS () GROUP[i].REMOVEMEMBER (equip) EQUIP[i].ADDTOGROUP (group) EQUIP[i].BYPASS () EQUIP[i].DISABLE () EQUIP[i].ENABLE () EQUIP[i].IsMemberOfGroup (group) EQUIP[i].MASK ()
Adds the equipment specified to the group considered Removes all the members from the group considered. Removes the equipment specified from the group considered Adds the node considered to the group specified. Bypasses the node considered. Disables the node considered. Enables the node considered. Checks if the equipment considered is a member of the group specified. Masks the node considered.
EQUIP[i]. Deletes all the existing group memberships. REMOVEALLGROUPMEMBERSHIPS () EQUIP[i].REMOVEFROMGROUP Removes the node considered from the (group) group specified. EQUIP[i].UNBYPASS () Unbypasses the node considered. EQUIP[i].UNMASK () Unmasks the node considered. EQUIP[i].VALIDATE () Validates the node considered. TANK[i].CalcDCTankCurPres(CurProd) Calculates the Current Pressure for the tank based on the Current Production specified. This is for Decline Curve Tanks only. Pipe Environment Parameters Pipeline Correlation Matching Calculation (DoCmd) GAP.MOD[{PROD}].PIPE[0].DOMATCH Matches the available pipeline test to () selected correlations
Matches the available coning data in the selected IPR. Disables the selected IPR. Enables the selected IPR. Matches the available IPR dataset. Masks the specified IPR. Unmasks the specified IPR. Validates the ipr considered.
Remark : All the arguments referring to a system node or element and referred as tag in the following descriptions will be expressed using the following syntax: MOD[i].EQUIP[j] Where the index i refers to the index or label (between {}) of the model considered and the index j refers to the index or label (between {}) of the well considered. Remark 2: Some of the functions include calculation processes that require the input of associated variables. The variables associated with the functions can be setup using the classic DoSet syntax. These calculation processes will as well output results through output associated variables. The value of these can be retrieved using a classic DoGet syntax. DoSet “GAP.MOD[i].EQUIP[j].k”, value
OpenServer User's Manual
GAP and the OpenServer
102
DoGet “GAP.MOD[i].EQUIP[j].k” Where the index i refers to the index or label (between {}) of the model considered, the index j refers to the index or label (between {}) of the node considered and the index k refers to the GAP function associated variable considered. The value refers to the value of this associated variable.
4.2.2 CALCCOMPDP (comp) / CALCPUMPDP (pump) ARGUMENTS comp / pump – Refers to the compressor / pump tag. DESCRIPTION and FUNCTION RETURN This function calculates the outlet conditions of the pump given the inlet conditions specified in a set of global variables, as described below. If the calculation succeeds, the function returns 0. If it fails, the function returns a negative number. ASSOCIATED VARIABLES Input Data Variable CPDH2S CPDCO2 CPDN2
Description Mole percentage of H2S. Mole percentage of CO2. Mole percentage of N2.
Gas gravity. Inlet pressure. Inlet temperature. Oil gravity. Inlet gas rate expressed at standard conditions. Inlet oil rate expressed at standard conditions. Inlet water rate expressed at standard conditions. Water Salinity.
Output Data Variable CPDEFF CPDFLUIDPWR CPDGFRC CPDHEAD
Inlet rate (compressors). Average throughput rate (pumps). Liquid fraction (compressors). Outlet pressure. Outlet temperature. Total power required.
Intermediate Stage Data Stage results are given in an array described below. In GAP, a stage consists of a cooler (compressors only), a separator and finally the pump or compressor unit. Cooling and separation can be set up after the final pump or compressor unit, and the results of these are found in the CPDSTGRES [n] array, where n is the number of stages Variable CPDSTGRES[0][j] CPDSTGRES[1][j] CPDSTGRES[2][j] CPDSTGRES[3][j] CPDSTGRES[4][j] CPDSTGRES[5][j] CPDSTGRES[6][j] CPDSTGRES[7][j] CPDSTGRES[8][j] CPDSTGRES[9][j] CPDSTGRES[10][j] CPDSTGRES[11][j] CPDSTGRES[12][j] CPDSTGRES[13][j]
4.2.3 CALCPIPEDP(pipe) ARGUMENTS Pipe – Refers to the pipe tag.
OpenServer User's Manual
Description Pressure at inlet of stage j. Temperature at inlet of stage j. Temperature at outlet of cooler stage j (compressor). Oil rate at inlet of stage j. Gas rate at inlet of stage j. Water rate at inlet of stage j. Average throughput rate (pumps), Inlet throughput rate (compressors). Head generated by stage j. Power required by stage j. Efficiency of stage j. Gas fraction (pumps) Liquid fraction (compressors). Oil rate after separation for stage j. Gas rate after separation for stage j. Water rate after separation for stage j.
GAP and the OpenServer
104
DESCRIPTION and FUNCTION RETURN This function calculates the pressure drop in the pipe given the upstream conditions specified in a set of global variables described below. If the calculation succeeds, the function returns 0. If it fails, the function returns a negative number. ASSOCIATED VARIABLES Input Data Variable PIPH2S PIPCO2 PIPN2
Description Mole percentage of H2S. Mole percentage of CO2. Mole percentage of N2.
Gas gravity. GOR. Injected gas rate. Oil gravity. Upstream pressure. Liquid rate expressed at standard conditions. Upstream temperature. Water cut. Water salinity.
The associated variables require a syntax as shown in the following examples: cells(1,1) = DoGet ("GAP.PIPH2S(MOD[i].PIPE[j])") DoSet ("GAP.PIPGOR(MOD[0].PIPE[{P1}])"), cells (2,1) where the index i refers to the index or label (between {}) of the model considered, the index j refers to the index or label (between {}) of the equipment considered.
4.2.4 COPYITEM( EquipDest, EquipSrc ) ARGUMENTS EquipDest – Refers to the tag of the destination node EquipSrc – Refers to the tag of the source node DESCRIPTION and FUNCTION RETURN This function copies data from a source node to a destination node. This is only allowed between nodes of the same type. The function, if successful, returns the index of EquipDest in the EQUIP list. The function can only be used if the destination equipment already exists in the network. To create a new equipment, the 'NEWITEM' command must be used (see section 5.2.9). EXAMPLE An example of its use in a system with a well labeled ‘w1’, the contents of which we wish to copy to a well labeled ‘newwell’, would be: CPYIND = DoGAPFunc(“GAP.COPYITEM(MOD[0].WELL [{newwell}], MOD[0].WELL[{w1}])”)
4.2.5 DELITEM (node) ARGUMENTS node – Refers to the tag of the node to be deleted DESCRIPTION This function deletes the specified node from the system. EXAMPLE An example of its use in a system with a well labelled ‘w1’ would be – DoGAPFunc “GAP.DELITEM(MOD[0].WELL[{w1}])”
4.2.6 ISMEMBEROFGROUP(Group) ARGUMENTS Group - Refers to the OpenServer string defining the group considered. DESCRIPTION This function enables to check if a specific element of the GAP network belongs to the group considered. OpenServer User's Manual
GAP and the OpenServer
106
The function will return 0 if the element consider does not belong to the group considered, and 1 if the element considered belongs to the group considered. EXAMPLE The example below will enable to check whether the well W1 belongs to the group Group1: DoCmd ("GAP.MOD[{PROD}].WELL[{W1}].ISMEMBEROFGROUP(MOD [{PROD}].GROUP[{Group1}])
4.2.7 LINKITEMS ( equip1, equip2, linklabel ) ARGUMENTS equip1 – Refers to the tag of the first node considered equip 2 – Refers to the tag of the second node considered linklabel (optional) – Refers to the label associated to the link created (if applicable). Needs to be specified in between quotes. DESCRIPTION This function links two items within a GAP model. If the two items are a joint and another joint, or a joint and a separator, then a pipe node will be created in order to link them, and in these cases the optional label linklabel, if supplied, will be used as the pipe label. EXAMPLE For instance, the following command will create a link between the joint J1 and the separator Sep1DoCmd ("GAP.LINKITEMS(MOD[0].JOINT[{J1}],MOD[0].SEP[{Sep1}])")
4.2.8 NEWFILE( ) ARGUMENTS None DESCRIPTION This function clears any currently loaded GAP model. Care should be taken with this function, since no check is made of whether the currently loaded model has changed and requires saving. EXAMPLE DoGAPFunc ("GAP.NEWFILE()")
The string will be one of "WELL", "PIPE", "TANK", "SEP", "PUMP", "COMP", "JOINT", "SOURCE", "SINK", "VALVE", "INLSEP", "INLCHK", "INLINJ", "INLGEN", "GROUP", "INFLOW". label – A string giving the label of the new node. The string should be specified in between quotes. iposcode (optional) – A string giving the direction a node will be displaced relative to the reference node. The string will be one of “RIGHT”, “LEFT”, “ABOVE” or “BELOW”. The default value is set to “RIGHT”. equip (optional) – The tag of a node in the system to use as the reference node. The reference node is used to calculate the position of the new node. The default value is set to “NULL”. model (optional) – The tag of the system in which the new item is to be created. The default value is set to MOD[0]. DESCRIPTION This function creates a new node in the system specified. Nodes will always be positioned such that they do not intersect each other. EXAMPLE To create a new well labeled “Well1” in the currently loaded production system located at the right of the Separator node, the following syntax could be used – DoGAPFunc “GAP.NEWITEM (""WELL"", ""Well1"", ""RIGHT"", MOD[0]. EQUIP[{Separator}])”
4.2.9.1 Working with Flowsheets The followig instructions can be used to create and define a Flowsheet in GAP using OpenServer: To create an element in a Flowsheet, in general: DoCmd GAP.NEWITEM( type, label, [iPosCode=RIGHT], [node=NULL], [model=MOD[0]], [flowsheet=MOD[0].FLOWSHEET[{xxx}]] ) type can be: EQUIP WELL PIPE TANK OpenServer User's Manual
GAP and the OpenServer
108
SEP PUMP COMP JOINT SOURCE SINK VALVE INLSEP INLCHK INLINJ INLGEN COMPLETION GROUP INFLOW FLOWSHEET Flowsheet Example: Create a Flowsheet in the main GAP model: DoCmd GAP.NEWITEM( "FLOWSHEET", "FlowS1", RIGHT, NULL, MOD[0]) Create a joint in the flowsheet: DoCmd GAP.NEWITEM( "JOINT", "Port1", RIGHT, MOD[0].FLOWSHEET [{FlowS1}], MOD[0], MOD[0].FLOWSHEET[{FlowS1}]) To define a joint as a flowsheet port: DoCmd GAP.MOD[{PROD}].JOINT[{Port1}].SetFlowsheetPort() To turn a port back to a normal joint: DoCmd GAP.MOD[{PROD}].JOINT[{Port1}].ClearFlowsheetPort() The following flag can be used to determine whther a joint is a flowsheet port: DoGet GAP.MOD[{PROD}].JOINT[{Port1}].IsFlowsheetPort()
DoGAPFunc (“GAP.OPENFILE ("”C:/Simple_Model/Simple.GAP”")”) Alternatively, an Excel spreadsheet located file can be opened using the following syntax: DoCmd ("GAP.OPENFILE(""" + Range("a4") + """)")
4.2.11 PCCALC (equip, PcCurve) ARGUMENTS equip – Refers to the tag of the node considered, other than a tank node. PcCurve – Specifies which type of performance curve is to be used. Can be specified using one of the following keywords: "QOIL", "QGAS", "QLIQ", "OG", "GG", "FBHP", "TEMP", "H2S", "CO2", "N2", "WSAL", "GIBACK", “OPTFUN”. DESCRIPTION and FUNCTION RETURN GAP builds performance curves for nodes in the system. This function allows access to these curves. The input conditions are set up in global variables described in the following section, then the function is called to calculate the answer. The function returns 0 if the calculation has been successful, and a negative number if not. Input Data Variable PCCGASINJ PCCMANIPRES
Description In a gas lifted system, specifies the gas injected. The manifold pressure.
Output Data
Variable PCCANS PCCDANSDG
Description The calculated quantity. In a gas lifted system, the derivative of the calculated quantity with respect to gas injected.
The Input and Output Data parameters are global variables, and hence do not require the equipment to be identified when using these variables. An Example for this is given below. EXAMPLE An example of its use with a gas lifted well labeled ‘w1’ would be –
OpenServer User's Manual
GAP and the OpenServer
110
REM Set up the input variables in the well considered
DoSet “GAP.PCCMANIPRES” , 500 DoSet “GAP.PCCGASINJ” , 1 REM Perform the calculation
DoGAPFunc “GAP.PCCALC(MOD[0].WELL[{w1}],””QLIQ””)” REM Obtain the output values
ANS = DoGet(“GAP.PCCANS”) DER = DoGet(“GAP.PCCDANSDG”)
4.2.12 PCGMAX (equip, PcCurve) ARGUMENTS equip – Refers to the tag of the node considered, other than a tank node. PcCurve – Specifies which type of performance curve is to be used. Can be specified using one of the following keywords: "QOIL", "QGAS", "QLIQ", "OG", "GG", "FBHP", "TEMP", "H2S", "CO2", "N2", "WSAL", "GIBACK", “OPTFUN”. DESCRIPTION and FUNCTION RETURN This function is used in a gaslifted system to calculate the maximum gaslift for a particular performance curve at a specified manifold pressure. The input conditions are set up in global variables (see below), then the function is called to calculate the answer. The function returns 0 if successful, and a negative number if not. Input Data
Variable PCOPTMANIPRES
Description The manifold pressure.
Output Data
Variable PCOPTGINJ PCOPTVAL
Description The calculated optimum gas injection. The calculated quantity at optimum gas injection.
The Input and Output Data parameters are global variables, and hence do not require the equipment to be identified when using these variables. An Example for this is given for the PCCALC command.
Can be specified using one of the following keywords: "QOIL", "QGAS", "QLIQ", "OG", "GG", "FBHP", "TEMP", "H2S", "CO2", "N2", "WSAL", "GIBACK", “OPTFUN”. DESCRIPTION and FUNCTION RETURN This function is used in a gas lifted system to calculate the gas lift required to meet a target value for a particular performance curve at a specified manifold pressure. The input conditions are set up in global variables (see below), then the function is called to calculate the answer. The function returns 0 if successful, and a negative number if not. ASSOCIATED VARIABLES Input Data
Variable PCSOLVMANIPRES PCSOLVTARGVAL
Description The manifold pressure. The target quantity.
Output Data
Variable PCSOLVGASINJ
Description The calculated gas injection required. The value in this variable on input is used as a starting value.
The Input and Output Data parameters are global variables, and hence do not require the equipment to be identified when using these variables. An Example for this is given for the PCCALC command.
4.2.14 PCPSOLV (equip, PcCurve) ARGUMENTS equip – Refers to the tag of the node considered, other than a tank node. PcCurve – Specifies which type of performance curve is to be used. Can be specified using one of the following keywords: "QOIL", "QGAS", "QLIQ", "OG", "GG", "FBHP", "TEMP", "H2S", "CO2", "N2", "WSAL", "GIBACK", “OPTFUN”. DESCRIPTION and FUNCTION RETURN This function is used to calculate the manifold pressure required to meet a target value for a particular performance curve (in gaslifted systems, at a specified gas injection). The input conditions are set up in global variables (see below), then the function is called to calculate the answer. OpenServer User's Manual
GAP and the OpenServer
112
The function returns 0 if successful, and a negative number if not. Input Data
Variable PCSOLVGASINJ PCSOLVTARGVAL
Description The gas injection. In a non gaslifted node, this value is ignored. The target quantity.
Output Data
Variable PCSOLVMANIPRES
Description The calculated manifold pressure. On input, the value in this variable is used as a starting value.
The Input and Output Data parameters are global variables, and hence do not require the equipment to be identified when using these variables. An Example for this is given for the PCCALC command.
Firstly, it totals up the production and injection volumes from the previous timestep and uses these to calculate the tank pressures for the current time-step. Secondly, it calculates the network performance using a solve network calculation along with the current tank pressures and flowing conditions. It then obtain the production rates for the wells included in the system. It then calculates the ideal injection required, based on voidage replacement conditions, etc. If associated injection systems are present, these ideal injection requirements are used as constraints, and the injection systems are built and allocated to obtain the actual injection volumes. When each PREDDOSTEP() call is finished, GAP is left in a state where it can respond to any set of OpenServer commands. This allows a large amount of flexibility, since virtually any action can be performed at each timestep. This can range from customized scheduling through to running GAP in conjunction with a facilities simulator at each timestep. EXAMPLE The following example performs the prediction set up in the GAP file, and on the timestep 01/03/1980 alters the PI of the first layer of well ‘w1’ to 15. At the end of the prediction run it saves the GAP file. REM Set up prediction NSTEPS = DoGAPFunc “GAP.PREDINIT()” For I = 1 To NSTEPS REM Do production prediction step RVAL = DoGAPFunc “GAP.PREDDOSTEP()” REM Check return code – should be 1 if step OK If (RVAL <> 1) Then Exit For End If If ( DoGet ("GAP.PREDCURDATE.DATESTR") = "01/03/1980") Then DoSet "GAP.MOD[0].WELL[{w1}].IPR[0].PI", 15 End If Next DoGAPFunc “GAP.PREDEND()” DoGAPFunc “GAP.SAVEFILE( “”C:\SAMPLES\PREDRUN1.GAP”” )”
4.2.16 PREDDOSOLVER (timestepsize, optimise, potential, model) ARGUMENTS Timestepsize – Should always be set to 0 OpenServer User's Manual
GAP and the OpenServer
114
optimise (optional) – Refers to the status of the optimiser when the prediction timestep is performed. The following options are available: -1 – GAP uses the optimisation mode and potential calculation settings saved in the file 0 – No Optimisation 1 – Optimise and Honour Constraints 2 – Optimise, No constraints The default value is set to optimise and honour constraints. potential (optional) – Refers to the status of the network potential calculation. The following options are available: 0 – No potential calculation 1 – Potential calculation The default value is set to no potential calculation. model (optional) – Refers to the tag of the model considered (i.e. production / water injection / gas injection). The default considers the production system. DESCRIPTION This function performs a solve network calculation in predictive mode without moving forward of one prediction step. It enables to run solve network sensitivities at a specific point during the prediction.
The following options are available: 0 – No potential calculation 1 – Potential calculation The default value is set to no potential calculation. DESCRIPTION This functions ends the prediction run. See discussion of PREDDOSTEP(), in the previous section.
4.2.18 PREDINIT (ignore internal timestep, ignore internal scheduling) ARGUMENTS ignore internal timestep (optional) – Enables to specify whether the GAP internal timesteps are ignored or not (i.e. mainly used when the GAP / RESOLVE coupling is used). The following values are possible:
0 – Do not ignore internal timesteps 1 – Ignore internal timesteps The default value is set to 0. Ignore internal scheduling (optional) - Enables to specify whether the GAP internal scheduling events are ignored or not (i.e. mainly used when the GAP / RESOLVE coupling is used). The following values are possible:
0 – Do not ignore internal scheduling events 1 – Ignore internal scheduling events The default value is set to 0.
DESCRIPTION This functions establishes all the setup required for a prediction run, i.e. the MBAL tanks are loaded, the well models are initialized, etc. This process leads to the calculation of the number of timestep required in the prediction run. Example: NumSteps = DoGAPFunc("GAP.PREDINIT()") 'Initialises the GAP Prediction and returns the total number of prediction steps NOTE Using of the command will initialize the prediction and define the number of steps required to perform the prediction. The number of step is defined according to Prediction Start, Prediction End and Step Size.
OpenServer User's Manual
GAP and the OpenServer
116
The prediction is run through the loop on a step by step basis. In this case GAP is driven by external application and completes the full number of prediction steps; the System Abandonment Constraints will be ignored. The full prediction run will be accomplished even if macro exits the loop and executes the GAP.PREDEND() command.
4.2.19 PURGEALLRESULTS (model) ARGUMENTS model (optional) – Refers to the tag of the model considered (i.e. production / water injection / gas injection). The model considered by default is the production system. DESCRIPTION This function purges all results saved in the model currently considered.
4.2.20 PURGEPREDLOG (model) ARGUMENTS model (optional) – Refers to the tag of the model considered (i.e. production / water injection / gas injection). The model considered by default is the production system. DESCRIPTION This function purges the prediction log of the model currently considered.
injection / gas injection). The model considerered by default is the production system. DESCRIPTION This function purges the prediction results saved in the model currently considered.
4.2.22 PURGEPREDSNAPSHOT (model) ARGUMENTS model (optional) – Refers to the tag of the model considered (i.e. production / water injection / gas injection). The model considered by default is the production system. DESCRIPTION This function purges the prediction snapshots saved in the model currently considered.
4.2.23 PURGESOLVERLOG (model) ARGUMENTS model (optional) – Refers to the tag of the model considered (i.e. production / water injection / gas injection). The model considered by default is the production system. DESCRIPTION This function purges the solver log of the model currently considered.
4.2.24 PURGESOLVERRESULTS (model) ARGUMENTS model (optional) – Refers to the tag of the model considered (i.e. production / water injection / gas injection). The model considered by default is the production system. DESCRIPTION This function purges the solver results saved in the model currently considered.
well – Refers to the tag of the well considered in the currently loaded model. DESCRIPTION This function calculates a set of performance curves for the well based on the input performance curve data. For example, the syntax if we would like to do a refit on a well with the name "well 2" would be: DoCmd("GAP.REFITPC(GAP.MOD[{PROD}].WELL[{WELL 2}])")
4.2.26 RESETSOLVERINPUTS () ARGUMENTS None DESCRIPTION This function resets any previously entered solver inout data (i.e. separator pressure, injection manifold pressure, gas lift gas available).
4.2.27 SAVEFILE( filename ) ARGUMENTS filename – Refers to the fully qualified (i.e. path included) file name to open. DESCRIPTION This function saves the currently loaded GAP model to the file specified. It should be used with caution since the file will overwrite a file of the same name if it exists. EXAMPLE To save a GAP file labelled “Simple.GAP” and located in the folder “Simple_Model” in the C: drive, the following syntax can be used – DoGAPFunc “GAP.SAVEFILE (""C:/Simple_Model/Simple.GAP"")”
0 – Do not save the GAP file 1 – Automatically save the GAP file if it has been modified. The default value is 1. DESCRIPTION This function closes down GAP.
4.2.29 SOLVENETWORK() ARGUMENTS optimise (optional) – Refers to the status of the solver when the calculation is performed. The following options are available: -1 – GAP uses the optimisation mode and potential calculation settings saved in the file 0 – No Optimisation 1 – Optimise and Honour Constraints 2 – Optimise, No constraints The default value is set to optimise and honour constraints. model (optional) – Refers to the tag of the model considered (i.e. production / water injection / gas injection). The default considers the production system. potential (optional) – Refers to the status of the network potential calculation. The following options are available: 0 – No potential calculation 1 – Potential calculation The default value is set to no potential calculation. DESCRIPTION This function performs a solver calculation within GAP. EXAMPLE This example assumes a naturally flowing system with two separators labeled ‘s1’ and ‘s2’ is loaded in GAP – REM Reset any previously set allocate pressures. DoGAPFunc “GAP.RESETALLOCINPUTS()” REM Set separators to desired allocate pressures. DoSet “GAP.MOD[0].SEP[{s1}].SOLVERPRES[0]”, 200 DoSet “GAP.MOD[0].SEP[{s2}].SOLVERPRES[0]”, 300 REM Set up constraints OpenServer User's Manual
GAP and the OpenServer
120
DoSet “GAP.MOD[0].MAXGAS”, 50 DoSet “GAP.MOD[0].SEP[{s1}].MAXQWAT”, 12000 REM Perform Allocation DoGAPFunc “GAP.SOLVENETWORK(1, MOD[0])” REM Get results QOILS1 = DoGet(“GAP.MOD[0].SEP[{s1}].SOLVERRESULTS[0]. Qoil”) QWATS2 = DoGet(“GAP.MOD[0].SEP[{s2}].SOLVERRESULTS[0]. Qwat”)
4.2.30 TRANSFERPROSPERIPR (well, layernumber, PVTMethod) ARGUMENTS well – Refers to the tag of the well or inflow node considered. layernumber (optional) – For multilayered wells, the number of the well layer to update. The valid values for this argument range from 0 to n-1. The default is set to 0 – first layer. PVTMethod (optional) – Refers to the set of PVT data used during the IPR transfer. The following options are available: 0 – Follow PROSPER File 1 – Black Oil 2 – Compositional The default value of this flag is set to 0. DESCRIPTION This function transfers the IPR from PROSPER for the well node. This is equivalent to the ‘Transfer Well IPR from PROSPER’ menu option EXAMPLE The following syntax can be used to transfer to the GAP system the PROSPER defined IPR of the well labeled “Well1” – DoGAPFunc “GAP.TRANSFERPROSPERIPR (MOD[0].WELL[{W1}])”
EXAMPLE To break the link between a well W1 and a joint J1, the following code can be used. DoGAPFunc ("GAP.UNLINKITEMS (MOD[0].JOINT[{J1}],MOD[0].WELL [{W1}])")
4.2.32 VALIDATE (solverorpred) ARGUMENTS
solverorpred (optional) – Enables to specify which input data needs to be validated. The following options are available: 0 – The input data needed for solver calculation is validated. 1 – The input data needed for prediction calculations is validated. 2 – The input data needed for both solver and prediction calculation is validated. The default value used is 2. DESCRIPTION
This functions validates all the input data needed for both solver and prediction calculations, at network level. The function returns 0 if all the model considered are valid, and a value # 0 if it is not the case.
4.2.33 VLPIMPORT (equip, filename) ARGUMENTS equip – Refers to the tag of the node considered. Here the type of node considered could be wells, outflows, pump or compressors. Filename – Refers to the the fully qualified (i.e. path included) TPD file name to open. DESCRIPTION and FUNCTION RETURN This function imports the specified file into the node, which should be a well or a pump node. If successful, it returns 1. If the function fails, it returns 0. EXAMPLE The following syntax can be used to import the lift curves .TPD file in the well labeled “W1” from the location C:\TEST DoGAPFunc “GAP.VLPIMPORT (MOD[0].WELL[{W1}], ""C:\TEST\Well1.tpd"")”
OpenServer User's Manual
GAP and the OpenServer
122
4.2.34 VLPIPRPCGEN (well, autowhp) ARGUMENTS well – Refers to the tag of the well considered. autowhp (optional) – A flag to indicate whether to use automatic wellhead pressure selection (0 – don’t use, 1 – use,). The default is 1 – use. DESCRIPTION This function generates performance curve data from the VLP and IPR data in the well node. The automatic wellhead pressure selection option does not apply to gaslifted wells. For example the following code may be used to calculate the Performance Curve for Well labelled "W2" where the Manifold Pressures used are defined by the user. For i = 0 To 19 DoSet ("GAP.MOD[{PROD}].WELL[{W2}].MANIPRES[" + CStr(i) + "]"), Cells(36 + i, 4) Next i DoGAPFunc ("GAP.VLPIPRPCGEN(MOD[0].WELL[{W2}],0)") For i = 0 To Cells(36+i, Cells(36+i, Cells(36+i, Next i
The syntax for the PACALC and the ACTUALCALC commands is as shown in the following lines. DoCmd ("GAP.WELLCALC(MOD[{PROD}].WELL[{W1}])") DoCmd ("GAP.PACALC(MOD[{PROD}].WELL[{W1}])") DoCmd ("GAP.ACTUALCALC(MOD[{PROD}].WELL[{W1}])")
4.2.36 MOD[i].CopyControls (from, to, SkipFNAs) ARGUMENTS From – Enables to specify which column is considered as the source column. The following keywords are used: “MEASURED” – Refers to the measured data column “ACTUAL” – Refers to the column containing the current data used by the solver “ESTIMATED” – Refers to the column estimated after an optimized solver run. “MINIMUM” – Refers to the minimum value column. “MAXIMUM” – Refers to the maximum value column. To – Enables to specify in which column the source column is to be copied. The same keywords that the from argument keywords are used. SkipFNAs (optional) – Enables to avoid copying the empty zones. In order to use this function, an argument value of 1 should be introduced. DESCRIPTION This function copies a chosen column of the Equipment control screen into a specified column in the same screen. An example will be to copy the Optimised column in the Actual column after a satisfactory optimised solver run for instance to use the optimised values obtained as default values for the next runs.
OpenServer User's Manual
GAP and the OpenServer
124
4.2.37 MOD[i].ResetControls (column) ARGUMENTS
column – Enables to specify which column is to be deleted. The following keywords are used: “MEASURED” – Refers to the measured data column “ACTUAL” – Refers to the column containing the current data used by the solver “ESTIMATED” – Refers to the column estimated after an optimized solver run. “MINIMUM” – Refers to the minimum value column. “MAXIMUM” – Refers to the maximum value column. DESCRIPTION
This function resets to zero the values of a specific column in the Equipment control screen.
type (optional) – Refers to the type of scheduled element to reset. The following keywords are used: “EVENT”– Refers to all the schedule events (i.e. change constraints, start and stop wells, etc…) “DCQ” – Refers to all the DCQ scheduling events equiptype (optional) – Refers to the type of equipment (i.e. “WELL”, “JOINT”, etc…) in which the scheduling needs to be reset. If the optional keywords are not used, the entire network schedule will be reset. DESCRIPTION
This function resets any scheduling data associated with the network elements specified.
This functions validates all the input data needed for both solver and prediction calculations, at model level. The function returns 0 if all the model considered are valid, and a value # 0 if it is not the case.
4.2.40 GROUPS Command GROUP[i].ADDMEMBER (equip) GROUP[i].REMOVEALLMEMBERS ()
Description "equip" refers to the tag of the equipment and the function adds the node specified to the given group This function removes all the members from the given group Use this command to remove a given piece of equipment from the group where: "equip" refers to the tag of the given piece of equipment that will be removed This function adds the node considered to the given group
Variables Description GAP.MOD.[{PROD}].GROUP[{GROUP1}]. Counts the number of connected elements to a given group member.count Returns the label of a given member where GAP.MOD.[{PROD}].GROUP[{GROUP1}]. 'i' corresponds to the given member index returned using the"GAP.MOD.[{PROD}]. member[i].label GROUP[{GROUP1}].member.count" string GAP.MOD.[{PROD}].GROUP[{GROUP1}]. Returns the "type" of equipment for the given group member index 'i' member[i].type GAP.MOD.[{PROD}].GROUP[{GROUP1}]. Returns the sequential index of the piece of equipment when it was added to the given member[i].Index GAP model Returns the label of the equipment based GAP.MOD.[{PROD}].EQUIP[i].label on the specified model index (i) value
OpenServer User's Manual
GAP and the OpenServer
126
4.2.41 EQUIP[i].ADDTOGROUP (group) ARGUMENTS
equip – Refers to the tag of the group considered. DESCRIPTION
This functions adds the node considered to the group specified.
4.2.42 EQUIP[i].BYPASS () ARGUMENTS
None. DESCRIPTION
This function bypasses the node considered. Example: To bypass a compressor called Compr1, the following command can be used: DoGAPFunc ("GAP.MOD[{PROD}].COMP[{Compr1}].bypass()")
Group – Refers to the tag of the group considered. (e.g. GAP.MOD[{PROD}].GROUP[{Group1}] for instance). DESCRIPTION
This function checks if the equipment considered is included in the group specified. ASSOCIATED VARIABLES
The function returns the following variables: - 0 if the equipment considered does not belong to the group specified. - 1 if the equipment considered does belong to the group specified.
4.2.46 EQUIP[i].MASK () ARGUMENTS
None DESCRIPTION
This function masks the node considered. See node.UNMASK for unmasking nodes. EXAMPLES
If well w1 is to be masked, the function call is: DoGAPFunc “GAP.MOD[0].WELL[{w1}].MASK()”
This function removes all the exiting group links of the considered node.
4.2.48 EQUIP[i].REMOVEFROMGROUP (group) ARGUMENTS
group – Refers to the tag of the group considered. DESCRIPTION
This functions removes the node considered of the group specified.
OpenServer User's Manual
GAP and the OpenServer
128
4.2.49 EQUIP[i].UNBYPASS () ARGUMENTS
None. DESCRIPTION
This functions un-bypasses the node considered. See node.BYPASS for bypassing nodes.
4.2.50 EQUIP[i].UNMASK () ARGUMENTS
None DESCRIPTION
This function unmasks the node considered. See node.MASK for masking nodes. EXAMPLE
If well w1 is to be unmasked, the function call is: DoGAPFunc “GAP.MOD[0].WELL[{w1}].UNMASK()”
4.2.51 EQUIP[i].VALIDATE (solverorpred) ARGUMENTS
solverorpred (optional) – Enables to specify which input data needs to be validated. The following options are available: 0 – The input data needed for solver calculation is validated. 1 – The input data needed for prediction calculations is validated. 2 – The input data needed for both solver and prediction calculation is validated. The default value used is 2. DESCRIPTION
This functions validates all the input data needed for both solver and prediction calculations, at node level. The function returns 0 if the model considered is valid, and a value # 0 if it is not the case.
4.2.52 TANK[i].CalcDCTankCurPres(CurProd) Calculates the Current Pressure for the tank based on the Current Production specified. This is for Decline Curve Tanks only. The CURPROD must be replaced by the value of the Current Production for which the calculations need to be performed.
for eg: DoCmd ("GAP.MOD[{PROD}].TANK[{T1}].CalcDCTankCurPres(1.22501)") This command will perform the calculation for the calculation for the Current Reservoir Pressure based upon the value of the Current Production specified in the string. in the above example the calculation is being performed to determine the pressure when the cumulative production is 1.22501 units. This command can be used in combination with DoGet("GAP.MOD[{PROD}].TANK [{T1}].TCURRESPRED") to obtain the Current Pressure.
4.2.53 PIPE[i].DOMATCH () ARGUMENTS
None DESCRIPTION
This function matches the available pipeline test data.
4.2.54 IPR[i].CONINGMATCH () ARGUMENTS None DESCRIPTION This function matches the available coning data in the selected IPR.
4.2.55 IPR[i].DISABLE () ARGUMENTS None DESCRIPTION This function disables the ipr considered. See ipr.ENABLE for enabling nodes. EXAMPLE To disable the Layer 1 of well W1 the following code can be used. DoCmd ("GAP.MOD[0].WELL[{W1}].IPR[0].DISABLE()") OpenServer User's Manual
GAP and the OpenServer
130
4.2.56 IPR[i].ENABLE () ARGUMENTS None DESCRIPTION This function enables the ipr considered. See ipr.DISABLE for disabling nodes. EXAMPLE To disable the Layer 2 of well W1 the following code can be used. DoCmd ("GAP.MOD[0].WELL[{W1}].IPR[1].ENABLE()")
4.2.57 IPR[i].IPRMATCH () ARGUMENTS None DESCRIPTION This function matches the available ipr dataset.
4.2.58 IPR[i].MASK () ARGUMENTS None DESCRIPTION This function masks the ipr considered.
4.2.59 IPR[i].UNMASK () ARGUMENTS None DESCRIPTION This function unmasks the ipr considered.
4.2.60 IPR[i].VALIDATE (solverorpred) ARGUMENTS solverorpred (optional) – Enables to specify which input data needs to be validated. The following options are available: 0 – The input data needed for solver calculation is validated. 1 – The input data needed for prediction calculations is validated. 2 – The input data needed for both solver and prediction calculation is validated. The default value used is 2. DESCRIPTION This functions validates all the input data needed for both solver and prediction calculations, at ipr level. The function returns 0 if the ipr considered is valid, and a value # 0 if it is not the case.
4.3
GAP Internal Script It is possible to control GAP models externally using Visula Basic applications. An internal GAP scripting procedure is also available. The script actions can be included at diverse levels within the prediction process. The workflow below illustrates the succession of actions that GAP follows during a prediction process, and illustrates at which stage the different sections of the GAP internal scripting are taken into account. Build systems () For (each system) Script.DoPredProlog (system) Run tank history simulation to start of prediction () For (each prediction timestep) {
OpenServer User's Manual
GAP and the OpenServer
132
do { redo = false For (each system) Script.DoPredStepProlog (system) Apply schedule for the current timestep () Refresh IPRs from tank () Apply abandonment constraints () Refit performance curves (for PC wells only) For (each system) { Script.DoPredStepSolverProlog (system) Solve Network () Script.DoPredStepSolverEpilog (system) If (system = production) then Set injection rate constraints of injection systems () } For (each system) Script.DoPredStepEpilog (system) } while (redo = true) Run tank model timestep () Save prediction step results () If (requested) Save prediction step snapshot () } For (each system) Script.DoPredEpilog (system) Destroy systems () For more information using GAP script, please see Section 12 of the GAP User Guide.
MBAL and the OpenServer This section describes MBAL's OpenServer options. As will all the IPM suite of tools, the easiest way to capture any input and output field OpenServer tag is using the Ctrl + Right-Click keyboard and mouse workflow. For reference, all available variables are listed in the Variable Text String section of the guide. A tool description is also provided, however, it is recommended to use the above Ctrl + Right-Click keyboard and mouse action to capture the requried input (or output) variable OpenServer tag. It is important to note that it is not possible to capture the OpenServer tag for a calculation button using the Ctrl + Right-Click keyboard and mouse workflow. A list of all corresponding DoCmd functions are listed in the Command section of the guide. Use of the DoSet and DoGet functions for variables which can take a value from a predefined list e.g. oil, water or gas will also be discussed and Unit handling using the DoSet and DoGet calls.
5.1
Finding a Variable Text String MBAL (and all IPM tools) has a very quick and easy method for finding the text string for a particular variable. First start the MBAL program. Open the sample file OIL.MBI. Open the tank dialog by selecting Input – Tank Data. Suppose the objective is to find the OpenServer variable string for the porosity. This can be achieved using the Ctrl + Right-Click keyboard and mouse workflow in the porosity input. Completing the above workflow should display a dialog box similar to that shown below:
This dialog displays the text string for the porosity variable. This can be used in the GetValue and SetValue functions. The Copy button can be used to copy the text string to the clipboard so it can then be pasted into the VBA macro or batch file.
5.2
Date Handling within MBAL By default, the dates in MBAL uses date in DD/MM/YYYY format. As soon as a TIME OpenServer keyword is used, it will refer to that type of numerical format. NOTE: When the date is retrieved from MBAL into the Excel spreadsheet using TIME keyword, Excel uses its internal conversion to translate the date. This some times lead to erroneous date representation in Excel; more specifically day and month numbers can be flipped (MM/DD/YYYY would be seen in Excel). To avoid this CDate() VBA command can be used for date conversion prior to passing the data to Excel.
5.3
Commands This section describes the possible calculations and other functions that can be called in MBAL using the DoCmd function. The following are a list of those functions and the text strings used to call them. Any commands beginning with MBAL.MB can only be used if the material balance tool is selected, where the 'MB' portion of the string indicates the material balance tool is being used.
OpenServer User's Manual
MBAL and the OpenServer
136
5.3.1 General MBAL.ChangeTool=MB Change to the material balance tool MBAL.ChangeTool=MC Change to the Monte Carlo tool MBAL.ChangeTool=DC Change to the decline curve tool MBAL.ChangeTool=1D Change to the 1D tool MBAL.ChangeTool=ML Change to the multi-layer tool MBAL.ChangeTool=TG Change to the tight gas model MBAL.OpenFile Open an MBAL file Example: DoCmd ("MBAL.OpenFile(C:\Test\Oil.MBI") for a macro based file path DoCmd ("MBAL.OPENFILE=" + Range("a3")) for a spreadsheet based file path, and: DoCmd ("MBAL.OPENFILE(""" + Range("a3") + """)") for a spreadsheet based file path MBAL.SaveFile Saves an MBAL file MBAL.NewFile Resets all the input data and is equivalent to the menu item File New
MBAL.MB.IMPORTTPD(MBAL.MB.PREDWELL[0],”C:\OIL1.TPD”) MBAL.MB.IMPORTMBV(,””) Imports the specified MBV file into the specified well e.g.:MBAL.MB.IMPORTMBV(MBAL.MB.PREDWELL[0],”C:\OIL1.MBV”) MBAL.MB.ALLOCTANKPRESSRATE() Calculates the tank production history pressure and rate from the entered well production history. Equivalent to using the Calc button on the tank production history input dialog. e.g.:MBAL.MB.ALLOCTANKPRESSRATE(MBAL.MB.TANK[1]) MBAL.MB.ALLOCTANKRATEONLY() Calculates the tank production history rate only from the entered well production history. Equivalent to using the Calc Rate button on the tank production history input dialog. e. g.:MBAL.MB.ALLOCTANKRATEONLY(MBAL.MB.TANK[1]) MBAL.MB.RESETREGRESSTANKHIST() Resets the inputs to the history matching regression for the specified tank. It will reset the start values for each regression parameter to the current stored value. This is equivalent to clicking the Reset button in the regression input dialog. e.g.:MBAL.MB.RESETREGRESSTANKHIST(MBAL.MB.TANK[{TankLabel}]) MBAL.MB.REGRESSTANKHIST() Performs the history matching regression for the for the specified tank. e.g.:MBAL.MB.REGRESSTANKHIST(MBAL.MB.TANK[1]) There are several commands that can be used to build models from scratch. Their use is demonstrated in the sample spreadsheet BUILD MODEL.XLS. MBAL.MB.VALIDATE It is possible to create new tanks, wells etc using the Open Server. It is also possible to populate the tank, well etc with the various items of data. However normally the object will be marked as invalid (shown as red on the MBAL interface) until the user enters the appropriate dialog. This functions will autmatically validate all the objects in the material balance tool without having to enter each of the dialogs. MBAL.MB.LINKITEMS(