Skip to content

Runfiles for an ML near-well model and to reproduce results from the article "A machine-learned near-well model in OPM Flow". Uses pyopmnearwell.

License

Notifications You must be signed in to change notification settings

cssr-tools/ML_near_well

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ML_near_well

ML_near_well is a collection of runfiles for a machine-learned near-well model. The key idea is to replace the analytical expression for well transmissibility from Peaceman-type well models with a neural network. The network is trained on data from fine-scale ensemble simulations of the near-well region under differing flow regimes. This novel approach allows for flexible and accurate modeling of transient and multiphase effects.

The accompanying paper is A machine-learned near-well model in OPM Flow, to be published later in 2024.

The ensemble simulations as well as tests of the final model are run in the open-source reservoir simulator OPM Flow. In addition, our code uses the pyopmnearwell package for near-well ensemble simulations and model training and the OPM Flow - neural network framework for integration of neural networks into OPM Flow.

Note: The latter is not publicly available yet (as of 06.06.2024); without it the code in this repository will only run partly. As soon as everything is available, this note will be removed.

06th August 2024: pyopmnearwell was just updated to require OPM Flow 2024.04 and python 3.10. This might cause some smaller issues with, e.g., renamed keywords, as this repo was tested with OPM Flow 2023.04 and python 3.8. We will test and update everything as soon as possible.

Installation

Note: Everything was tested on WSL2 with an ubuntu 20.02 installation, python 3.8.10, and OPM Flow 2023.04.

  1. Create a virtual environment (e.g., with conda) and install the dependencies with pip install -r requirements.txt.
  2. Clone https://github.com/cssr-tools/pyopmnearwell/tree/development, go to the local repo, and install with pip install .-.
  3. Install OPM or build from source https://opm-project.org/?page_id=36 (needed to run the ensemble scripts).
  4. Build OPM with ML integration from source https://github.com/fractalmanifold/ml_integration2opm/tree/main (needed to run the integration scripts).
  5. Clone this repo git clone ....
  6. Update the paths to OPM and OPM with ML integration in the runscripts.
h2o/runspecs.py
co2_2d/runspecs.py
co2_3d/runspecs.py

Usage

You can reproduce the paper results as described below. To create and integrate your own near-well model, follow the structure of the examples. The workflow consists of four steps:

  1. Run an ensemble of radial fine-scale near-well simulations. pyopmnearwell.ml.ensemble provides useful functions.
  2. Extract and upscale features and targets to create a dataset. pyopmnearwell.ml.ensemble and pyopmnearwell.ml.upscale provide useful functions.
  3. Train a neural network in Tensorflow. pyopmnearwell.ml.nn and ML_near_well.utils provide useful functions.
  4. Integrate the network into OPM Flow and run a full simulation. pyopmnearwell.ml.integration provides useful functions.

NOTE: At the moment, some hardcoded hacks are needed to make everything work. Make sure that you use the right values to get correct results.

  • The total injected volume inside OPM Flow is calculated by multiplying elapsed time with injection rate. The injection rate is hardcoded for each model and needs to be adjusted in standardwell_impl.mako inside the wellIndexEval function. (This is relevant for the CO2 examples.)
  • The scaling of outputs and inputs for the NN is done inside OPM Flow. However, the scaling values are hardcoded and OPM Flow needs to be recompiled each time the model changes. pyopmnearwell provides some helper functions (in ml.nn and ml.integration) that automatically store these values, fill them into the standardwell_impl.mako templates and recompile Flow. In the release version of OPM Flow - NN version, scaling values will be stored directly inside the neural network, such that this procedure is no longer needed.
  • OPM Flow does not support radial simulations. Instead the near-well ensemble simulations are run on a triangle shaped domain. The results correspond then to radii adjusted with pyopmnearwell.utils.formulas.pyopmnearwell_correction on a radial grid of the same angle as the triangle. Afterwards, some results/values, such as injection rate, still need to be adjusted to a full 360° well.

Reproduce results

To reproduce the paper results and figures, run these commands:

cd examples
bash run.bash

Alternatively, you can run each of the examples individually, e.g.,:

cd examples/h2o_extended
python main.py

Results 1, 2, and 3 in the paper correspond to h2o, co2_2d, and co2_3d.

Citing

If you use either all or part of of the code in this repository, we kindly ask you to cite the following reference:

P. von Schultzendorff, T. H. Sandve, B. Kane, D. Landa-Marbán, J. W. Both, and J. M. Nordbotten, “A Machine-Learned Near-Well Model in OPM Flow”, presented at ECMOR 2024, European Association of Geoscientists & Engineers, Sep. 2024, pp. 1–23. doi: 10.3997/2214-4609.202437033.

About

Runfiles for an ML near-well model and to reproduce results from the article "A machine-learned near-well model in OPM Flow". Uses pyopmnearwell.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published