Skip to content

sede-open/Core2Relperm

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. Roadmap
  5. Contributing
  6. License
  7. Contact
  8. Acknowledgments
  9. How to Cite

Logo

Core2Relperm

A Python library for interpreting core flooding experiments
Explore the docs »

View Demo · Report Bug · Request Feature

About The Project

Product Name Screen Shot

For modelling studies of underground storage of carbon dioxide and hydrogen, transport in the vadoze zone, contaminant hydrology as well as hydrocarbon recovery, it is important to have a consistent set of relative permeability and capillary pressure-saturation functions as inputs for numerical reservoir models in order to assess risks and uncertainties and provide forward-models for different scenarios. Such relative permeability and capillary-pressure saturations functions are typically obtained in Special Core Analysis (SCAL) where core flooding experiments are a central element (see also The Society of Core Analysts). Interpreation of such core flooding experiments by analytical approximations has several disadvantages and instead, interpretation by inverse modelling is the preferred approach. This project has been created to provide a standalone Python tool for the interpretation of such core flooding experiments. It contains

  • a 1D numerical flow solver (Darcy fractional flow solver with capillarity in 1D) and
  • an inverse modelling framework which is utilizing the optimization package called lmfit from Python
The inverse modelling framework is in its default version a least-squares fit using the Levenberg-Marquardt algorithm. It essentially performs a least-squares fit of the numerical solution of a set of partial differential equations (which are numerically solved by the flow solver) to numerical data. The Jacobian is automatically computed numerically in the background by the lmfit package. The flow solver is accelerated with the numba just-in-time compiler which makes the flow solver code run in just about 50 ms. For a few tens of iterations required for a typical inverse modelling with least-squares fit, the code runs just in a few seconds. One can also change an option in the lmfit package (only a single line) to using the emcee Markov chain Monte Carlo (MCMC) package. About 10,000-20,000 iterations will run in a few hours in single-threaded mode. The advantage of using the MCMC approach is that one can address problems non-uniqueness and non-Gaussian errors.

Flow simulator code and inverse modelling framework are research code. The 1D flow code has been validated against benchmarks developed by Jos Maas and respective benchmark examples are included as examples. The inverse modelling framework has been validated in a series of publications

  1. S. Berg, E. Unsal, H. Dijk, Non-Uniqueness and Uncertainty Quantification of Relative Permeability Measurements by Inverse Modelling, Computers and Geotechnics 132, 103964, 2021.

  2. S. Berg, E. Unsal, H. Dijk, Sensitivity and uncertainty analysis for parameterization of multi phase flow models, Transport in Porous Media 140(1), 27-57, 2021.

  3. S. Berg, H. Dijk, E. Unsal, R. Hofmann, B. Zhao, V. Ahuja, Simultaneous Determination of Relative Permeability and Capillary Pressure from an Unsteady-State Core Flooding Experiment Computers and GeoSciences 168, 106091, 2024.

(back to top)

Built With

(back to top)

Getting Started

Read the paper to get some background info. Then install your favorite Python distribution of you don't already have one (we used Anaconda), install required libraries, download the code and run the examples.

Dependencies

The code and examples can be run from most modern Python distributions such as Anaconda. You may want to choose a distribution that has matplotlib, numpy and other standard packages pre-installed. There are a few extra libraries to install:

  • pandas (using internally pandas data frames, but also to import/expert data)
  • lmfit (the engine for the least squares fits)
  • emcee (Markov chain Monte Carlo sampler, optional)
  • numba (Just In Time compiler)
  • seaborn (for statistical data visualization)

Installation

Quick installation by replicating the environment in Anaconda:

  1. Clone the repo
    git clone https://github.com/sede-open/core2relperm.git
  2. Configure conda
    conda update conda
    conda config --set ssl_verify false
  3. Replicate environment using either of the following commands:
    conda env create -f environment.yml 
  4. Activate the environment
    conda activate relperm

Alternatively, if you face issues with above mentioned quick installtion, you can install the packages manually as shown below:

  1. Clone the repo
    git clone https://github.com/sede-open/core2relperm.git
  2. Configure conda, create new environment and activate it
    conda update conda
    conda config --set ssl_verify false
    conda create --name relperm 
    conda activate relperm
  3. Install additional Python libraries
    pandas
    conda install pandas
    lmfit
    conda install -c conda-forge lmfit
    emcee
    conda install -c conda-forge emcee
    seaborn
    conda install -c anaconda seaborn
    numba
    conda install -c numba numba

Usage

Solver Benchmarks

We included 4 SCAL benchmarks from https://www.jgmaas.com

  benchmark_scores_Case1.ipynb
  benchmark_scores_Case2.ipynb
  benchmark_scores_Case3.ipynb
  benchmark_scores_Case4.ipynb

that are benchmarking the 2-phase 1D flow solver defined in R. Lenormand, K. Lorentzen, J. G. Maas and D. Ruth, COMPARISON OF FOUR NUMERICAL SIMULATORS FOR SCAL EXPERIMENTS, SCA2016-006

Running Inverse Modelling Examples

We include 2 examples from the paper S. Berg, E. Unsal, H. Dijk, Sensitivity and uncertainty analysis for parameterization of multi phase flow models, Transport in Porous Media 140(1), 27-57, 2021.

  • Fig. 09
    example_Fig09_USS_dpw+dpo+noSwz.py
  • Fig. 17
    example_Fig17_USS_dpw+dpo+Swz_bumpfloods.py

The .py files are also available as .ipynb Jupyter notebooks (generated with jupytext). Respective markdown tags are included in the .py files to generate the formatting e.g. headers in the Jupyter notebooks.

(back to top)

Roadmap

  • Add Changelog
  • Add more examples from previous papers
    • steady-state experiments
    • matching real data

(back to top)

Contributing

It would be great if you could contribute to this project. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

(back to top)

License

Distributed under the MIT License. See LICENSE.txt for more information.

(back to top)

Contact

Steffen Berg - LinkedIn - steffen.berg@shell.com

Project Link: https://github.com/sede-open/Core2Relperm

(back to top)

Acknowledgments

We would like to acknowledge

  • Sherin Mirza, Aarthi Thyagarajan and Luud Heck from Shell supporting the OpenSource release on GitHub
  • Holger Ott, Omidreza Amrollahinasab (University of Leoben), and Jos Maas (PanTerra) for helpful discussions
  • Tibi Sorop and Yingxue Wang for reviewing the paper manuscript

(back to top)

How to Cite

  1. S. Berg, H. Dijk, E. Unsal, R. Hofmann, B. Zhao, V. Ahuja, Simultaneous Determination of Relative Permeability and Capillary Pressure from an Unsteady-State Core Flooding Experiment Computers and GeoSciences 168, 106091, 2024.

  2. S. Berg, E. Unsal, H. Dijk, Non-Uniqueness and Uncertainty Quantification of Relative Permeability Measurements by Inverse Modelling, Computers and Geotechnics 132, 103964, 2021.

  3. S. Berg, E. Unsal, H. Dijk, Sensitivity and uncertainty analysis for parameterization of multi phase flow models, Transport in Porous Media 140(1), 27-57, 2021.

  4. R. Lenormand, K. Lorentzen, J. G. Maas and D. Ruth COMPARISON OF FOUR NUMERICAL SIMULATORS FOR SCAL EXPERIMENTS SCA2016-006

(back to top)

About

Core2Relperm project for inverse modelling of core flooding experiments

Resources

License

MIT, MIT licenses found

Licenses found

MIT
LICENSE
MIT
LICENSE.txt

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published