Skip to content

Commit

Permalink
Merge pull request #1 from OPM/development
Browse files Browse the repository at this point in the history
Support to generate the benchmark data
  • Loading branch information
daavid00 authored Oct 21, 2023
2 parents 086fe42 + 67d767a commit de0c33a
Show file tree
Hide file tree
Showing 121 changed files with 2,639 additions and 1,445 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# SPDX-FileCopyrightText: 2023 NORCE
# SPDX-License-Identifier: MIT

name: Run the pyopmcsp11 executable
name: Run the pyopmspe11 executable

on:
push:
Expand Down Expand Up @@ -44,7 +44,7 @@ jobs:
pip install --upgrade pip setuptools wheel
pip install -r dev-requirements.txt
- name: Install pyopmcsp11
- name: Install pyopmspe11
run: |
pip install .
Expand All @@ -56,7 +56,7 @@ jobs:
- name: Run the tests
run: |
pytest --cov=pyopmcsp11 --cov-report term-missing tests/
pytest --cov=pyopmspe11 --cov-report term-missing tests/
- name: Build documentation
run: |
Expand Down
13 changes: 9 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,14 @@ cython_debug/
.DS_Store

# Environment
vpyopmcsp11
vpyopmspe11

# Examples outputs
examples/csp11a
examples/csp11b
examples/csp11c
tests/configs/test_compare
tests/configs/output
tests/configs/spe11a
tests/configs/spe11c
examples/spe11a
examples/spe11b
examples/spe11c
developing
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Contributing

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

## Ground Rules

Expand Down
12 changes: 6 additions & 6 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
include README.md
include LICENSE
include src/pyopmcsp11/core/*
include src/pyopmcsp11/templates/co2/*
include src/pyopmcsp11/templates/common/*
include src/pyopmcsp11/templates/reference_mesh/*
include src/pyopmcsp11/utils/*
include src/pyopmcsp11/visualization/*
include src/pyopmspe11/core/*
include src/pyopmspe11/templates/co2/*
include src/pyopmspe11/templates/common/*
include src/pyopmspe11/templates/reference_mesh/*
include src/pyopmspe11/utils/*
include src/pyopmspe11/visualization/*
65 changes: 19 additions & 46 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[![Build Status](https://github.com/daavid00/pyopmcsp11/actions/workflows/CI.yml/badge.svg)](https://github.com/daavid00/pyopmcsp11/actions/workflows/CI.yml)
[![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-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/)

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

<img src="docs/text/figs/animation.gif" width="830" height="400">

This repository contains scripts to set up a workflow in python for the three cases in the CSP11 project.
This repository contains scripts to set up a workflow in python for the three cases in the SPE11 project.
Here we use the [_OPM-Flow_](https://opm-project.org/?page_id=19) simulator.

## Installation
Expand All @@ -22,66 +22,39 @@ You can install the requirements in a virtual environment with the following com

```bash
# Clone the repo
git clone https://github.com/daavid00/pyopmcsp11.git
git clone https://github.com/OPM/pyopmspe11.git
# Get inside the folder
cd pyopmcsp11
cd pyopmspe11
# Create virtual environment
python3 -m venv vpyopmcsp11
python3 -m venv vpyopmspe11
# Activate virtual environment
source vpyopmcsp11/bin/activate
source vpyopmspe11/bin/activate
# Upgrade pip, setuptools, and wheel
pip install --upgrade pip setuptools wheel
# Install the pyopmcsp11 package (in editable mode for contributions/modifications, i.e., pip install -e .)
pip install .
# Install the pyopmspe11 package (in editable mode for contributions/modifications; otherwise, pip install .)
pip install -e .
# For contributions/testing/linting, install the dev-requirements
pip install -r dev-requirements.txt
```

See the [_CI.yml_](https://github.com/daavid00/pyopmcsp11/blob/main/.github/workflows/CI.yml) script
for installation of OPM Flow and the pyopmcsp11 package in Ubuntu.
See the [_CI.yml_](https://github.com/OPM/pyopmspe11/blob/main/.github/workflows/CI.yml) script
for installation of OPM Flow and the pyopmspe11 package in Linux.

## Running pyopmcsp11
You can run _pyopmcsp11_ as a single command line:
## Running pyopmspe11
You can run _pyopmspe11_ as a single command line:
```
pyopmcsp11 -i some_input.txt -o some_output_folder
pyopmspe11 -i some_input.txt -o some_output_folder
```
Run `pyopmcsp11 --help` to see all possible command line
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 examples
folders.

## Running in a docker

Docker container allows to run opm inside an encapsulated environment. To use it either pull the public [docker image](https://hub.docker.com/r/jafranc/opm-u22-spe11csp)

```
docker pull jafranc/opm-u22-spe11csp
```

or build it from the source _omp-spe11csp-ubuntu.Dockerfile_ located at _./dockers_ with command:

```
cd dockers
docker build --build-arg IMG=ubuntu --build-arg VERSION=jammy -t <tag-docker> -f omp-spe11csp-ubuntu.Dockerfile .
```

Then using `docker images`, the created or pulled image should be visible. Running the data generator and simulation for a case is then done by

```
docker run -e SPE_CASE=<a,b or c> -v <host-path-to-result>:/opt/spe11csp/output_csp11<a,b or c> <tag-docker>
```

Then you can inspect what has been produced at \<host-path-to-result\>. \<tag-docker\> being the tag you choose when building the image or if pulled from _docker://_ , _jafranc/opm-u22-spe11csp:latest_. Eventually \<a,b or c\> will set a variable in the docker container generating and running the simulation either for csp SPE 11th case a (2D surface conditions), case b (2D reservoir conditions) or c (3D extruded reservoir conditions).

Results can be visualized using [ResInsight](https://resinsight.org/) or other viewers.


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

## About pyopmcsp11
The pyopmcsp11 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)
## 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 csp11 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.
24 changes: 24 additions & 0 deletions build_opm-flow_mpi.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
CURRENT_DIRECTORY="$PWD"

# OPM modules
for repo in common grid models simulators
do
git clone https://github.com/OPM/opm-$repo.git
done

mkdir build

for repo in common grid models
do
mkdir build/opm-$repo
cd build/opm-$repo
cmake -DUSE_MPI=1 -DOPM_ENABLE_PYTHON=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="$CURRENT_DIRECTORY/build/opm-common;$CURRENT_DIRECTORY/build/opm-grid" $CURRENT_DIRECTORY/opm-$repo
make -j5
cd ../..
done

mkdir build/opm-simulators
cd build/opm-simulators
cmake -DUSE_MPI=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
make -j5 flow
cd ../..
25 changes: 25 additions & 0 deletions dockers/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
## Running in a docker

Docker container allows to run opm inside an encapsulated environment. To use it either pull the public [docker image](https://hub.docker.com/r/jafranc/opm-u22-spe11spe)

```
docker pull jafranc/opm-u22-spe11csp
```

or build it from the source _omp-spe11csp-ubuntu.Dockerfile_ located at _./dockers_ with command:

```
cd dockers
docker build --build-arg IMG=ubuntu --build-arg VERSION=jammy -t <tag-docker> -f omp-spe11csp-ubuntu.Dockerfile .
```

Then using `docker images`, the created or pulled image should be visible. Running the data generator and simulation for a case is then done by

```
docker run -e SPE_CASE=<a,b or c> -v <host-path-to-result>:/opt/spe11csp/output_csp11<a,b or c> <tag-docker>
```

Then you can inspect what has been produced at \<host-path-to-result\>. \<tag-docker\> being the tag you choose when building the image or if pulled from _docker://_ , _jafranc/opm-u22-spe11csp:latest_. Eventually \<a,b or c\> will set a variable in the docker container generating and running the simulation either for csp SPE 11th case a (2D surface conditions), case b (2D reservoir conditions) or c (3D extruded reservoir conditions).

Results can be visualized using [ResInsight](https://resinsight.org/) or other viewers.
4 changes: 0 additions & 4 deletions docs/.buildinfo

This file was deleted.

2 changes: 1 addition & 1 deletion docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ help:
# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
sphinx-apidoc --private -e -f -o text ../src/pyopmcsp11
sphinx-apidoc --private -e -f -o text ../src/pyopmspe11
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

github:
Expand Down
Binary file modified docs/_images/contents.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/_images/output.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_images/spe11b_performance.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_images/spe11b_sparse_data.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_images/spe11b_temp_2Dmaps.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions docs/_sources/about.rst.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
================
About pyopmcsp11
About pyopmspe11
================

.. image:: ./figs/about.png
:scale: 65%

This **pyopmcsp11** 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>`_
This **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 csp11 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.
9 changes: 4 additions & 5 deletions docs/_sources/api.rst.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
=====================
pyopmcsp11 Python API
pyopmspe11 Python API
=====================

The main script for the **pyopmcsp11** executable is located in the core folder.
The main script for the **pyopmspe11** executable is located in the core folder.
The reference_mesh folder contains `Gmsh <https://gmsh.info>`_ files to obtain the
coordinates used for the location of the different facies and generation of the corner-point grid.
The scripts in the utils folder process the input configuration
file, creates the geological model, and write the input files by using the files in the templates folder.
The visualization folder contains files for the postprocessing of the results (currently only
to plot 2D spatial maps for the last time step simulated.)
The visualization folder contains files for the postprocessing of the results.

.. figure:: figs/contents.png

Files in the pyopmcsp11 package.
Files in the pyopmspe11 package.

.. include:: modules.rst
35 changes: 18 additions & 17 deletions docs/_sources/configuration_file.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ The first input parameter in the configuration file is:
:linenos:
"""Set the full path to the flow executable and flags"""
flow --enable-tuning=true --enable-opm-rst-file=true
flow --linear-solver=cprw --enable-tuning=true --enable-opm-rst-file=true --output-extra-convergence-info=steps,iterations --enable-well-operability-check=false --min-time-step-before-shutting-problematic-wells-in-days=1e-99
If **flow** is not in your path, then write the full path to the executable
(e.g., /Users/dmar/Github/opm/build/opm-simulators/bin/flow). We also add in the same
(e.g., /Users/dmar/opm/build/opm-simulators/bin/flow). We also add in the same
line as many flags as required (see the OPM Flow documentation `here <https://opm-project.org/?page_id=955>`_).

.. note::
Expand All @@ -29,19 +29,19 @@ The following input lines in the configuration file are:
:lineno-start: 4
"""Set the model parameters"""
csp11c master #Name of the csp case (csp11a, csp11b, or csp11c) and OPM Flow version (master or release)
spe11c master #Name of the spe case (spe11a, spe11b, or spe11c) and OPM Flow version (master or release)
complete #Name of the co2 model (immiscible or complete)
cartesian #Type of grid (cartesian, tensor, or corner-point)
8400. 5000. 1200. #Length, width, and depth [m]
84 #If cartesian, number of x cells [-]; otherwise, variable array of x-refinment
50 #If cartesian, number of y cells [-]; otherwise, variable array of y-refinment [-] (for csp11c)
50 #If cartesian, number of y cells [-]; otherwise, variable array of y-refinment [-] (for spe11c)
12 #If cartesian, number of z cells [-]; if tensor, variable array of z-refinment; if corner-point, fix array of z-refinment (17 entries)
70. 36.25 #Temperature bottom and top rig [C]
19620000. #Pressure on the top [Pa]
1e-9 2e-8 #CO2 diffusion (in liquid and gas) [m^2/s]
8.5e-1 2500. #Rock specific heat and density (for csp11b/c)
5e4 1. #Pore volume on lateral boundaries and width of buffer cell [m] (for csp11b/c)
150. 10. #Elevation of the parabola and back [m] (for csp11c)
8.5e-1 2500. #Rock specific heat and density (for spe11b/c)
5e4 1. #Pore volume on lateral boundaries and width of buffer cell [m] (for spe11b/c)
150. 10. #Elevation of the parabola and back [m] (for spe11c)
In line 5 you specify if you are using OPM Flow from the master branch or from the latest stable release (OPM-flow 2023.4 release).
This since there are continuous changues in the OPM master branch (e.g., the format of the boundary condition keyword BC). Then we
Expand All @@ -51,9 +51,9 @@ gas and liquid phases, in addition to thermal effects. Regarding the grid type,
with the defined number of elements in lines 9 to 11. The tensor grid allows to define arrays in each direction where the grid
is first divided with the number of entries in the array, and after it divides each of these elements by the assigned number in
the array entry. The corner-point mode generates a grid where the x and y direction are defined as in the array mode, but the
cell faces in the z-direction follows the lines as defined in the `lines_coordinates.geo <https://github.com/daavid00/pyopmcsp11/blob/main/src/pyopmcsp11/reference_mesh/lines_coordinates.geo>`_ script,
resulting in 17 levels. Then, the z-refinment in each of these levels is set. See the configuration files in the `tests <https://github.com/daavid00/pyopmcsp11/blob/main/tests>`_ and
`examples <https://github.com/daavid00/pyopmcsp11/blob/main/examples>`_ folder for the setting of these grids.
cell faces in the z-direction follows the lines as defined in the `lines_coordinates.geo <https://github.com/OPM/pyopmspe11/blob/main/src/pyopmspe11/reference_mesh/lines_coordinates.geo>`_ script,
resulting in 17 levels. Then, the z-refinment in each of these levels is set. See the configuration files in the `tests <https://github.com/OPM/pyopmspe11/blob/main/tests>`_ and
`examples <https://github.com/OPM/pyopmspe11/blob/main/examples>`_ folder for the setting of these grids.

.. figure:: figs/cartesian.png
.. figure:: figs/tensor.png
Expand Down Expand Up @@ -113,16 +113,17 @@ The last part of the configuration file sets the wells radius, location, and the
:lineno-start: 45
"""Wells radius and position"""
"""radius, x, y, and z position [m] (final positions as well for csp11c)"""
"""radius, x, y, and z position [m] (final positions as well for spe11c)"""
0.15 2700. 1000. 300. 2700. 4000. 300. #Well 1
0.15 5100. 1000. 700. 5100. 4000. 700. #Well 2
"""Define the injection values 'inj[]'"""
"""injection time [s], time step size to write results [s], maximum solver time step [s], injected fluid (0 water, 1 co2) (well1), injection rate [kg/s] (well1), temperature [C] (well1), injected fluid (0 water, 1 co2) (well2), ..."""
31536000000 31536000000 315360000 0 0 10 0 0 10
788400000 788400000 31536000 1 50 10 0 0 10
788400000 788400000 31536000 1 50 10 1 50 10
29959200000 29959200000 315360000 0 0 10 0 0 10
"""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), ..."""
995 995 1 0 0 10 0 0 10
5 5 1 0 0 10 0 0 10
25 5 1 1 50 10 0 0 10
25 5 1 1 50 10 1 50 10
950 5 1 0 0 10 0 0 10
.. warning::
Keep the linebreak between the sections (in the current implementation this is used for the reading of the parameters).
Loading

0 comments on commit de0c33a

Please sign in to comment.