Skip to content

Commit 4d5dfbf

Browse files
authored
Merge pull request #12 from daavid00/developing
Update to toml and docs
2 parents fe0b8b7 + 55aae6b commit 4d5dfbf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+1301
-326
lines changed

.github/workflows/CI.yml

+4-3
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,17 @@ jobs:
4141
run: |
4242
pip install --upgrade pip setuptools wheel
4343
pip install -r dev-requirements.txt
44+
pip install opm
4445
4546
- name: Install expreccs
4647
run: |
4748
pip install .
4849
4950
- name: Check code style and linting
5051
run: |
51-
black --check src/ tests/ setup.py
52-
pylint src/ tests/ setup.py
53-
mypy --ignore-missing-imports src/ tests/ setup.py
52+
black --check src/ tests/
53+
pylint src/ tests/
54+
mypy --ignore-missing-imports src/ tests/
5455
5556
- name: Run the tests
5657
run: |

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,8 @@ opm-common/
142142
opm-grid/
143143
opm-models/
144144
opm-simulators/
145+
build_opm_mpi.sh
146+
build_opm_macos.sh
145147

146148
# Extra folders
147149
tests/configs/back

README.md

+13-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[![Build Status](https://github.com/cssr-tools/expreccs/actions/workflows/CI.yml/badge.svg)](https://github.com/cssr-tools/expreccs/actions/workflows/CI.yml)
2-
<a href="https://www.python.org/"><img src="https://img.shields.io/badge/python-3.8%20|%203.9%20|%203.10%20|%203.11-blue.svg"></a>
2+
<a href="https://www.python.org/"><img src="https://img.shields.io/badge/python-3.8%20to%203.12-blue.svg"></a>
33
[![Code style](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black)
44
[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
55
[![DOI](https://zenodo.org/badge/760077220.svg)](https://zenodo.org/doi/10.5281/zenodo.12100600)
@@ -12,9 +12,15 @@ This repository contains scripts to set up a workflow to run site and regional r
1212

1313
## Installation
1414
You will first need to install
15-
* Flow (https://opm-project.org, Release 2024.04 or current master branches)
15+
* Flow (https://opm-project.org, Release 2024.04 or current master branches)
1616

17-
You can install the Python requirements in a virtual environment with the following commands:
17+
To install the _expreccs_ executable in an existing Python environment:
18+
19+
```bash
20+
pip install git+https://github.com/cssr-tools/expreccs.git
21+
```
22+
23+
If you are interested in modifying the source code, then you can clone the repository and install the Python requirements in a virtual environment with the following commands:
1824

1925
```bash
2026
# Clone the repo
@@ -27,26 +33,24 @@ python3 -m venv vexpreccs
2733
source vexpreccs/bin/activate
2834
# Upgrade pip, setuptools, and wheel
2935
pip install --upgrade pip setuptools wheel
30-
# Install the expreccs package (in editable mode for contributions/modifications; otherwise, pip install .)
36+
# Install the expreccs package
3137
pip install -e .
3238
# For contributions/testing/linting, install the dev-requirements
3339
pip install -r dev-requirements.txt
3440
```
3541

36-
If you are a Linux user (including the Windows subsystem for Linux), then you could try to build Flow from the master branches with mpi support, by running the script `./build_opm-flow_mpi.bash` (see the [_CI.yml_](https://github.com/cssr-tools/expreccs/blob/main/.github/workflows/CI.yml)), which in turn should build the executable in ./build/opm-simulators/bin/flow_gaswater_dissolution.
37-
38-
For macOS users with the latest chips (M1/M2, guessing also M3?), the opm Python package is not available via pip install, while resdata might not be available depending on the Python version (e.g., it is not found using Python 3.9, but it is installed using Python 3.10). If you face this issue, then before installation, remove resdata and opm from the `requirements.txt`, then proceed with the Python requirements installation, install the OPM Flow dependencies (using macports or brew), and once inside the vexpreccs Python environment, run the `./build_opm-flow_macOS.bash`, and deactivate and activate the virtual environment (this script builds OPM Flow as well as the opm Python package, and it exports the required PYTHONPATH).
42+
See the [_installation_](https://cssr-tools.github.io/exprecss/installation.html) for further details on building OPM Flow from the master branches in Linux, Windows, and macOS, as well as the opm Python package.
3943

4044
## Running expreccs
4145
You can run _expreccs_ as a single command line:
4246
```
4347
expreccs -i some_input.txt -o some_output_folder
4448
```
4549
Run `expreccs --help` to see all possible command line argument options. Inside the `some_input.txt` file you provide the path to the
46-
flow executable and simulation parameters. See the .txt files in the examples and tests/configs folders.
50+
flow executable and simulation parameters. See the .txt files in the [_examples_](https://github.com/cssr-tools/expreccs/tree/main/examples) and [_tests_](https://github.com/cssr-tools/expreccs/tree/main/tests/configs) folders.
4751

4852
## Getting started
49-
See the [_documentation_](https://cssr-tools.github.io/expreccs/introduction.html).
53+
See the [_examples_](https://cssr-tools.github.io/expreccs/examples.html) in the [_documentation_](https://cssr-tools.github.io/expreccs/introduction.html).
5054

5155
## About expreccs
5256
The expreccs package is funded by Wintershall Dea, Equinor, Shell, and the Research Council of Norway [project number 336294].

build_opm-flow_macOS.bash

-40
This file was deleted.

build_opm-flow_mpi.bash

-27
This file was deleted.

buildopm.sh

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
CURRENT_DIRECTORY="$PWD"
2+
3+
for module in common
4+
do git clone https://gitlab.dune-project.org/core/dune-$module.git --branch v2.9.1
5+
done
6+
for module in common
7+
do ./dune-common/bin/dunecontrol --only=dune-$module cmake -DCMAKE_DISABLE_FIND_PACKAGE_MPI=1
8+
./dune-common/bin/dunecontrol --only=dune-$module make -j5
9+
done
10+
11+
for repo in common
12+
do
13+
git clone https://github.com/OPM/opm-$repo.git
14+
done
15+
16+
source vexpreccs/bin/activate
17+
18+
mkdir build
19+
20+
for repo in common
21+
do
22+
mkdir build/opm-$repo
23+
cd build/opm-$repo
24+
cmake -DPYTHON_EXECUTABLE=$(which python) -DWITH_NDEBUG=1 -DUSE_MPI=0 -DOPM_ENABLE_PYTHON=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="$CURRENT_DIRECTORY/dune-common/build-cmake;$CURRENT_DIRECTORY/dune-grid/build-cmake;$CURRENT_DIRECTORY/dune-geometry/build-cmake;$CURRENT_DIRECTORY/dune-istl/build-cmake;$CURRENT_DIRECTORY/build/opm-common;$CURRENT_DIRECTORY/build/opm-grid" $CURRENT_DIRECTORY/opm-$repo
25+
make -j5
26+
cd ../..
27+
done
28+
29+
echo "export PYTHONPATH=\$PYTHONPATH:$CURRENT_DIRECTORY/build/opm-common/build/python" >> $CURRENT_DIRECTORY/vexpreccs/bin/activate

dev-requirements.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
black
2-
pylint
2+
numpydoc
33
mypy
4+
pylint
45
pytest-cov
56
sphinx
67
sphinx-rtd-theme

docs/_images/plopm.png

565 KB
Loading

docs/_images/pycopm.gif

3.19 MB
Loading

docs/_images/pyopmspe11.gif

3.4 MB
Loading

docs/_sources/examples.rst.txt

+12
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,15 @@ to generate the animation (using ResInsight) in the :doc:`introduction section <
6363
.. code-block:: bash
6464
6565
expreccs -i example2.txt -m reference
66+
67+
Generic (under development)
68+
---------------------------
69+
70+
See/run the last lines (34 to 42) in the `test_main.py <https://github.com/cssr-tools/expreccs/blob/main/pyproject.toml>`_
71+
for an example where **expreccs** is used in two given models (regional and site, in this case they are created using
72+
the **expreccs** package, but in general can be any given geological models), generating a new input deck where
73+
the pressures are projected.
74+
75+
.. code-block:: bash
76+
77+
expreccs -e name_of_folder_for_the_regional_model,name_of_folder_for_the_site_model
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
expreccs.utils.reg\_sit\_given\_decks module
2+
============================================
3+
4+
.. automodule:: expreccs.utils.reg_sit_given_decks
5+
:members:
6+
:undoc-members:
7+
:show-inheritance:
8+
:private-members:

docs/_sources/expreccs.utils.rst.txt

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Submodules
1111
expreccs.utils.inputvalues
1212
expreccs.utils.mapboundaries
1313
expreccs.utils.mapproperties
14+
expreccs.utils.reg_sit_given_decks
1415
expreccs.utils.runs
1516
expreccs.utils.writefile
1617

docs/_sources/index.rst.txt

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Welcome to expreccs's documentation!
77
:maxdepth: 4
88

99
introduction
10+
installation
1011
configuration_file
1112
examples
1213
api

docs/_sources/installation.rst.txt

+136
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
============
2+
Installation
3+
============
4+
5+
Python package
6+
--------------
7+
8+
To install the **expreccs** executable in an existing Python environment:
9+
10+
.. code-block:: bash
11+
12+
pip install git+https://github.com/cssr-tools/expreccs.git
13+
14+
If you are interested in modifying the source code, then you can clone the repository and
15+
install the Python requirements in a virtual environment with the following commands:
16+
17+
.. code-block:: console
18+
19+
# Clone the repo
20+
git clone https://github.com/cssr-tools/expreccs.git
21+
# Get inside the folder
22+
cd expreccs
23+
# Create virtual environment
24+
python3 -m venv vexpreccs
25+
# Activate virtual environment
26+
source vexpreccs/bin/activate
27+
# Upgrade pip, setuptools, and wheel
28+
pip install --upgrade pip setuptools wheel
29+
# Install the expreccs package
30+
pip install -e .
31+
# For contributions/testing/linting, install the dev-requirements
32+
pip install -r dev-requirements.txt
33+
34+
.. note::
35+
36+
For not macOS users, to install the Python opm package, execute in the terminal **pip install opm**.
37+
For macOS, see :ref:`macOS`.
38+
39+
OPM Flow
40+
--------
41+
You also need to install:
42+
43+
* OPM Flow (https://opm-project.org, Release 2024.04 or current master branches)
44+
45+
.. tip::
46+
47+
See the `CI.yml <https://github.com/cssr-tools/expreccs/blob/main/.github/workflows/CI.yml>`_ script
48+
for installation of OPM Flow (binary packages) and the expreccs package in Linux.
49+
50+
Source build in Linux/Windows
51+
+++++++++++++++++++++++++++++
52+
If you are a Linux user (including the Windows subsystem for Linux), then you could try to build Flow (after installing the `prerequisites <https://opm-project.org/?page_id=239>`_) from the master branches with mpi support by running
53+
in the terminal the following lines (which in turn should build flow in the folder ./build/opm-simulators/bin/flow.):
54+
55+
.. code-block:: console
56+
57+
CURRENT_DIRECTORY="$PWD"
58+
59+
for repo in common grid models simulators
60+
do
61+
git clone https://github.com/OPM/opm-$repo.git
62+
done
63+
64+
mkdir build
65+
66+
for repo in common grid models
67+
do
68+
mkdir build/opm-$repo
69+
cd build/opm-$repo
70+
cmake -DUSE_MPI=1 -DWITH_NDEBUG=1 -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="$CURRENT_DIRECTORY/build/opm-common;$CURRENT_DIRECTORY/build/opm-grid" $CURRENT_DIRECTORY/opm-$repo
71+
make -j5 opm$repo
72+
cd ../..
73+
done
74+
75+
mkdir build/opm-simulators
76+
cd build/opm-simulators
77+
cmake -DUSE_MPI=1 -DWITH_NDEBUG=1 -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="$CURRENT_DIRECTORY/build/opm-common;$CURRENT_DIRECTORY/build/opm-grid;$CURRENT_DIRECTORY/build/opm-models" $CURRENT_DIRECTORY/opm-simulators
78+
make -j5 flow
79+
cd ../..
80+
81+
82+
.. tip::
83+
84+
You can create a .sh file (e.g., build_opm_mpi.sh), copy the previous lines, and run in the terminal **source build_opm_mpi.sh**
85+
86+
.. _macOS:
87+
88+
Source build in macOS
89+
+++++++++++++++++++++
90+
For macOS, there are no available binary packages, so OPM Flow needs to be built from source, in addition to the dune libraries and the opm Python
91+
package (see the `prerequisites <https://opm-project.org/?page_id=239>`_, which can be installed using macports or brew). This can be achieved by the following lines:
92+
93+
.. code-block:: console
94+
95+
CURRENT_DIRECTORY="$PWD"
96+
97+
for module in common geometry grid istl
98+
do git clone https://gitlab.dune-project.org/core/dune-$module.git --branch v2.9.1
99+
done
100+
for module in common geometry grid istl
101+
do ./dune-common/bin/dunecontrol --only=dune-$module cmake -DCMAKE_DISABLE_FIND_PACKAGE_MPI=1
102+
./dune-common/bin/dunecontrol --only=dune-$module make -j5
103+
done
104+
105+
for repo in common grid models simulators
106+
do
107+
git clone https://github.com/OPM/opm-$repo.git
108+
done
109+
110+
source vexpreccs/bin/activate
111+
112+
mkdir build
113+
114+
for repo in common grid models
115+
do
116+
mkdir build/opm-$repo
117+
cd build/opm-$repo
118+
cmake -DPYTHON_EXECUTABLE=$(which python) -DWITH_NDEBUG=1 -DUSE_MPI=0 -DOPM_ENABLE_PYTHON=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="$CURRENT_DIRECTORY/dune-common/build-cmake;$CURRENT_DIRECTORY/dune-grid/build-cmake;$CURRENT_DIRECTORY/dune-geometry/build-cmake;$CURRENT_DIRECTORY/dune-istl/build-cmake;$CURRENT_DIRECTORY/build/opm-common;$CURRENT_DIRECTORY/build/opm-grid" $CURRENT_DIRECTORY/opm-$repo
119+
make -j5
120+
cd ../..
121+
done
122+
123+
mkdir build/opm-simulators
124+
cd build/opm-simulators
125+
cmake -DUSE_MPI=0 -DWITH_NDEBUG=1 -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="$CURRENT_DIRECTORY/dune-common/build-cmake;$CURRENT_DIRECTORY/dune-grid/build-cmake;$CURRENT_DIRECTORY/dune-geometry/build-cmake;$CURRENT_DIRECTORY/dune-istl/build-cmake;$CURRENT_DIRECTORY/build/opm-common;$CURRENT_DIRECTORY/build/opm-grid;$CURRENT_DIRECTORY/build/opm-models" $CURRENT_DIRECTORY/opm-simulators
126+
make -j5 flow
127+
cd ../..
128+
129+
echo "export PYTHONPATH=\$PYTHONPATH:$CURRENT_DIRECTORY/build/opm-common/python" >> $CURRENT_DIRECTORY/vexpreccs/bin/activate
130+
131+
132+
This builds OPM Flow as well as the opm Python package, and it exports the required PYTHONPATH. Then after execution, deactivate and activate the Python virtual environment.
133+
134+
Regarding the resdata Python package, it might not be available depending on the Python version (e.g., it is not found using Python 3.9, but it is installed using Python 3.10).
135+
Then, it is recommended to use a Python version equal or higher than 3.10; otherwise, remove resdata from the requirements in the `pyproject.toml <https://github.com/cssr-tools/expreccs/blob/main/pyproject.toml>`_,
136+
and the opm Python package will be used (this is the default package for reading the simulation files, see the :ref:`overview`).

0 commit comments

Comments
 (0)