Written and Edited by Debora Martogi
Earning a degree in petroleum engineering, doing petroleum projects, training, and internship will help you familiarize yourself with the petroleum industry. Somewhere in the process, you will become really good with the technical aspect of it and eventually become the subject matter expert (SME) in petroleum engineering. In today’s age of digital transformation, aka the “Industry 4.0”, SMEs are encouraged to adapt and learn new tools to help them analyze big data. And when we talk about big data, the first things that came into mind are usually Artificial Intelligence (AI) or Machine Learning (ML). Now, I am a firm believer though these tools will help us to automate a lot of things and demonstrate superior intelligence than us humans, SMEs should still be involved in understanding whether the results interpreted using AI makes sense or not. Adapting/ copying an algorithm, plugging in your data sets, and getting output is pretty straightforward. But, without intelligent sound judgment, carelessly using and depending on AI could lead to uneconomical and dangerous decisions. This is why we still need these SMEs, people who understood the concept pretty well.
In this age of digital transformation, companies have been looking into candidates who are not only SMEs but also can program. This way, they do not necessarily need to hire software engineers to update their software packages and in-house programs. This is why having a petroleum engineering degree and experience in programming makes you ahead in getting into the industry. Some of the popular programming languages used in the industry are Python, C++, Fortran, and maybe MATLAB. In terms of easiness, learning Python is relatively easy once you are familiar with MATLAB. C++ and Fortran, on the other hand, is more challenging to learn in my experience. Fortran is one of the oldest programming languages. It is usually needed when companies need to dig into their old programs and perhaps update/ adapt them to a newer programming version. In terms of computational efficiency, generally, the lineup from most efficient to least efficient is Fortran (tie), C++ (tie), Python, and MATLAB. This is since Fortran and C++ are low-level fast languages, while Python and MATLAB are high-level scripting languages. Usually, you will need to build all script and structure of your code or use open-source code shared online when using C++ and Fortran. What’s convenient about Python and MATLAB, there are built-in packages available to perform general engineering computations and scripting (i.e., integral, differential equations, arithmetic, geometric, etc.). Personally, I use MATLAB for plotting and currently shifting into Python to run the algorithm. One disadvantage of MATLAB is users need to pay to access it while free compilers are available for Fortran, C++, and Python. MATLAB is available for free for Texas A&M University students and can be obtained from the TAMU software store. Given the high popularity of knowing Python in the job application lately, we will share with you several ways to analyze petroleum engineering problems using Python.
Python Starting Guide
Here are a few starting tips to get you started with Python.
One of the popular Python compilers out there is Anaconda. Anaconda individual edition is free for students, solo practitioners, and researchers. Anaconda is equipped with several basic applications under the home tab. The CMD.exe prompt is similar to the terminal in your PC/laptop. This is where we initialize application (i.e., Spyder, Jupyter, JupyterLab, etc.) updates, install packages for the applications, etc. Spyder, Jupyter Notebook, and IP[y] are some of the applications you could use to write Python scripts. Spyder is recommended for beginner users. Jupyter notebook can also be useful where users can write Live Script (description) as shown on this site.
To perform calculations, plot figures, use symbolic terms, etc., we need to call several built-in Python libraries. Several useful ones are numpy (array, arithmetic, basic statistics), Matplotlib (plotting), Pandas (data analysis and manipulation), SciPy (linear algebra, scientific computing), and SymPy (symbolic terms). To call the library, you will need to enter the following command at the beginning of your script or before calling the associated command. The following are several ways of calling a library.
Recommended: import [insert library name] as X
Example: Calculating cos(60)
import numpy as np
answer = np.cos(np.radians(60))
Not recommended: from [insert library name] import *
Example: Calculating cos(60)
from numpy import *
Answer = cos(radians(60))
The second approach is not recommended when you are using multiple libraries. Use this approach only if you are using one library throughout the whole script.
Following are several cheat sheets links for each library:
Reading data from files
Reading text files in format of .txt can be done easily through the following command
import numpy as np
Finding python resources online (GitHUB, google)
There are plenty of Python resources online, which is searchable through google. Complete documentation of Python can be found here, and complete documentation of spyder can be found here. More information on GitHub repository will be shared in future articles.
Stay tuned for our first article on tackling petroleum engineering analysis using Python in the next 2 weeks. Until then, stay well everyone!
Disclaimer: The Well Log is a non-profit publication aimed “purely” to educate students at Texas A&M University and beyond on information pertinent to the petroleum engineering industry. All articles are written by student volunteers based on information obtained through online sources and SPE publications. If you are the owner of any materials we cited and would like us to remove it from our publications, please contact us at firstname.lastname@example.org.