Skip to content

Commit

Permalink
Merge pull request #69 from daavid00/documentation
Browse files Browse the repository at this point in the history
Benchmark results, update to toml, and documentation
  • Loading branch information
daavid00 authored Aug 26, 2024
2 parents 499064e + d62d15e commit a420b40
Show file tree
Hide file tree
Showing 75 changed files with 1,619 additions and 252 deletions.
14 changes: 6 additions & 8 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
# SPDX-FileCopyrightText: 2023 NORCE
# SPDX-License-Identifier: MIT

name: Run the pyopmspe11 executable
name: Run pyopmspe11

on:
push:
Expand Down Expand Up @@ -40,20 +37,21 @@ jobs:
sudo apt-get install libopm-simulators-bin
sudo apt-get install texlive-fonts-recommended texlive-fonts-extra dvipng cm-super
- name: Install test dependecies
- name: Install dependecies
run: |
pip install --upgrade pip setuptools wheel
pip install -r dev-requirements.txt
pip install opm
- name: Install pyopmspe11
run: |
pip install .
- name: Check code style and linting
run: |
black --check src/ tests/ setup.py
pylint src/ tests/ setup.py
mypy --ignore-missing-imports src/ tests/ setup.py
black --check src/ tests/
pylint src/ tests/
mypy --ignore-missing-imports src/ tests/
- name: Run the tests
run: |
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,8 @@ examples/finner_grids/spe11b
examples/finner_grids/spe11c
examples/hello_world/spe11a
examples/hello_world/spe11b
examples/hello_world/spe11
examples/hello_world/spe11c
playground
tests/configs/test_compare
tests/configs/output
tests/configs/spe11a
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Contributing

Hola hola :).
Hola hola 🙂.
The following is a set of guidelines for contributing to pyopmspe11.

## Ground Rules
Expand Down
26 changes: 15 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
[![Build Status](https://github.com/OPM/pyopmspe11/actions/workflows/CI.yml/badge.svg)](https://github.com/OPM/pyopmspe11/actions/workflows/CI.yml)
<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>
<a href="https://www.python.org/"><img src="https://img.shields.io/badge/python-3.8%20to%203.12-blue.svg"></a>
[![Code style](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black)
[![License: MIT](https://img.shields.io/badge/license-MIT-blue)](https://opensource.org/license/mit/)

# pyopmspe11: A Python framework using OPM Flow for the SPE11 benchmark project

<img src="docs/text/figs/animationspe11a.gif" width="830" height="360">

This repository contains scripts to set up a workflow in python for the three cases in the [_SPE11 project_](https://www.spe.org/en/csp/).
This repository contains scripts to set up a workflow using Python for the three cases in the [_SPE11 project_](https://www.spe.org/en/csp/).
Here we use the [_OPM-Flow_](https://opm-project.org/?page_id=19) simulator.

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

You can install the Python requirements in a virtual environment with the following commands:
To install the _pyopmspe11_ executable in an existing Python environment:

```bash
pip install git+https://github.com/OPM/pyopmspe11.git
```

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:

```bash
# Clone the repo
Expand All @@ -27,29 +33,27 @@ python3 -m venv vpyopmspe11
source vpyopmspe11/bin/activate
# Upgrade pip, setuptools, and wheel
pip install --upgrade pip setuptools wheel
# Install the pyopmspe11 package (in editable mode for contributions/modifications; otherwise, pip install .)
# Install the pyopmspe11 package
pip install -e .
# For contributions/testing/linting, install the dev-requirements
pip install -r dev-requirements.txt
```

See the [_CI.yml_](https://github.com/OPM/pyopmspe11/blob/main/.github/workflows/CI.yml) script for installation of OPM Flow (binary packages) and the pyopmspe11 package. 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`, which in turn should build flow in the folder ./build/opm-simulators/bin/flow.

For macOS users with the latest chips (M1/M2, guessing also M3?), the resdata Python package might not available via pip install, 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 from the `requirements.txt`, then proceed with the Python requirements installation, install the OPM Flow dependencies (using macports or brew), and once inside the vpyopmspe11 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).
See the [_installation_](https://OPM.github.io/pyopmsep11/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.

## Running pyopmspe11
You can run _pyopmspe11_ as a single command line:
```
pyopmspe11 -i some_input.txt -o some_output_folder
pyopmspe11 -i configuration_file.txt
```
Run `pyopmspe11 --help` to see all possible command line
argument options. Inside the `some_input.txt` file you provide the path to the flow executable and simulation parameters. See the .txt files in the tests and examples folders.
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.

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

## About pyopmspe11
The pyopmspe11 package is being funded by the [_HPC Simulation Software for the Gigatonne Storage Challenge project_](https://www.norceresearch.no/en/projects/hpc-simulation-software-for-the-gigatonne-storage-challenge) [project number 622059] and [_Center for Sustainable Subsurface Resources (CSSR)_](https://cssr.no)
[project no. 331841].
This is work in progress. [_Here_](https://www.spe.org/en/csp/) is the link to the spe11 details.
This is work in progress. [_Here_](https://www.spe.org/en/csp/) is the link to the SPE11 details.
Contributions are more than welcome using the fork and pull request approach.
54 changes: 54 additions & 0 deletions benchmark/spe11a/result1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
"""Set the full path to the flow executable and flags"""
mpirun -np 32 flow --partition-method=2 --edge-weights-method=2 --imbalance-tol=1.1 --nonlinear-solver=nldd --matrix-add-well-contributions=1 --tolerance-mb=1e-7 --linear-solver=cpr_trueimpes --enable-tuning=false --solver-max-time-step-in-days=0.02 --enable-opm-rst-file=true --output-extra-convergence-info=steps,iterations --newton-min-iterations=1 --time-step-control-target-newton-iterations=2 --time-step-control-growth-rate=1.15 --time-step-control-decay-rate=0.85 --newton-max-iterations=6 --relaxed-max-pv-fraction=0 --min-strict-cnv-iter=8 --tolerance-cnv-relaxed=1e-2 --tolerance-cnv=1e-3 --local-domains-ordering-measure=residual --time-step-control=newtoniterationcount --use-update-stabilization=0 --enable-drift-compensation=0 --max-local-solve-iterations=50 --linear-solver-max-iter=50

"""Set the model parameters"""
spe11a master #Name of the spe case (spe11a, spe11b, or spe11c) and OPM Flow version (master or release)
complete gaswater #Name of the co2 model (immiscible or complete) and co2store implementation (gaswater or gasoil [oil properties are set to water internally in OPM flow])
cartesian #Type of grid (cartesian, tensor, or corner-point)
2.8 0.01 1.2 #Length, width, and depth [m]
280 #If cartesian, number of x cells [-]; otherwise, variable array of x-refinment
1 #If cartesian, number of y cells [-]; otherwise, variable array of y-refinment [-] (for spe11c)
120 #If cartesian, number of z cells [-]; if tensor, variable array of z-refinment; if corner-point, fix array of z-refinment (18 entries)
20 20 #Temperature bottom and top rig [C]
1.2 110000 1 #Datum [m], pressure at the datum [Pa], and multiplier for the permeability in the z direction [-]
1e-9 1.6e-5 #Diffusion (in liquid and gas) [m^2/s]
0 0 #Rock specific heat and density (for spe11b/c)
0 0 0 #Added pore volume on top boundary (for spe11a [if 0, free flow bc]), pore volume on lateral boundaries, and width of buffer cell [m] (for spe11b/c)
0 0 #Elevation of the parabola and back boundary [m] (for spe11c)

"""Set the saturation functions"""
(max(0, (s_w - swi) / (1 - swi))) ** 2 #Wetting rel perm saturation function [-]
(max(0, (1 - s_w - sni) / (1 - sni))) ** 2 #Non-wetting rel perm saturation function [-]
penmax * math.erf(pen * ((s_w-swi) / (1.-swi)) ** (-(1.0 / 2)) * math.pi**0.5 / (penmax * 2)) #Capillary pressure saturation function [Pa]
(np.exp(np.flip(np.linspace(0, 5.0, npoints))) - 1) / (np.exp(5.0) - 1) #Points to evaluate the saturation functions (s_w) [-]

"""Properties sat functions"""
"""swi [-], sni [-], pen [Pa], penmax [Pa], npoints [-]"""
SWI1 0.32 SNI1 0.1 PEN1 1500 PENMAX1 9.5E4 NPOINTS1 1000
SWI2 0.14 SNI2 0.1 PEN2 300 PENMAX2 9.5E4 NPOINTS2 1000
SWI3 0.12 SNI3 0.1 PEN3 100 PENMAX3 9.5E4 NPOINTS3 1000
SWI4 0.12 SNI4 0.1 PEN4 25 PENMAX4 9.5E4 NPOINTS4 1000
SWI5 0.12 SNI5 0.1 PEN5 10 PENMAX5 9.5E4 NPOINTS5 1000
SWI6 0.10 SNI6 0.1 PEN6 1 PENMAX6 9.5E4 NPOINTS6 1000
SWI7 0 SNI7 0 PEN7 0 PENMAX7 9.5E4 NPOINTS7 2

"""Properties rock"""
"""K [mD], phi [-], disp [m]"""
PERM1 44529.9988 PORO1 0.44 DISP1 1e-2
PERM2 506624.985 PORO2 0.43 DISP2 1e-2
PERM3 1013249.97 PORO3 0.44 DISP3 1e-2
PERM4 2026499.95 PORO4 0.45 DISP4 1e-2
PERM5 4052999.88 PORO5 0.43 DISP5 1e-2
PERM6 10132499.7 PORO6 0.46 DISP6 1e-2
PERM7 0 PORO7 0 DISP7 0

"""Wells position"""
"""radius (0 to use the SOURCE keyword instead of well keywords), x, y, and z position [m] (final positions as well for spe11c)"""
0 0.9 0.005 0.3 #Well 1
0 1.7 0.005 0.7 #Well 2

"""Define the injection values ([hours] for spe11a; [years] for spe11b/c)"""
"""injection time, time step size to write results, maximum solver time step, injected fluid (0 water, 1 co2) (well1), injection rate [kg/s] (well1), temperature [C] (well1), injected fluid (0 water, 1 co2) (well2), ..."""
2.5 0.5 0.5 1 1.7e-7 20 1 0 20
2.5 0.5 0.5 1 1.7e-7 20 1 1.7e-7 20
115 1 1 1 0 20 1 0 20
54 changes: 54 additions & 0 deletions benchmark/spe11a/result2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
"""Set the full path to the flow executable and flags"""
mpirun -np 32 flow --partition-method=2 --edge-weights-method=2 --imbalance-tol=1.1 --nonlinear-solver=nldd --matrix-add-well-contributions=1 --tolerance-mb=1e-7 --linear-solver=cpr_trueimpes --enable-tuning=false --solver-max-time-step-in-days=0.02 --enable-opm-rst-file=true --output-extra-convergence-info=steps,iterations --newton-min-iterations=1 --time-step-control-target-newton-iterations=2 --time-step-control-growth-rate=1.15 --time-step-control-decay-rate=0.85 --newton-max-iterations=6 --relaxed-max-pv-fraction=0 --min-strict-cnv-iter=8 --tolerance-cnv-relaxed=1e-2 --tolerance-cnv=1e-3 --local-domains-ordering-measure=residual --time-step-control=newtoniterationcount --use-update-stabilization=0 --enable-drift-compensation=0 --max-local-solve-iterations=50 --linear-solver-max-iter=50

"""Set the model parameters"""
spe11a master #Name of the spe case (spe11a, spe11b, or spe11c) and OPM Flow version (master or release)
complete gaswater #Name of the co2 model (immiscible or complete) and co2store implementation (gaswater or gasoil [oil properties are set to water internally in OPM flow])
cartesian #Type of grid (cartesian, tensor, or corner-point)
2.8 0.01 1.2 #Length, width, and depth [m]
280 #If cartesian, number of x cells [-]; otherwise, variable array of x-refinment
1 #If cartesian, number of y cells [-]; otherwise, variable array of y-refinment [-] (for spe11c)
120 #If cartesian, number of z cells [-]; if tensor, variable array of z-refinment; if corner-point, fix array of z-refinment (18 entries)
20 20 #Temperature bottom and top rig [C]
1.2 110000 1 #Datum [m], pressure at the datum [Pa], and multiplier for the permeability in the z direction [-]
1e-9 1.6e-5 #Diffusion (in liquid and gas) [m^2/s]
0 0 #Rock specific heat and density (for spe11b/c)
0 0 0 #Added pore volume on top boundary (for spe11a [if 0, free flow bc]), pore volume on lateral boundaries, and width of buffer cell [m] (for spe11b/c)
0 0 #Elevation of the parabola and back boundary [m] (for spe11c)

"""Set the saturation functions"""
(max(0, (s_w - swi) / (1 - swi))) ** 2 #Wetting rel perm saturation function [-]
(max(0, (1 - s_w - sni) / (1 - sni))) ** 2 #Non-wetting rel perm saturation function [-]
penmax * math.erf(pen * ((s_w-swi) / (1.-swi)) ** (-(1.0 / 2)) * math.pi**0.5 / (penmax * 2)) #Capillary pressure saturation function [Pa]
(np.exp(np.flip(np.linspace(0, 5.0, npoints))) - 1) / (np.exp(5.0) - 1) #Points to evaluate the saturation functions (s_w) [-]

"""Properties sat functions"""
"""swi [-], sni [-], pen [Pa], penmax [Pa], npoints [-]"""
SWI1 0.32 SNI1 0.1 PEN1 1500 PENMAX1 2500 NPOINTS1 1000
SWI2 0.14 SNI2 0.1 PEN2 300 PENMAX2 2500 NPOINTS2 1000
SWI3 0.12 SNI3 0.1 PEN3 100 PENMAX3 2500 NPOINTS3 1000
SWI4 0.12 SNI4 0.1 PEN4 25 PENMAX4 2500 NPOINTS4 1000
SWI5 0.12 SNI5 0.1 PEN5 10 PENMAX5 2500 NPOINTS5 1000
SWI6 0.10 SNI6 0.1 PEN6 1 PENMAX6 2500 NPOINTS6 1000
SWI7 0 SNI7 0 PEN7 0 PENMAX7 2500 NPOINTS7 2

"""Properties rock"""
"""K [mD], phi [-], disp [m]"""
PERM1 44529.9988 PORO1 0.44 DISP1 1e-2
PERM2 506624.985 PORO2 0.43 DISP2 1e-2
PERM3 1013249.97 PORO3 0.44 DISP3 1e-2
PERM4 2026499.95 PORO4 0.45 DISP4 1e-2
PERM5 4052999.88 PORO5 0.43 DISP5 1e-2
PERM6 10132499.7 PORO6 0.46 DISP6 1e-2
PERM7 0 PORO7 0 DISP7 0

"""Wells position"""
"""radius (0 to use the SOURCE keyword instead of well keywords), x, y, and z position [m] (final positions as well for spe11c)"""
0 0.9 0.005 0.3 #Well 1
0 1.7 0.005 0.7 #Well 2

"""Define the injection values ([hours] for spe11a; [years] for spe11b/c)"""
"""injection time, time step size to write results, maximum solver time step, injected fluid (0 water, 1 co2) (well1), injection rate [kg/s] (well1), temperature [C] (well1), injected fluid (0 water, 1 co2) (well2), ..."""
2.5 0.5 0.5 1 1.7e-7 20 1 0 20
2.5 0.5 0.5 1 1.7e-7 20 1 1.7e-7 20
115 1 1 1 0 20 1 0 20
54 changes: 54 additions & 0 deletions benchmark/spe11a/result3.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
"""Set the full path to the flow executable and flags"""
mpirun -np 32 flow --partition-method=2 --edge-weights-method=2 --imbalance-tol=1.1 --min-strict-cnv-iter=5 --tolerance-cnv-relaxed=1e-2 --tolerance-cnv=1e-3 --tolerance-mb=1e-7 --linear-solver=cprw --newton-min-iterations=1 --enable-tuning=true --enable-opm-rst-file=true --output-extra-convergence-info=steps,iterations --enable-drift-compensation=0

"""Set the model parameters"""
spe11a master #Name of the spe case (spe11a, spe11b, or spe11c) and OPM Flow version (master or release)
complete gaswater #Name of the co2 model (immiscible or complete) and co2store implementation (gaswater or gasoil [oil properties are set to water internally in OPM flow])
corner-point #Type of grid (cartesian, tensor, or corner-point)
2.8 0.01 1.2 #Length, width, and depth [m]
280 #If cartesian, number of x cells [-]; otherwise, variable array of x-refinment
1 #If cartesian, number of y cells [-]; otherwise, variable array of y-refinment [-] (for spe11c)
20,7,1,5,6,3,8,8,12,8,10,10,6,16,6,28,28,1 #If cartesian, number of z cells [-]; if tensor, variable array of z-refinment; if corner-point, fix array of z-refinment (18 entries)
20 20 #Temperature bottom and top rig [C]
1.2 110000 1 #Datum [m], pressure at the datum [Pa], and multiplier for the permeability in the z direction [-]
1e-9 1.6e-5 #Diffusion (in liquid and gas) [m^2/s]
0 0 #Rock specific heat and density (for spe11b/c)
0 0 0 #Added pore volume on top boundary (for spe11a [if 0, free flow bc]), pore volume on lateral boundaries, and width of buffer cell [m] (for spe11b/c)
0 0 #Elevation of the parabola and back boundary [m] (for spe11c)

"""Set the saturation functions"""
(max(0, (s_w - swi) / (1 - swi))) ** 2 #Wetting rel perm saturation function [-]
(max(0, (1 - s_w - sni) / (1 - sni))) ** 2 #Non-wetting rel perm saturation function [-]
penmax * math.erf(pen * ((s_w-swi) / (1.-swi)) ** (-(1.0 / 2)) * math.pi**0.5 / (penmax * 2)) #Capillary pressure saturation function [Pa]
(np.exp(np.flip(np.linspace(0, 5.0, npoints))) - 1) / (np.exp(5.0) - 1) #Points to evaluate the saturation functions (s_w) [-]

"""Properties sat functions"""
"""swi [-], sni [-], pen [Pa], penmax [Pa], npoints [-]"""
SWI1 0.32 SNI1 0.1 PEN1 1500 PENMAX1 2500 NPOINTS1 1000
SWI2 0.14 SNI2 0.1 PEN2 300 PENMAX2 2500 NPOINTS2 1000
SWI3 0.12 SNI3 0.1 PEN3 100 PENMAX3 2500 NPOINTS3 1000
SWI4 0.12 SNI4 0.1 PEN4 25 PENMAX4 2500 NPOINTS4 1000
SWI5 0.12 SNI5 0.1 PEN5 10 PENMAX5 2500 NPOINTS5 1000
SWI6 0.10 SNI6 0.1 PEN6 1 PENMAX6 2500 NPOINTS6 1000
SWI7 0 SNI7 0 PEN7 0 PENMAX7 2500 NPOINTS7 2

"""Properties rock"""
"""K [mD], phi [-], disp [m]"""
PERM1 44529.9988 PORO1 0.44 DISP1 1e-2
PERM2 506624.985 PORO2 0.43 DISP2 1e-2
PERM3 1013249.97 PORO3 0.44 DISP3 1e-2
PERM4 2026499.95 PORO4 0.45 DISP4 1e-2
PERM5 4052999.88 PORO5 0.43 DISP5 1e-2
PERM6 10132499.7 PORO6 0.46 DISP6 1e-2
PERM7 0 PORO7 0 DISP7 0

"""Wells position"""
"""radius (0 to use the SOURCE keyword instead of well keywords), x, y, and z position [m] (final positions as well for spe11c)"""
0 0.9 0.005 0.3 #Well 1
0 1.7 0.005 0.7 #Well 2

"""Define the injection values ([hours] for spe11a; [years] for spe11b/c)"""
"""injection time, time step size to write results, maximum solver time step, injected fluid (0 water, 1 co2) (well1), injection rate [kg/s] (well1), temperature [C] (well1), injected fluid (0 water, 1 co2) (well2), ..."""
2.5 0.5 0.5 1 1.7e-7 20 1 0 20
2.5 0.5 0.5 1 1.7e-7 20 1 1.7e-7 20
115 1 1 1 0 20 1 0 20
Loading

0 comments on commit a420b40

Please sign in to comment.