petrel tips&tricks from scm - scminc.com · 1 tips for writing workflows the process manager is...

13
Knowledge Worth Sharing Petrel TIPS&TRICKS from SCM Petrel is a mark of Schlumberger 4801 Woodway Drive, Suite 150W Houston, TX 77056 www.scminc.com [email protected] © 2011 SCM E&P Solutions, Inc. 1 Tips for Writing Workflows The Process Manager is the tool used to write workflows. A workflow manages Petrel processes (hence the name), files, graphics, and parameters. A workflow can execute many dozens or 100s of steps without interruption. Using workflows allows you to document what you are doing and rerun the steps when data or parameters change. Workflows allow users to build multiple models to test uncertainty around specific parameters. Workflows are the tools that allow experienced users to up their Petrel modeling efficiency by one or two orders of magnitude. Writing good workflows in Petrel requires that you set conventions and follow them whenever possible. By this we mean that you use the same organization in each workflow, document consistently and in the same way, use variables in an organized fashion, set up loops the same way each time, manage files effectively, and the list goes on. These are not difficult things to do but for those who do not write workflows or programs on a daily basis, their implementation may not be obvious. This TIPS&TRICKS article describes several techniques that, when used, will let you write better quality workflows faster. This TIPS&TRICKS article assumes that you already know how to write a Petrel workflow. If you don’t know how, we suggest you take a one day Process Manager class to learn the syntax and basics of workflow writing. SCM has such a class and it’s schedule is on our website. Even if you don’t know how to write a workflow, we feel you will gain a better understanding of what a workflow is from reading this article. Workflow Techniques There are probably as many workflow writing techniques as there are workflow writers. We have selected five that we feel significantly improve the quality of a workflow and the ease of writing and using it. Each is discussed below with examples. Organization A Petrel workflow is a program. Many of the Process Manager tools are programming tools. You will need to learn to use these tools in order to be an effective Workflow writer. Like a well written program, the well written workflow should have a simple organization that is easy to follow. The approach that we use is to place all items that will change at the top of the workflow; the Input section. These are followed by commands that initialize various petrel windows and actions; the Initialization section. The Processing section is the third part of the workflow. Generally the Processing section is much larger than the other two sections. Spaces and comments are used to separate the sections and to tell the user what is and is not to be changed. Spaces and comments are also used to make a long workflow easier to read and tell the user what is happening in each section.

Upload: others

Post on 31-Aug-2019

75 views

Category:

Documents


6 download

TRANSCRIPT

K n o w l e d g e W o r t h S h a r i n g

Petrel TIPS&TRICKS from SCM

Petrel is a mark of Schlumberger

4801 Woodway Drive, Suite 150W • Houston, TX 77056 • www.scminc.com • [email protected]

© 2011 SCM E&P Solutions, Inc.

1

Tips for Writing Workflows The  Process Manager  is  the  tool  used  to write workflows.    A workflow manages  Petrel  processes (hence the name),  files, graphics, and parameters.   A workflow can execute many dozens or 100s of steps without  interruption.   Using workflows allows you  to document what you are doing and rerun the steps when data or parameters change.   Workflows allow users  to build multiple models  to  test uncertainty around specific parameters.   Workflows are the tools that allow experienced users to up their Petrel modeling efficiency by one or two orders of magnitude. 

Writing  good  workflows  in  Petrel  requires  that  you  set  conventions  and  follow  them  whenever possible.    By  this  we  mean  that  you  use  the  same  organization  in  each  workflow,  document consistently and  in  the same way, use variables  in an organized  fashion, set up  loops  the same way each time, manage  files effectively, and the  list goes on.   These are not difficult things to do but  for those who  do not write workflows or programs on  a daily basis,  their  implementation may not be obvious.    This  TIPS&TRICKS  article  describes  several  techniques  that, when  used, will  let  you write better quality workflows faster. 

This TIPS&TRICKS article assumes that you already know how to write a Petrel workflow.  If you don’t know how, we  suggest you  take a one day Process Manager class  to  learn  the  syntax and basics of workflow writing.   SCM has such a class and  it’s schedule  is on our website.   Even  if you don’t know how  to write  a workflow, we  feel  you will  gain  a better understanding of what a workflow  is  from reading this article.  

Workflow Techniques 

There are probably as many workflow writing techniques as there are workflow writers.  We have selected five that we feel significantly improve the quality of a workflow and the ease of writing and using it.  Each is discussed below with examples.  

Organization 

A Petrel workflow is a program.  Many of the Process Manager tools are programming tools.  You will need to learn to use these tools in order to be an effective Workflow writer.  Like a well written program, the well written workflow should have a simple organization that is easy to follow.  The approach that we use is to place all items that will change at the top of the workflow; the Input section.  These are followed by commands that initialize various petrel windows and actions; the Initialization section.  The Processing section is the third part of the workflow.  Generally the Processing section is much larger than the other two sections.  Spaces and comments are used to separate the sections and to tell the user what is and is not to be changed.  Spaces and comments are also used to make a long workflow easier to read and tell the user what is happening in each section.  

Petrel is a mark of Schlumberger

4801 Woodway Drive, Suite 150W • Houston, TX 77056 • www.scminc.com • [email protected]

© 2011 SCM E&P Solutions, Inc.

2

The figure below shows a simple but effective workflow organization.  Version 2010 is the first Petrel version to have line numbers in the workflow.  This is a welcome addition to the Process Manager. 

Figure: Workflow showing the Input, Initialization, and Processing sections (top) the folder input to the workflow (bottom left) and the messages written by the workflow (bottom right).  

 

     

 

Variable Usage 

Definition 

If files are the packages that are moved around by the workflow then variables are the handles attached to the packages (files) that allow the workflow (and you) to grab and move them.  By linking a variable to a file then every time that file is needed by the workflow, the variable is used to point to it.  This has a huge advantage when building a workflow because the file is only input once at the top of the workflow.  At that time it is linked to the variable.  Then even if the file must be used 5 or 100 times 

Petrel is a mark of Schlumberger

4801 Woodway Drive, Suite 150W • Houston, TX 77056 • www.scminc.com • [email protected]

© 2011 SCM E&P Solutions, Inc.

3

in the workflow, you have only had to point to the file once.  When you want to point to a different file, you don’t have to change 100 locations, but rather only the single input location.   

Figure: Two workflows that do the same thing. The left workflow requires that the grid name be entered 4 times and the right workflow requires only one entry.  

     

 

Name Conventions 

Variables are the messiest part of most workflows.  Normally there is no organization in the way variables are used and it is hard to follow the logic.  True, you must think in a distorted manner (sort of like a programmer) when using variables, but there is no reason the thought process can’t be somewhat organized.  We follow a simple convention when assigning variables in a workflow. For the input files we start at the top of the variable list and use A for the first file, B for the second and so on.  For the assignment of variables when processing we start at the bottom and use AZ for the first processing assignment, AY for the next, and so on.  This way the organization of the variables has some meaning and it is a little easier to follow the logic.  Also, when you are half way finished writing the workflow and remember another input file that is needed, it can be assigned the next letter in the variable list.  This keeps the workflow neat and organized.   This is particularly helpful in long workflows so that you don’t have to go back and try to find which variables haven’t been used when you need a new one. 

Petrel is a mark of Schlumberger

4801 Woodway Drive, Suite 150W • Houston, TX 77056 • www.scminc.com • [email protected]

© 2011 SCM E&P Solutions, Inc.

4

Figure: Variables available for use in a Petrel workflow.  Note that variables AA thru AZ are only available in Petrel 2010 and later versions. 

     

Petrel is a mark of Schlumberger

4801 Woodway Drive, Suite 150W • Houston, TX 77056 • www.scminc.com • [email protected]

© 2011 SCM E&P Solutions, Inc.

5

Figure: Workflow using variables from the top of the variable list for the Input files and from the bottom of the list for the processing files.  

 

 

Petrel is a mark of Schlumberger

4801 Woodway Drive, Suite 150W • Houston, TX 77056 • www.scminc.com • [email protected]

© 2011 SCM E&P Solutions, Inc.

6

Figure: Display created by the above workflow (left), messages written by the workflow (center), and files created by the workflow (right).  

       

Documenting 

Note that for each input variable assignment there is a comment line in front of the Set reference step.  That comment line says what the variable name is and what type of file is linked to it.  It also tells you if the file will be modified by the workflow (e.g., the folder’s contents will be deleted).  Using these comments is a habit you should adopt.  If the file linked to variable A is deleted, then, without the comment, there is no way you will know what file to re‐link to without studying the logic.  Often the logic is so complex it takes a long time to figure it out.  This problem also occurs when you copy a workflow from one Petrel project to another and don’t also copy the data. 

Figure: File existing in left workflow and having been deleted in right workflow.  With the comment you know what file was suppose to be linked to variable A.  

     

 

Documentation 

Documentation is a key component of any workflow.  The logic in workflows can quickly become complex, therefore, you must add comments so that, when you return to your workflow 6 months after you write it, you can quickly determine what is being done.  There are three tools we use to comment workflows, one is the “Comment” line, another is the “Empty line”, and the third the “Message” line.  The “Comment” line is just that, a line with text comments.  It is used throughout the workflow to describe what is happening.  New users tend to put in a comment line for each step and the workflow quickly becomes huge.   Since the developers of Petrel have not chosen to provide a way to print a workflow, multiple screen captures must be used to save the workflow to a Word document and then that is printed.  If the workflow is huge this printing becomes even more painful.  We tend to state what is happening in a group of workflow steps using just one or two comment lines, thus, 

Petrel is a mark of Schlumberger

4801 Woodway Drive, Suite 150W • Houston, TX 77056 • www.scminc.com • [email protected]

© 2011 SCM E&P Solutions, Inc.

7

providing the information but keeping the workflow length shorter.  A “Comment” line is always used in front of a “Set reference” line as described in the section above.  

Figure: Example of comment lines used to separate major sections of the workflow.  

 

Figure: Lines 35‐36 in this workflow are an example of one comment describing several steps.  

 

 

Another form of documentation of variables that many workflow writers use is to summarize the variables at the bottom of the Input section.  This summary is a set of comments describing the use of all variables in the workflow.  This summary aids in knowing which variables are used in the workflow (whether they are described at the top or throughout the workflow).  If new variables are added to the workflow, they need to be added to this summary. 

Petrel is a mark of Schlumberger

4801 Woodway Drive, Suite 150W • Houston, TX 77056 • www.scminc.com • [email protected]

© 2011 SCM E&P Solutions, Inc.

8

Figure: Lines 13‐19 are the Variable Summary  

 

 

 

“Empty lines” are key to making the workflow readable.  A workflow should be treated like a chapter in a book.  It contains paragraphs, each covering a specific topic and those paragraphs are separated one from another by spaces.   

Figure: Workflow with no empty lines (left) and with empty lines used to make the workflow readable.  

     

 

 

Petrel is a mark of Schlumberger

4801 Woodway Drive, Suite 150W • Houston, TX 77056 • www.scminc.com • [email protected]

© 2011 SCM E&P Solutions, Inc.

9

“Message lines” are meant to write information to the Petrel message log so that you know what is happening while the workflow runs. If a message line is carefully written, it will usually act as both a message and a comment. These then reduce the need for some of your comment lines. In a long running workflow, messages should be used to inform you of the workflow’s progress.  

Figure: Line 14 is a message used both to inform about the Workflow’s actions and as a comment line.  

 

 

Loop Management 

“Loops” are used in well over half of the workflows that are written.  Following simple conventions when writing loops will make them easier to understand, to write, and to decipher 6 months down the road.  Most workflows loop over folders of objects.  The loop runs as many times as there are objects of a specific type in the folder.  Because it is looping over objects it does not have a counter and you must create a counter.  This is done with the “Numeric expression” line.  Before the loop the expression is set equal zero.  Just after the start of the loop it is set to itself plus 1.0.  

Petrel is a mark of Schlumberger

4801 Woodway Drive, Suite 150W • Houston, TX 77056 • www.scminc.com • [email protected]

© 2011 SCM E&P Solutions, Inc.

10

 

Figure: Single loop setup with counter and message stating what iteration the loop is on (top, line 18) and message log generated by the loop (bottom).  

 

 

Many loops need to be nested.  For example, you may wish to display several isochore grids along with their data on a picture.  You need two loops, one over the folder of thickness grids and one over the folder of thickness data.  The loops are nested, each has its own counter, and an “If” statement is used to test that the two loops are at the same iteration before displaying the picture.  Messages are used to report what is happening in the loops.   Of course, if you use this technique, the data in the two folders must be the same.  It is usually wise to place the data in Stratigraphic order, shallowest to deepest, to keep objects in the same order.  The Message command prints out which files are being used.  You can use this printout to ensure the correct files are used each time thru the loops. 

Petrel is a mark of Schlumberger

4801 Woodway Drive, Suite 150W • Houston, TX 77056 • www.scminc.com • [email protected]

© 2011 SCM E&P Solutions, Inc.

11

Figure: Nested pair of loops (top, lines 17‐22) and messages stating what is happening in each loop (bottom). 

 

 

 

Petrel is a mark of Schlumberger

4801 Woodway Drive, Suite 150W • Houston, TX 77056 • www.scminc.com • [email protected]

© 2011 SCM E&P Solutions, Inc.

12

File Management 

File management is required to make a workflow run correctly.  A well written workflow can be run many times with the correct answer each time and with no duplicate files remaining.  This means that it does not change the input data while running, it clears out permanent files before it recreates them the next time it runs, it deletes temporary files before it quits, and it clears the messages and displays it creates either at the end or when it is restarted.  The workflows presented in this paper meet these criteria.  

A useful technique in file management is to create a work folder specifically for the workflow and to place all files that are to be kept after the workflow finishes in that folder.  The folder should exist before the workflow is run (is not created by the workflow) and its contents are cleaned out at the top of the workflow and refilled as the workflow executes.  After a file is created, it is moved into the folder.  If a file is not to be kept, it is not moved into the folder but instead is deleted at the end of the workflow.  

Figure: Portion of workflow showing use of a work folder (linked to Variable C) that is cleaned out each time the workflow is run.  

 

Figure: Portion of a workflow showing the copy to a folder, naming, and use of a file. 

 

 

If a workflow “bombs” part‐way thru execution, it will often leave temporary files at the bottom of the input tab.  If you can, clean up any possible left‐over files at the beginning of the workflow execution before generating them again.  

Petrel is a mark of Schlumberger

4801 Woodway Drive, Suite 150W • Houston, TX 77056 • www.scminc.com • [email protected]

© 2011 SCM E&P Solutions, Inc.

13

Summary 

Remember the 5 main ingredients to a good workflow: 1. Organization 

Place all items that will change at the top of the workflow 

Separate into Sections – Input, Initialization, Processing and split Processing into tasks 

Separate Sections with empty lines and comments 2. Variable Usage 

Define all variables that you can at the top of the workflow 

Assign all objects that may change to variables 

Find a naming and usage convention that works for you.  In this paper, we started naming all variables that represented Petrel objects with names from the top of the variable list; (A, B, etc.).  We named all variables that were defined in the Processing area of the workflow from the bottom of the list; (AZ, AY, etc.). 

Use a Comment to explain each variable’s use 

Optionally, use a Variable Summary section to show all variables used. 3. Documentation 

Use Comments, Empty lines and Messages to tell about all variables and what the workflow is doing in each section. 

4. Loop Management 

Use Loops to perform the same workflow steps over different files in a folder. 

Use Numeric expression to count the number of times a loop is iterated 

If loops must be nested, match the counter from an outer loop to an inner loop to perform the workflow steps on the correct objects in the folders 

Use a Message command to ensure the correct files are being used each time thru the loop. 

5. File Management 

A workflow should be able to be run multiple times (always giving the correct answer) without leaving extra files in Petrel’s Input tab. 

Use a work folder to keep track of files generated in the workflow 

Clean out the work folder at the beginning of the workflow 

Delete any temporary files created by the workflow at the end of the workflow. 

 

Using these 5 ingredients in the suggested manners will help in initially writing a workflow and keeping it simple to understand.  It will also help if you wrote a workflow a while ago and now want to remember what it does and possibly modify it.  A third way this helps is if someone else needs to modify a workflow written by you.  If you used these five ingredients properly when creating the workflow, it will greatly speed their understanding of a complex workflow.