Skip to content

Commit

Permalink
Don't import ert in heat-eq forward model
Browse files Browse the repository at this point in the history
Importing ert increases runtime of ES-MDA from 50s to 2min 30s.
  • Loading branch information
dafeda committed Aug 16, 2024
1 parent 1336b7c commit 3594762
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion test-data/heat_equation/config.ert
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ GRID CASE.EGRID

OBS_CONFIG observations

FIELD COND PARAMETER cond.grdecl INIT_FILES:cond.grdecl FORWARD_INIT:True
FIELD COND PARAMETER cond.bgrdecl INIT_FILES:cond.bgrdecl FORWARD_INIT:True

GEN_DATA MY_RESPONSE RESULT_FILE:gen_data_%d.out REPORT_STEPS:10,71,132,193,255,316,377,438 INPUT_FORMAT:ASCII

Expand Down
9 changes: 5 additions & 4 deletions test-data/heat_equation/heat_equation.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@
import geostat
import numpy as np
import numpy.typing as npt
import resfo
from definition import dx, k_end, k_start, nx, obs_coordinates, obs_times, u_init

from ert.field_utils.grdecl_io import export_grdecl, import_grdecl


def heat_equation(
u: npt.NDArray[np.float64],
Expand Down Expand Up @@ -65,9 +64,11 @@ def sample_prior_conductivity(ensemble_size, nx, rng):
cond = sample_prior_conductivity(ensemble_size=1, nx=nx, rng=rng).reshape(nx, nx)

if iteration == 0:
export_grdecl(cond, "cond.grdecl", "COND", binary=False)
resfo.write(
"cond.bgrdecl", [("COND ", cond.flatten(order="F").astype(np.float32))]
)
else:
cond = import_grdecl("cond.grdecl", "COND", dimensions=(nx, nx))
cond = resfo.read("cond.bgrdecl")[0][1].reshape(nx, nx)

# The update may give non-physical parameter values, which here means negative heat conductivity.
# Setting negative values to a small positive value but not zero because we want to be able to divide by them.
Expand Down

0 comments on commit 3594762

Please sign in to comment.