A reservoir simulation processing software based on the combination of Excel and Python. main banner


It’s a reservoir simulation processing software based on Microsoft Excel, but is developed with Python language. That’s, Microsoft Excel is the main work platform or main frame for reservoir simulation work, but the software is developed with Python, not the embedded VBA.


Reservoir or geological engineers are born data analyst!And Python is the popular language for data analysis, machine learning and AI, refer to How popular is Python. At the same time, Microsoft Excel is the software we use frequently when we work. Why not write a reservoir simulation processing software based on Excel+Python, which will enable us to learn new python skill while working in a familiar Excel environment?


How to integrate Python into Excel?

Thanks XlWings, it provides the solution for us because it makes it easy to call Python from Excel and vice versa. Please install XlWings and read its documents at first before you try ExcelPySim.

How it work?

A xlsm file is open to input data which is read by and converted into a deck file for XXSim reservoir simulation software. After finishing input, a button in the xlsm file could be clicked to call the XXSim simulator to run. Please visit XXSim Github or XXSim Website for more.

Getting Started

It is started with a simple black oil case.

Tutorial 1

tutor 1
There are two files, ‘tutor1.xlsm’ and ‘tutor1.py’ which process the grid section of black oil case. By tutorial 1, it is shown that the combination of XlWings and Excel can provide a solution to a Excel-based reservoir simulation pre-processing tool. The use of xlwings is simple, just call your Python functions in your VBA macros. As follow is the python code to read and write Excel,

        # read value from excel
        nx = sheet.range('B3').options(numbers=int).value
        # write value to excel
        sheet.range('A10').value = 'Grid Size: DX'

Tutorial 2

tutor 2
Reservoir engineers need to process production data frequently, so the reading and plotting of well production data is put forward to the tutorial 2. The production data format in tutor2.xlsm is just an example, so when you use it, it is need to adjust the Excel format and edit the code according to the actual situation. Two important libs for data analysis, numpy and pandas, have been imported in Tutorial 2 to process chunks of production data, which is much more convenient and effective than VBA. Just one line code to read production data:

    df_prod = sheet.range((iRow,2),(iEndRow,7)).options(pd.DataFrame,index=False).value

Please visit pandas tutorial to learn more.

Tutorial 3

In this tutorial, PVT and SCAL data are readed and shown in graph. Also Pandas is used to read and store table data.

Joining us?

Reservoir simulation technology is important one of reservoir engineering methods and reservoir simulation tool should be one of tools at hand of a reservoir engineer. I hope it is helpful by the open source method to those that want to learn or use reservoir simulation technology and even python or machine learning. Anyone is welcome to participate.

About me

Wang Tao, Co-Founder of XXSim reservoir simulation software
Reservoir simulation engineer, C++ coder
Found more about Wang Tao check out these links:
LinkedIn | AAPG Blog | Twitter | Website


View Github