Understand grids Module#

Open in Colab

Author: Zakariya Abugrin | Date: May 2025

Introduction#

In this tutorial, we will see how the grids module is an essential part of any model in reservoirflow which allows to create a grid model. Currently, only RegularCartesian grid models are supported. In the near future, Radial and IrregularCartesian models will be added.

1import reservoirflow as rf
2
3print(rf.__version__)
0.1.0b3

Create 1D Model#

We can use RegularCartesian from grids module to build a gird, see the documentation.

Grid model dimensionality can be defined based on nx, ny, nz arguments as following:

 1# Create a 1D regular cartesian grid:
 2grid = rf.grids.RegularCartesian(
 3    nx=4,
 4    ny=1,
 5    nz=1,
 6    dx=200,
 7    dy=200,
 8    dz=40,
 9    phi=0.27,
10    kx=270,
11    ky=200,
12    kz=10,
13    comp=1e-6,
14    unit="field",
15)
1# Show the grid model with cells id
2a = grid.show(
3    label="id",
4    boundary=False,
5    static=True,
6    notebook=True,
7    azimuth=25,
8)
../../_images/806c18cac5f9b9714fe5c787b3aa76384a06f31f143ba23d69a8dffdba1b805f.png
1# Show the grid model with cells id
2grid.show(
3    label="coords",
4    boundary=False,
5    static=True,
6    notebook=True,
7    azimuth=25,
8)
../../_images/0f0f0b69729c182433ee4f2f905a743404a3aa75302b28b8f750c1f324fbd1c3.png

Cells id#

Cells id are arranged in natural order starting from the bottom left corner and can be accessed in several ways:

  • attribute cells_id provides cells_id without boundary cells as flat array:

1grid.cells_id
array([1, 2, 3, 4])
  • more options can be found under get_cells_id() method:

1cells_id = grid.get_cells_id(boundary=False, fshape=True, fmt="array")
2cells_id.shape  # -> (nz, ny, nx)
(1, 1, 4)

Note: fshape (flow shape) argument provides the cells_id array as flow shape (nz, ny, nx) and boundary argument can be used to include or exclude boundary cells.

Using nz=3, but actually nz=5 (i.e. 5 layers) in total including upper and lower boundaries. If you do not want to deal with boundary cells just set boundary=False.

Comments ๐Ÿ’ฌ#

Feel free to make a comment, ask a question, or share your opinion about this specific content. Please keep in mind the Commenting Guidelines โš–.