Customizing the simulation workflow in enkf
The default simulation workflow, or forward model, when using the enkf application, is to run the ECLIPSE 100 reservoir simulator between the requested report steps. However, it may be convenient to change the forward model, for example if:
- Elastic properties are calculated using a special rock physics program. The rock physics program can then be executed before or after ECLIPSE100 for each simulation.
- Relative permeability curves are generated with a separate script, and sensitivity analysis and/or history matching on the relative permeability parameters is sought. The relative permeability script can then be executed before ECLIPSE100 to generate relative permeability curves for the particular simulation.
- The ECLIPSE model uses a special option, such as multi-segment wells. A custom ECLIPSE job can then be installed, to ensure that a multi-segment license is available before the simulation starts.
When using the ERT application, it the forward model can be changed quite easily, and allows for a great deal of flexibility. In principle, it is possible to add any program to the forward model, the only requirement is that it must be callable in batch, i.e. without user interaction. The forward model is defined with the FORWARD_MODEL keyword in the ERT configuration file. The FORWARD_MODEL keyword expects a sequence of strings, referring to jobs that are executed sequentially. These jobs are defined with the INSTALL_JOB keyword in the main configuration file. As explained in Creating a configuration file for ERT, the INSTALL_JOB keyword takes two arguments, a name for the job and the name of a configuration file for the job. A list of already installed jobs can be found in available jobs in ERT.
The INSTALL_JOB configuration file
The configuration file presented to INSTALL_JOB is quite similar to the main configuration file. It is a plain text file, with one statement per line. The first word on each line is a keyword, which then is followed by some data for that particular keyword. Please note the following:
- Lines starting with "--" are treated as comments.
- All keywords in the INSTALL_JOB configuration are optional, i.e. you only need to set those that apply.
- All paths can be given relative to the particular simulation directory. E.g., full paths are not required for input/output files.
- A set of magic strings are available to set the context for the external program.
If your program expects to read from standard input you must redirect stdin. That is done with the STDIN keyword:
-- Re-direct standard input. STDIN my_program.stdin
Observe that when you are redirecting standard input the file you are redirecting from must exist when the job starts, i.e. if your program does not expect to read from standard input you should not redirect it with the STDIN keyword.
The keyword STDOUT is used to re-direct the standard output to a file. Observe that if you do not set STDOUT, it takes the default value /dev/null and everything written to stdout by the program is lost.
-- Re-direct stdout. STDOUT my_program.stdout
The keyword STDERR is used to re-direct the standard error stream to a file.
-- Re-direct the standard error stream. STDERR my_program.stderr
This is the name of a file which the external program should produce. When the external program is complete the job_script checks if this file has indeed been produced, and exits with failure if the file can not be found.
-- Set the target file TARGET_FILE my_program_output_<IENS>.txt
This is the name of the program to run, it can either be a full path, or just the name of a binary. In the latter case the PATH variable of the user is consulted to locate the executable. Observe that it is assumed that the same executable can be invoked on all platforms, in the case of binary applications in a heterogenous cluster EXECUTABLE must point to a portable script, which will subsequently execute the correct binary.
-- Set the name of the program EXECUTABLE my_program.exe
The ENV keyword can be used to set environmental variables. It takes two arguments, the environment variable and the value to set.
-- Setting up the environment for the job. ENV LM_LICENSE_FILE firstname.lastname@example.org ENV LD_LIBRARY_PATH /some/funny/lib/path:$LD_LIBRARY_PATH
The ARGLIST keyword is used to give a list of arguments to the executable.
-- Set some flags ARGLIST -ia -some_option <RESTART_FILE2>
Since the data for the keywords in the INSTALL_JOB configuration file (e.g. the input for the program to be executed) often will be a function of the ECLIPSE base name, the realization number, the report steps etc., a set of magic strings are provided. These a replaced when the job is submitted, e.g. <IENS> will be replaced with 0 for realization number 0, 1 for realization number 1 and so on.
|Magic string||Replaced with|
|<RESTART_FILE1>||The name of the restart file this simulation is starting from.|
|<RESTART_FILE2>||The name of the restart file this simulation should end up with.|
|<SMSPEC_FILE>||The name of the SMSPEC file for this simulation.|
|<REPORT_STEP1>||The report step we are starting from - without leading zeroes.|
|<REPORT_STEP2>||The report step we are simulating to - without leading zeroes.|
|<ECLBASE>||The ECLIPSE base name of this simulation.|
|<IENS>||The realization number of this simulation - without leading zeroes.|
|<IENS4>||The realization number of this simulation formatted as a four digit number - with leading zeroes.|
The set of magic strings can easily be extended upon request.
The following INSTALL_JOB configuration file is used for ECLIPSE100.
STDIN eclipse.stdin STDERR eclipse.stderr STDOUT eclipse.stdout TARGET_FILE <RESTART_FILE2> EXECUTABLE /ERT/Scripts/run_eclipse.py ENV F_UFMTENDIAN big ENV LM_LICENSE_FILE *********
Passing arguments to the job
In addition to the magic strings mentioned above you can insert your own magic string enclosed in '<' and '>' in the job description file. These strings can then either be provided with DATA_KW command, or by using KEY = VALUE in the spesification of the forward model. The following INSTALL_JOB configuration file used to copy a file, illustrates this:
PORTABLE_EXE /bin/cp ARGLIST <FILE> <STORAGE_PATH>
In the following configuration file the STORAGE_PATH variable is set with the DATA_KW argument, and the FILE argument is set when the job is specified in the FORWARD_MODEL>:
... DATA_KW <STORAGE_PATH> /some/path/where/I/store/results FORWARD_MODEL ECLIPSE100 COPY_FILE(<FILE> = file1.txt) COPY_FILE(<FILE> = <ECL_BASE>.SMSPEC) ...