Sunteți pe pagina 1din 73

Landmark Graphics Corporation

User Programming

Building Algorithms with MathPack

Overview
Using MathPack
PetroWorks comes with a wide range of algorithms; from simple data
conversion, to standard porosity and fluid saturation calculations, to
complex processes for the simultaneous estimation of lithology,
porosity, and fluid saturation. Those algorithms reside in a variety of
applications under the PetroWorks Command Menu items of Data
Prep, PreInterp, and Interpret. In some cases, however, those prepackaged algorithms may not meet your specific needs.
MathPack provides an easy way for you to quickly create the
algorithms that will meet your needs in specific interpretive situations.
Remember that if you have very complex processing needs
(simultaneously accessing multiple depths, complex looping and
branching, or creating a process that can be securely distributed to
colleagues), you should also consider ModelBuilder as another
application in which to build your algorithms.

About this Version of MathPack


This version of PetroWorks introduces a MathPack which has been
extensively reworked. While the interface is almost identical to older
MathPack versions, the underlying implementation that processes your
algorithms is new. MathPacks purpose is still to provide you with an
easy method to enter and execute algorithms, but now it takes
advantage of the richness of the OpenWorks data model when
retrieving data and when writing new data back to OpenWorks.
This documentation not only shows you how to use MathPack, but also
details all the features of the interface and the underlying functionality.

R2003.12.1

Building Algorithms with MathPack: Overview

121

Reports and Utilities

Landmark

MathPack Features

122

MathPack allows you to write, execute, and save your own


multiple-line processing algorithms, with comments.
Algorithms can be applied to one or more wells in a single
processing instance; over the entire well interval, a common depth
range, or one or more named units (StratUnits).
Curves can be specified by Curve Alias, Curve Name, or Curve
Details. See more about the different methods of accessing curves
in the Petroworks/LogEdit Basics section of the Introduction to
the PetroWorks Family of Products manual.
Algorithmic parameters can be defined locally (specific to the
algorithm), or can be Global Parameters (shared by MathPack,
ModelBuilder, and the provided PetroWorks applications).
Algorithmic processing preserves/honors sample frameworks for
unevenly sampled and non-resampleable data (e.g., core data and
flag curves).
Processing parameters can be written to OpenWorks as curves,
creating a map of the parameter value over the processed
interval.
Equations (as from regression lines) which are determined in
Crossplot can be pasted into Mathpack algorithms.

Shared Utilities: Building Algorithms with MathPack

R2003.12.1

Landmark Graphics Corporation

User Programming

MathPack Workflow

Open MathPack
Interpret > MathPack

Select one or more wells from the Wells list.


Press Apply Well Selections.

Select the interval(s) over which you want to process:


Total Depth Range, or Depth Interval, or Unit Selections.

Type your algorithm in the Algorthm text box, or


Open an existing algorithm (File > Open Algorithm...), or
Select a symbolic equation (Tools > Select Symbolic Equations...)

Optionally, you can Output Petrophysical Parameters as Curves.

Check Syntax and modify your algorithms as necessary.

If you have used any Global Parameters in your algorithms, go to


Utilities > Wellbore Parameter Editor, then chose
Applications: Global Parameters
to set or check the parameter values.

Click Process to process the chosen wells over the interval(s).

Close MathPack

R2003.12.1

Building Algorithms with MathPack: Overview

123

Reports and Utilities

Landmark

Opening and Closing MathPack


To Open MathPack
1.

From the PetroWorks Command Menu, select


Interpret > MathPack.

2.

The MathPack main window appears.

3.

Follow the workflow on the previous page, or the more detailed


instructions in the following sections of the documentation, to
create and execute an algorithm.

To Close MathPack

124

1.

On the MathPack main window, select File > Exit.

2.

If you have not saved the algorithm that you created, a warning
window will appear which will allow you to Cancel the Exit
command (so you can save the algorithm, then exit) or continue
with the exit of MathPack (OK) without saving the algorithm.

Shared Utilities: Building Algorithms with MathPack

R2003.12.1

Landmark Graphics Corporation

User Programming

How Do I Use MathPack?


There are two parts to using MathPack:

Creating an algorithm (or restoring one from a .mathpack file or


from the Symbolic Equations list);
Running that algorithm against intervals in wells.

This section will guide you through the steps of creating a simple
algorithm and running it. For information about how to create more
complex algorithms, see the Building Algorithms section of this
documentation.

Creating an Algorithm
You create an algorithm by typing in the curves, parameters, and
functions to create an equation. Some rules are:

The curve or parameter that you want to create is always on the left
side of the equal sign, which is interpreted as an assignment
statement.
Each equation in the algorithm always ends with a semi-colon (;).
The names of curves that you use are always enclosed in double
quotes ( ).
The names of parameters (Local Variables or Global Parameters)
or numbers are NOT enclosed in double-quotes.

Here is an example taken from the A simple example section. The


section shows several different ways to create the same equation, and
you might want to visit that section before continuing here.
In this example you want to create a sonic porosity (PHIsonic) from the
sonic log measurement (DT). The Raymer-Hunt-Gardner transform to
accomplish this is:
DT DT matrix
PH I sonic = 0.625 -----------------------------------DT
You know that the formation in which you are interested is a sandstone,
and that the DTmatrix value for this sandstone is 56 us/ft.
In its simplest form, the equation above looks like this in MathPack:
SPHI = 0.625*(DT-56)/DT;

R2003.12.1

Building Algorithms with MathPack: How Do I Use MathPack?

125

Reports and Utilities

Landmark

Once you have typed the equation into MathPack, click the Check
Syntax button below the Algorithm window. If you have typed the
algorithm correctly, >> Syntax check passed. will appear in the Status
Area. If you have made a mistake in your algorithm, the Status Area
will display an error message, and MathPack will highlight the part of
the algorithm that has the error.
Once you have passed the syntax check, you are ready to use the
algorithm for processing.

Running the Algorithm


1.

In the Well Selection window, pick the wells that you want to
process. You can use a combination of the Select All (Select None)
button and mouse clicks to select the wells.

2.

After you have selected all the wells that you want, click the
Apply Well Selections button. This causes MathPack to query the
OpenWorks database and (among other things) update the items in
the Unit Selections text field. This MUST be done before you
select the processing interval.

3.

Select the interval over which you want to process.


You can process the wells over the interval of valid data in each
well by clicking the Total Depth Range radio button, or
Process the wells over a common Depth Interval that you supply
by clicking the Depth Interval radio button and filling out the Top
Depth and Bottom Depth fields, or
You can process over one or more named intervals (StratUnits) by
clicking on the Unit Selections radio button and selecting the
intervals that you want.

4.

You can Set Sample Increment, but leaving the choice defaulted
to Follow Framework Rules will ensure that MathPack honors
non-resampleable curves like core data.

5.

Press the Process button. MathPack re-evaluates the algorithm and


provides information about the processing via a pop-up window
and text in the Status Area.

The curves that you created during processing will be written to the
selected wells in the OpenWorks database, and are immediately
available for use and display.
126

Shared Utilities: Building Algorithms with MathPack

R2003.12.1

Landmark Graphics Corporation

User Programming

MathPack Window Descriptions


MathPack Main Window

Main Menu

Interval and
Sample Framework Selection

Well Selection

Divider/ Sash
Button

Algorithm Field

Status Area

MathPack Main Window Components

Main Menu
The Main Menu consists of 5 items.
File
New Algorithm clears the Algorithm Field and then enters the
following text in that field, in preparation for creation of a new
algorithm.

R2003.12.1

Building Algorithms with MathPack: MathPack Window Descriptions

127

Reports and Utilities

Landmark

--- PetroWorks MathPack algorithm


--- User : <user id>
-- Created : <date> <time>
--

New Algorithm... will clear the Algorithm Field WITHOUT asking if you want
to save the algorithm that is already there. There is no way to recover the text that
was in place before New Algorithm... is invoked.

Open Algorithm... opens a window that allows you to select and


existing algorithm file (<filename>.mathpack). See Open
Algorithm window for details of the window and its use.
Open Algorithm... pastes the entire contents of the selected algorithm into the
Algorithm Field beginning at the current location of the cursor. This command
DOES NOT over-write or erase the current contents of the Algorithm Field, but
adds to the contents.

Save Algorithm... allows you to save the algorithm that you created to
a file with your choice of name and location. The file will automatically
be appended with a suffix of .mathpack. See Save Algorithm
Window for details of the window and its use.
The first time you use this command after you have opened
MathPack, a window opens that allows you to set the name and
location of the file that you want to create.
Subsequent times that you use this command, the previouslyselected file is automatically updated with the contents of the
Algorithm Field. The window does not appear, but a message is
displayed in the Status Area.
To change the destination of subsequent changes in your algorithm, use Save As...
instead of Save Algorithm...

Save As... opens a window that allows you to save the algorithm that
you created to a file with your choice of name and location. The file

128

Shared Utilities: Building Algorithms with MathPack

R2003.12.1

Landmark Graphics Corporation

User Programming

will automatically be appended with a suffix of .mathpack. See


Save Algorithm Window for details of the window and its use.
Use Save As... instead of Save Algorithm... when you have already saved an
algorithm file during the current session of MathPack, and you want to save your
current work to a different file name or location.

Exit closes the MathPack application. If you have not saved the
information in the Algorithm Field, a window will appear that allows
you to
Cancel the exit and return to MathPack, or
OK the exit, and exit MathPack WITHOUT saving your current
work.

Edit
Cut removes highlighted text from the Algorithm Field.
Copy copies highlighted text in the Algorithm Field in preparation for
pasting the text in another part of the field or in the Symbolic
Equations window.
Paste pastes text that has been Cut or Copied in to a location in the
Algorithm Field starting at the current cursor location.
The three operations above can be accessed by clicking MB3 when the
cursor is in the Algorithm Field.

View
Clear Algorithm clears the entire contents of the Algorithm Field.
Once the field is cleared, you cannot recover the previous contents.
This feature can also be accessed by clicking MB3 when the cursor is
in the Algorithm Field.
Clear Status Area clears the entire contents of the Status Area. Once
the text field is cleared, you cannot recover the previous contents. This
feature can also be accessed by clicking MB3 when the cursor is in the
Status Area.

R2003.12.1

Building Algorithms with MathPack: MathPack Window Descriptions

129

Reports and Utilities

Landmark

Options
The History Insertions feature ensures that a curve history is created
each of the output curves. That information will help you to understand
where the curve came from. The curve history is accessed in Curve
Utility.
Automatic is the default option for curve history.
None is available only if you have Project Manager status for the
project.

Tools
Select Log Curves... opens the Log Curve Selection window. You can
insert curves into your algorithm from this window (by Curve Alias,
Curve Name, or Curve Details) instead of typing directly in the
Algorithm Field. See the Log Curve Selection Window section of
this documentation for more details.
Select Wellbore Parameters... opens the Parameter Selection
window. You can insert Global Parameters into your algorithm from
this window instead of typing directly in the Algorithm Field. See the
Parameter Selection Window section of this documentation for more
details.
Global Parameters
You can use two types of parameters in MathPack. Local parameters are defined
in your algorithm and are not available to any other algorithmic processes. Global
Parameters are available to all algorithmic processes including the algorithms
that you write in MathPack. The value of the global parameter at the time that the
MathPack algorithm is executed is used by the algorithm. See the Local Variables
and Global (Wellbore) Parameters sections for more details.

Select Algorithmic Elements... opens the Algorithmic Elements


window. You can insert algorithmic elements into your algorithm from
this window instead of typing directly in the Algorithm Field. See the
Algorithm Elements Window section of this documentation for more
details.
Select Symbolic Equations... opens the Symbolic Equations window.
Symbolic equations are one-line algorithms that can be used exactly
like .mathpack files. These algorithms can be inserted directly into
the Algorithm Field at the current location of the cursor. See the
Symbolic Equations Window section of this documentation for more
details.
130

Shared Utilities: Building Algorithms with MathPack

R2003.12.1

Landmark Graphics Corporation

User Programming

Remarks... opens the Remarks window. You can add comments here
that will be included in the curve history of each curve created by your
algorithm. The remarks will come before information about how the
curve was created. See the Remarks Window section of this
documentation for more details.

Well Selection
The wells that appear in the list are from the Well List chosen in
OpenWorks Project Status Tool, or selected when you started
PetroWorks. The list responds to changes in the Well Format (in the
Project Status Tool) but does NOT respond to the Well Order.
There are several ways to select wells on the list:

You can single click on individual wells to select one or more.


You can click the Select All button to select all the wells in the list.
(The button then becomes Select None.) If you have selected all
the wells, you can then single click on individual selected wells to
de-select or re-select them.

You can click on the Select None button (which then becomes
Select All).
The display at the bottom of the well list shows how many wells have
been selected out of the total number of wells in the well list.

Select All/Select None button toggles between the two shown settings
and allows you to select or deselect all the wells in the well list.
The Apply Well Selections button causes MathPack to read well data
from the project database.
Press the Apply Well Selections button
You MUST press the Apply Well Selections button AFTER you have selected the
wells that you want to process, and BEFORE you make any Unit Selections, for
the algorithms to process properly.

Interval and Sample Framework Selection


Total Depth Range processes the algorithms over the entire depth of
each well that is selected.

R2003.12.1

Building Algorithms with MathPack: MathPack Window Descriptions

131

Reports and Utilities

Landmark

Depth Interval processes the algorithms over a common depth range


for all wells that are selected, from Top Depth to Bottom Depth.
Using MB3 over the Top Depth or Bottom Depth text fields will
invoke the menu shown at left. The Minimum and Maximum
depth values are fixed at 0.00 and 30,000.00 respectively.
Unit Selections processes the algorithms over one or more named units
(StratUnits) in each well that is selected. The units do NOT have to be
contiguous. The units are displayed in the format:
<Unit Name>:<geofeature>:<occurence#>
If no geofeature has been assigned, <geofeature> will be
shown as UNKNOWN.
<occurence#> will be blank unless there are multiple
occurences.
Set Sample Increment has two options:

Follow Framework Rules will create a common data framework


from the frameworks of the individual curves. This setting will
honor the frameworks of non-resampleable curves, such as core
data.
User-specified Increment will set the output curves to a fixed
sample increment which you can specify in the text box.
Using MB3 over the User-Specified Increment text field will
invoke the menu shown at left. The Minimum and Maximum
increment values are fixed at 0.0001 and 100.000 respectively.
The Default value changes with the measurement system:
0.5 for feet-based systems, like US Oil Field;
0.125 for metre-based systems, like Canadian Metric and
SPE Preferred.

Algorithm Field
You can Output Petrophysical Parameters as Curves. This will
create curves with the parameter values over the interval which you
have processed the algorithm.
The text field is where you actually create the algorithm that you want
to use. Remember that the algorithm can have multiple lines, and can
132

Shared Utilities: Building Algorithms with MathPack

R2003.12.1

Landmark Graphics Corporation

User Programming

contain comments. Details about creating algorithms are in the


Building Algorithms section of this documentation. The algorithm can
be saved to a file at any time.
The Check Syntax button causes MathPack to check the syntax of the
algorithms that you have written. It will identify any problem areas
directly in the algorithm text field, along with an error message in the
Status Area.
Check Syntax does not verify the existence of referenced curves.
Check Syntax only checks for errors in grammar or syntax; you must process the
algorithm to verify that referenced curves exist for the selected wells.
Syntax errors stop processing.
Invalid curve references cause processing of the current well to stop, and
processing to continue with the next well in the list.

The Process button causes MathPack to process the algorithms that you
have created over the interval (or intervals) and wells that you have
specified. Process checks the syntax and ensures that all referenced
curves exist before MathPack begins processing for each well. If an
error is found, an informational message informs you of the type of
error and processing is attempted on the next well. Otherwise, the
application continues to process the algorithm currently displayed in
the Algorithm field.
Using MB3 in the Algorithm Field will invoke the menu shown at
left. Clear Algorithm clears the entire algorithm field. There is no
recovery from this action.

Status Area
Results of the syntax check and processing are reported in the Status
Area, as are other messages that are broadcast to all open applications,
such as when wells or projects are changed.
Using MB3 in the Status Area allows you to clear the status area.

Divider/Sash Buttons
These two buttons, on the right side of the MathPack window, between
the Interval and Sample Framework Selection area and the Algorithm
Field, and between the Algorithm Field and the Status Area, allow you
to resize the three panes in the MathPack window. When you move
R2003.12.1

Building Algorithms with MathPack: MathPack Window Descriptions

133

Reports and Utilities

Landmark

your cursor over the button, the cursor arrow turns to a plus (+). Hold
down MB1 and drag the cursor up or down to resize the pane. Each
pane has a minimum size.

Pointing Dispatcher
The OpenWorks PD (Pointing Dispatcher) allows you to import single
and multiple wells and curves from Curve Utility into MathPack. You
can PD OUT well names and PD IN well names and curve names.
Press Ctrl-l to activate/deactivate the PD facility. When the PD border
is green, PD is listening for other curve/well data. When the border is
red, PD is deactivated for this application.
Iconified windows can receive information.
You can PD information to a window that is iconified as long as the border on the
icon is green. If the iconified window is a StratUtil application and the border is red,
you can use the key combination Ctrl+l (lowercase letter el) or click on the
iconified window and select PD Listen from the menu that appears to turn the
border green and to enable listening capability.

To receive a curve in MathPack:

134

1.

With the PD frame active (green), press MB1 in the Algorithm


Builder window.

2.

Go to another application and select a curve name.

3.

Press Shift-MB2. A flying box appears in the MathPack window,


and the current curve name appears at the insertion point in the
algorithm window. The curve name is enclosed in quotes,
according to MathPack syntax.

Shared Utilities: Building Algorithms with MathPack

R2003.12.1

Landmark Graphics Corporation

User Programming

Log Curve Selection Window


The Log Curve Selection window provides an alternate method of
selecting curves to typing curve identifiers in the algorithms. The Log
Curve Selection Window is accessed from the Main Menu via
Tools > Select Log Curves...

Curve
Selection

Search/Filter

Curve List

Selection
Display
Action Buttons

Log Curve Selection Window Components


Curve Selection
The illustration above shows the Log Curve Selection window in its
three display modes (as indicated by the red arrows): Curve Aliases,
Curve Names, and Curve Details. The Show Curve Details choice is
active when only one well has been selected.
When Curve Aliases or Curve Names is selected, you can choose
to have All Curves in Selected Wells displayed (the union of all
curve identifiers), or you can choose to have only Curves
R2003.12.1

Building Algorithms with MathPack: MathPack Window Descriptions

135

Reports and Utilities

Landmark

Common to Selected Wells displayed (the intersection of all


curve identifiers).

Search/Filter
The text box provides for entry of a text string by which to search or
filter the items in the Curve List.
If you enter a character string, all curves having that character
string anywhere in their identifier will be found.
* can be used to indicate any character, and can be used as part
of a character string.
I*M will find ILM, TIDMR, and CALIMAX.
^ can be used to indicate that the following character string
must occur at the beginning of the entry.
Search/Find Next highlights the next table entry that matches the text
string, and moves the list so that the highlighted entry is at the top of
the list.
Filter causes the list to be reduced to only those entries which match
the text string.
Reset causes the curve list to be returned to its original contents, and
deletes the text string from the text box.

Curve List
The curve list shows the curves in alphabetical order, based on the
selections made in the Curve Selection area. The list cannot be
reordered.

Selection Display
Immediately below the Curve List, the Selection Display shows the
number of curves that:

136

Are in the original list (Total:)


Are currently displayed in the list, as a result of a filtering
operation (Displayed:)
Are currently selected (Selected:)

Shared Utilities: Building Algorithms with MathPack

R2003.12.1

Landmark Graphics Corporation

User Programming

Action Buttons
Insert causes the selected curve to be inserted into the algorithm at the
location of the cursor in the Algorithm Field. Insert must be used to
insert the curve into the algorithm; double-clicking on the curve
identifier to insert it in the algorithm is not supported.
Close closes the Log Curve Selection window with no further action.

R2003.12.1

Building Algorithms with MathPack: MathPack Window Descriptions

137

Reports and Utilities

Landmark

Parameter Selection Window


The Parameter Selection window provides a list of the 92 Global
Parameters and provides an alternate method of selecting those
parameters to typing global parameters in the algorithms. The
Parameter Selection Window is accessed from the Main Menu via
Tools > Select Wellbore Parameters...
This window is for the selection of Global Parameters only. You can
add your own local parameters to your algorithms, instead of using
Global Parameters.

Search/Filter

Parameter List

Selection
Display
Action Buttons

Parameter Selection Window Components


Search/Filter
The text box provides for entry of a text string by which to search or
filter the items in the Parameter List.
If you enter a character string, all parameters having that character
string anywhere in their identifier will be found.

138

Shared Utilities: Building Algorithms with MathPack

R2003.12.1

Landmark Graphics Corporation

User Programming

* can be used to indicate any character, and can be used as part


of a character string.
I*M will find ILM, TIDMR, and CALIMAX.
^ can be used to indicate that the following character string
must occur at the beginning of the entry.
Search/Find Next highlights the next table entry that matches the text
string, and moves the list so that the highlighted entry is at the top of
the list.
Filter causes the list to be reduced to only those entries which match
the text string.
Reset causes the list to be returned to its original contents, and deletes
the text string from the text box.

Parameter List
The parameter list shows the Global Parameters in alphabetical order.
The left-hand column is the actual parameter name; the right-hand
column is the title of the parameter as it appears as a column heading in
the Wellbore Parameter Editor. The list cannot be reordered.
More information about each Global Parameter is available in
Appendix 5: MathPack Syntax, and in the Wellbore Parameter
Editor documentation.
Appendix 5 shows the parameter Name, Title, Description,
Minimum and Maximum Values, optional Default Values, and the
Units of Measurement.
Wellbore Parameter Editor documentation contains the above
information, plus expanded default values for a small number of
parameters. To open Wellbore Parameter Editor:
Go to PetroWorks Command Menu > Utilities > Wellbore
Parameter Editor, make sure Applications is set to Global
Parameters and Columns (Parameter Group) is set to All.
Find the parameter that you want, then double-click on a cell in
that parameters column. The Cell/Parameter Detail window
will appear which provides details about the parameter and its
current value.

R2003.12.1

Building Algorithms with MathPack: MathPack Window Descriptions

139

Reports and Utilities

Landmark

Selection Display
Immediately below the Parameter List, the Selection Display shows
the number of parameters that:

Are in the original list (Total:)


Are currently displayed in the list, as a result of a filtering
operation (Displayed:)
Are currently selected (Selected:)

Action Buttons
Insert causes the selected parameter to be inserted into the algorithm at
the location of the cursor in the Algorithm Field. Insert must be used
to insert the parameter into the algorithm; double-clicking on the
parameter to insert it in the algorithm is not supported.
Close closes the Parameter Selection window with no further action.

140

Shared Utilities: Building Algorithms with MathPack

R2003.12.1

Landmark Graphics Corporation

User Programming

Algorithm Elements Window


The Algorithm Elements window provides an alternate method of
entering algorithm elements to typing the elements in the algorithms.
The Algorithm Elements Window is accessed from the Main Menu via
Tools > Select Algorithm Elements...

Algorithm
Elements
Palette

Close button

Algorithm Elements Window Components

Algorithm Elements Palette


This palette of algorithm elements can be used instead of typing the
elements directly in the Algorithm Field. To place an element in an
algorithm, position the cursor at the location that you want the element
placed (in the Algorithm Field of the MathPack Main window), then
MB1 on the element in the Algorithm Element Palette.
The algorithm elements are defined Appendix 1: Algorithm elements
with definitions.

R2003.12.1

Building Algorithms with MathPack: MathPack Window Descriptions

141

Reports and Utilities

Landmark

Close button
The Close button closes the Algorithm Elements window with no
further action.

142

Shared Utilities: Building Algorithms with MathPack

R2003.12.1

Landmark Graphics Corporation

User Programming

Symbolic Equations Window


The Symbolic Equations window provides an alternate method of
entering algorithms to typing the algorithms or loading a .mathpack
file. The Symbolic Equations Window is accessed from the Main Menu
via Tools > Select Symbolic Equations...
Symbolic Equations are useful as a quick way to save one-line
equations that you might want to use in several different algorithms, or
just use occasionally by themselves. Symbolic Equations allow you to
write an equation once, and verify its validity in an algorithm, then
quickly use it at another time.

Main Menu

Equation
List

Equation Field
Equation
Name
Field
Action
Buttons

The list of pre-defined symbolic equations is detailed in Appendix 2:


Pre-Defined Symbolic Equations.

Symbolic Equations Window components


Main Menu
The menu has one option.
File
Save saves all the symbolic equations to a single file which resides in
$PWHOME/dat/mpkEquations.dat.
Close closes the window without further action.

R2003.12.1

Building Algorithms with MathPack: MathPack Window Descriptions

143

Reports and Utilities

Landmark

Equation List
The Equation List shows all the symbolic equations and their names.
The equations are listed in alphabetical order by name. The equations
are defined in Appendix 2: Pre-Defined Symbolic Equations.

Equation Name Field


The Equation Name Field shows the name of the selected equation. If
you create a new Symbolic Equation, you type the desired name here.

Equation Field
The Equation Field shows the selected equation. If you create a new
Symbolic Equation, you type the entire equation here (information
from BOTH sides of the equal sign), or paste the equation here from the
MathPack Main Window Algorithm Area.

Action Buttons
Add/Update adds a new Symbolic Equation to the Equation List, or
updates an existing Symbolic Equation.
Delete removes the Symbolic Equation in the Equation Name Field
from the list of equations.
Insert into Algorithm inserts the Symbolic Equation in the Equation
Field into the algorithm in the MathPack Main Window Algorithm
Area at the location of the cursor.
Close closes the Symbolic Equation window without further action.

Adding an Equation to the Symbolic Equations List


To add an equation to the list of Symbolic Equations:

144

1.

Enter a name for the equation in the Equation Name Field. Pick a
name that you can easily recognize at a later date.

2.

Type the equation in the Equation Field, or copy the equation


from the Algorithm Field on the MathPack main window and
paste it in the Equation Field.

3.

Click the Add/Update button to add the equation to the list.

Shared Utilities: Building Algorithms with MathPack

R2003.12.1

Landmark Graphics Corporation

User Programming

Modifying an Existing Symbolic Equation


To update an existing equation:
1.

Click on the equation or the equation name in the Equation List to


bring the equation into the Equation Field.

2.

Modify the equation as needed.

3.

Click the Add/Update button to make the changes in the list.

4.

Click File > Save to save the changes to the Symbolic Equations
file.

To delete an existing equation:


1.

Click on the equation or the equation name in the Equation List to


bring the equation into the Equation Field.

2.

Click the Delete button to delete the equation from the list.

3.

Click File > Save to save the changes to the Symbolic Equations
file.

Storing multiple line equations in Symbolic Equations is NOT


recommended.
Although storing a multiple line equation in Symbolic Equations is possible, it is
strongly recommended that you DO NOT do so. When a multiple line equation is
stored in Symbolic Equations, all equations are reformatted to the same number of
lines as the multiple line equation, causing the list to expand. In addition, the lines
after the first line are left-justified to under the equation title.
To save multiple line algorithms, go to File > Save Algorithm on the MathPack
Main Window, and store the file in a directory of your choice.

R2003.12.1

Building Algorithms with MathPack: MathPack Window Descriptions

145

Reports and Utilities

Landmark

Remarks Window
The Remarks window allows you to add remarks to the history file of
curves. The same remarks are added to the history files of all curves
generated during a single MathPack processing event. The Remarks
Window is accessed from the Main Menu via Tools > Remarks...

Text Window

OK button

Remarks Window Components


Text Window
Type the remarks that you want to be added to the curve history of all
curves generated in a single MathPack processing instance. The text
does NOT wrap in the text field. You can use the Enter (Return)
keyboard button to start a new line.
Remarks are limited to a maximum of 80 characters per line.
Multiple lines of remarks may be used.

OK Button
The OK button closes the window and saves the text that you have
written for inclusion in the curve histories of all the curves processed in
the next MathPack processing instance.

146

Shared Utilities: Building Algorithms with MathPack

R2003.12.1

Landmark Graphics Corporation

User Programming

Save Algorithm Window


The Save Algorithm window provides the means to store the algorithm
that you have created in a directory of your choice with a name of your
choice. The Save Algorithm window is accessed from the Main Menu
via File > Save Algorithm... or File > Save As...

Filter Text Box

Directory and File Lists

Selection Text Box

Saving a New Algorithm


To save a new algorithm in MathPack:
1.

Go to File > Save Algorithm... or File > Save As... Either menu
item will open the Save Algorithm window shown above.

2.

Move to directory in which you want to store the algorithm by


double-clicking through the directory levels, or by typing the
directory path in the Filter Text Box and clicking the Filter
button.

3.

Type the file name that you want to use in the Selection Text Box
and click OK.

Saving a Previously-Saved Algorithm


To save an algorithm that was previously saved in the same MathPack
session, with the same file name, select File > Save Algorithm... The
Save Algorithm window will NOT appear. Instead, a note will appear
in the status area that the algorithm has been saved.

R2003.12.1

Building Algorithms with MathPack: MathPack Window Descriptions

147

Reports and Utilities

Landmark

To save an algorithm that was previously saved with a different file


name, select File > Save As... The Save Algorithm window will
appear. Follow the directions for saving an algorithm listed in the
Saving a New Algorithm section.

148

Shared Utilities: Building Algorithms with MathPack

R2003.12.1

Landmark Graphics Corporation

User Programming

Open Algorithm window


The Open Algorithm window provides the means to open an algorithm
that you have previously created. The Open Algorithm window is
accessed from the Main Menu via File > Open Algorithm...

Filter Text Box


Directory and File Lists

Algorithm Preview

Selection Text Box

Opening an Existing Algorithm


To open an existing algorithm in MathPack:

R2003.12.1

1.

Go to File > Open Algorithm... to open the Open Algorithm


window.

2.

Move to the directory in which the desired algorithm is located by


double-clicking through the directory levels, or by typing the
directory path in the Filter Text Box and clicking the Filter
button.

3.

Highlight the file that you want to load.

4.

If you are unsure of the contents of the file, you can click the
Preview button at the bottom of the window. The contents of the
file will be displayed in the Algorithm Preview window.

5.

Click OK to load the contents of the file to the MathPack Main


Window Algorithm Field.

Building Algorithms with MathPack: MathPack Window Descriptions

149

Reports and Utilities

Landmark

Opening an Existing Algorithm


When you open an existing algorithm, the entire contents of the algorithm file is
loaded to the MathPack Main Window Algorithm Field, beginning at the location
of the cursor in the field. The contents of the file will be ADDED TO the current
contents of the Algorithm Field; it will NOT overwrite the contents.

150

Shared Utilities: Building Algorithms with MathPack

R2003.12.1

Landmark Graphics Corporation

User Programming

Building Algorithms
This section provides the details of creating algorithms, including the
grammar and syntax of the algorithms, and an explanation of error
messages when they appear.

Introduction
Algorithms in MathPack are based on a simple language and grammar.
Algorithms can take on a free-form user-defined arrangement and may
be composed of any number of lines, including comments in separate
lines or in lines containing algorithms. Moreover, no limits are placed
on the number of lines or curves used, or the length of individual lines.
Arithmetic and logical (boolean) operators have their conventional
meanings and follow their conventional order of precedence. The order
of precedence (the order of evaluation) of the operators may be
modified by grouping expressions within parentheses. The groupings
may be of arbitrary complexity and may be repeated to any level.
Statements are processed sequentially in the algorithm from top to
bottom, for each valid sample point; i.e., the algorithms apply only to
the current depth; no access to depths other than the current depth is
possible.
The algorithm checker (parser) performs reasonable static checks on
the algorithm, searching for common errors in syntax and semantics.
When an error occurs, a message that indicates the nature of the error
(and where applicable, possible solutions to the problem) is generated
in the Status Area of the MathPack window. See Appendix 4:
Understanding Error Messages for more details.

A simple example
This section illustrates the different ways in which a simple algorithm
can be written. The basic algorithm calculates a sonic porosity
(PHIsonic) from acoustic wave travel time (DT) using the Raymer-HuntGardner transform:
DT DT matrix
PH I sonic = 0.625 -----------------------------------DT

R2003.12.1

Building Algorithms with MathPack: Building Algorithms

151

Reports and Utilities

Landmark

PHIsonic = sonic porosity (= SPHI in the equations below);


DT = acoustic wave travel time (the log measurement);
DTmatrix = matrix (zero porosity) acoustic wave travel time.
Here, the equation is written in its simplest form. Although
DT matrix varies based on the porosity of the formation, it is
written here as a constant; 56 usec/ft, the sandstone value.

This version of the equation introduces DTmatrix as a variable,


which is defined as 56 usec/ft immediately below its declaration as a VARIABLE. In this form, the equation can easily be
used for matrix values other than 56, by changing the value in
one place.

This version of the equation substitutes the Curve Alias (Acoustic_Wave_Travel_Time) for
the Curve Name (DT), and substitutes the Global Parameter (TransitTimeMatrix) for the locally-defined variable (DTmatrix). The Curve Alias provides the means to process wells with
variations in the
name of the
sonic measurement, and the
Global Parameter provides the means to access a parameter which is shared by several applications, and
which is defined in the Wellbore Parameter Editor.
Note that the Global Parameter is NOT declared in the algorithm.
This version of the equation is exactly like
the version immediately above, except
that it has been written on several lines to
limit the width of the text.

This version of the equation is in the same form as the two immediately above, and also includes an IFTHEN-ELSE statement. In this form, SPHI is calculated by the Raymer-Hunt-Gardner transform when
Acoustic_Wave_Travel_Time (DT) is greater than TransitTimeMatrix (DTmatrix). If the log measurement
is less than or equal to the matrix value, SPHI is set to 0.001 (0.1 percent porosity).

152

Shared Utilities: Building Algorithms with MathPack

R2003.12.1

Landmark Graphics Corporation

User Programming

Algorithmic Results
Some reasons that an expression cannot be computed:

Divide by zero;
The function call has an argument which is out of range;
One or more input curves does not exist.

If an expression cannot be computed, it resolves to the NULL value.


Null values in input data or from incomputable expressions will cause
the affected output curve(s) to be NULL at that sample point.

Algorithm Component Details


Algorithms consist of three components:

Comments (optional)
Variable declarations (optional)
Statements

Comments
Comments are preceded by a double-dash ( -- ) and extend to the end of
the line on which they begin. They may appear anywhere on a line or
anywhere in an algorithm. Comments are an optional part of an
algorithm, but are strongly suggested, especially when creating
complex algorithms, or algorithms that you will share with others.
Comments do not affect the meaning of the line on which they appear
and are ignored when the algorithm is processed.
Comment examples:

Variable Declarations
Local Variables must be declared at the beginning of an algorithm,
before they are used in any statement. Variables can be assigned
R2003.12.1

Building Algorithms with MathPack: Building Algorithms

153

Reports and Utilities

Landmark

numeric values or the value of computed expressions. Variables can be


parameters that are needed in the algorithm, or they can be intermediate
results in an algorithm.
Unlike curve references, Local Variable references appear without
quotation marks. They are initialized to NULL before processing at
each sample level.
Local Variables are declared by use of the statement:
VARIABLE <variable name>;
VARIABLE is insensitive to case.
Examples of Local Variable declarations:

Note the possible forms


of the word variable.
These are Global Parameters. They
have the same form (no quotation
marks) as Local Variables.
The Local Variable m is
used in the Rwa equation.

In the example above, Rw, m, and RHOB_calc are local variables. After
their declaration by the Variable statement, Rw is defined as a
constant while m and RHOB_calc are defined as expressions.
The example above also contains two Global Parameters,
DensityFluid and DensityMatrix. They are used like Local Variables,
and have the same appearance (they are used in expressions without
quotation marks). They are not explicitly declared in the algorithm, but
they are implicitly declared, and as such are available to all
applications. See Global (Wellbore) Parameters for more details.

Using Global Parameter names as Local Variables


If a parameter with exactly the same name as a Global Parameter is declared as a
Local Variable in an algorithm (by the VARIABLE <parmname>; statement,
the value of the Global Variable is hidden in processing, and the declared or
calculated value in the algorithm is used.

154

Shared Utilities: Building Algorithms with MathPack

R2003.12.1

Landmark Graphics Corporation

User Programming

Statements
There are three types of statements:

Assignment Statements
IF Statements
LOOP Statements

Statements can consist of the following elements:

Curve Identifiers by Curve Alias, Curve Name, or Curve Details


Numeric Literals
Local Variables
Global (Wellbore) Parameters
Reserved Literals/Reserved Words
Function Calls

Assignment Statements
Assignment statements evaluate an expression by computing a value,
and placing that value in the specified curve or variable at the given
depth for which the algorithm is being applied.
Examples of assignment statements:

IF Statements
IF statements allow a MathPack user to define conditional processing
on enclosed algorithm statements.
IF statements come in two forms:
IF (expression) THEN
(expression);
END IF;
If the expression immediately following IF is satisfied, the expression
immediately following THEN is evaluated. If the expression

R2003.12.1

Building Algorithms with MathPack: Building Algorithms

155

Reports and Utilities

Landmark

immediately following IF is NOT satisfied, the expression immediately


following THEN is NOT evaluated, and is skipped.
IF (expression) THEN
(expression);
ELSE
(expression);
END IF;
If the expression immediately following IF is satisfied, the expression
immediately following THEN is evaluated, and the expression
immediately following ELSE is skipped. If the expression immediately
following IF is NOT satisfied, the expression immediately following
THEN is skipped, and the expression immediately following ELSE is
evaluated.
MathPack grammar recognizes equality, inequality, and relational
operators that can be combined with the logical operators AND, OR,
and NOT to create sophisticated conditional control.
Examples of IF statements:

LOOP Statements
LOOP statements allow you to iteratively process data. By using a
LOOP statement you can converge on a value by using the previous
value determined by the expression in the same expression, and you can
also set a counter that will terminate a loop after a reasonable number
of iterations. The LOOP statement takes the form of the classic dowhile loop.
The LOOP statement has the form:
(expressions setting initial conditions);
WHILE (expressions) LOOP

156

Shared Utilities: Building Algorithms with MathPack

R2003.12.1

Landmark Graphics Corporation

User Programming

(expression);
(expressions to iterate values);
END LOOP;
The condition of each loop statement is evaluated once for each
iteration. If upon evaluation the condition is met, the loop body is
entered. Statements in the loop body are processed and control is
passed back to the top of the loop, where the condition of the loop body
is re-evaluated.
Static checks (via the Check Syntax button) are performed to
determine if the loop will be infinite or entered at all. If the loop is
determined to be infinite, the parser will produce an error message in
the Status Area. If the loop will never be entered, the parser will warn
the user and will remove all associated statements (including the
evaluation of the condition) from processing.
Loops are processed and must terminate or run to completion FOR
EACH DEPTH at which the algorithm is applied. Loops that require
large numbers of iterations to complete will greatly increase processing
time for an algorithm.
Example of a LOOP statement:

Variable declarations
Variable initialization

LOOP body

Statement Elements
Curve Identifiers
Curve identifiers are the way that you specify curves as inputs to
algorithms, and as outputs; that is, as the results of algorithm

R2003.12.1

Building Algorithms with MathPack: Building Algorithms

157

Reports and Utilities

Landmark

computations. Curve identifiers can be Curve Aliases, Curve Names, or


Curve Details, with limitations as shown in the table below.

Identifier

Input Curve

Output Curve

Curve Alias

Can be used. This is the preferred


format for input curves, as its use
will invoke the aliasing and autocompositing features of OpenWorks
and PetroWorks.

Can be used. (OpenWorks and the


applications will regard the Alias as a
Curve Name.)

Curve Name

Can be used. Useful if curve names


are consistent between wells.
Invokes the auto-compositing
features of OpenWorks and
PetroWorks.

Can be used. This is the preferred


format for output curves.

Curve Details

Can be used. This format is useful


ONLY if your algorithm is built for a
specific well, and/or you want to
process using a specific curve
instance.

Cannot be used as an output curve


format.

Curve identifiers must be enclosed in double quotation marks ( )


since they may be composed of printable characters that the algorithm
uses as operators and separators, and may contain embedded spaces.
Because OpenWorks has an open namespace for curves; that is, curves
are not constrained to a limited set of names, you can give a new curve
any name, up to 25 characters in length
Some examples of curve identifier usage:

Case 1
Case 2
Case 3
Case 4

Case 1 shows the use of Curve Names as input and output curve
identifiers.
158

Shared Utilities: Building Algorithms with MathPack

R2003.12.1

Landmark Graphics Corporation

User Programming

Case 2 shows the use of a Curve Name as an output curve


identifier, and Curve Aliases as input curve identifiers. This format
provides the most flexibility in processing, especially when
processing multiple wells.
Case 3 shows the use of Curve Aliases as input and output curve
identifiers. This format is permissible, but the use of Curve Aliases
as output curve identifiers is discouraged.
Case 4 shows the use of a Curve Name as an output curve
identifier, and Curve Details as input curve identifiers. This is most
useful for the processing of a specific individual well, when you
want to access a specific curve instance.

Curve Identifiers:
Cannot contain quotes within the enclosing quotes. My new Curve is not a
valid curve name.
Are case sensitive. Sw SW and sw are interpreted as three different curves.
Are limited to 25 characters.
Can be Curve Names or Curve Aliases, or Curve Details. (See the table above for
identifier usage limitations.)

Output Curves and Curve Details


Curve references (Service, Run, and Pass) are automatically generated for all
output curves.
If all input curves used in the equation are specified by Curve Details, and all
curves used in the equation have the same Service, Run, and Pass, the output curve
will inherit those attributes.
If input curve attributes are different, the output curve attributes will be: Service
= PETROWORKS, Run = C, Pass = NONE.

Numeric Literals
Numeric literals are numbers that are used in an algorithm. Numbers do
NOT have to contain a decimal point.

R2003.12.1

Building Algorithms with MathPack: Building Algorithms

159

Reports and Utilities

Landmark

Local Variables
Local Variables are algorithm components that you have defined in the
algorithm. As described in the Variable Declarations section, they are
declared at the beginning of the algorithm by the word VARIABLE.
The value of a Local Variable can be set to a constant, or can be
determined by an expression.
Local Variable names are not limited in length, and the names are case
sensitive. Local Variable names are used in algorithms WITHOUT
quotation marks.

Global (Wellbore) Parameters


Global Parameters, also known as Wellbore Parameters, are parameters
which are shared by many applications. Those applications include the
PetroWorks-supplied applications like those under
Interpret > Petrophysics on the PetroWorks Launcher Bar,
ModelBuilder applications, and now MathPack algorithms. The Global
Parameters are shared; that is, their values are set in Wellbore
Parameter Editor as part of processing a particular model, and those
values are used by all applications that reference particular parameters.
Global Parameters are described in Appendix 5: MathPack Syntax.
Global Parameter are NOT declared in MathPack (whereas Local
Variables must be declared to be recognized).
Global Parameters are used with the same format as Local Variables;
they are included in expressions without double quotation marks.
The value of a Global Parameter can be changed in Wellbore Parameter
Editor. The value of a Global Parameter CANNOT be changed in
MathPack. For that reason, Global Parameters are not allowed to be
used on the left side of statements in algorithms.
Global Parameters can be hidden if a Local Variable of exactly the
same name (including case) is declared in an algorithm. In this case, the
value of the parameter as declared or calculated in the algorithm will be
used, and the actual value of the Global Parameter will be ignored and
unchanged.
For example:
The algorithm
SPHI = 0.625*(DT-TransitTimeMatrix)/DT;
160

Shared Utilities: Building Algorithms with MathPack

R2003.12.1

Landmark Graphics Corporation

User Programming

will use the value of the Global Parameter TransitTimeMatrix that


exists in the OpenWorks database.
The algorithm
VARIABLE TransitTimeMatrix;
TransitTimeMatrix = 42.68;
SPHI = 0.625*(DT-TransitTimeMatrix)/DT;
will use the value 42.68, and will disregard the value of
TransitTimeMatrix which resides in OpenWorks.

Reserved Literals/Reserved Words


Reserved Literals (Words) are words which are interpreted literally by
the MathPack parser. They represent elements of an algorithm, or have
specific values. Reserved literals include IF, THEN, ELSE, OR,
TRUE, FALSE, NULL, END, LOOP, VARIABLE.
Reserved Literals are case insensitive; IF, if, If, iF are all
interpreted as the same literal word.
Reserved Literals/Reserved Words are defined in Appendix 1:
Algorithm elements with definitions, in the Logical Operators,
Statement Elements, and Value Literals sections.

Function Calls
Function calls are references to built-in arithmetic and trigonometric
functions. MathPack provides a varied selection of functions and
maintains their conventional meanings. All but one function (MOD) act
as operations on a simple expression. MOD is a binary operation that
requires two values.
Function calls are case insensitive; LN, Ln, ln, lN are considered
the same function.
Trigonometric Function Calls expect Radians
The trigonometric Function Calls operate on a number or on a resolved expression
which are expected to be in RADIANS, NOT degrees.
The conversion from degrees to radians is:
Degrees
Radians = ---------------------- 2
360

R2003.12.1

Building Algorithms with MathPack: Building Algorithms

161

Reports and Utilities

Landmark

Some examples of the format of function calls are:

Function Calls are defined in Appendix 1: Algorithm elements with


definitions, in the Function Calls section.

Exponentiation
Exponentiation is represented by the carat symbol ( ^ ) or by the
Function Call EXP. The expressions are equivalent.
Roots may be calculated by using a fractional exponent.
Fractions may be calculated by using a negative exponent.
Roots of negative values cannot be calculated.
Some examples of exponentiation are shown here:

These two expressions are equivalent.


These three expressions are equivalent.

162

Shared Utilities: Building Algorithms with MathPack

R2003.12.1

Landmark Graphics Corporation

User Programming

Top Twelve Check List


The following table contains a list of tips for ensuring smooth
processing when using MathPack.
Before processing an algorithm, be sure to:

R2003.12.1

1.

Make sure that all curves used in calculations exist in the selected wells

2.

Check for a disk file of the algorithm youre interested in chances are it may
already have been written.

3.

Add any commonly-used constant (or equation) to the constant (equation) table. Edits
to that constant or equation then only need to be made once in the table.

4.

Terminate all statements with a semi-colon.

5.

Include both opening and closing parentheses.

6.

Check for typographical errors.

7.

Check for missing or misspelled reserved words such as thne for then.

8.

Enclose curve names in both opening and closing quotes.

9.

Check for quoted curve names that span multiple lines. Note that curve names should
not exceed 25 characters.

10.

Ensure that all curve i.d.s are in the proper case.

11.

Ensure that all comments are preceded by a double dash --.

12.

Use NEG (), not a minus sign (-) for negative values.

Building Algorithms with MathPack: Building Algorithms

163

Reports and Utilities

Landmark

Appendices
Appendix 1: Algorithm elements with definitions

Element

Definition

Arithmetic Operations
+

addition

subtraction

multiplication

division

exponentiation. See also EXP( )

Relational Operations
=

is equal to

!=

is not equal to

<

is less than

<=

is less than or equal to

>

is greater than

>=

is greater than or equal to

Logical Operators
AND

and, as <expression> AND <expression>

OR

or, as <expression> OR <expression>

Function Calls

164

ABS( )

Arithmetic absolute value of the specified numeric expression.

ACOS( )

Trigonometric arccosine (inverse cosine) of the specified numeric


expression. The expression is assumed to be in radians, and its value
must be in the range [-1, 1].

ASIN( )

Trigonometric arcsine (inverse sine) of the specified numeric expression.


The expression is assumed to be in radians, and its value must be in the
range [-1, 1].

ATAN( )

Trigonometric arctangent (inverse tangent) of the specified numeric


expression. The expression is assumed to be in radians.

Shared Utilities: Building Algorithms with MathPack

R2003.12.1

Landmark Graphics Corporation

User Programming

Element

Definition

COS( )

Trigonometric cosine of the specified numeric expression. The


expression is assumed to be in radians.

LN( )

Natural logarithm (base e) of the specified numeric expression. The value


of the expression must be positive.

LOG( )

Logarithm (base 10) of the specified numeric expression. The value of


the expression must be positive.

MOD( )

First expression modulo the second expression.

NEG( )

Negative value of the specified numeric expression.

SIN( )

Trigonometric sine of the specified numeric expression. The expression


is assumed to be in radians, and its value must be in the range [-1, 1].

SQRT( )

Square root of the specified numeric expression. The value of the


expression must be non-negative.

TAN( )

Trigonometric tangent of the specified numeric expression. The


expression is assumed to be in radians, and its value must be equal to+-/
2.

EXP( )

exponentiation. See also ^.

RANDOM( )

Supplies a random floating-point value between two numbers. This


function has the format RANDOM(min_value, max_value), where the
output ranges between the min_value and the max_value.

Statement Elements
VARIABLE

Reserved word for declaration of a Local Variable.

equal to

open parenthesis

close parenthesis

semi-colon. Ends algorithmic lines

IF ( ) THEN

IF statement

( );
END IF;
IF ( ) THEN

IF-THEN statement

ELSE ( );
END IF;
WHILE ( )
LOOP

LOOP statement

( );
END LOOP;
R2003.12.1

Building Algorithms with MathPack: Appendices

165

Reports and Utilities

Landmark

Element
--

Definition
Precedes comments, either at the beginning of a line, or at the end of a
line containing an expression, after the semi-colon.

Value Literals

166

TRUE

TRUE reserved literal

FALSE

FALSE reserved literal

NULL

NULL reserved literal

Shared Utilities: Building Algorithms with MathPack

R2003.12.1

Landmark Graphics Corporation

User Programming

Appendix 2: Pre-Defined Symbolic Equations


The pre-defined Symbolic Equations are accessed from the MathPack
Main Menu via Tools > Select Symbolic Equations... The Symbolic
Equations are written with curves represented by Curve Aliases, and
parameters represented by Global Parameters.

Equation Name

ARCHIE

Equation in traditional format, with components defined


in terms of Curve Aliases and Global Parameters.

Definition

a Rmf
Sw = ---------------------m

Rxo

Undisturbed zone water


saturation from the Archie
(clean formation) equation.

1
--n

Sw = SW_ARCH (water saturation)


a = TortuosityFactor
Rw = ResWater (formation water resistivity)
Rt = Deep_Resistivity
= Porosity
m = CementationExponent
n = SaturationExponent
1
---

ARCHIE_SXO

Flushed zone water saturation


from the Archie (clean
formation) equation.

BVW

Bulk Volume Water: The


amount of water in the
formation as a fraction of the
total formation volume.

R2003.12.1

a Rw n
Sxo = -----------------m

Rt
Sxo =SXO_ARCH (flushed zone water saturation
a = TortuosityFactor
Rmf = ResMudFiltrate (mud filtrate resistivity)
Rxo = Flushed_Zone_Resistivity
= Porosity
m = CementationExponent
n = SaturationExponent

BVW = S w
BVW = BVWC (bulk volume water)
Sw = Water_Saturation
= Effective_Porosity

Building Algorithms with MathPack: Appendices

167

Reports and Utilities

Equation Name

DEN_to_POR

Landmark

Definition

Converts bulk density to


density porosity, using matrix
density and fluid density.

DT_to_POR

Converts acoustic wave travel


time to acoustic (sonic)
porosity, using matrix travel
time and fluid travel time
using the Wyllie TimeAverage equation (no
compaction correction).

F_FACTOR

Formation Resistivity Factor.


Used to relate the bulk
resistivity of a rock to the
resistivity of the water with
which it is saturated.

Equation in traditional format, with components defined


in terms of Curve Aliases and Global Parameters.

matrix b
DPHI = ---------------------------------- matrix fluid
DPHI = DPHI (density porosity)

b = Bulk_Density (the log measurement)


matrix = DensityMatrix
fluid = DensityFluid
T T matrix
SPHI = -------------------------------------------T fluid T matrix
SPHI = DTPORC (sonic porosity)
T = Acoustic_Wave_Travel_Time (log measurement)
Tmatrix = TransitTimeMatrix
Tfluid = TransitTimeFluid

a
F = -----m

F = F (formation factor)
a = TortuosityFactor
= Porosity
m = CementationExponent

MOVEABLE_SH

168

Moveable hydrocarbon
saturation (also called
moveable oil saturation). The
fraction of in-place
hydrocarbons that can be
moved or produced.

MOS = Sxo Sw

MOS = MOS
Sxo = Flushed_Zone_Water_Sat
Sw = Water_Saturation

Shared Utilities: Building Algorithms with MathPack

R2003.12.1

Landmark Graphics Corporation

User Programming

Equation in traditional format, with components defined


in terms of Curve Aliases and Global Parameters.

Equation Name

Definition

POR_to_DEN

Bulk density calculated from


density porosity, using matrix
density and fluid density.

RESIDUAL_SH

Residual hydrocarbon
saturation (also called
residual oil saturation). The
fraction of in-place
hydrocarbons that cannot be
produced.

b = ( 1 ) matrix + fluid
b = RHOBC)

= Density_Porosity

matrix = DensityMatrix
fluid = DensityFluid

ROS = 1 Sxo

ROS = ROS
Sxo = Flushed_Zone_Water_Sat
m

RMFA

Apparent mud filtrate


resistivity, from flushed zone
resistivity and porosity
measurements.

Rxo
Rmfa = ----------------------a
Rmfa = RMFA
Rxo = Flushed_Zone_Resistivity
a = TortuosityFactor
= Porosity
m = CementationExponent

RWA

Apparent formation water


resistivity, from true (deep)
resistivity and porosity
measurements.

Rt
Rwa = -----------------a

Rwa = RWA
Rt = True_Resistivity
a = TortuosityFactor
= Porosity
m = CementationExponent

R2003.12.1

Building Algorithms with MathPack: Appendices

169

Reports and Utilities

Landmark

Equation Name

Definition

RWA_ARCH

Apparent formation water


resistivity, from true (deep)
resistivity and formation
factor. Requires the
F_FACTOR equation.

Equation in traditional format, with components defined


in terms of Curve Aliases and Global Parameters.

Rt
Rwa = ----F

Rwa = RWA_ARCH
Rt = True_Resistivity
F = F_Factor

RWA_RATIO

Rt
Rwa = Rmf ----------
Rxo

Apparent formation water


resistivity, from mud filtrate
resistivity and measured
resistivities.

Rwa = RWA_RATIO
Rmf = ResMudFiltrate (mud filtrate resistivity)
Rt = True_Resistivity
Rxo = Flushed_Zone_Resistivity

170

Shared Utilities: Building Algorithms with MathPack

R2003.12.1

Landmark Graphics Corporation

User Programming

Appendix 3: Global (Wellbore) Parameters and Definitions


The following table describes the Global Parameters that are available
in MathPack and ModelBuilder, and which appear in many of the
PetroWorks interpretive applications (which are built with
ModelBuilder).

Parameter Name is the actual name of the parameter, to be used


WITHOUT double-quotes in MathPack algorithms.
Parameter Title is the title of the parameter in Wellbore
Parameter Editor.
Description is an attempt to describe the parameter. The
description also appears if you double-click a cell in Wellbore
Parameter Editor.
Min. Value and Max. Value describe the valid range of the
parameter.
Default Value provides a reasonable value for the parameter, if the
parameter can support a general (default) value.
Units describes the units of measurement for each parameter.

Min. Max. Default


Value Value Value

Parameter Name

Parameter Title Description

BitSize

Bit Size

The size of the bit used to drill this 0


section of the wellbore.This is not
the size of the wellbore itself
because of factors such as
wellbore rugosity, mud cake,
shale sloughs and wellbore
collapse.

60

8.75

inches

BottomHoleDepth

Bottom Hole
Depth

The total depth to which the well 0


is drilled

50000

10000

feet

BottomHoleTemperature

Bottom Hole
Temperature

The temperature downhole at the 0


bottom of the well.

600

175

degF

CementationExponent

Cementation
Exponent (m)

Cementation exponent (m) for


the Archie equation.

0.1

unitless

ConcentrationKcl

Concentration
KCl

Concentration KCl

30

DensityAnhydrite

Anhydrite
Density

Bulk density for Anhydrite.

2.95

3.1

2.98

g/cm3

DensityCasing

Casing Density

Density of the casing

66.427

lbm/
galUS

DensityCoal

Coal Density

Bulk density for Coal.

1.4

g/cm3

DensityDolomite

Dolomite
Density

Bulk density for Dolomite.

2.82

2.92

2.87

g/cm3

DensityDryShale

Dry Shale
Density

Bulk density for Dry Shale.

2.65

g/cm3

DensityFluid

Fluid Density

Density of the reservoir fluids


(includes water, dissolved salts
and hydrocarbons)

g/cm3

DensityFormationWater

Formation Water Density of formation water


Density

g/cm3

R2003.12.1

Building Algorithms with MathPack: Appendices

Units

171

Reports and Utilities

Landmark

Parameter Name

Parameter Title Description

Min. Max. Default


Value Value Value

DensityHydrocarbon

Hydrocarbon
Density

Density of the hydrocarbon


present in the formation

g/cm3

DensityLimestone

Limestone
Density

Bulk density for Limestone

2.69

2.8

2.71

g/cm3

DensityMatrix

Matrix Density

Bulk density for the Matrix.

1.5

3.5

2.65

g/cm3

DensityMudFiltrate

Mud Filtrate
Density

Density of the drilling fluids which 0


have invaded the formation after
losing some of their solids as
mud cake on the walls of the
wellbore.

g/cm3

DensityPorosityCoal

Coal density
Porosity

density porosity for Coal.

0.65

v/v
decimal

DensityPorositySalt

Salt Density
Porosity

Density porosity for Salt .

-1

-0.03

v/v
decimal

DensityPorosityShale

Shale Density
Porosity

Density porosity for Shale.

0.2

v/v
decimal

DensitySalt

Salt Density

Bulk density for Salt.

2.1

g/cm3

DensitySandstone

Sandstone
Density

Bulk density for Sandstone.

2.62

2.68

2.65

g/cm3

DensityShale

Shale Density

Bulk density for Shale.

2.65

g/cm3

DensityWetShale

Wet Shale
Density

Bulk density for Wet Shale.

2.3

g/cm3

DiameterBorehole

Borehole
Diameter

Diameter of the borehole.

100

8.75

inches

DiameterCasing

Casing Diameter Diameter of the casing.

36

inches

DiameterOfInvasion

Diameter of
Invasion

100

inches

DiameterTubing

Tubing Diameter Diameter of the tubing.

inches

DielectricConstantHC

Hydrocarbon
Dielectric
Constant

2.2

fred

DielectricConstantMatrix

Matrix Dielectric Dielectric constant for the


Constant
formation matrix.

3.5

35

4.65

unitless

DielectricConstantShale

Shale Dielectric
Constant

Dielectric constant for Shale.

10

55

25

unitless

EmpiricalInvasionFactor

Invasion Factor
Sw Sxo

Empirical invasion factor based


on Sw and Sxo

0.5

unitless

EquivCationConductance

Equivalent
Equivalent cation conductance.
Cation
Conductance(B)

30

3.83

mho/m
per
meq/cc

GammaRayClean

Gamma Ray
Clean

Gamma Ray count rate for a


clean zone. Sensitized only if
shale volume is to be calculated
from gamma ray counts.

500

20

API

GammaRayShale

Gamma Ray
Shale

Gamma Ray count rate for a zone 0


that is completely shale.
Sensitized only if shale volume is
to be calculated from gamma ray
counts.

500

100

API

HydrogenIndexFluid

Hydrogen Index Hydrogen index of fluid


of Fluid

1.5

unitless

NeutronPorosityAnhydrite

Anhydrite
Neutron porosity for Anhydrite.
Neutron Porosity

-0.025 0.025

-0.015

v/v
decimal

172

0
Diameter of the invasion of
drilling fluids into the surrounding
reservoir rock.

Dielectric constant of the


reservoir hydrocarbons.

Shared Utilities: Building Algorithms with MathPack

Units

R2003.12.1

Landmark Graphics Corporation

User Programming

Parameter Name

Parameter Title Description

Min. Max. Default


Value Value Value

NeutronPorosityClean

Neutron Porosity Neutron porosity in a clean


Clean
formation

NeutronPorosityCoal

Coal Neutron
Porosity

0.38

v/v
decimal

NeutronPorosityDryShale

Neutron Porosity Neutron porosity for Dry Shale.


of Dry Shale

0.2

v/v
decimal

NeutronPorosityHM

Heavy Mineral
Neutron porosity for Heavy
Neutron Porosity Minerals.

0.6

0.03

v/v
decimal

NeutronPorositySalt

Salt Neutron
Porosity

-1

-0.03

v/v
decimal

NeutronPorosityShale

Neutron Porosity Neutron porosity for Shale.


of Shale

0.2

v/v
decimal

NeutronPorosityShale

Neutron Porosity Neutron porosity in a shaly


Shale
formation

0.4

v/v
decimal

NeutronPorosityWetShale

Neutron Porosity Neutron porosity for Wet Shale.


of Wet Shale

0.25

v/v
decimal

PermeabilityConstant

Permeability
Constant

Permeability constant (K)

10000

250

unitless

PhotoelecIndexWetShale

Wet Shale
Photoelectric
Factor

Photoelectric index in Wet Shale 0

100

b/elec

PhotoelecXsecShale

Photoelectric
Cross Section
Shale

Macroscopic Photoelectric Cross 1


Section.

10

b/cm3

PorosityShale

Shale Porosity

Shale porosity

0.4

v/v
decimal

PropagationTimeDolomite

Propagation
Time Dolomite

Travel time in Dolomite for high


frequency (microwave) waves.

15

8.7

ns/m

PropagationTimeHC

Propagation
Time
Hydrocarbons

Travel Time in Hydrocarbons for 0


High Frequency (microwave)
waves. The rate of travel is
determined almost entirely by the
dielectric (insulating) properties
of the formation which is largely
related to the water content of the
formation.

10

4.7

ns/m

PropagationTimeLimestone

Propagation
Travel time in Limestone for high 0
Time Limestone frequency (microwave) waves.

15

9.7

ns/m

PropagationTimeSand

Propagation
Travel time in Sandstone for high 0
Time Sandstone frequency (microwave) waves.

15

7.2

ns/m

PropagationTimeShale

Propagation
Time Shale

Travel time in Shale for high


frequency (microwave) waves.

20

12

ns/m

PropagationTimeWater

Propagation
Time Water

20
Travel Time in Water for High
Frequency (microwave) waves.
The rate of travel is determined
almost entirely by the dielectric
(insulating) properties of the
formation, which is largely related
to the water content of the
formation.

90

29.5

ns/m

ResBoundWater

Water Resistivity Resistivity of water bound to the


Bound
clay minerals in the formation.

0.01

100

0.04

ohm.m

ResBoundWaterInv

Mud Filtrate
Bound
Resistivity

0.01

0.2

0.04

ohm.m

R2003.12.1

Neutron porosity for Coal.

Neutron porosity for Salt .

Resistivity of water bound to the


minerals in the invaded zone.

Units
v/v
decimal

Building Algorithms with MathPack: Appendices

173

Reports and Utilities

Landmark
Min. Max. Default
Value Value Value

Parameter Name

Parameter Title Description

ResBoundWaterInvTemp

Mud Filtrate
Temperature which the resistivity 32
Bound
of the bound water in the invaded
Resistivity Temp zone was measured

500

75

degF

ResBoundWaterTemp

Water Resistivity Temperature of the bound water


Bound Temp
at the time resistivity was
measured.

32

500

75

degF

ResistivityCleanLimit

True Resistivty
Clean limit

10000

ResistivityFlushZoneShale

Resistivity Shale Resistivity of Shale in the


Flushed Zone
Flushed Zone.

20

12

ohm.m

ResistivityShale

Resistivity Shale Resistivity for Shale in the


Undisturbed
undisturbed zone.
Zone

0.001

2000

0.5

ohm.m

ResistivityShaleLimit

True Resistivity
Shale limit

True Resistivity (Rt) in a shaly


formation

10000

ohm.m

ResMud

Mud Resistivity

Resistivity of the mud.

0.005

10

ohm.m

ResMudcake

Mudcake
Resistivity

Resistivity of the mudcake.

0.005

10

ohm.m

ResMudcakeTemp

Mudcake
Temperature which the resistivity 32
Resistivity Temp of the mudcake was measured

500

degF

ResMudFiltrate

Mud Filtrate
Resistivity of the Mud Filtrate
Resistivity (Rmf) which is present in the invaded
zone.

10

ohm.m

ResMudFiltrateTemp

Mud Filtrate
Temperature which the resistivity 32
Resistivity Temp of the Mud Filtrate which is
(TRmf)
present in the invaded zone was
measured

500

degF

ResMudTemp

Mud Resistivity
Temp

Temperature which the resistivity 32


of the mudwas measured

500

degF

ResWater

Water Resistivity Resistivity of the formation water. 0.001 10


(Rw)

ohm.m

ResWaterTemp

Water Resistivity Temperature which the resistivity 32


Temp (TRw)
of the formation waters was
measured.

degF

RHGFactor

Raymer Hunt
Gardner Factor
(k)

SalinityBorehole

Borehole Salinity The salinity of the borehole fluids. 0.001 300000

True Resistivity (Rt) in a clean


formation

0.005

0.625

SalinityFormation

Formation Water Salinity of the formation Waters.


Salinity

0.001

SalinityMudFiltrate

Mud Filtrate
Salinity

Salinity of the Mud Filtrate.

0.001

300000

SaturationExponent

Saturation
Exponent (n)

Saturation exponent (n) for the


Archie equation

0.1

SigmaBoundWater

Bound Water
Sigma

Neutron Capture Cross Section 20


of the Bound Water in the
formation. This term
encapsulates the apparent
capture cross section of the shale
should it differ from the sigma
matrix. This value can be
determined from a Sigma Water
Apparent vs SWB crossplot.

174

Shared Utilities: Building Algorithms with MathPack

ohm.m

500

Raymer Hunt Gardner Factor (k) 0


used to calculate sonic porosityif
the Raymer-Hunt-Gardner
Equation is selected

Units

unitless

ppm

300000

ppm
ppm

150

unitless
cu

R2003.12.1

Landmark Graphics Corporation

User Programming
Min. Max. Default
Value Value Value

Parameter Name

Parameter Title Description

SigmaFreeWater

Free Water
Sigma

Neutron Capture Cross Section 20


of the free (i.e. contained in the
effective porosity) water in the
formation. This term can be
determined from a knowledge of
Rw, and Rw temperature, Fluid
Salinity, or from a Sigma Water
Apparent vs Swb crossplot.

150

cu

SigmaHydrocarbon

Hydrocarbon
Sigma

Neutron Capture Cross Section


of the Hydrocarbons in the
formation.

25

cu

SigmaMatrix

Matrix Sigma

The capture cross section of the 0


rock (mineral, non-porous)
fraction. Due to diffusion effects
on the TDT, intrinsic matrix sigma
values are rarely used, instead
apparent matrix values are
commonly used. Sigma Matrix
can be determined in a clean,
non-hydrocarbon (gas) interval
by examining a Sigma log vs.
Porosity crossplot or the following
values might be used initially in
conjunction with sigma curves
that are not diffusion-corrected
formation / apparent capture
cross section Orthoquartzitic
Sand / 8.0 c.u. Subarkosic sand /
10.0 c.u.

300

10

cu

SonicPorosityShale

Shale Sonic
Porosity

The sonic porosity for Shale

0.5

0.3

v/v
decimal

SpontaneousPotentialClean

Spontaneous
Potential Clean

Spontaneous Potential for a


clean zone. Sensitized only if
shale volume is to be calculate
from spontaneous potential.

-200

100

-100

mV

SpontaneousPotentialShale

Spontaneous
Potential Shale

Spontaneous Potential for a shaly -200


zone. Sensitized only if shale
volume is to be calculate from
spontaneous potential.

100

mV

ThicknessCasing

Casing
Thickness

Thickness of the casing

0.5

inches

TortuosityFactor

Tortuosity Factor Tortuosity factor (a) for the Archie 0.1


(a)
equation

unitless

TransitTimeCoal

Coal Transit
Time

Acoustic transit time (delta t) in


Coal.

150

120

us/ft

TransitTimeCp

Transit Time
Compaction
Correction

Acoustic Compaction Correction 1


Factor for Sonic Logs. Transit
Time (Delta t) shale /100.

10

unitless

TransitTimeDolomite

Dolomite Transit Acoustic transit time (delta t) in


Time
Dolomite.

38.5

43.5

41

us/ft

TransitTimeDryShale

Dry Shale
Transit Time

Acoustic transit time (delta t) in


Dry Shale.

20

150

50

us/ft

TransitTimeFluid

Fluid Transit
Time

Travel Time in the Reservoir


Fluids

100

500

189

us/ft

TransitTimeLimestone

Limestone
Transit Time

Acoustic transit time (delta t) in


Limestone.

43.5

47.6

46

us/ft

TransitTimeMatrix

Matrix Transit
Time

Acoustic transit time (delta t) in


Matrix.

20

150

50

us/ft

TransitTimeSalt

Salt Transit Time Acoustic transit time (delta t) in


Salt.

20

150

64.4

us/ft

R2003.12.1

20

Building Algorithms with MathPack: Appendices

Units

175

Reports and Utilities

Landmark

Parameter Name

Parameter Title Description

Min. Max. Default


Value Value Value

TransitTimeSandstone

Sandstone
Transit Time

Acoustic transit time (delta t) in


Sandstone.

51.3

55.5

53.4

us/ft

TransitTimeShale

Acoustic Transit
Time in Shale

Acoustic transit time (delta t) in


Dry Shale.

20

150

50

us/ft

TransitTimeWetShale

Wet Shale
Transit Time

Acoustic transit time (delta t) in


Wet Shale.

20

150

50

us/ft

WeightCasing

Casing Weight

Weight of the casing

120

30

lbm/ft

30

15

lbm/
galUS

28

11

lbm/
galUS

WeightCement

Cement Weight

Weight of the cement.

WeightMud

Mud weight

Weight of the drilling fluid

176

Shared Utilities: Building Algorithms with MathPack

Units

R2003.12.1

Landmark Graphics Corporation

User Programming

Appendix 4: Understanding Error Messages


MathPack generates a set of messages as it processes an algorithm.
These messages are displayed in the Main MathPack window, in the
status area.
Common syntax errors include misspelled or misplaced reserved words
and missing or misplaced lexical elements like parentheses, commas,
etc. Common semantic errors include values inappropriate for their
context such as parameters known to be out of range for a given
function or operands whose type is invalid within a given
expression.These messages may be broadly classified into two groups:

Information messages
Error messages

Information Messages
Information messages are generated for different reasons, but are
always preceded by the pattern
>> INFO:
These messages may display the status of MathPack algorithm
processing or provide additional detail about a previous message. One
or more information messages often follow an error message. See the
discussion that follows.

Error Messages
Error messages are generated when the algorithm checker detects an
unresolved error in the specified algorithm. Error messages are always
preceded by the pattern
>> ERROR:
These messages state the nature of the error and attempt to provide the
lexical element (or part) of the algorithm causing the error. This
explanation generally consists of an element enclosed in quotes and the
line number of the offending occurrence in the algorithm. As in the
fragment:
at ")" on line 3
Note that the lines are not numbered as currently displayed in the
algorithm builder, but when possible, the offending element is
R2003.12.1

Building Algorithms with MathPack: Appendices

177

Reports and Utilities

Landmark

highlighted in the text of the algorithm builder window. The detail is


appended to generalized message text. For example,
>> ERROR: Unexpected lexical element
encountered at ")" on line 3
Error messages may be followed by one or more information messages
that give more detail about an error or supply status information
resulting from the error. As in
>> ERROR: Incorrect assignment statement syntax
at ":=" on line 12
>> INFO: Assignment symbol "=" expected
>> INFO: Pass One failed
Errors in the source can be categorized into two general types:

Syntax errors
Semantic errors

Syntax Errors
Syntax errors originate when a grammar rule for the correct
specification of an algorithm has been violated. Examples include:

mismatched parentheses
missing or misplaced commas
unterminated statements
missing or misspelled reserved words
improperly quoted curve ids

Semantic Errors
Semantic errors may occur in syntactically correct algorithms, but
violate some meaning of a construct. Examples include:

a divide by zero is attempted.


a curve does not exist for a given well.
parameters that are inappropriate for a function, if an expression is
outside a specified bound or is of the wrong type

The algorithm checker attempts to statically check the algorithm being


processed for syntax and semantic errors. If a syntax error is detected,
the algorithm checker will report an error message. While the detail
178

Shared Utilities: Building Algorithms with MathPack

R2003.12.1

Landmark Graphics Corporation

User Programming

supplied in the message or in supporting information messages may not


accurately pinpoint the source of the error, the offending element is at
or near (usually before) the point reported by the message.
A list of all MathPack messages is given below. Note that Informational
Messages are marked with an (I) and Error Messages are marked with
an (E).

Explanation of Information and Error Messages


Parse completed (I)
The parser has completed processing of the current algorithm
specification.
Parse failed (I)
The parser failed during processing of the current algorithm
specification. This message would normally be preceded by more
explicit (error or) information messages.
Unknown error condition (I)
Internal status information about parser progress. An error of
unknown origin has occurred. This is a critical error and should be
reported to customer support. In order to reproduce the error,
Landmark Customer Service will need the following information:

current dataset
depth and sampling parameters,
the algorithm specification

Division by zero (E)


The parser has detected an attempt to evaluate a division by zero in
the current algorithm specification. Since the result of this
operation cannot be represented arithmetically, the parser will not
proceed.

R2003.12.1

Building Algorithms with MathPack: Appendices

179

Reports and Utilities

Landmark

Taking the root of a negative value (E)


The parser has statically detected an attempt to evaluate the root of
a negative value in the current algorithm specification. Since the
result of this operation cannot be represented arithmetically, the
parser cannot proceed.
Taking square root of a negative value (E)
A more specific version of the previous message, used in
conjunction with the predefined function SQRT.
Zero base with negative exponent (E)
The parser has statically detected an attempt to raise a base of zero
to a negative exponent.
Taking log of non-positive value (<= 0.0) (E)
The parser has statically detected an attempt to evaluate the log of
a non-positive value, i.e. a value that is less than or equal to zero.
Parameter not in required range (E)
The parser has statically detected a function parameter that is not
in the required range for the pre-defined function where the
parameter is used.
Must be in range [-1, 1] (I)
The function parameter must be in the inclusive range from -1 to 1.
Values outside this range are inapplicable for the specified predefined function.
Must be in range [-(/2), (/2)] (I)
The parameter must be in the inclusive range from -/2 to /2.
Values outside this range are inapplicable for the specified predefined function.
Must not be equal to 90 or -90 degrees (/2 or -

/2) (I)

The parameter must not be equal to 90 or -90 degrees, in a


trigonometric context. Parameters having these values are
inappropriate for the specified pre-defined function.

180

Shared Utilities: Building Algorithms with MathPack

R2003.12.1

Landmark Graphics Corporation

User Programming

Incorrect syntax (E)


The parser has detected incorrect syntax in the current algorithm
specification. This is a general syntax error used, when no other
(more specific) message is applicable.
Incorrect algorithm syntax (E)
The parser has detected incorrect syntax in the current algorithm
specification. This is a general syntax error used, when no other
(more specific) message is defined. This message is
interchangeable with the previous message.
Incorrect declaration syntax (E)
The parser has detected incorrect syntax for a variable declaration
in the current algorithm specification.
Incorrect statement syntax (E)
The parser has detected incorrect syntax for a statement in the
current algorithm specification.
Incorrect assignment statement syntax (E)
The parser has detected incorrect syntax for an assignment
statement in the current algorithm specification.
Incorrect if statement syntax (E)
The parser has detected incorrect syntax for an if statement in
the current algorithm specification.
Incorrect loop statement syntax (E)
The parser has detected incorrect syntax for a loop statement in
the current algorithm specification.
Invalid function parameter (E)
The parser has detected use of a invalid parameter to the specified
pre-defined function. The parameter is:

R2003.12.1

not in a required range


not of the required type, i.e. boolean instead of numeric
not static when required.

Building Algorithms with MathPack: Appendices

181

Reports and Utilities

Landmark

Unexpected lexical element encountered (E)


The parser has detected a lexical element that has no meaning or is
inappropriate for its position in the current algorithm specification.
Assignment symbol "=" expected (I)
The parser has encountered incorrect syntax in what it believes is
an assignment statement. Another (or no) lexical element was
found when expecting the assignment symbol =.
Semi-colon expected (I)
The parser has encountered incorrect syntax at what it believes
should be a statement termination. Another (or no) lexical element
was found when expecting the statement terminator, semi-colon
(;).
Valid statement expected (I)
The parser has encountered a pattern in the current algorithm that
cannot be interpreted as a statement.
Variable identifier expected (I)
The parser has encountered incorrect syntax in a variable
declaration, where a variable identifier was expected.
Reserved word then expected (I)
The parser has encountered incorrect syntax in an if statement,
where the reserved word then was expected.
Reserved words end if expected (I)
The parser has encountered incorrect syntax in an if statement,
where the reserved words end if were expected.
Reserved words end expected (I)
The parser has encountered incorrect syntax in a loop statement,
where the reserved words end was expected.
Nested if statement encountered (I)
The parser has encountered nested if statements. Current
restrictions prevent nesting of if statements.

182

Shared Utilities: Building Algorithms with MathPack

R2003.12.1

Landmark Graphics Corporation

User Programming

Mismatched parenthesis (I)


The parser has encountered incorrect syntax in an expression,
where the number of opening and closing parenthesis are not
equal.
Undefined curve (E)
The parser has found reference to a curve that does not exist for the
given well.
Undefined zone(I)
The specified zone (or depth interval) is undefined for the given
curve in the well currently being processed.
Unterminated curve name (I)
The parser has encountered incorrect syntax while processing a
curve name. An opening quote (indicating the beginning of a curve
id) was found and the end of a line was reached without finding the
corresponding closing quote.
Curve name exceeds allowable length(26chars) (E)
A quoted curve name was encountered that contained more than
the maximum allowable number of characters. Log curve names
may not be longer than 26 characters in length.
Shorten curve name (I)
Use a log curve name with fewer characters.
Undefined symbolic constant (I)
The parser cannot resolve reference to what it believes is a
symbolic constant. Beware to quote curve names. Some unquoted
curves names may appear in context to be symbolic constants.
Check curve selection for well (I)
The parser has found reference to a curve that does not exist for the
given well. The list of valid curves for that well should be verified.

R2003.12.1

Building Algorithms with MathPack: Appendices

183

Reports and Utilities

Landmark

Check unit selection for well (I)


The parser has encountered a unit (or depth interval) that is
undefined for a curve in the current well. Valid units (or top and
bottom) should be checked for the well.
*Check for typographical spelling error(s) (I)
The parser has encountered a syntax or semantic error that might
classically arise through a typographical error. Where the error
message occurs, check that all symbolic constants exist as named.
Check that all curves exist in appropriate wells as named.
Check for closing quotation mark (I)
The parser has encountered what it believes is a curve name with
no closing quotation mark. Remember that quoted curve names
may not span multiple lines. Check that all curve names have
opening and closing quotes.
Undeclared temporary variable (E)
The parser has encountered what it believes is a variable name in
the context of an assignment statement, where no declaration has
been provided for the named variable.
Only declared variables and log curves may be
assigned values (I)
The parser has encountered an assignment to an unknown
identifier and suggests the proper use.
Temporary variable redeclared (E)
The parser has encountered a duplicate declaration for a temporary
variable in the current algorithm specification.
A variable may be declared only once (I)
The names of declared temporary variables must be unique. The
declaration for a variable with a given name may only appear once
in the current algorithm specification.

184

Shared Utilities: Building Algorithms with MathPack

R2003.12.1

Landmark Graphics Corporation

User Programming

Condition statically evaluated (I)


The parser has detected the condition of an if or loop
statement that was statically determined to be TRUE (or FALSE).
The appropriate parts of the algorithm will either be performed or
automatically removed, i.e are not considered during processing of
the algorithm.

The next several messages are related to the above message and will
appear in some combination, depending on the context.
Check terms and relations, if static condition
is not intended (I)
This message serves as an additional warning. Some static
conditions may be intentional.
Condition is always TRUE (I)
Condition is always FALSE (I)
The parser has detected a condition of an if or loop statement
that is statically determined to be TRUE (or FALSE).
If statement will never be performed (I)
The condition of an if statement (without an else part) was
statically determined to be FALSE. The condition is not
considered and the if statement (including all of its enclosed
statements) is effectively removed from processing.
Note that the case for if statements that are ALWAYS TRUE is
not explicitly announced. The condition of the if statement is not
considered during processing and the statements enclosed by the
if are always performed.
Else part will always be performed (I)
The condition of an if statement (with an else part) was
statically determined to be FALSE. The condition is not
considered during processing and the statements enclosed by the
else part are always performed.

R2003.12.1

Building Algorithms with MathPack: Appendices

185

Reports and Utilities

Landmark

Else part will never be performed (I)


The condition of an if statement (with an else part) was
statically determined to be TRUE. The condition is not considered
during processing and the statements enclosed by the if part are
always performed. Statements enclosed by the else part are
never performed and are effectively removed from the algorithm.
Loop wont terminate (E)
The parser has detected a loop condition that was statically
evaluated to be TRUE. Once entered, the loop will never terminate
nad cause an endless iteration over the enclosed statements. Note
that this case is considered to be an error and will prevent the
algorithm from being processed.
Loop will never be entered (I)
The parser has detected a loop condition that was statically
evaluated to be FALSE. The condition is not considered during
processing and the loop statement (including all of its enclosed
statements) is effectively removed from the algorithm. Note that
this case is not considered to be an error, as for non-terminating
loops.
Boolean expression expected (I)
The parser has encountered a numeric expression when expecting
a boolean expression. A boolean expression is one that, when
evaluated, yields a logical result of TRUE or FALSE.
Numeric expression expected (I)
The parser has encountered a boolean expression when expecting a
numeric expression.

186

Shared Utilities: Building Algorithms with MathPack

R2003.12.1

Landmark Graphics Corporation

User Programming

Appendix 5: MathPack Syntax


This appendix describes the grammar and syntax of MathPack in
formal mathematical notation and details. It is presented here for those
who have the background and interest to explore MathPack more
deeply. It is NOT necessary to understand (or even read) this section to
become proficient as a MathPack user.
The syntax for MathPack algorithms is expressed as a set of grammar
rules. For each rule, there is a left hand side, a special meta-symbol
::= (read is represented by), and a right hand side. The left hand
side of a rule is called a non-terminal, while the right hand side may be
a combination of non-terminals, terminals, and literals.
Example:
Curve Name

Expression

PHIE = PHI + Vsh*PHIsh;


Non-terminal

Non-terminals, Terminals, and/or Literals

The table beginning on the following page lists the syntax rules that
you must adhere to when you generate a MathPack algorithm.
For example, the first rule states that
An algorithm is represented as an optional
declaration_list followed by a statement_list.

The second rule states that:


A declaration_list is represented as a declaration
followed by an optional declaration list

The next rule states that:


a declaration is represented by the reserved literal,
VARIABLE, followed by a symbol name, followed by a
semi-colon.

R2003.12.1

Building Algorithms with MathPack: Appendices

187

Reports and Utilities

Landmark

The following table describes MathPack syntax rules in a formal


format; the Modified BNF Format

Left Side

Meta
Symbol

Right Side

algorithm

::=

{declaration_list}
statement_list

declaration_list

::=

declaration
{declaration_list}

declaration

::=

VARIABLE id;

statement_list

::=

statement
statement_list |
EMPTY

statement

::=

assignment_statement|
if_statement
loop_statement|

assignment_statement

::=

CURVE_ID = expression;

if_statement

::=

if (condition) then
statement
statement_list
[else
statement;
statement_list]
end if;

condition

::=

expression

expression

::=

relation
relation and relation
relation or relation

relation

::=

simple_expression
simple_expression =
simple_expression!=
simple_expression <
simple_expression<=
simple_expression >
simple_expression>=

simple_expression

::=

term
term + simple_expression
term - simple_expression

term

::=

factor
factor * term
factor / term

188

Shared Utilities: Building Algorithms with MathPack

|
|

|
simple_expression|
simple_expression|
simple_expression|
simple_expression|
simple_expression|
simple_expression
|
|

|
|

R2003.12.1

Landmark Graphics Corporation

User Programming

Meta
Symbol

Left Side

Right Side

factor

::=

primary |
primary ^ primary

primary

::=

ID
CURVE_ID
REAL_LITERAL
INTEGER_LITERAL
BOOLEAN_LITERAL
NULL_LITERAL
function_call
(expression)

function_call

::=

abs
aco
asin
atan
cos
exp
cot
log
ln
mod
neg
random
sin
sqrt
tan

|
|
|
|
|
|
|

(simple_expression)|
(simple_expression)|
(simple_expression)|
(simple_expression)|
(simple_expression)|
(simple_expression)
(simple_expression |
(simple_expression)|
(simple_expression |
(simple_expression,
simple expression)|
(simple_expression) |
(min_value, max_value)
(simple_expression) |
(simple_expression) |
(simple_expression)

Non-terminals
Non-terminals do not end an expression by themselves; they refer to
other grammar rules. Notice that this process may lead to recursive,
self-reference and allows the grammar to represent arbitrarily nested
constructs.

Meta-symbols
Meta-symbols have no meaning except to help define the grammar
itself. As such, meta symbols do not become a part of the algorithm
specification.The following meta-symbols are used in the grammar
rules:

R2003.12.1

Colon, Colon, Equal Sign (::=) is placed between the left and the
right hand side of a rule, and stands for is represented by.
Building Algorithms with MathPack: Appendices

189

Reports and Utilities

Landmark

Vertical bar (|) denotes variations in the rule, essentially meaning


OR, i.e., one part of the rule OR another (not both) may be applied.

Curly braces ({ }) denote part of a rule that may appear 0 or more


times, i.e., the part is optional and may be used repeatedly for the
rule.

Square brackets ([ ]) denote part of a rule that may appear 0 or 1


times, i.e., the part is optional but may be used only once for the
rule.

Terminals
Terminals are not defined in terms of further grammar rules and
therefore cannot be reduced further. Each terminal is composed of
unique patterns of characters that help distinguish it from another
terminal. The patterns for each terminal are shown in the following
table. The ellipsis (...) is used to indicate a range of possible values.
Terminals

190

Representation

I
D

alphanum{alphanum | otherchar}

C
U
R
V
E
_I
D

alphanum{otherchar}

I
N
T
E
G
E
R
_
L
I
T
E
R
A
L

digit{digit}

Shared Utilities: Building Algorithms with MathPack

R2003.12.1

Landmark Graphics Corporation

User Programming

Terminals

R2003.12.1

Representation

R
E
A
L
_
L
I
T
E
R
A
L

{digit}.digit{digit}

B
O
O
L
E
A
N
_
L
I
T
E
R
A
L

true | false

N
U
L
L
_
L
I
T
E
R
A
L

null

Building Algorithms with MathPack: Appendices

191

Reports and Utilities

Landmark

Terminals

192

Representation

al
p
h
a
n
u
m

a...z | A...Z | 0 ... 9

di
gi
t

0 ... 9

ot
h
er
c
h
ar

<any printable non-alphanumeric character>

V
A
R
I
A
B
L
E

symbol name

E
M
P
T
Y

<nothing>

Shared Utilities: Building Algorithms with MathPack

R2003.12.1

Landmark Graphics Corporation

User Programming

Literals
Literals stand for themselves, that is, are to be interpreted literally, and
are, in fact, terminals. Some literals are special markers and are
reserved.
Following is a list of reserved literals:
if
then
else
or
true
false
null
end
loop
variable

Other literals may represent numbers. For example:


1
0
0.0
1.2345
.12345

R2003.12.1

Building Algorithms with MathPack: Appendices

193

S-ar putea să vă placă și