Skip to content

Core2Relperm project for inverse modelling of core flooding experiments

License

MIT, MIT licenses found

Licenses found

MIT
LICENSE
MIT
LICENSE.txt
Notifications You must be signed in to change notification settings

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 Geotechnics 168, 106091, 2024.

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

(back to top)

(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 create the environment and install the Python packages manually as shown below:

  1. Create new environment and install required Python libraries
    conda create -n relperm numpy matplotlib numba scipy seaborn pandas lmfit emcee
  2. For rendering in VSCode install the ipykernel package
    conda install ipykernel

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

Inverse Modelling Examples from latest Computers & GeoTechnics Paper

We include 2 examples from the paper 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 Geotechnics 168, 106091, 2024.

  • 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)

Interpretation of Unsteady-state drainage and imbibition experiments

We include 4 Jupyter notebooks with synthetic data for drainage and imbibition which are based on the example_Fig17_USS_dpw+dpo+Swz_bumpfloods.ipynb. In the "_to-Excel" notebooks the "simulated" experimental data is written to Excel files, then loaded again and interpreted by inverse modelling. In the "_from-Excel" notebooks only the data from the Excel sheets is loaded and then interpreted by inverse modelling.

  • Drainage
    USS_synthetic_data_drainage_to-Excel.ipynb
    which generates expdataHISUSSdrainage.xlsx
    USS_synthetic_data_drainage_from-Excel.ipynb
  • Imbibition
    USS_synthetic_data_imbibition_to-Excel.ipynb
    which generates expdataHISUSSimbibition.xlsx
    USS_synthetic_data_imbibition_from-Excel.ipynb

The Excel files and "_from-Excel" notebooks can be used to interpret user experimental data sets. In principle only the Excel sheets have to be modified with the user experimental data sets. But it is important to maintain the format given in the Excel sheets.

In these notebooks two alternative methods for assessing the uncertainty regions have been added"

  1. for each varied fit parameter a normal distribution is generated with 1000 samples and then from these samples mean and standard deviation are determined and plotted as uncertainty ranges
  2. Making use of the numpy.random.Generator.multivariate_normal function the covariance matrix from lmfit is direclty used to draw random samples. With a few modifiations i.e. not allowing negative values for fit parameters that should not become negative respective 95% confidence intervals are shows, which is the cleanest way.

Interestingly, the uncertainty ranges from the proper 95% confidence intervals are not dramatically different that the guestimate used in the previous examples.

Also, plotting the correlation matrix has been improved where the varied parameters are automatically determined from the lmfit report.

Interpretation of Steady-state imbibition experiments

We include 2 Jupyter notebooks with synthetic data for imbibition for steady-state flow derived from examples in Transport in Porous Media 140(1), 27-57, 2021. In the "_to-Excel" notebooks the "simulated" experimental data is written to Excel files, then loaded again and interpreted by inverse modelling. In the "_from-Excel" notebooks only the data from the Excel sheets is loaded and then interpreted by inverse modelling.

  • Imbibition
    SS_synthetic_data_imbibition_to-Excel.ipynb
    which generates expdataHISSSimbibition.xlsx
    SS_synthetic_data_imbibition_from-Excel.ipynb

The Excel files and "_from-Excel" notebooks can be used to interpret user experimental data sets. In principle only the Excel sheets have to be modified with the user experimental data sets. But it is important to maintain the format given in the Excel sheets.

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 - [email protected]

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
  • Vishal Ahuja supporting the project in general and also the initial 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
  • Daan de Kort for providing an updated relperm uncertainty quantification making use of the covariance matrix.

(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 Geotechnics 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.

(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