PYACTION polish II

This commit is contained in:
Joakim Hove
2022-01-31 12:33:25 +01:00
parent b8cecd9ce4
commit 8c95c64e9b

View File

@@ -216,7 +216,7 @@ Python \inlinecode{run()} function. In the example below we create an \actionx{}
\begin{deck}
ACTIONX
CLOSEWELLS 0 /
DAY = 1 /
/
/
WELOPEN
@@ -226,11 +226,11 @@ WELOPEN
ENDACTIO
\end{deck}
The \inlinecode{CLOSEWELLS} action is set up to run zero times, so the normal
\actionx{} machinery will never run this action\footnote{The condition
\inlinecode{DAY=1} is completely dummy, in the future the \actionx{}
implementation should be improved to handle empty conditions.}. Then in the
Python run function we go through all the wells and call the
\inlinecode{CLOSEWELL} action to close those with \inlinecode{OPR < 1000}:
\actionx{} machinery will never run this action\footnote{The \kw{CLOSEWELL}
action has an \emph{empty condition}, the \actionx{} keywords with empty
condition will always evaluate as false.}. Then in the Python run function we go
through all the wells and call the \inlinecode{CLOSEWELL} action to close those
with \inlinecode{OPR < 1000}:
\begin{code}
def run(ecl_state, schedule, report_step, summary_state, actionx_callback):
close_wells = []
@@ -275,8 +275,50 @@ UDQ
\subsection{Using \pyaction{} instead of \udq{} + \actionx{}}
Towards the end of section \ref{actionx_structure} it is demonstrated how \udq{}
and \actionx{} can be combined to implement an action in case a complicated
condition applies. The same goal can be achivede using \pyaction{}.
condition applies. As described in section \ref{pyaction_actionx} the best way
to actually invoke changes on the \kw{SCHEDULE} section is through the use of a
dummy \actionx{} keyword, but \pyaction{} is very well suited to evaluate
complex conditions. In the example below we close all wells which have
consistently produced less than 1000 $\mathrm{m^3/day}$ for more than 60 days:
\begin{code}
wopr_limit = 1000
time_limit = 60 * 3600 * 24
def init_state(summary_state):
if 'closed_wells' in state:
return
state['closed_wells'] = set()
bad_wells = {}
for well in summary_state.wells:
bad_wells[well] = None
state['bad_wells'] = bad_wells
def run(ecl_state, schedule, report_step, summary_state, actionx_callback):
shut_wells = []
init_state(summary_state)
for well in summary_state.wells:
if well in state['closed_wells']:
continue
if summary_state.well_var(well, 'WOPR') < wopr_limit:
elapsed = summary_state.elapsed()
if state['bad_wells'][well] is None:
state['bad_wells'][well] = elapsed
else:
bad_time = elapsed - state['bad_wells'][well]
if bad_time > time_limit:
shut_wells.append(well)
state['closed_wells'].add( well )
else:
state['bad_wells'][well] = None
if shut_wells:
actionx_callback(shut_wells)
\end{code}
\subsection{Using \pyaction{} to report to the summary file}
The important point when using \pyaction{} to report complex results to the