-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Docs for opm common and embedded #7
Open
lisajulia
wants to merge
4
commits into
OPM:main
Choose a base branch
from
lisajulia:docs-for-opm-common-and-embedded
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
f265b1e
Fix typo in opm_embedded/__init__.pyi
lisajulia dc62cde
Generate docstrings for common and simulators instead of only simulators
lisajulia 5ae5cdc
Use the generated .hpp file in the cpp files of opm-common
lisajulia 69c9c34
Use the documentation from opm-common and opm-embedded on the generat…
lisajulia File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,29 @@ | ||
# Set the path to the input docstrings.json file and the output .hpp file | ||
set(PYTHON_DOCSTRINGS_FILE "${PROJECT_SOURCE_DIR}/docs/docstrings.json") | ||
set(DOCSTRINGS_GENERATED_HPP "PyBlackOilSimulatorDoc.hpp") | ||
set(DOCSTRINGS_GENERATED_HEADER_PATH "${PROJECT_BINARY_DIR}/${TEMP_GEN_DIR}/${DOCSTRINGS_GENERATED_HPP}") | ||
set(PYBLACKOIL_DOCSTRINGS_FILE "${PROJECT_SOURCE_DIR}/docs/docstrings_simulators.json") | ||
set(PYBLACKOIL_DOCSTRINGS_GENERATED_HPP "PyBlackOilSimulatorDoc.hpp") | ||
set(PYBLACKOIL_DOCSTRINGS_GENERATED_HEADER_PATH "${PROJECT_BINARY_DIR}/${TEMP_GEN_DIR}/${PYBLACKOIL_DOCSTRINGS_GENERATED_HPP}") | ||
|
||
# Command to run the Python script to generate the .hpp file | ||
set(COMMON_DOCSTRINGS_FILE "${PROJECT_SOURCE_DIR}/docs/docstrings_common.json") | ||
set(COMMON_DOCSTRINGS_GENERATED_HPP "OpmCommonPythonDoc.hpp") | ||
set(COMMON_DOCSTRINGS_GENERATED_HEADER_PATH "${PROJECT_BINARY_DIR}/${TEMP_GEN_DIR}/${COMMON_DOCSTRINGS_GENERATED_HPP}") | ||
|
||
# Commands to run the Python script to generate the .hpp file | ||
|
||
add_custom_command( | ||
OUTPUT ${PYBLACKOIL_DOCSTRINGS_GENERATED_HEADER_PATH} | ||
COMMAND ${Python3_EXECUTABLE} ${PROJECT_SOURCE_DIR}/helper_scripts/generate_docstring_hpp.py ${PYBLACKOIL_DOCSTRINGS_FILE} "${PYBLACKOIL_DOCSTRINGS_GENERATED_HEADER_PATH}" | ||
PYBLACKOILSIMULATORDOC_HPP "Opm::Pybind::DocStrings" | ||
DEPENDS ${PYBLACKOIL_DOCSTRINGS_FILE} | ||
COMMENT "Generating ${PYBLACKOIL_DOCSTRINGS_GENERATED_HPP} from JSON file" | ||
) | ||
add_custom_command( | ||
OUTPUT ${DOCSTRINGS_GENERATED_HEADER_PATH} | ||
COMMAND ${Python3_EXECUTABLE} ${PROJECT_SOURCE_DIR}/helper_scripts/generate_docstring_hpp.py ${PYTHON_DOCSTRINGS_FILE} "${DOCSTRINGS_GENERATED_HEADER_PATH}" | ||
DEPENDS ${PYTHON_DOCSTRINGS_FILE} | ||
COMMENT "Generating ${DOCSTRINGS_GENERATED_HPP} from JSON file" | ||
OUTPUT ${COMMON_DOCSTRINGS_GENERATED_HEADER_PATH} | ||
COMMAND ${Python3_EXECUTABLE} ${PROJECT_SOURCE_DIR}/helper_scripts/generate_docstring_hpp.py ${COMMON_DOCSTRINGS_FILE} "${COMMON_DOCSTRINGS_GENERATED_HEADER_PATH}" | ||
OPMCOMMONPYTHONDOC_HPP "Opm::Common::DocStrings" | ||
DEPENDS ${COMMON_DOCSTRINGS_FILE} | ||
COMMENT "Generating ${COMMON_DOCSTRINGS_GENERATED_HPP} from JSON file" | ||
) | ||
|
||
# Create a custom target for the generated header file | ||
add_custom_target(generate_docstring_hpp DEPENDS ${DOCSTRINGS_GENERATED_HEADER_PATH}) | ||
# Create custom targets for the generated header files | ||
add_custom_target(pyblackoil_generate_docstring_hpp DEPENDS ${PYBLACKOIL_DOCSTRINGS_GENERATED_HEADER_PATH}) | ||
add_custom_target(common_generate_docstring_hpp DEPENDS ${COMMON_DOCSTRINGS_GENERATED_HEADER_PATH}) |
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,52 @@ | ||
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. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The plan is to remove the |
||
|
||
2. The keyword PYACTION must be added to the SCHEDULE section: | ||
|
||
.. code-block:: python | ||
|
||
<PYACTION\_NAME> <SINGLE/UNLIMITED> / | ||
<pythonscript> / | ||
|
||
3. You need to provide the Python script. | ||
lisajulia marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
|
||
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. | ||
lisajulia marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
- 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. | ||
lisajulia marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
- 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. | ||
lisajulia marked this conversation as resolved.
Show resolved
Hide resolved
|
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,4 @@ | ||
Introduction | ||
============ | ||
|
||
Documentation for the ``opm.simulators`` Python module. | ||
Documentation for the OPM Python interfaces. | ||
lisajulia marked this conversation as resolved.
Show resolved
Hide resolved
|
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,5 @@ | ||
OPM Simulators Python Documentation | ||
=================================== | ||
|
||
.. opm_simulators_docstrings:: | ||
|
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this file, only
PYBLACKOIL_DOCSTRINGS_GENERATED_HEADER_PATH
andCOMMON_DOCSTRINGS_GENERATED_HEADER_PATH
needs to be exported to the global scope, right? I like to export only necessary variables, I think it helps with maintenance in the long run. Could we make this a function like in e.g. OpmPythonSetupInstall.cmake ? I realize this was something I forgot to do in the original version of this file..