Skip to content

Document UDQ support in PYACTION - #40

Draft
panasun1994 wants to merge 2 commits into
OPM:masterfrom
panasun1994:pyaction-udq-doc
Draft

panasun1994 wants to merge 2 commits into
OPM:masterfrom
panasun1994:pyaction-udq-doc

Conversation

@panasun1994

@panasun1994 panasun1994 commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

After adding the valid keyword in PR#5500 and creating the test in PR#7581, here is the first documentation of UDQ support. Note that this documentation assumes that PR#7581, PR#5500, and PR#1673 have been merged into master. The links to PYACTION_UDQ_INSERT_KW.DATA, pyaction_udq_insert_kw.py and ACTIONX_UDQ_INSERT_KW.DATA need one more opm-tests PR, which I will open and link here.

Another note: In the code block for Inserting UDQ keywords. the body of if is not related to the condition; this because the keyword ASSIGN WU_X '?' is still not supported yet. So, I use a named well, ASSIGN WU_FLAG 'OP01' 5, instead.

@panasun1994

Copy link
Copy Markdown
Contributor Author

@SoilRos, this is the documentation for UDQ support. Please review it.

----------------------------------------------

The ``UDQ`` keyword can be inserted from a PYACTION script. These features are supported
in both serial and parallel runs:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any difference between serial and parallel runs for pyaction? If not, I would exclude this sentence. If yes, we need to explain the difference.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the view of the user, I think it is the same... at least both serial and parallel provide the same result. The difference is (also what I concern) is that the parallel run writes the insert UDQ variable once per rank (say you have 4 similar variables for 4 rank) but only rank 0 writes the summary. My experience is still not enough to find a case where you can have different values of the same variable across ranks. But as far as I know, it does not make sense; i.e., the case does not exist.

Anyway, I will remove the sentence These features are supported in both serial and parallel runs because it just tells the user that we tested it, nothing more.

schedule = opm_embedded.current_schedule

# Run the insertion only once
if 'setup_done' not in globals():

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens when the user has more than one pyaction? Is this variable shared among all python scripts or is there one for each one? If there is only one globally, we need to be careful to advertise this generic variable name as it would only be initialized by the first script.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is a very interesting point. I already tested it. The test result says that every pyaction has its own global step_done. Let's say you have action_a.py and action_b.py. If action_a.py fires first, then we have done = true. After that, check step_done in action_b.py; it is still false.

Should I have to add anything about this to the document?

@panasun1994 panasun1994 Oct 27, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SoilRos. I investigated whether this is the intention or a bug. The commit of Joakim in 2020. He said, "The purpose of this dictionary is to allow PYACTION scripts to store state between invocations". Claude found it.... In addition, the code in PyRunModule.cpp also shows that each Python script has its own namespace. Each script is imported by py::module::import(file name) and globals() in Python is a dictionary of the module that the code is in.

As I said before, this structure makes sense because the execution of script a.py should not immediately be the reason to stop the execution of b.py.

So, I will find the place to write this note. Still not sure where, because I think it is a topic outside UDQ.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should be another pull request because it is a topic outside UDQ. What do you think @SoilRos


.. warning::

The well name ``'?'`` (for example ``ASSIGN WU_Q '?' 7 /``) is **not supported yet**.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a warning for the schedule or for the summary? Its position seems to make it as a warning for inserting quantities to the summary, but the contents show the scheduler.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is C++ error and Python pass it back as a runtime error.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants