Skip to content

Commit

Permalink
add case with actnum
Browse files Browse the repository at this point in the history
  • Loading branch information
oddvarlia committed Nov 8, 2023
1 parent 6c14e86 commit ea05837
Show file tree
Hide file tree
Showing 5 changed files with 217 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# ROFF format standard Eclipse origo
settings:
grid_size:
xsize: 7500.0
ysize: 12500.0
zsize: 50.0
use_eclipse_grid_index_origo: True
polygon_file: "Polygons.txt"

field:
name: "FIELDPAR"
algorithm: "gstools"
file_format: "ROFF"
initial_file_name: "init_files/FieldParam"
updated_file_name: "FieldParam"
seed_file: "randomseeds.txt"
variogram: "gaussian"
correlation_range: [3000.0, 2000.0, 2.0]
correlation_azimuth: 45.0
correlation_dip: 0.0
correlation_exponent: 1.9
trend_use: False
trend_params: [ 1.0, -1.0 ]
trend_relstd: 0.15
grid_dimension: [150, 250, 1]
grid_file_name: "GRID_WITH_ACTNUM.EGRID"

response:
name: "UPSCALED"
grid_dimension: [15, 25, 1]
upscaled_file_name: "Upscaled"
grid_file_name: "UpscaleGrid.EGRID"
file_format: "ROFF"
write_upscaled_field: True
response_function: "average"
gen_data_file_name: "UpscaledField_0.txt"

observation:
directory: "observations"
file_name: "observations.obs"
data_dir: "obs_data"
reference_param_file: "init_files/ObsField"
reference_field_name: "ObsField"
rel_error: 0.10
min_abs_error: 0.01
# selected_grid_cells:
# - [5, 10, 1]
# - [10, 5, 1]

localisation:
method: "gaussian"

optional:
write_obs_pred_diff_field_file: True
43 changes: 42 additions & 1 deletion tests/jobs/localisation/example_case/scripts/common_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class GridSize:
# xsize: float = 7500.0
# ysize: float = 7500.0
zsize: float = 50.0
polygon_file: str = None
use_eclipse_grid_index_origo: bool = True


Expand Down Expand Up @@ -145,7 +146,7 @@ class Settings:
def read_config_file(config_file_name=None):
# Modify default settings if config_file exists
if config_file_name:
if os.path.isfile(config_file_name):
if os.path.exists(config_file_name):
with open(config_file_name, "r", encoding="utf-8") as yml_file:
settings_yml = yaml.safe_load(yml_file)

Expand Down Expand Up @@ -178,6 +179,46 @@ def update_settings(config_dict: dict):
if key not in valid_keys:
raise KeyError(f"Unknown keyword {key} in 'settings' ")

key = "grid_size"
grid_size_dict = settings_dict[key] if key in settings_dict else None
valid_keys = [
"xsize",
"ysize",
"zsize",
"polygon_file",
"use_eclipse_grid_index_origo",
]
if grid_size_dict:
err_msg = []
for sub_key in grid_size_dict:
if sub_key not in valid_keys:
err_msg.append(f" {sub_key}")
if len(err_msg) > 0:
print(f"Unknown keywords in config file under keyword {key}: ")
for text in err_msg:
print(text)
raise KeyError("Unknown keywords")

grid_size_object = settings.grid_size
grid_size_object.xsize = update_key(
"xsize", grid_size_object.xsize, grid_size_dict, key
)
grid_size_object.ysize = update_key(
"ysize", grid_size_object.ysize, grid_size_dict, key
)
grid_size_object.zsize = update_key(
"zsize", grid_size_object.zsize, grid_size_dict, key
)
grid_size_object.polygon_file = update_key(
"polygon_file", grid_size_object.polygon_file, grid_size_dict, key
)
grid_size_object.use_eclipse_grid_index_origo = update_key(
"use_eclipse_grid_index_origo",
grid_size_object.use_eclipse_grid_index_origo,
grid_size_dict,
key,
)

key = "field"
field_dict = settings_dict[key] if key in settings_dict else None
valid_keys = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,12 @@ def create_grid():
flip=flip,
)

polygon_file_name = settings.grid_size.polygon_file
if polygon_file_name is not None and os.path.exists(polygon_file_name):
print(f"Use polygon file {polygon_file_name} to create actnum ")
polygon = xtgeo.polygons_from_file(polygon_file_name, fformat="xyz")
grid_object.inactivate_outside(polygon)

print(f"Write grid file: {grid_file_name} ")
grid_object.to_file(grid_file_name, fformat="egrid")
return grid_object
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
DEFINE <USER> $USER
DEFINE <SCRATCH> /scratch/fmu
DEFINE <CASE_DIR> sim_field_A_with_actnum
DEFINE <ENSEMBLE_SEED_FILE> randomseeds.txt
DEFINE <TEST_CONFIG> <CONFIG_PATH>/example_test_config_A_with_actnum.yml
INSTALL_JOB SIM_FIELD scripts/FM_SIM_FIELD
-----------------------------------------------------
-- Observations
-----------------------------------------------------

DEFINE <OBS_FILE> <CONFIG_PATH>/observations/observations.obs
OBS_CONFIG <OBS_FILE>
TIME_MAP time_map.txt

JOBNAME sim_fields_<IENS>


NUM_REALIZATIONS 10 -- Set number of realizations to run
MAX_RUNTIME 18000 -- Set the maximum allowed run time (in seconds)
MIN_REALIZATIONS 1 -- Success criteria
MAX_SUBMIT 1 -- How many times should the queue system retry a simulation.
QUEUE_OPTION LSF MAX_RUNNING 100 -- Choke the number of simultaneous run
QUEUE_OPTION LSF LSF_QUEUE mr -- Assign LSF cluster queue to use

RUNPATH <SCRATCH>/<USER>/<CASE_DIR>/realization-<IENS>/iter-<ITER>
RANDOM_SEED 123456 -- ERT seed value

ENSPATH output/<CASE_DIR>/storage -- Storage of internal ert data
UPDATE_LOG_PATH output/<CASE_DIR>/update_log -- Info of active and inactive data points
RUNPATH_FILE output/<CASE_DIR>/runpath_file -- List of runpaths

-- LOAD_WORKFLOW localisation.wf LOCALISATION_WORKFLOW
-- HOOK_WORKFLOW LOCALISATION_WORKFLOW PRE_FIRST_UPDATE

--Result data from forward model--
GEN_DATA RESULT_UPSCALED_FIELD RESULT_FILE:UpscaledField_%d.txt REPORT_STEPS:0 INPUT_FORMAT:ASCII OUTPUT_FORMAT:ASCII

-----------------------------------------------------
-- Forward models
-----------------------------------------------------
--Simulate Gaussian field with trend and calculate upscaled values. Observables are upscaled values of selected grid cells.
FORWARD_MODEL MAKE_DIRECTORY(<DIRECTORY>=init_files)
-- Is used to identify iteration number (only relevant for old komodo versions)
FORWARD_MODEL MAKE_DIRECTORY(<DIRECTORY>=<ITER>)
-- The common seed file
FORWARD_MODEL COPY_FILE(<FROM>=<CONFIG_PATH>/<ENSEMBLE_SEED_FILE>, <TO>=<RUNPATH>/<ENSEMBLE_SEED_FILE>)
-- For QC purpose only
FORWARD_MODEL COPY_FILE(<FROM>=<CONFIG_PATH>/init_files/ObsField.roff, <TO>=<RUNPATH>/init_files/ObsField.roff)
FORWARD_MODEL MAKE_SYMLINK(<TARGET>=<CONFIG_PATH>/GRID_WITH_ACTNUM.EGRID, <LINKNAME>=<RUNPATH>/GRID_WITH_ACTNUM.EGRID)
FORWARD_MODEL MAKE_SYMLINK(<TARGET>=<CONFIG_PATH>/UpscaleGrid.EGRID, <LINKNAME>=<RUNPATH>/UpscaleGrid.EGRID)

-- The main forward model simulating gaussian field with trend, and upscale
FORWARD_MODEL SIM_FIELD(<ITERATION>=<ITER>, <REALNUMBER>=<IENS>, <TEST_CONFIG>=<TEST_CONFIG>)


GRID <CONFIG_PATH>/GRID_WITH_ACTNUM.EGRID -- Necessary for AHM using field parameters

FIELD FIELDPAR PARAMETER FieldParam.roff INIT_FILES:init_files/FieldParam.roff MIN:-5.0 MAX:5.0 FORWARD_INIT:True
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
DEFINE <USER> $USER
DEFINE <SCRATCH> /scratch/fmu
DEFINE <CASE_DIR> sim_field_local_A_with_actnum
DEFINE <ENSEMBLE_SEED_FILE> randomseeds.txt
DEFINE <TEST_CONFIG> <CONFIG_PATH>/example_test_config_A_with_actnum.yml
INSTALL_JOB SIM_FIELD scripts/FM_SIM_FIELD
-----------------------------------------------------
-- Observations
-----------------------------------------------------

DEFINE <OBS_FILE> <CONFIG_PATH>/observations/observations.obs
OBS_CONFIG <OBS_FILE>
TIME_MAP time_map.txt

JOBNAME sim_fields_<IENS>


NUM_REALIZATIONS 10 -- Set number of realizations to run
MAX_RUNTIME 18000 -- Set the maximum allowed run time (in seconds)
MIN_REALIZATIONS 1 -- Success criteria
MAX_SUBMIT 1 -- How many times should the queue system retry a simulation.
QUEUE_OPTION LSF MAX_RUNNING 100 -- Choke the number of simultaneous run
QUEUE_OPTION LSF LSF_QUEUE mr -- Assign LSF cluster queue to use

RUNPATH <SCRATCH>/<USER>/<CASE_DIR>/realization-<IENS>/iter-<ITER>
RANDOM_SEED 123456 -- ERT seed value

ENSPATH output/<CASE_DIR>/storage -- Storage of internal ert data
UPDATE_LOG_PATH output/<CASE_DIR>/update_log -- Info of active and inactive data points
RUNPATH_FILE output/<CASE_DIR>/runpath_file -- List of runpaths

LOAD_WORKFLOW localisation.wf LOCALISATION_WORKFLOW
HOOK_WORKFLOW LOCALISATION_WORKFLOW PRE_FIRST_UPDATE

--Result data from forward model--
GEN_DATA RESULT_UPSCALED_FIELD RESULT_FILE:UpscaledField_%d.txt REPORT_STEPS:0 INPUT_FORMAT:ASCII OUTPUT_FORMAT:ASCII

-----------------------------------------------------
-- Forward models
-----------------------------------------------------
--Simulate Gaussian field with trend and calculate upscaled values. Observables are upscaled values of selected grid cells.
FORWARD_MODEL MAKE_DIRECTORY(<DIRECTORY>=init_files)
-- Is used to identify iteration number (only relevant for old komodo versions)
FORWARD_MODEL MAKE_DIRECTORY(<DIRECTORY>=<ITER>)
-- The common seed file
FORWARD_MODEL COPY_FILE(<FROM>=<CONFIG_PATH>/<ENSEMBLE_SEED_FILE>, <TO>=<RUNPATH>/<ENSEMBLE_SEED_FILE>)
-- For QC purpose only
FORWARD_MODEL COPY_FILE(<FROM>=<CONFIG_PATH>/init_files/ObsField.roff, <TO>=<RUNPATH>/init_files/ObsField.roff)
FORWARD_MODEL MAKE_SYMLINK(<TARGET>=<CONFIG_PATH>/GRID_WITH_ACTNUM.EGRID, <LINKNAME>=<RUNPATH>/GRID_WITH_ACTNUM.EGRID)
FORWARD_MODEL MAKE_SYMLINK(<TARGET>=<CONFIG_PATH>/UpscaleGrid.EGRID, <LINKNAME>=<RUNPATH>/UpscaleGrid.EGRID)

-- The main forward model simulating gaussian field with trend, and upscale
FORWARD_MODEL SIM_FIELD(<ITERATION>=<ITER>, <REALNUMBER>=<IENS>, <TEST_CONFIG>=<TEST_CONFIG>)

GRID <CONFIG_PATH>/GRID_WITH_ACTNUM.EGRID -- Necessary for AHM using field parameters

FIELD FIELDPAR PARAMETER FieldParam.roff INIT_FILES:init_files/FieldParam.roff MIN:-5.0 MAX:5.0 FORWARD_INIT:True

0 comments on commit ea05837

Please sign in to comment.