diff --git a/python/sphinx_docs/docs/embedded-python.rst b/python/sphinx_docs/docs/embedded-python.rst index 6533a9e..33cf697 100644 --- a/python/sphinx_docs/docs/embedded-python.rst +++ b/python/sphinx_docs/docs/embedded-python.rst @@ -169,3 +169,79 @@ Use this code snippet with the example `MSW-3D-TWO-PRODUCERS = summary_state["FU_GOR2"] for w in wells): + opm_embedded.OpmLog.info("PYACTION PYACTION_UDQ triggered") + schedule.insert_keywords(""" + UDQ + DEFINE WU_NEW WOPR * 2 / + ASSIGN WU_FLAG 'OP01' 5 / + / + """) + done = True + +Here ``WU_NEW`` and ``WU_FLAG`` are already declared in the UDQ section of the DATA file. + +Computing UDQ values in Python +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Instead of inserting the ``UDQ`` keyword, a PYACTION script can also compute the values +in Python and write them into the summary state. Then the DATA file needs no ``UDQ`` +keyword; the variables are only listed in the SUMMARY section, so they are written to +the summary output: + +.. code-block:: python + + summary_state = opm_embedded.current_summary_state + + if "FU_TIME" not in summary_state: + summary_state["FU_TIME"] = 0.0 + summary_state["FU_TIME"] += summary_state["TIMESTEP"] + summary_state["FU_VAR19"] = summary_state.well_var("INJ1", "WWIR") + +Complete examples in opm-tests, each with an ACTIONX version that gives the same results +(serial and with 4 MPI processes): + +- Inserting UDQ keywords: + `PYACTION_UDQ_INSERT_KW.DATA `_ + with the script + `pyaction_udq_insert_kw.py `_; + ACTIONX version + `ACTIONX_UDQ_INSERT_KW.DATA `_. +- Computing UDQ values in Python: + `UDQ_M3_PYACTION.DATA `_ + with the script + `udq_m3_pyaction.py `_; + ACTIONX version + `UDQ_M3.DATA `_.