def test_create(self): grid = EclGridGenerator.create_rectangular((10, 20, 5), (1, 1, 1)) field_config = FieldConfig("PRESSURE", grid) block_obs = BlockObservation("P-CONFIG", field_config, grid) self.assertEqual(len(block_obs), 0) block_obs.addPoint(1, 2, 3, 100, 25) self.assertEqual(len(block_obs), 1) self.assertEqual(block_obs.getValue(0), 100) self.assertEqual(block_obs.getStd(0), 25) self.assertEqual(block_obs.getStdScaling(0), 1) block_obs.addPoint(1, 2, 4, 200, 50) self.assertEqual(len(block_obs), 2) self.assertEqual(block_obs.getValue(1), 200) self.assertEqual(block_obs.getStd(1), 50) self.assertEqual(block_obs.getStdScaling(1), 1) active_list = ActiveList() block_obs.updateStdScaling(0.50, active_list) self.assertEqual(block_obs.getStdScaling(0), 0.50) self.assertEqual(block_obs.getStdScaling(1), 0.50) active_list.addActiveIndex(1) block_obs.updateStdScaling(2.00, active_list) self.assertEqual(block_obs.getStdScaling(0), 0.50) self.assertEqual(block_obs.getStdScaling(1), 2.00)
def setUp(self): self.grid = EclGridGenerator.create_rectangular((46, 112, 22), (1, 1, 1)) self.rst_file_ICON0 = self.createTestPath( "local/ECLIPSE/well/missing-ICON/ICON0.X0027") self.rst_file_ICON1 = self.createTestPath( "local/ECLIPSE/well/missing-ICON/ICON1.X0027")
def test_create_3d_is_create_kw_inverse(self): nx = 10 ny = 7 nz = 5 grid = GridGen.create_rectangular((nx, ny, nz), (1, 1, 1)) kw1 = EclKW("SWAT", nx * ny * nz, EclDataType.ECL_FLOAT) for k, j, i in itertools.product(range(nz), range(ny), range(nx)): kw1[i + j * nx + nx * ny * k] = i * j * k numpy_3d = grid.create3D(kw1) kw2 = grid.create_kw(numpy_3d, "SWAT", False) self.assertEqual(kw2.name, "SWAT") assert_allclose(grid.create3D(kw2), numpy_3d)
def test_basics(self): grid = EclGridGenerator.create_rectangular((17, 13, 11), (1, 1, 1)) fc = FieldConfig('PORO', grid) print(fc) print(str(fc)) print(repr(fc)) pfx = 'FieldConfig(type' rep = repr(fc) self.assertEqual(pfx, rep[:len(pfx)]) fc_xyz = fc.get_nx(), fc.get_ny(), fc.get_nz() ex_xyz = 17, 13, 11 self.assertEqual(ex_xyz, fc_xyz) self.assertEqual(0, fc.get_truncation_mode()) self.assertEqual(ex_xyz, (grid.getNX(), grid.getNY(), grid.getNZ()))
def test_large_case(self): with open("config", "w") as fp: fp.write( """NUM_REALIZATIONS 10 GRID CASE.EGRID FIELD PORO PARAMETER poro.grdecl INIT_FILES:fields/poro%d.grdecl SUMMARY WBHP OBS_CONFIG observations.txt TIME_MAP timemap.txt """ ) for f in ["timemap.txt", "observations.txt"]: src_file = self.createTestPath(os.path.join("local/row_scaling", f)) shutil.copy(src_file, "./") # The grid size must be greater than 250000 (the default matrix size in # enkf_main_update()) grid = EclGridGenerator.create_rectangular((70, 70, 70), (1, 1, 1)) grid.save_EGRID("CASE.EGRID") res_config = ResConfig(user_config_file="config") main = EnKFMain(res_config) init_fs = init_data(main) # Configure the local updates local_config = main.getLocalConfig() local_config.clear() local_data = local_config.createDataset("LOCAL") local_data.addNode("PORO") obs = local_config.createObsdata("OBSSET_LOCAL") obs.addNode("WBHP0") ministep = local_config.createMinistep("MINISTEP_LOCAL") ministep.attachDataset(local_data) ministep.attachObsset(obs) updatestep = local_config.getUpdatestep() updatestep.attachMinistep(ministep) # Apply the row scaling row_scaling = local_data.row_scaling("PORO") ens_config = main.ensembleConfig() poro_config = ens_config["PORO"] field_config = poro_config.getFieldModelConfig() grid = main.eclConfig().getGrid() row_scaling.assign(field_config.get_data_size(), ScalingTest(grid)) es_update = ESUpdate(main) update_fs = main.getEnkfFsManager().getFileSystem("target2") run_context = ErtRunContext.ensemble_smoother_update(init_fs, update_fs) es_update.smootherUpdate(run_context)
def test_basics(self): nx = 17 ny = 13 nz = 11 actnum = [1] * nx * ny * nz actnum[0] = 0 grid = EclGridGenerator.create_rectangular((nx, ny, nz), (1, 1, 1), actnum) fc = FieldConfig("PORO", grid) pfx = "FieldConfig(type" rep = repr(fc) self.assertEqual(pfx, rep[: len(pfx)]) fc_xyz = fc.get_nx(), fc.get_ny(), fc.get_nz() ex_xyz = nx, ny, nz self.assertEqual(ex_xyz, fc_xyz) self.assertEqual(0, fc.get_truncation_mode()) self.assertEqual(ex_xyz, (grid.getNX(), grid.getNY(), grid.getNZ())) self.assertEqual(fc.get_data_size(), grid.get_num_active())
def test_field_config(): nx = 10 ny = 10 nz = 5 actnum = [1] * nx * ny * nz actnum[0] = 0 actnum[3] = 0 actnum[10] = 0 grid = EclGridGenerator.create_rectangular((nx, ny, nz), (1, 1, 1), actnum) fc = FieldConfig("PORO", grid) row_scaling = RowScaling() obs_pos = grid.get_xyz(ijk=(5, 5, 1)) length_scale = (2, 1, 0.50) gaussian = partial(gaussian_decay, obs_pos, length_scale, grid) row_scaling.assign(grid.get_num_active(), gaussian) for g in range(grid.get_num_active()): assert row_scaling[g] == row_scaling.clamp( gaussian_decay(obs_pos, length_scale, grid, g))
def test_create(self): grid = EclGridGenerator.create_rectangular((10, 10, 5), (1, 1, 1)) field_config = FieldConfig("SWAT", grid)