Skip to content

Commit

Permalink
Commitin
Browse files Browse the repository at this point in the history
  • Loading branch information
dafeda committed Aug 13, 2024
1 parent ef5f5e2 commit ea1969f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 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 @@ -23,4 +23,4 @@ FIELD COND PARAMETER cond.grdecl INIT_FILES:cond.grdecl 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

INSTALL_JOB heat_equation HEAT_EQUATION
SIMULATION_JOB heat_equation <IENS>
SIMULATION_JOB heat_equation <IENS> <ITER>
21 changes: 10 additions & 11 deletions test-data/heat_equation/heat_equation.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import numpy.typing as npt
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 @@ -58,21 +60,18 @@ def sample_prior_conductivity(ensemble_size, nx, rng):

if __name__ == "__main__":
iens = int(sys.argv[1])
iteration = int(sys.argv[2])
rng = np.random.default_rng(iens)
cond = sample_prior_conductivity(ensemble_size=1, nx=nx, rng=rng).reshape(nx, nx)

# Write the array to a GRDECL formatted file
with open("cond.grdecl", "w", encoding="utf-8") as f:
f.write("COND\n") # Write the property name
f.write("-- Conductivity data\n") # Optional comment line

# Write the data
for row in cond:
for value in row:
f.write(f"{value:.6f} ")
f.write("\n")
if iteration == 0:
export_grdecl(cond, "cond.grdecl", "COND", binary=False)
else:
cond = import_grdecl("cond.grdecl", "COND", dimensions=(nx, nx))

f.write("/\n") # End the data section with a slash
# 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.
cond = cond.clip(min=1e-8)

# Calculate maximum `dt`.
# If higher values are used, the numerical solution will become unstable.
Expand Down

0 comments on commit ea1969f

Please sign in to comment.