You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: python/sphinx_docs/docs/embedded-python.rst
+24-23Lines changed: 24 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,39 +17,40 @@ See also: PYACTION in the `reference manual <https://opm-project.org/?page_id=95
17
17
18
18
In order to enable the PYACTION keyword:
19
19
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:
22
21
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``).
24
23
25
-
..code-block:: python
24
+
..
26
25
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:
29
27
30
-
3. You need to provide the Python script.
28
+
.. code-block:: python
31
29
30
+
<PYACTION_NAME><SINGLE/UNLIMITED>/
31
+
<pythonscript>/-- path to the python script, relative to the location of the DATA-file
32
32
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.
34
34
35
-
.. code-block:: python
35
+
To interact with the simulator in the embedded Python code, you can access four variables from the simulator:
- 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.
50
51
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.
52
53
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.
54
55
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>`_ class — this 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.
Copy file name to clipboardExpand all lines: python/sphinx_docs/docs/flow-in-python.rst
+47-47Lines changed: 47 additions & 47 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,61 +3,61 @@ Run OPM Flow from Python
3
3
4
4
To run OPM from Python, you need to:
5
5
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.
- 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.
2. Now you should be able to use the module from a Python script.
32
31
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:
0 commit comments