-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Directive for OPM Common and OPM Embedded
A rebuild of the documentation is also triggered when the file docstrings_common.json is updated in opm-common
- Loading branch information
Showing
12 changed files
with
165 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 25 additions & 20 deletions
45
python/docstrings.json → python/docstrings_simulators.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,78 +1,83 @@ | ||
{ | ||
"PyBlackOilSimulator":{ | ||
"type": "class", | ||
"signature": "opm.simulators.BlackOilSimulator", | ||
"doc": "The SummaryState class - this is where the current summary results of the simulator are stored.\nThe SummaryState class has methods to get hold of well, group and general variables." | ||
}, | ||
"PyBlackOilSimulator_filename_constructor": { | ||
"signature": "__init__(deck_filename: str) -> None", | ||
"signature": "opm.simulators.BlackOilSimulator.__init__(deck_filename: str) -> None", | ||
"doc": "Constructor using a deck file name.\n\n:param deck_filename: The file name of the deck to be used for the simulation.\n:type deck_filename: str" | ||
}, | ||
"PyBlackOilSimulator_objects_constructor": { | ||
"signature": "__init__(deck: Deck, state: EclipseState, schedule: Schedule, summary_config: SummaryConfig) -> None", | ||
"signature": "opm.simulators.BlackOilSimulator.__init__(deck: Deck, state: EclipseState, schedule: Schedule, summary_config: SummaryConfig) -> None", | ||
"doc": "Constructor using Deck, EclipseState, Schedule, and SummaryConfig objects.\n\n:param deck: Deck object.\n:type deck: Deck\n:param state: EclipseState object.\n:type state: EclipseState\n:param schedule: Schedule object.\n:type schedule: Schedule\n:param summary_config: SummaryConfig object.\n:type summary_config: SummaryConfig" | ||
}, | ||
"advance": { | ||
"signature": "advance(report_step: int) -> None", | ||
"signature": "opm.simulators.BlackOilSimulator.advance(report_step: int) -> None", | ||
"doc": "Advance the simulation to a specific report step.\n\n:param report_step: Target report step to advance to.\n:type report_step: int" | ||
}, | ||
"checkSimulationFinished": { | ||
"signature": "check_simulation_finished() -> bool", | ||
"signature": "opm.simulators.BlackOilSimulator.check_simulation_finished() -> bool", | ||
"doc": "Check if the simulation has finished.\n\n:return: True if the simulation is finished, False otherwise." | ||
}, | ||
"currentStep": { | ||
"signature": "current_step() -> int", | ||
"signature": "opm.simulators.BlackOilSimulator.current_step() -> int", | ||
"doc": "Get the current simulation step.\n\n:return: The current step number." | ||
}, | ||
"getCellVolumes": { | ||
"signature": "get_cell_volumes() -> NDArray[float]", | ||
"signature": "opm.simulators.BlackOilSimulator.get_cell_volumes() -> NDArray[float]", | ||
"doc": "Retrieve the cell volumes of the simulation grid.\n\n:return: An array of cell volumes.\n:type return: NDArray[float]" | ||
}, | ||
"getDT": { | ||
"signature": "get_dt() -> float", | ||
"signature": "opm.simulators.BlackOilSimulator.get_dt() -> float", | ||
"doc": "Get the timestep size of the last completed step.\n\n:return: Timestep size in days.\n:type return: float" | ||
}, | ||
"getFluidStateVariable": { | ||
"signature": "get_fluid_state_variable(name: str) -> NDArray[float]", | ||
"signature": "opm.simulators.BlackOilSimulator.get_fluid_state_variable(name: str) -> NDArray[float]", | ||
"doc": "Retrieve a fluid state variable for the simulation grid.\n\n:param name: The name of the variable. Valid names are 'pw' (pressure water), 'pg' (pressure gas), 'po' (pressure oil), 'rho_w' (density water), 'rho_g' (density gas), 'rho_o' (density oil)'Rs' (soultion gas-oil ratio), 'Rv' (volatile gas-oil ratio), 'Sw' (water saturation), 'Sg' (gas saturation), 'So' (oil saturation), and 'T' (temperature).\n:type name: str\n\n:return: An array of fluid state variables.\n:type return: NDArray[float]" | ||
}, | ||
"getPorosity": { | ||
"signature": "get_porosity() -> numpy.ndarray", | ||
"signature": "opm.simulators.BlackOilSimulator.get_porosity() -> NDArray[float]", | ||
"doc": "Retrieve the porosity values of the simulation grid.\n\n:return: An array of porosity values.\n:type return: numpy.ndarray" | ||
}, | ||
"getPrimaryVarMeaning": { | ||
"signature": "get_primary_var_meaning(variable: str) -> NDArray[int]", | ||
"signature": "opm.simulators.BlackOilSimulator.get_primary_var_meaning(variable: str) -> NDArray[int]", | ||
"doc": "Retrieve the primary variable meaning of the simulation grid.\n\n:param variable: The name of the variable. Valid names are 'pressure', 'water', 'gas', and 'brine'.\n:type variable: str\n\n:return: An array of primary variable meanings. See ``get_primary_variable_meaning_map()`` for more information.\n:type return: NDArray[int]" | ||
}, | ||
"getPrimaryVarMeaningMap": { | ||
"signature": "get_primary_var_meaning_map(variable: str) -> dict[str, int]", | ||
"signature": "opm.simulators.BlackOilSimulator.get_primary_var_meaning_map(variable: str) -> dict[str, int]", | ||
"doc": "Retrieve the primary variable meaning map for each primary variable.\n\n:param variable: The name of the variable. Valid names are 'pressure', 'water', 'gas', and 'brine'.\n:type variable: str\n\n:return: A dictionary of primary variable meanings. The keys are the primary variable meanings and the values are the corresponding integer codes. The integer codes are used to represent the primary variable meanings in the simulation grid. For variable name 'pressure', the valid keys are: 'Po', 'Pg', and 'Pw', for variable name 'water', the valid keys are: 'Sw', 'Rvw', 'Rsw', and 'Disabled', for variable name 'gas', the valid keys are: 'Sg', 'Rs', 'Rv', and 'Disabled', for variable name 'brine', the valid keys are: 'Cs', 'Sp', and 'Disabled'.\n:type return: dict[str, int]" | ||
}, | ||
"getPrimaryVariable": { | ||
"signature": "get_primary_variable(variable: str) -> NDArray[float]", | ||
"signature": "opm.simulators.BlackOilSimulator.get_primary_variable(variable: str) -> NDArray[float]", | ||
"doc": "Retrieve the primary variable's values for the simulation grid.\n\n:param variable: The name of the variable. Valid names are 'pressure', 'water', 'gas', and 'brine'.\n:type variable: str\n\n:return: An array of primary variable values. See ``get_primary_variable_meaning()`` for more information.\n:type return: NDArray[float]" | ||
}, | ||
"run": { | ||
"signature": "run() -> int", | ||
"signature": "opm.simulators.BlackOilSimulator.run() -> int", | ||
"doc": "Runs the simulation to completion with the provided deck file or previously set deck.\n\n:return: EXIT_SUCCESS if the simulation completes successfully." | ||
}, | ||
"setPorosity": { | ||
"signature": "set_porosity(array: NDArray[float]) -> None", | ||
"signature": "opm.simulators.BlackOilSimulator.set_porosity(array: NDArray[float]) -> None", | ||
"doc": "Set the porosity values for the simulation grid.\n\n:param array: An array of porosity values to be set.\n:type array: NDArray[float]" | ||
}, | ||
"setPrimaryVariable": { | ||
"signature": "set_primary_variable(variable: str, value: NDArray[float]) -> None", | ||
"signature": "opm.simulators.BlackOilSimulator.set_primary_variable(variable: str, value: NDArray[float]) -> None", | ||
"doc": "Set the primary variable's values for the simulation grid.\n\n:param variable: The name of the variable. Valid names are 'pressure', 'water', 'gas', and 'brine'.\n:type variable: str\n:param value: An array of primary variable values to be set. See ``get_primary_variable()`` for more information.\n:type value: NDArray[float]" | ||
}, | ||
"setupMpi": { | ||
"signature": "mpi_init(init: bool, finalize: bool) -> None", | ||
"signature": "opm.simulators.BlackOilSimulator.mpi_init(init: bool, finalize: bool) -> None", | ||
"doc": "Setup MPI for parallel simulation. This method should be called before any other method.\n:param init: Whether to call ``MPI_Init()`` or not.\n:param finalize:Whether to call ``MPI_Finalize()```when the simulator object goes out of scope.\n\n:return: None" | ||
}, | ||
"step": { | ||
"signature": "step() -> int", | ||
"signature": "opm.simulators.BlackOilSimulator.step() -> int", | ||
"doc": "Execute the next simulation report step.\n\n:return: Result of the simulation step." | ||
}, | ||
"stepCleanup": { | ||
"signature": "step_cleanup() -> int", | ||
"signature": "opm.simulators.BlackOilSimulator.step_cleanup() -> int", | ||
"doc": "Perform cleanup after the last simulation step.\n\n:return: EXIT_SUCCESS if cleanup is successful." | ||
}, | ||
"stepInit": { | ||
"signature": "step_init() -> int", | ||
"signature": "opm.simulators.BlackOilSimulator.step_init() -> int", | ||
"doc": "Initialize the simulation before taking the first report step. This method should be called before the first call to ``step()``\n\n:return: EXIT_SUCCESS if the initialization is successful." | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
OPM Common Python Documentation | ||
=============================== | ||
|
||
.. opm_common_docstrings:: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
OPM Embedded Python Documentation | ||
================================= | ||
|
||
The PYACTION keyword is a flow specific keyword which allows for executing embedded Python | ||
code in the SCHEDULE section. The embedded Python code will then be executed at the end of each successful timestep. | ||
|
||
The PYACTION keyword is inspired | ||
by the ACTIONX keyword, but instead of a .DATA formatted condition you | ||
are allowed to implement the condition with a general Python script. The | ||
ACTIONX keywords are very clearly separated in a condition part and an | ||
action part in the form of a list of keywords which are effectively injected in | ||
the SCHEDULE section when the condition evaluates to true. | ||
This is not so for PYACTION where there is one Python script in which both | ||
conditions can be evaluated and changes applied. | ||
|
||
In order to enable the PYACTION keyword: | ||
|
||
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. | ||
|
||
2. The keyword PYACTION must be added to the SCHEDULE section: | ||
|
||
.. code-block:: python | ||
<PYACTION\_NAME> <SINGLE/UNLIMITED> / | ||
<pythonscript> / -- path to the python script, relative to the location of the DATA-file | ||
3. You need to provide the Python script. | ||
|
||
|
||
To interact with the simulator in the embedded Python code, you can access four variables from the simulator: | ||
|
||
.. code-block:: python | ||
# Python module opm_embedded | ||
import opm_embedded | ||
# The current EclipseState | ||
ecl_state = opm_embedded.current_ecl_state | ||
# The current Schedule | ||
schedule = opm_embedded.current_schedule | ||
# The current SummaryState | ||
summary_state = opm_embedded.current_summary_state | ||
# The current report step | ||
report_step = opm_embedded.current_report_step | ||
- 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. | ||
|
||
- 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. | ||
|
||
- 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. | ||
|
||
- 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. | ||
|
||
See also: PYACTION in the `reference manual <https://opm-project.org/?page_id=955>`_ for more information. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
Introduction | ||
============ | ||
|
||
Documentation for the ``opm.simulators`` Python module. | ||
Documentation for the OPM Python interfaces. | ||
|
||
#TODO: expand on the introduction, add information about installation and requirements for example. Some example code would also be nice. | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
OPM Simulators Python Documentation | ||
=================================== | ||
|
||
.. opm_simulators_docstrings:: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters