opm-simulators/python
Arne Morten Kvarving 2353ba56a6 changed: don't store schedule keywords unless required in simulators
in the python simulator we cannot make this decision up front
since the schedule can be modified from python code so we have
to do the safe thing
2024-09-27 11:24:20 +02:00
..
opm add python packaging fluff 2024-08-30 14:28:25 +02:00
simulators changed: don't store schedule keywords unless required in simulators 2024-09-27 11:24:20 +02:00
test changed references 2024-08-29 11:19:29 +02:00
test_data Remove UNIFOUT keyword from python test data file SPE1CASE1b/SPE1CASE1.DATA file as well 2024-07-09 17:27:50 +02:00
build-deps.sh add python packaging fluff 2024-08-30 14:28:25 +02:00
CMakeLists.txt changed: vendor pybind11 using FetchContent 2023-11-16 10:02:04 +01:00
Dockerfile add python packaging fluff 2024-08-30 14:28:25 +02:00
docstrings_simulators.json Fix typos and test the automatic deployment to opm-python-documentation 2024-07-25 19:34:17 +02:00
generate-pypi-package.sh fix python package versioning 2024-09-09 12:45:00 +02:00
MANIFEST.in add python packaging fluff 2024-08-30 14:28:25 +02:00
pyproject.toml add python packaging fluff 2024-08-30 14:28:25 +02:00
README.md Removed reference to unit system 2023-09-25 11:01:12 +02:00
requirements.txt add python packaging fluff 2024-08-30 14:28:25 +02:00
setup-docker-image.sh add python packaging fluff 2024-08-30 14:28:25 +02:00
setup.py.in add python packaging fluff 2024-08-30 14:28:25 +02:00

Python bindings for the OPM-common module of the Open Porous Media project.

To compile with python support:

  • Add the cmake flags -DOPM_ENABLE_PYTHON=ON and -DOPM_INSTALL_PYTHON=ON
  • Optionally add prefix -DCMAKE_INSTALL_PREFIX=/opt/opm to install outside the standard distro directories
  • Optionally specify python binary -DPython3_EXECUTABLE=/home/user/miniconda3/envs/rkt/bin/python3 if you don't want to use the system python, e.g. use a python from pyenv or from a conda environment

Sample compilation on linux:

#! /bin/bash

flags="-DPython3_EXECUTABLE=/home/hakon/miniconda3/envs/rkt/bin/python3 -DOPM_ENABLE_PYTHON=ON -DOPM_INSTALL_PYTHON=ON -DCMAKE_INSTALL_PREFIX=/opt/opm"
for repo in opm-common opm-grid opm-models opm-simulators
do
    cd "$repo"
    mkdir -p build
    cd build
    cmake  $flags ..
    make -j8
    sudo make install
    cd ..
    cd ..
done

Then you should be able to use the module from a Python script. If you installed in a non-standard directory by specifying -DCMAKE_INSTALL_PREFIX you may need to set the PYTHONPATH environment variable before running your Python script, for example:

$ PYTHONPATH=/opt/opm/lib/python3.11/site-packages python3 spe1case1.py

and spe1case1.py could be:

import os
from opm.simulators import BlackOilSimulator
from opm.io.parser import Parser
from opm.io.ecl_state import EclipseState
from opm.io.schedule import Schedule
from opm.io.summary import SummaryConfig

os.chdir("SPE1CASE1")
deck  = Parser().parse('SPE1CASE1.DATA')
state = EclipseState(deck)
schedule = Schedule( deck, state )
summary_config = SummaryConfig(deck, state, schedule)

sim = BlackOilSimulator(deck, state, schedule, summary_config)
sim.step_init()
sim.step()
poro = sim.get_porosity()
poro = poro *.95
sim.set_porosity(poro)
sim.step()
sim.step_cleanup()