Skip to content

Commit 4a22cf9

Browse files
author
Lisa Julia Nebel
committed
Fix indentation
1 parent 87a7f52 commit 4a22cf9

File tree

2 files changed

+71
-70
lines changed

2 files changed

+71
-70
lines changed

python/sphinx_docs/docs/embedded-python.rst

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -17,39 +17,40 @@ See also: PYACTION in the `reference manual <https://opm-project.org/?page_id=95
1717

1818
In order to enable the PYACTION keyword:
1919

20-
1. OPM Flow must be compiled with the cmake switches -DOPM ENABLE EMBEDDED PYTHON=ON and -DOPM ENABLE PYTHON=ON, the default is to build with these switches set to OFF.
21-
You can also change these settings in the CMakeLists.txt of opm-common.
20+
1. Compile Flow with Embedded Python support:
2221

23-
2. The keyword PYACTION must be added to the SCHEDULE section:
22+
- Add the cmake flags ``-DOPM_ENABLE_PYTHON=ON`` and ``-DOPM_ENABLE_EMBEDDED_PYTHON=ON`` (you can also change these settings in the ``CMakeLists.txt`` of ``opm-common`` and ``opm-simulators``).
2423

25-
.. code-block:: python
24+
..
2625
27-
<PYACTION\_NAME> <SINGLE/UNLIMITED> /
28-
<pythonscript> / -- path to the python script, relative to the location of the DATA-file
26+
2. The keyword PYACTION must be added to the SCHEDULE section:
2927

30-
3. You need to provide the Python script.
28+
.. code-block:: python
3129
30+
<PYACTION_NAME> <SINGLE/UNLIMITED> /
31+
<pythonscript> / -- path to the python script, relative to the location of the DATA-file
3232
33-
To interact with the simulator in the embedded Python code, you can access four variables from the simulator:
33+
3. You need to provide the Python script.
3434

35-
.. code-block:: python
35+
To interact with the simulator in the embedded Python code, you can access four variables from the simulator:
3636

37-
# Python module opm_embedded
38-
import opm_embedded
39-
# The current EclipseState
40-
ecl_state = opm_embedded.current_ecl_state
41-
# The current Schedule
42-
schedule = opm_embedded.current_schedule
43-
# The current SummaryState
44-
summary_state = opm_embedded.current_summary_state
45-
# The current report step
46-
report_step = opm_embedded.current_report_step
37+
.. code-block:: python
4738
39+
# Python module opm_embedded
40+
import opm_embedded
41+
# The current EclipseState
42+
ecl_state = opm_embedded.current_ecl_state
43+
# The current Schedule
44+
schedule = opm_embedded.current_schedule
45+
# The current SummaryState
46+
summary_state = opm_embedded.current_summary_state
47+
# The current report step
48+
report_step = opm_embedded.current_report_step
4849
49-
- current_ecl_state: An instance of the `EclipseState <common.html#opm.io.ecl_state.EclipseState>`_ class - this is a representation of all static properties in the model, ranging from porosity to relperm tables. The content of the ecl state is immutable - you are not allowed to change the static properties at runtime.
50+
- ``current_ecl_state``: An instance of the `EclipseState <common.html#opm.io.ecl_state.EclipseState>`_ class this is a representation of all static properties in the model, ranging from porosity to relperm tables. The content of the ecl state is immutable you are not allowed to change the static properties at runtime.
5051

51-
- current_schedule: An instance of the `Schedule <common.html#opm.io.schedule.Schedule>`_ class - this is a representation of all the content from the SCHEDULE section, notably all well and group information and the timestepping.
52+
- ``current_schedule``: An instance of the `Schedule <common.html#opm.io.schedule.Schedule>`_ class this is a representation of all the content from the SCHEDULE section, notably all well and group information and the timestepping.
5253

53-
- current_report_step: This is an integer for the report step we are currently working on. Observe that the PYACTION is called for every simulator timestep, i.e. it will typically be called multiple times with the same value for the report step argument.
54+
- ``current_report_step``: This is an integer for the report step we are currently working on. Observe that the PYACTION is called for every simulator timestep, i.e. it will typically be called multiple times with the same value for the report step argument.
5455

55-
- current_summary_state: An instance of the `SummaryState <common.html#opm.io.sim.SummaryState>`_ class, this is where the current summary results of the simulator are stored. The SummaryState class has methods to get hold of well, group and general variables.
56+
- ``current_summary_state``: An instance of the `SummaryState <common.html#opm.io.sim.SummaryState>`_ classthis is where the current summary results of the simulator are stored. The `SummaryState <common.html#opm.io.sim.SummaryState>`_ class has methods to get hold of well, group, and general variables.

python/sphinx_docs/docs/flow-in-python.rst

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -3,61 +3,61 @@ Run OPM Flow from Python
33

44
To run OPM from Python, you need to:
55

6-
1. Compile Flow with python support:
7-
8-
- Add the cmake flags -DOPM_ENABLE_PYTHON=ON and -DOPM_INSTALL_PYTHON=ON.
9-
- Optionally add prefix -DCMAKE_INSTALL_PREFIX=/opt/opm to install outside the standard directories.
10-
- 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.
11-
12-
Sample compilation on linux:
13-
14-
.. code-block:: bash
15-
16-
#! /bin/bash
17-
18-
flags="-DPython3_EXECUTABLE=/home/hakon/miniconda3/envs/rkt/bin/python3 -DOPM_ENABLE_PYTHON=ON -DOPM_INSTALL_PYTHON=ON -DCMAKE_INSTALL_PREFIX=/opt/opm"
19-
for repo in opm-common opm-grid opm-models opm-simulators
20-
do
21-
cd "$repo"
22-
mkdir -p build
23-
cd build
24-
cmake $flags ..
25-
make -j8
26-
sudo make install
27-
cd ..
28-
cd ..
29-
done
6+
1. Compile Flow with Python support:
7+
8+
- Add the cmake flags ``-DOPM_ENABLE_PYTHON=ON`` and ``-DOPM_INSTALL_PYTHON=ON`` (you can also change these settings in the ``CMakeLists.txt`` of ``opm-common`` and ``opm-simulators``).
9+
- Optionally add prefix ``-DCMAKE_INSTALL_PREFIX=/opt/opm`` to install outside the standard directories.
10+
- 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.
11+
12+
Sample compilation on Linux:
13+
14+
.. code-block:: bash
15+
16+
#! /bin/bash
17+
flags="-DPython3_EXECUTABLE=/home/hakon/miniconda3/envs/rkt/bin/python3 -DOPM_ENABLE_PYTHON=ON -DOPM_INSTALL_PYTHON=ON -DCMAKE_INSTALL_PREFIX=/opt/opm"
18+
for repo in opm-common opm-grid opm-models opm-simulators
19+
do
20+
cd "$repo"
21+
mkdir -p build
22+
cd build
23+
cmake $flags ..
24+
make -j8
25+
sudo make install
26+
cd ..
27+
cd ..
28+
done
3029
3130
2. Now you should be able to use the module from a Python script.
3231

33-
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:
32+
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:
3433

35-
.. code-block:: bash
34+
.. code-block:: bash
3635
37-
PYTHONPATH=/opt/opm/lib/python3.11/site-packages python3 spe1case1.py
36+
PYTHONPATH=/opt/opm/lib/python3.11/site-packages python3 spe1case1.py
3837
39-
Here, the example script spe1case1.py could be:
38+
Here, the example script ``spe1case1.py`` could be:
4039

41-
.. code-block:: python
40+
.. code-block:: python
4241
43-
from opm.simulators import BlackOilSimulator
44-
from opm.io.parser import Parser
45-
from opm.io.ecl_state import EclipseState
46-
from opm.io.schedule import Schedule
47-
from opm.io.summary import SummaryConfig
42+
from opm.simulators import BlackOilSimulator
43+
from opm.io.parser import Parser
44+
from opm.io.ecl_state import EclipseState
45+
from opm.io.schedule import Schedule
46+
from opm.io.summary import SummaryConfig
4847
49-
deck = Parser().parse('SPE1CASE1.DATA')
50-
state = EclipseState(deck)
51-
schedule = Schedule( deck, state )
52-
summary_config = SummaryConfig(deck, state, schedule)
48+
deck = Parser().parse('SPE1CASE1.DATA')
49+
state = EclipseState(deck)
50+
schedule = Schedule(deck, state)
51+
summary_config = SummaryConfig(deck, state, schedule)
5352
54-
sim = BlackOilSimulator(deck, state, schedule, summary_config)
55-
sim.step_init()
56-
sim.step()
57-
poro = sim.get_porosity()
58-
poro = poro *.95
59-
sim.set_porosity(poro)
60-
sim.step()
61-
sim.step_cleanup()
53+
sim = BlackOilSimulator(deck, state, schedule, summary_config)
54+
sim.step_init()
55+
sim.step()
56+
poro = sim.get_porosity()
57+
poro = poro * 0.95
58+
sim.set_porosity(poro)
59+
sim.step()
60+
sim.step_cleanup()
6261
63-
where you could use the SPE1CASE1.DATA file from `the opm-test repository <https://github.com/OPM/opm-tests/tree/master/spe1>`_.
62+
You could use the ``SPE1CASE1.DATA`` file from the ``opm-tests`` repository:
63+
https://github.com/OPM/opm-tests/tree/master/spe1

0 commit comments

Comments
 (0)