Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 2 additions & 18 deletions paper/paper.bib
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,6 @@ @ARTICLE{2020NumPy-Array
doi = {10.1038/s41586-020-2649-2}
}

@software{the_pandas_development_team,
author = {{The pandas development team}},
title = {pandas-dev/pandas: Pandas},
month = sep,
year = 2025,
publisher = {Zenodo},
version = {v2.3.3},
doi = {10.5281/zenodo.17229934},
url = {https://doi.org/10.5281/zenodo.17229934},
swhid = {swh:1:dir:5bc73e541e362cf8e7068ebb434b9d7bc1194c14
;origin=https://doi.org/10.5281/zenodo.3509134;vis
it=swh:1:snp:8c6e563b81f60a3d62fec309b38f470a0eacf
596;anchor=swh:1:rel:b0f463d37766850a89633bd05643d
45342b9241d;path=pandas-dev-pandas-1efe649
}
}

@software{Gillies_Shapely_2025,
author = {Gillies, Sean and van der Wel, Casper and Van den Bossche, Joris and Taves, Mike W. and Arnott, Joshua and Ward, Brendan C. and {others}},
doi = {10.5281/zenodo.5597138},
Expand Down Expand Up @@ -95,7 +78,8 @@ @misc{landamarbán2025
eprint={2508.08670},
archivePrefix={arXiv},
primaryClass={physics.geo-ph},
url={https://arxiv.org/abs/2508.08670},
url={https://arxiv.org/abs/2508.08670},
doi={10.48550/arXiv.2508.08670}
}

@article{Sandve2025,
Expand Down
12 changes: 6 additions & 6 deletions paper/paper.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ bibliography: paper.bib

# Summary

Reservoir simulations help the energy industry make better decisions by predicting how fluids like oil, gas, water, hydrogen, and carbon dioxide will flow underground. To keep these predictions accurate, engineers often need to update geological models quickly as new information becomes available. `pycopm` is a tool designed to make this process faster and easier. It allows users to adjust geological models in several ways, such as simplifying complex grids, focusing on specific parts of a reservoir, or changing the shape and position of the model. These capabilities help engineers test different scenarios efficiently. Although `pycopm` was first used on two well‑known public datasets, it has since become useful in many other situations because of its easy‑to‑use features and recent extensions. Today, it supports studies involving model refinement, comparing coarse and detailed models, analyzing interactions between nearby sites, and speeding up troubleshooting in large simulations.
Reservoir simulations help the energy industry make better decisions by predicting how fluids like oil, gas, water, hydrogen, and carbon dioxide will flow underground. To keep these predictions accurate, engineers often need to update geological models quickly as new information becomes available. `pycopm` is a tool designed to make this process faster and easier. It allows users to adjust geological models in several ways, such as simplifying complex grids, focusing on specific parts of a reservoir, or changing the shape and position of the model (Figure \ref{pycopm-graphical-abstract}). These capabilities help engineers test different scenarios efficiently. Although `pycopm` was first used on two well‑known public datasets, it has since become useful in many other situations because of its easy‑to‑use features and recent extensions. Today, it supports studies involving model refinement, comparing coarse and detailed models, analyzing interactions between nearby sites, and speeding up troubleshooting in large simulations.

![Graphical representation of pycopm's functionality ([here](https://cssr-tools.github.io/pycopm/examples.html#graphical-abstract) are details to reproduce this).](paper.png){ width=100% }
![Graphical representation of pycopm's functionality ([here](https://cssr-tools.github.io/pycopm/examples.html#graphical-abstract) are details to reproduce this). \label{pycopm-graphical-abstract}}](paper.png){ width=100% }

# Statement of need

The first step in reservoir simulations is to choose a simulation model, which serves as the computational representation of a geological model, incorporating properties such as heterogeneity, physics, fluid properties, boundary conditions, and wells. Once the spatial model is designed, it is discretized into cells containing average properties of the continuous reservoir model. All this information is then communicated to the simulator, which internally solves conservation equations (mass, momentum, and energy) and constitutive equations (e.g., saturation functions, well models) to perform the predictions. OPM Flow is an open-source simulator for subsurface applications such as hydrocarbon recovery, CO$_2$ storage, and H$_2$ storage [@Rassmussen:2021]. The input files of OPM Flow follow the standard-industry Eclipse format. The different functionalities are defined using keywords in a main input deck with extension .DATA and additional information is usually added in additional .INC files such as tables (saturation functions, PVT) and the grid discretization. We refer to the OPM Flow manual [OPM Flow manual](https://opm-project.org/?page_id=955) for an introduction to OPM Flow and all supported keywords.
The first step in reservoir simulations is to choose a simulation model, which serves as the computational representation of a geological model, incorporating properties such as heterogeneity, physics, fluid properties, boundary conditions, and wells. Once the spatial model is designed, it is discretized into cells containing average properties of the continuous reservoir model. All this information is then communicated to the simulator, which internally solves conservation equations (mass, momentum, and energy) and constitutive equations (e.g., saturation functions, well models) to perform the predictions. OPM Flow is an open-source simulator for subsurface applications such as hydrocarbon recovery, CO$_2$ storage, and H$_2$ storage [@Rassmussen:2021]. The input files of OPM Flow follow the industry-standard Eclipse format. The different functionalities are defined using keywords in a main input deck with the .DATA extension, while additional information is typically provided in supplementary .INC files, including tables for saturation functions and PVT (pressure-volume-temperature) properties, as well as the grid discretization. We refer to the [OPM Flow manual](https://opm-project.org/?page_id=955) for an introduction to OPM Flow and all supported keywords.


Simulation models can be substantial, typically encompassing millions of cells, and can be quite complex due to the number of wells and faults, defined by cell indices in the x, y, and z direction (i, j, and k nomenclature). While manually modifying small input decks is feasible, it becomes impractical for large models. In addition, these models commonly rely on corner‑point grids defined through pillars and horizons, and they may include further geometric modifications specified through deck keywords. Such representations are not intuitive to manipulate, particularly for users who are not familiar with the internal structure of simulation decks.
Expand All @@ -48,14 +48,14 @@ Two of the most widely used commercial software suites in reservoir modeling are
[ResInsight](https://resinsight.org) is an open-source C++ tool designed for postprocessing reservoir models and simulations. It can export modified simulation grids and supports operations such as grid refinement and submodel extraction. Nevertheless, it does not generate an updated input deck reflecting the modified i, j, and k coordinates. It also lacks built-in capabilities for model coarsening or for applying general affine transformations. Users on macOS may encounter installation challenges, and the software has difficulty handling models with very small cell dimensions (below 1 mm) or with very large cell counts (greater than 100 million).


To the author's knowledge, prior to the development of `pycopm` there was no integrated Python-based solution that combined coarsening, refinement, submodel extraction, and geometric transformations for modifying geological models compatible with OPM Flow. Python offers a significantly more accessible environment than C++, which lowers the entry barrier for researchers, engineers, and students who need flexible model manipulation tools. `pycopm` offers flexibility in selecting different approaches, allowing end-users to compare methods and choose the one that best fits their needs. For additional information about the different approaches implemented in `pycopm` for coarsenings, refinements, submodels, and transformations, see the [theory](https://cssr-tools.github.io/pycopm/theory.html) in `pycopm`'s documentation.
To the author's knowledge, prior to the development of `pycopm` there was no integrated Python-based solution that combined coarsening, refinement, submodel extraction, and geometric transformations for modifying geological models compatible with OPM Flow. Python offers a significantly more accessible environment than C++, which lowers the entry barrier for researchers, engineers, and students who need flexible model manipulation tools. `pycopm` offers flexibility in selecting different approaches, allowing end-users to compare methods and choose the one that best fits their needs. For additional information about the different approaches implemented in `pycopm` for coarsenings, refinements, submodels, and transformations, see the section on [theory](https://cssr-tools.github.io/pycopm/theory.html) in `pycopm`'s documentation.

# Software design

`pycopm` leverages well-established and excellent Python libraries. The Python package numpy [@2020NumPy-Array] forms the basis for performing array operations. The pandas package [@the_pandas_development_team] is used for handling cell clusters, specifically employing the methods in pandas.Series.groupby. The Shapely package [@Gillies_Shapely_2025], particularly the contains_xy method, is fundamental for submodel implementation used to locate grid cells within a given polygon. To parse the output binary files of OPM Flow, the [opm](https://pypi.org/project/opm/) Python libraries are utilized. The primary methods developed in `pycopm` include handling of corner-point grids, upscaling transmissibilities in complex models with faults (non-neighboring connections) and inactive cells, projecting pore volumes on submodel boundaries, interpolating to extend the definition of i, j, and k dependent properties (e.g., wells, faults) in grid refinement, and parsing and writing input decks.
`pycopm` leverages well-established and excellent Python libraries. The Python package numpy [@2020NumPy-Array] forms the basis for performing array operations. The Shapely package [@Gillies_Shapely_2025], particularly the `contains_xy` method, is fundamental for submodel implementation used to locate grid cells within a given polygon. To parse the output binary files of OPM Flow, the [opm](https://pypi.org/project/opm/) Python libraries are utilized. The primary methods developed in `pycopm` include handling of corner-point grids, upscaling transmissibilities in complex models with faults (non-neighboring connections) and inactive cells, projecting pore volumes on submodel boundaries, interpolating to extend the definition of i, j, and k dependent properties (e.g., wells, faults) in grid refinement, and parsing and writing input decks.


While graphical user interfaces (GUIs) are generally more intuitive for beginners, command-line interfaces (CLIs) offer advantages in speed and efficiency, enable powerful automation and scripting, provide fine-grained control, require minimal computational resources, and integrate naturally with modern AI-driven workflows. Therefore, interaction with the tool is performed through a terminal executable named `pycopm`, which provides a set of command-line flags (27 at the time of writing; see the online documentation for the [current list](https://cssr-tools.github.io/pycopm/introduction.html#overview)). These flags control the desired functionality, such as specifying the input deck, defining how the model should be modified, and selecting the output file name. This design enables users to chain multiple operations by further editing the generated decks. For example, a user may refine a model first and subsequently extract a submodel. An illustrative example is provided in [test_4_submodel.py](https://github.com/cssr-tools/pycopm/blob/main/tests/test_4_submodel.py) in the project repository. Advanced users who are familiar with Python can access the underlying functionality directly through Python scripts. This provides greater flexibility for integrating the tool into more sophisticated workflows and for customizing model transformations to meet specific research or engineering needs.
While graphical user interfaces (GUIs) are generally more intuitive for beginners, command-line interfaces (CLIs) offer advantages in speed and efficiency, enable powerful automation and scripting, provide fine-grained control, require minimal computational resources, and integrate naturally with modern AI-driven workflows. Therefore, interaction with the tool is performed through a terminal executable named `pycopm`, which provides a set of command-line flags (29 at the time of writing; see the online documentation for the [current list](https://cssr-tools.github.io/pycopm/introduction.html#overview)). These flags control the desired functionality, such as specifying the input deck, defining how the model should be modified, and selecting the output file name. This design enables users to chain multiple operations by further editing the generated decks. For example, a user may refine a model first and subsequently extract a submodel. An illustrative example is provided in [test_4_submodel.py](https://github.com/cssr-tools/pycopm/blob/main/tests/test_4_submodel.py) in the project repository. Advanced users who are familiar with Python can access the underlying functionality directly through Python scripts. This provides greater flexibility for integrating the tool into more sophisticated workflows and for customizing model transformations to meet specific research or engineering needs.

Internally, `pycopm` is structured as a modular Python package with clearly defined subpackages, each responsible for a specific aspect of the workflow. These include:

Expand Down