User Model - Log Transform

 

 

User models can perform log analysis functions such as computing clay volume, water saturation, effective porosity or any other calculation involving one or more log curves.  The model is executed one time through for each depth or sample increment in the selected depth interval.  Users should be familiar with programming languages such as FORTRAN before attempting to create or modify a user model file.  All models must end in a .TXT extension.  

This log transformation is available on the Advanced Transforms tool.

User Model File – This dropdown lists the existing user models in Petra’s USERMOD subdirectories.  For standalone licenses, both the “Shared” and “Private” directories are C:\geoplus1\USERMOD by default. The network location of the USERMOD folder will depend on the installation.  Commonly, for network licenses, the “Shared” directory will be in the PetraSERV\USERMOD directory, and the “Private” directory will usually be in the client geoplus1\USERMOD directory.

Compile Model – This button loads the model into Petra’s memory and populates the Input and Output tabs with variables.

Execute Model – Once the model is compiled and all input and output variables are assigned, this button actually runs the user model.

 

Model tab

View Model – This option opens a read-only text editor with the currently selected model.  Changes made here cannot be saved.

Modify Model – This option opens a text editor with the currently selected User Model.  Changes made to the model can be saved.

New Model – This option attempts to open C:\geoplus1\USERMOD\Untitled.TXT with the computer’s default text editor.  

Refresh List – This option refreshes the User Model File dropdown list at the top of the User Model Transform tool.

Delete – This option deletes the currently selected User Model.

Copy As… - This option copies the currently selected User Model with a user-selected name.

Copy to Private Dir – This option saves the user model to the private directory.  Once in the private directory, the specific user model can be accessed by the user in any project.

Copy to Public Dir – This option saves the user model to the public directory.  Once in the public directory, the specific user model can be accessed by any user in any project.

 

Input Variables tab

User Models can use log curves, constant values, zone data items, 'NULL' values, 'DEPTH' or 'STEP' values as input variables.  Each input variable should be assigned to the appropriate database entity.

To assign a model variable, select the variable name listed in the “Input Variable Assignments" list.  Next, select the relevant log, zone item, constant, or "Other" item (including nulls, depth values, sample rates, TVD or SSTVDs). Select the “Apply” button to set the assignment and add it to the ”Input Variable Assignments” list.

Load Assignments – This option loads a saved set of input variable assignments.

Save Assignments - This option saves the existing set of input variable assignments.

 

Output Variables tab

The model stores one or more output log curves stored in the log database.  These logs can be either be existing logs or new log names.  

To assign an output model variable, select the variable name listed on the "Output Variable Assignments" list and select the desired output log.   To create a new log name, type the log name in the "Log" drop down list. Click the Apply button and the log definition dialog screen will prompt you for the log units and description.  Output logs computed in the model but not stored back in the database can be specified as "UNASSIGNED".

 

Options tab

The Options tab sets how Petra handles missing curves and establishes a depth range for the calculation.

If well is missing an input log – This dropdown establishes how Petra handles missing values.  Petra can either skip wells missing any input values, or can simply assign missing values a NULL value.

Set Depths... – This button opens the “Set Depth Range” box.  The settings here are already populated from the Log Transformation module, but can be changed here as well.  Deselecting the “Restrict Model to Depth Limits” will run the user model over the entire depth range of the well.

 

Messages tab

The Messages tab provides the results of the user model, including which wells failed to go through the model due to missing data.

 

 

Creating User Models

User models are text files that contain the programming logic to perform complicated, multi-line equation and conditional operations on logs. The User Model Transform sets the input and output variables, establishes how Petra handles missing or incomplete data, and runs the models.  

Statements

Each statement in the model consists of variables, operators, and keywords.  Each statement in the model is terminated with a semicolon (;). Statements may be continued over more than one line.  An operator or delimiter, such as a space or parenthesis separates constants, variables, and numbers.  Statements which control the flow of the program logic contain keywords "GOTO", "IF...THEN...ELSE", or "BEGIN...END".  Branching is done using statement LABELS placed on a line prior to the point of continued processing.  Each label consists of a character string terminated by a colon (:). Examples of labels are LABEL1:, L999: and DONE:.

Variables 

Variables can be named up to a maximum of 40 characters.

Log Definitions

LOGDEF statements precede all other declaration statements, and define the log’s name, units, and descriptions.  Log definitions use the syntax:

LOGDEF NAME(logname)  UNITS(units)  DESC(description);

Example:

LOGDEF NAME(GRTEMP)    UNITS(API) DESC(GAMMA RAY);

Comments

 An exclamation mark (!) or double forward slash (//) defines the beginning of a comment.  A ! or // in column one will comment an entire line, while a ! or // comment text following the semicolon (;) will create an in-line comment.

 Examples:

!  this is a commented line.

A= B + C; !  this is an in-line comment.

// this is a comment as well

X = Y/Z;        // and so is this

 

Symbols and Keywords

(;)                                        End of statement terminator

(!)                                        Comment indicator (start comment)

(:)                                        Label terminator

Space                                        Delimiter

IF                                        Test control word

THEN                                        Continuation of test

THEN BEGIN                        Starts "TRUE" condition of test

ELSE BEGIN                                Starts "FALSE" condition of test

GOTO                                        Branch to a label

CONSTANT                                Declare constant

LOG                                        Declare curve

LOGDEF                                Defines new curve in database

IN                                        Declare LOG curve as input only

OUT                                        Declare LOG curve as output only

UPDATE                                Declare LOG curve as input but may be modified and

                                 stored back in the DB

DO                                        Do loop

END                                        End THEN BEGIN or ELSE BEGIN section

ENDDO                                End Do Loop

ENDMOD                                Terminates the model

Functions

Function                                Keyword                Example

------------                                ------------                -------------

Add                                        +                        A+B

Subtract                                -                        A-B

Multiply                                *                        A*B

Divide                                        /                        A/B

Exponential                                ** or ^                        A**2 or A^2  (A squared)

Assign                                =                        A = 1.0

Compare equal                        = or .EQ.                IF(A=B) THEN...    or

IF(A.EQ.B) THEN...

Compare not equal                        .NE.                        IF(A.NE.B) THEN

Logical AND                                .AND.                        IF( A=B) .AND. (C=D))...

Logical OR                                .OR.                        IF((A=B).OR.(C=D))...

Greater than                                > or .GT.                IF(A.GT.B)...

Less than                                < or .LT.                IF(A<B)...

Greater or equal                        >= or .GE.                IF(A.GE.B)...

Less or equal                        <= or .LE.                IF(A.LE.B)...

E to power of X                        EXP(x)

Log (natural)                                LN(x)

Log (base 10)                        LOG10(x)

Absolute value                        ABS(x)

Square of X                                SQR(x)

Square root of X                        SQRT(x)

Negative (-x)                                NEG(x)

Truncate to integer                        TRUNC(x)

Sign of number times 1                SIGN(x                 IF(SIGN(x)=-1) THEN BEGIN;

Round to 2 dec places                ROUND(x)

Maximum of x and y                        MAX(x,y)

Minimum of x and y                        MIN(x,y)

Remainder of x / y                        MOD(x,y)

Sine of x                                SIN(x)                        x is in degrees

Cosine of x                                COS(x)                x is in degrees

Tangent of x                                TAN(x)                x is in degrees

Arcsine of x                                ASIN(x)                angle returned is in degrees

( -1 >= x <=1  )

Arccosine of x                                ACOS(x)                angle returned is in degrees

( -1 >= x <=1  )

Arctangent of x                        ATAN(x)                angle returned is in degrees

( -1 >= x <=1  )

Ternary Interpolation Functions

A = ATERN(Ax,Ay,Bx,By,Cx,Cy,x,y);

B = BTERN(Ax,Ay,Bx,By,Cx,Cy,x,y);

C = CTERN(Ax,Ay,Bx,By,Cx,Cy,x,y);

SW = INTERN(Ax,Ay,Bx,By,Cx,Cy,x,y);

or

SW = TERNIN(Ax,Ay,Bx,By,Cx,Cy,x,y);

 

Ternary iterpolation functions can be used to solve a triangular phase diagram defined by the vertices, AxAy, BxBy, and CxCy.  Given the point x,y:

 

ATERN computes the percentage of A from 0-100,

BTERN computes the percentage of B from 0-100, and

CTERN computes the percentage of C from 0-100.

INTERN or TERNIN returns 1 if xy is inside the ternary triangle and 0 if outside.

Parenthesis

Binary operators are defined as an expression enclosed within parentheses, such as, (x+y) or (x*y). Statements require parentheses only when more than one binary operation is used or when you wish to force the evaluation precedence. The normal operator precedence from lowest to highest is:

+ and -

* and /

**

unary -  (minus sign)

The expression A+B*C**D/E-F is equivalent to (A+((B*(C**D))/E))-F  and would be evaluated in the following steps. Intermediate expressions are shown in braces.

 

K = C**D                        [A+B*K/E-F]

L = B*K                        [A+L/E-F]

M = L/E                        [A+M-F]

N = A+M                        [N-F]

O = N-F

 

Parenthesis force the sub-expression enclosed to be evaluated first, as illustrated below.

(A+B)*C**D/(E-F)

 

K = A+B                        [K*C**D/(E-F)]

L = C**D                        [K*L/(E-F)]

M = K*L                        [M/(E-F)]

N = E-F                        [M/N]

O = M/N

 

Declaration Statement

The declaration section is the first part of a model program in which the input and output logs and constants are defined.  Each declaration statement consists of a "type" keyword, a variable name, and a "use" keyword.   It is not necessary to declare temporary variables; temporary variables are defined for the first time with an assignment statement.

Examples:

LOG        SW                IN;

LOG        RHOB                OUT;

CONSTANT                SAND                2.5;        ! value is optional

CONSTANT                NULL;                        ! assumed to represent NULL log value

Executable Statement

An executable statement is any statement in which an equation type calculation is performed or an assignment is made. The general form is:

ASSIGNMENT_VARIABLE = executable_statement;

 

Examples:

x = a * b;

x = (a*(b+c))/(x-y);

Note that each line is terminated with a semicolon (;) and the equal sign (=) is required.  Variables appearing on the right side of the equation must either be declared as constants, logs, or be temporary variables defined as the result of an earlier assignment statement.

GOTO and Label Statement

The "GOTO" keyword and following label is used to branch to another part of the program.

Example:

IF ( x > 0.0 ) THEN GOTO DIVIDE;

y = 0.0;

GOTO MORE;

DIVIDE:

y = y / x;

MORE:

statement;

statement;

etc.

 

IF-THEN Statement

The IF-THEN statement conditionally executes a single assignment statement, GOTO, or BEGIN-END group based on the results of a logical comparison.

 

Example: 

IF( GR = NULL ) THEN  GOTO DONE;

IF( B .NE. 0.0 ) THEN  C = A / B;

IF( SW > 0.75 ) THEN  BEGIN;

SW3 = (1-SW)**3;

SW  = 1-(16/3)*SW3*(5-128*SW3);

END;

IF-THEN-ELSE Statement

The IF-THEN-ELSE compound statement provides conditional processing in a clear and efficient manner without the use of a GOTO.

 

Example:

IF ( logical expression ) THEN BEGIN;

statement;

statement;

etc.

END;

ELSE BEGIN;

statement;

statement;

etc.

END;

DO-LOOP Statement 

The DO loop statement is used to repeat a section of the model a set number of times.

The general format of the DO loop is:

 

       DO counter = first TO last;

               statement;

               statement;

               etc.

       ENDDO;

 

Example:

The following example sums values from 1 to 10. "A" is summed when K is even and "B" is summed when K is odd.                

SUM = 0.0;

N = 10;

DO K = 1 TO N;

IF( MOD(K,2)=0) THEN BEGIN;

SUM = SUM + A;

END;

ELSE BEGIN;

SUM = SUM + B;

                END;

ENDDO;