• No results found

Working with Flowsheets

In document OpenServer Complete (Page 118-133)

4 GAP and the OpenServer

ARGUMENTS None

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

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()

4.2.10 OPENFILE( filename )

ARGUMENTS

filename – Refers to the fully qualified (i.e. path included) file name to open.

DESCRIPTION

This function opens the GAP file specified. It should be used with caution since the file will replace the currently loaded file, whether or not the currently loaded file needs saving.

EXAMPLE

To open 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.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 Description

PCCGASINJ In a gas lifted system, specifies the gas injected.

PCCMANIPRES The manifold pressure.

Output Data

Variable Description

PCCANS The calculated quantity.

PCCDANSDG 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 –

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 Description

PCOPTMANIPRES The manifold pressure.

Output Data

Variable Description

PCOPTGINJ The calculated optimum gas injection.

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

4.2.13 PCGSOLV (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 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 Description

PCSOLVMANIPRES The manifold pressure.

PCSOLVTARGVAL The target quantity.

Output Data

Variable Description

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

The function returns 0 if successful, and a negative number if not.

Input Data

Variable Description

PCSOLVGASINJ The gas injection. In a non gaslifted node, this value is ignored.

PCSOLVTARGVAL The target quantity.

Output Data

Variable Description

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

4.2.15 PREDDOSTEP (optimise, potential)

ARGUMENTS

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.

DESCRIPTION

This function, together with PREDINIT() and PREDEND(), allows step by step predictions to be performed.

PREDINIT() performs all the setup required for a prediction run, i.e. the MBAL tanks are loaded, the well models are initialized, etc. and PREDEND() is called to end the prediction run. For details regarding these functions, see their associated sections.

PREDDOSTEP() is called once for each timestep in the prediction run.

The function performs two main tasks.

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 time-step 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

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.

4.2.17 PREDEND(dorest, optimise, potential)

ARGUMENTS

dorest (optional) – Refers to the time-step at which the prediction run ends.

The following options are available:

0 – The prediction forecast is ended as soon as the the function is called.

1 – The prediction forecast is ended at the end of the defined prediction schedule.

The default value is set to 1.

optimise (optional) – Refers to the status of the optimiser when the prediction time-step 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.

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.

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.

4.2.21 PURGEPREDRESULTS (model)

ARGUMENTS

model (optional) – Refers to the tag of the model considered (i.e. production / water

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.

4.2.25 REFITPC(well)

ARGUMENTS

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"")”

4.2.28 SHUTDOWN (save)

ARGUMENTS

save – Enables to specify whether the file needs to be saved before closing down GAP

or not.

The following values are possible:

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

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}])”

4.2.31 UNLINKITEMS (equip1, equip2)

ARGUMENTS

equip1 – Refers to the tag of the first node considered.

equip2 (optional) – Refers to the tag of the first node considered.

DESCRIPTION

This function deletes the link between the first node and second node (if one exists). If only the first node is specified, then the link between that node and its parent node is deleted.

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"")”

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 19

Cells(36+i, 6) = DoGet("GAP.MOD[{PROD}].WELL[{W2}].PCDATA[0][0]["+ CStr(i)+"]") Cells(36+i, 7) = DoGet("GAP.MOD[{PROD}].WELL[{W2}].PCDATA[0][1]["+ CStr(i)+"]") Cells(36+i, 8) = DoGet("GAP.MOD[{PROD}].WELL[{W2}].PCDATA[0][2]["+ CStr(i)+"]") Next i

4.2.35 WELLCALC (well)

ARGUMENTS

well – Refers to the well tag in the currently loaded model.

The structure used to define this argument will be as follow: MOD[i].WELL[j]

Where the index i refers to the index or label of the model considered and the index j refers to the index or label (i.e. between {}) of the well considered.

DESCRIPTION

This function performs the same calculation than the GAP Model Validation screen.

The WELLCALC(well) command performs the same task as the PACALC(well) command and the ACTUALCALC(well) command. Thus all these three commands will perform the VLP/IPR validation in the GAP model.

the following example shows the use of the WELLCALC(well) option.

In document OpenServer Complete (Page 118-133)