File: README.md

package info (click to toggle)
opm-simulators 2025.10%2Bds-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 21,460 kB
  • sloc: cpp: 193,029; sh: 1,807; python: 1,704; lisp: 1,108; makefile: 31; awk: 10
file content (62 lines) | stat: -rw-r--r-- 1,873 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# 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:

```bash
#! /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:

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

and `spe1case1.py` could be:

```python
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()
```