Skip to content

Commit b92009b

Browse files
committed
Support for toml input files
1 parent 38929a3 commit b92009b

Some content is hidden

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

47 files changed

+836
-107
lines changed

.github/workflows/CI.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
strategy:
1313
fail-fast: false
1414
matrix:
15-
python-version: ['3.8']
15+
python-version: ['3.11']
1616
os: [ubuntu-latest]
1717

1818
runs-on: ${{ matrix.os }}

.gitignore

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,7 @@ examples/hello_world/spe11a
180180
examples/hello_world/spe11b
181181
examples/hello_world/spe11c
182182
playground
183-
tests/configs/test_compare
184-
tests/configs/output
185-
tests/configs/spe11a
186-
tests/configs/spe11b
187-
tests/configs/spe11c
188-
tests/configs/check_format.py
183+
184+
# Tests
185+
tests/configs/check_format.py
186+
**/tests/configs/*/

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ See the [_installation_](https://OPM.github.io/pyopmspe11/installation.html) for
4646
## Running pyopmspe11
4747
You can run _pyopmspe11_ as a single command line:
4848
```
49-
pyopmspe11 -i configuration_file.txt
49+
pyopmspe11 -i configuration_file
5050
```
5151
Run `pyopmspe11 --help` to see all possible command line
52-
argument options. Inside the `configuration_file.txt` you provide the path to the flow executable and simulation parameters. See the .txt files in the [_examples_](https://github.com/OPM/pyopmspe11/tree/main/examples), [_benchmark_](https://github.com/OPM/pyopmspe11/tree/main/benchmark), and [_tests_](https://github.com/OPM/pyopmspe11/tree/main/tests/configs) folders.
52+
argument options. Inside the `configuration_file` you provide the path to the flow executable and simulation parameters. See the .txt and .toml files in the [_examples_](https://github.com/OPM/pyopmspe11/tree/main/examples), [_benchmark_](https://github.com/OPM/pyopmspe11/tree/main/benchmark), and [_tests_](https://github.com/OPM/pyopmspe11/tree/main/tests/configs) folders.
5353

5454
## Getting started
5555
See the [_examples_](https://OPM.github.io/pyopmspe11/examples.html) in the [_documentation_](https://OPM.github.io/pyopmspe11/introduction.html).

docs/_sources/configuration_file.rst.txt

Lines changed: 102 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,25 @@
1-
==================
1+
******************
22
Configuration file
3-
==================
3+
******************
4+
5+
In the initial development of **pyopmspe11**, the adopted configuration file format was the
6+
one described below, i.e., via :ref:`txt` files. The current development of **pyopmspe11** considers
7+
:ref:`toml` files. To keep compatibility with previous configuration files, then support for :ref:`txt` files
8+
will be kept, while new features will by added using :ref:`toml` configuration files.
9+
10+
.. _txt:
11+
12+
===
13+
txt
14+
===
415

516
The first input parameter in the configuration file is:
617

718
.. code-block:: python
819
:linenos:
920
1021
"""Set the full path to the flow executable and flags"""
11-
flow --linear-solver=cprw --enable-tuning=true --enable-opm-rst-file=true --output-extra-convergence-info=steps,iterations --newton-min-iterations=1
22+
flow --enable-tuning=true --enable-opm-rst-file=true --output-extra-convergence-info=steps,iterations
1223
1324
If **flow** is not in your path, then write the full path to the executable
1425
(e.g., /Users/dmar/opm/build/opm-simulators/bin/flow). We also add in the same
@@ -23,9 +34,9 @@ line as many flags as required (see the OPM Flow documentation `here <https://op
2334
flow simulator to improve/fix convergence and mass issues (i.e., by setting the flag \-\-linear-solver=cprw to change the linear solver,
2435
by tightening the cnv tolerances (\-\-tolerance-cnv), etc.).
2536

26-
****************************
37+
----------------------------
2738
Reservoir-related parameters
28-
****************************
39+
----------------------------
2940

3041
The following input lines in the configuration file are:
3142

@@ -35,7 +46,7 @@ The following input lines in the configuration file are:
3546
3647
"""Set the model parameters"""
3748
spe11c master #Name of the spe case (spe11a, spe11b, or spe11c) and OPM Flow version (master or release)
38-
complete gaswater #Name of the co2 model (immiscible, convective [convective requires a Flow version newer than 22-08-2024], or complete) and co2store implementation (gaswater or gasoil [oil properties are set to water internally in OPM flow])
49+
complete gaswater #Name of the co2 model (immiscible, convective, or complete) and co2store implementation (gaswater or gasoil [oil properties are set to water internally in OPM flow])
3950
corner-point #Type of grid (cartesian, tensor, or corner-point)
4051
8400 5000 1200 #Length, width, and depth [m]
4152
420 #If cartesian, number of x cells [-]; otherwise, variable array of x-refinment
@@ -68,9 +79,9 @@ resulting in 18 levels. Then, the z-refinment in each of these levels is set. Se
6879
The top figure shows the 7 different facies, while the bottom figure shows the fipnum numbers used to identify
6980
the boxes (A, B, and C), sensors, and the required regions to report the benchmark data.
7081

71-
***********************
82+
-----------------------
7283
Soil-related parameters
73-
***********************
84+
-----------------------
7485
The following entries define the properties of the different facies:
7586

7687
.. code-block:: python
@@ -108,9 +119,9 @@ The following entries define the properties of the different facies:
108119

109120
Visualization in ResInsight of the relative permeability and capillary pressure functions in the facie 1.
110121

111-
***********************
122+
-----------------------
112123
Well-related parameters
113-
***********************
124+
-----------------------
114125
The last part of the configuration file sets the wells radius, location, and the injection schedule.
115126

116127
.. code-block:: python
@@ -133,4 +144,84 @@ The last part of the configuration file sets the wells radius, location, and the
133144
500 100 100 1 0 10 1 0 10
134145
135146
.. warning::
136-
Keep the linebreak between the sections (in the current implementation this is used for the reading of the parameters).
147+
Keep the linebreak between the sections (in the current implementation this is used for the reading of the parameters).
148+
149+
.. _toml:
150+
151+
====
152+
toml
153+
====
154+
155+
The previous configuration file can be written using the widely in-use `toml format <https://docs.python.org/3/library/tomllib.html>`_ as:
156+
157+
.. code-block:: python
158+
:linenos:
159+
160+
# Set the full path to the flow executable and flags
161+
flow = "flow --enable-tuning=true --enable-opm-rst-file=true --output-extra-convergence-info=steps,iterations"
162+
163+
# Set the model parameters
164+
spe11 = "spe11c" # Name of the spe case (spe11a, spe11b, or spe11c)
165+
version = "release" # OPM Flow version (release or master)
166+
model = "complete" # Name of the co2 model (immiscible, convective, or complete)
167+
co2store = "gaswater" # co2store implementation (gaswater or gasoil [oil properties are set to water internally in OPM flow])
168+
grid = "corner-point" # Type of grid (cartesian, tensor, or corner-point)
169+
dims = [8400.0, 5000.0, 1200.0] # Length, width, and depth [m]
170+
x_n = [420] # If cartesian, number of x cells [-]; otherwise, variable array of x-refinment
171+
y_n = [30, 40, 50, 40, 30] # If cartesian, number of y cells [-]; otherwise, variable array of y-refinment [-] (for spe11c)
172+
z_n = [5, 3, 1, 2, 3, 2, 4, 4, 10, 4, 6, 6, 4, 8, 4, 15, 30, 9] # If cartesian, number of z cells [-]; if tensor, variable array of z-refinment; if corner-point, fix array of z-refinment (18 entries)
173+
temperature = [70.0, 36.12] # Temperature bottom and top rig [C]
174+
datum = 300 # Datum [m]
175+
pressure = 3e7 # Pressure at the datum [Pa]
176+
kzMult = 0.1 # Multiplier for the permeability in the z direction [-]
177+
diffusion = [1e-9, 2e-8] # Diffusion (in liquid and gas) [m^2/s]
178+
rockExtra = [8.5e-1, 2500.0] # Rock specific heat capacity [kJ/(kg K)] and rock density [kg/m^3] (for spe11b/c)
179+
pvAdded = 5e4 # Extra pore volume per area on lateral boundaries [m] (for spe11b/c)
180+
widthBuffer = 1 # Width of buffer cells [m] (for spe11b/c)
181+
elevation = 150 # Maximum elevation difference (relative to the baseline gradient) of the arch in the y direction [m] (for spe11c)
182+
backElevation = 10 # Back boundary elevation w.r.t the front boundary [m] (for spe11c)
183+
dispersion = [10, 10, 10, 10, 10, 10, 0] # Dispersion rock [m], facie 1 to 7
184+
rockCond = [1.9, 1.25, 1.25, 1.25, 0.92, 0.26, 2.0] # Thermal conductivity rock [W/(m K)], facie 1 to 7
185+
radius = [0.15, 0.15] # Wells radius [m] (0 to use the SOURCE keyword instead of well keywords), well 1 to 2
186+
wellCoord = [[2700.0, 1000.0, 300.0], [5100.0, 1000.0, 700.0]] # Well positions: x, y, and z coordinates [m], well 1 to 2
187+
wellCoordF = [[2700.0, 4000.0, 300.0], [5100.0, 4000.0, 700.0]] # Well final positions: x, y, and z coordinates [m], well 1 to 2 (for spe11c)
188+
189+
# Set the saturation functions
190+
krw = "(max(0, (s_w - swi) / (1 - swi))) ** 1.5" # Wetting rel perm saturation function [-]
191+
krn = "(max(0, (1 - s_w - sni) / (1 - sni))) ** 1.5" # Non-wetting rel perm saturation function [-]
192+
pcap = "penmax * math.erf(pen * ((s_w-swi) / (1.-swi)) ** (-(1.0 / 1.5)) * math.pi**0.5 / (penmax * 2))" # Capillary pressure saturation function [Pa]
193+
s_w = "(np.exp(np.flip(np.linspace(0, 5.0, npoints))) - 1) / (np.exp(5.0) - 1)" # Points to evaluate the saturation functions (s_w) [-]
194+
195+
# Properties sat functions: 1) swi [-], 2) sni [-], 3) pen [Pa], 4) penmax [Pa], and 5) npoints [-], facie 1 to 7
196+
safu = [[0.32, 0.1, 193531.39, 3e7, 1000],
197+
[0.14, 0.1, 8654.99, 3e7, 1000],
198+
[0.12, 0.1, 6120.00, 3e7, 1000],
199+
[0.12, 0.1, 3870.63, 3e7, 1000],
200+
[0.12, 0.1, 3060.00, 3e7, 1000],
201+
[0.10, 0.1, 2560.18, 3e7, 1000],
202+
[0, 0, 0, 3e7, 2]]
203+
204+
# Properties rock: 1) K [mD] and 2) phi [-], facie 1 to 7
205+
rock = [[0.10132, 0.10],
206+
[101.324, 0.20],
207+
[202.650, 0.20],
208+
[506.625, 0.20],
209+
[1013.25, 0.25],
210+
[2026.50, 0.35],
211+
[1e-5, 1e-6]]
212+
213+
# Define the injection values ([hours] for spe11a; [years] for spe11b/c): 1) injection time, 2) time step size to write results, 3) maximum solver time step, 4) injected fluid (0 water, 1 co2) (well1), 5) injection rate [kg/s] (well1), 6) temperature [C] (well1), 7) injected fluid (0 water, 1 co2) (well2), 8) injection rate [kg/s] (well2), and 9) temperature [C] (well2)
214+
inj = [[999.9, 999.9, 100, 1, 0, 10, 1, 0, 10],
215+
[ 0.1, 0.1, 0.1, 1, 0, 10, 1, 0, 10],
216+
[ 25, 5, 5, 1, 50, 10, 1, 0, 10],
217+
[ 25, 5, 5, 1, 50, 10, 1, 50, 10],
218+
[ 50, 25, 25, 1, 0, 10, 1, 0, 10],
219+
[ 400, 50, 50, 1, 0, 10, 1, 0, 10],
220+
[ 500, 100, 100, 1, 0, 10, 1, 0, 10]]
221+
222+
223+
For additional examples of configuration files using toml, see the
224+
`hello_world <https://github.com/OPM/pyopmspe11/tree/main/examples/hello_world>`_ and `configs <https://github.com/OPM/pyopmspe11/tree/main/tests/configs>`_ folders.
225+
226+
.. note::
227+
A Python version of at least 3.11 is requiered to use the toml format. For older Python versions, then use the :ref:`txt` configuration files.

docs/_sources/contributing.rst.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Contribute to the software
2525
#. **black src/ tests/** (this formats the code)
2626
#. **pylint src/ tests/** (this analyses the code, and might rise issues that need to be fixed before the pull request)
2727
#. **mypy --ignore-missing-imports src/ tests/** (this is a static checker, and might rise issues that need to be fixed before the pull request)
28-
#. **pytest --cov=pyopmspe11 --cov-report term-missing tests/** (this runs locally the tests, and might rise issues that need to be fixed before the pull request)
28+
#. **pytest --cov=pyopmspe11 --cov-report term-missing tests/** (this runs locally the tests, and might rise issues that need to be fixed before the pull request; to save the files, add the flag **--basetemp=test_outputs**)
2929
#. **pushd docs & make html** (this generates the documentation, and might rise issues that need to be fixed before the pull request; if the build succeeds and if the contribution changes the documentation, then delete all content from the `docs <https://github.com/cssr-tools/pyopmspe11/tree/main/docs>`_ folder except `Makefile <https://github.com/OPM/pyopmspe11/blob/main/docs/Makefile>`_, `text <https://github.com/OPM/pyopmspe11/blob/main/docs/text>`_, and `.nojekyll <https://github.com/OPM/pyopmspe11/blob/main/docs/.nojekyll>`_, after copy all contents from the docs/_build/html/ folder, and finally paste them in the `docs <https://github.com/cssr-tools/pyopmspe11/tree/main/docs>`_ folder)
3030

3131
.. tip::

docs/_sources/examples.rst.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ compare your example results to this figure to evaluate if your example ran corr
1919

2020
.. figure:: figs/spe11b_tco2_2Dmaps.png
2121

22+
Using the :ref:`toml` format, the previous run is equivalent to:
23+
24+
.. code-block:: bash
25+
26+
pyopmspe11 -i spe11b.toml -o spe11b -m all -g all -t 5 -r 50,1,15 -w 1
27+
2228
Let us now change the grid type from corner-point to tensor in line 7 of the configuration file.
2329
Then, we run the simulations and we save the results in a different output folder:
2430

docs/_sources/introduction.rst.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ The current implementation supports the following executable with the argument o
2929

3030
.. code-block:: bash
3131
32-
pyopmspe11 -i configuration_file.txt
32+
pyopmspe11 -i configuration_file
3333
3434
where
3535

0 commit comments

Comments
 (0)