Skip to content

Commit 88f6d34

Browse files
committed
Update rips module and proto files
1 parent 4fcac75 commit 88f6d34

8 files changed

Lines changed: 418 additions & 74 deletions

File tree

docs/proto/Commands.proto

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,8 @@ message ScaleFractureTemplateRequest {
178178
int32 id = 1;
179179
double halfLength = 2;
180180
double height = 3;
181+
double dFactor = 4;
182+
double conductivity = 5;
181183
}
182184

183185
message SetFracContainmentRequest {

docs/rips/generated/Commands_pb2.py

Lines changed: 74 additions & 74 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/rips/tests/test_cases.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,30 @@ def test_selected_cells(rips_instance, initialize_test):
211211
assert len(soil_results) == 0
212212

213213

214+
def test_selected_cells_async(rips_instance, initialize_test):
215+
case = rips_instance.project.load_case(
216+
dataroot.PATH + "/TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID"
217+
)
218+
accumulated = []
219+
for chunk in case.selected_cells_async():
220+
accumulated.extend(chunk.cells)
221+
assert accumulated == case.selected_cells()
222+
223+
224+
def test_selected_cell_property_async(rips_instance, initialize_test):
225+
case = rips_instance.project.load_case(
226+
dataroot.PATH + "/TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID"
227+
)
228+
accumulated = []
229+
for chunk in case.selected_cell_property_async(
230+
rips.PropertyType.DYNAMIC_NATIVE, "SOIL", 0
231+
):
232+
accumulated.extend(chunk.values)
233+
assert accumulated == case.selected_cell_property(
234+
rips.PropertyType.DYNAMIC_NATIVE, "SOIL", 0
235+
)
236+
237+
214238
def test_multiple_load_of_same_case(rips_instance, initialize_test):
215239
# Test related to issue https://github.com/OPM/ResInsight/issues/9332
216240
path_name = dataroot.PATH + "/flow_diagnostics_test/SIMPLE_SUMMARY2.EGRID"

docs/rips/tests/test_grids.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,55 @@ def test_10k(rips_instance, initialize_test):
6767
check_corner(cell_corners[cell_index].c7, expected_corners[7])
6868

6969

70+
def test_10k_cell_centers_async(rips_instance, initialize_test):
71+
casePath = dataroot.PATH + "/TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID"
72+
case = rips_instance.project.load_case(path=casePath)
73+
grid = case.grid(index=0)
74+
75+
accumulated = []
76+
for chunk in grid.cell_centers_async():
77+
accumulated.extend(chunk.centers)
78+
79+
sync_centers = grid.cell_centers()
80+
assert len(accumulated) == len(sync_centers)
81+
82+
cell_index = 168143
83+
assert math.isclose(accumulated[cell_index].x, sync_centers[cell_index].x)
84+
assert math.isclose(accumulated[cell_index].y, sync_centers[cell_index].y)
85+
assert math.isclose(accumulated[cell_index].z, sync_centers[cell_index].z)
86+
87+
88+
def test_10k_cell_corners_async(rips_instance, initialize_test):
89+
casePath = dataroot.PATH + "/TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID"
90+
case = rips_instance.project.load_case(path=casePath)
91+
grid = case.grid(index=0)
92+
93+
accumulated = []
94+
for chunk in grid.cell_corners_async():
95+
accumulated.extend(chunk.cells)
96+
97+
sync_corners = grid.cell_corners()
98+
assert len(accumulated) == len(sync_corners)
99+
100+
cell_index = 168143
101+
check_corner(
102+
accumulated[cell_index].c0,
103+
[
104+
sync_corners[cell_index].c0.x,
105+
sync_corners[cell_index].c0.y,
106+
sync_corners[cell_index].c0.z,
107+
],
108+
)
109+
check_corner(
110+
accumulated[cell_index].c7,
111+
[
112+
sync_corners[cell_index].c7.x,
113+
sync_corners[cell_index].c7.y,
114+
sync_corners[cell_index].c7.z,
115+
],
116+
)
117+
118+
70119
def check_reek_grid_box(case: rips.Case):
71120
assert len(case.grids()) == 1
72121
grid = case.grid(index=0)

docs/rips/tests/test_key_value_store.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,21 @@ def test_set_and_get_values(rips_instance, initialize_test):
1616
assert input_values == output_values
1717

1818

19+
def test_set_and_get_values_async(rips_instance, initialize_test):
20+
project = rips_instance.project
21+
key = "my-async-key"
22+
input_values = [float(x) for x in range(2000)]
23+
project.set_key_values(key, input_values)
24+
25+
accumulated = []
26+
chunk_count = 0
27+
for chunk in project.key_values_async(key):
28+
accumulated.extend(chunk.values)
29+
chunk_count += 1
30+
assert chunk_count > 0
31+
assert input_values == accumulated
32+
33+
1934
def test_get_non_existing_key(rips_instance, initialize_test):
2035
project = rips_instance.project
2136
key = "this-key-does-not-exist"

docs/rips/tests/test_nnc_properties.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,52 @@ def test_10kSync(rips_instance, initialize_test):
6161
assert new_data[i] == new_prop_vals[i]
6262

6363

64+
def test_10k_nnc_connections_async(rips_instance, initialize_test):
65+
casePath = dataroot.PATH + "/TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID"
66+
case = rips_instance.project.load_case(path=casePath)
67+
68+
accumulated = []
69+
chunk_count = 0
70+
for chunk in case.nnc_connections_async():
71+
accumulated.extend(chunk.connections)
72+
chunk_count += 1
73+
assert chunk_count > 0
74+
75+
sync_connections = case.nnc_connections()
76+
assert len(accumulated) == len(sync_connections)
77+
78+
first = accumulated[0]
79+
assert first.cell1.i == 33
80+
assert first.cell1.j == 40
81+
assert first.cell1.k == 14
82+
assert first.cell_grid_index1 == 0
83+
84+
85+
def test_10k_nnc_connections_static_values_async(rips_instance, initialize_test):
86+
casePath = dataroot.PATH + "/TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID"
87+
case = rips_instance.project.load_case(path=casePath)
88+
89+
accumulated = []
90+
for chunk in case.nnc_connections_static_values_async("TRAN"):
91+
accumulated.extend(chunk.values)
92+
assert accumulated == case.nnc_connections_static_values("TRAN")
93+
94+
95+
def test_10k_nnc_connections_generated_values_async(rips_instance, initialize_test):
96+
casePath = dataroot.PATH + "/TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID"
97+
case = rips_instance.project.load_case(path=casePath)
98+
99+
nnc_connections = case.nnc_connections()
100+
new_data = [float(c) for c, _ in enumerate(nnc_connections)]
101+
property_name = "ASYNC_PROP"
102+
case.set_nnc_connections_values(new_data, property_name, 0)
103+
104+
accumulated = []
105+
for chunk in case.nnc_connections_generated_values_async(property_name, 0):
106+
accumulated.extend(chunk.values)
107+
assert accumulated == new_data
108+
109+
64110
def test_non_existing_dynamic_values(rips_instance, initialize_test):
65111
casePath = dataroot.PATH + "/TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID"
66112
case = rips_instance.project.load_case(path=casePath)

docs/rips/tests/test_project.py

Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,178 @@ def test_loadGridCaseGroup(rips_instance, initialize_test):
6666
)
6767
assert grid_case_group is not None and grid_case_group.group_id == 0
6868

69+
project = rips_instance.project
70+
groups = project.grid_case_groups()
71+
assert len(groups) == 1
72+
looked_up = project.grid_case_group(grid_case_group.group_id)
73+
assert looked_up is not None
74+
assert looked_up.group_id == grid_case_group.group_id
75+
assert project.grid_case_group(9999) is None
76+
77+
78+
def test_save_project_round_trip(rips_instance, initialize_test):
79+
case_path = dataroot.PATH + "/TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID"
80+
project = rips_instance.project
81+
project.load_case(case_path)
82+
assert len(project.cases()) == 1
83+
84+
with tempfile.TemporaryDirectory(prefix="rips") as tmpdirname:
85+
project_file = os.path.join(tmpdirname, "round_trip.rsp")
86+
project.save(project_file)
87+
assert os.path.exists(project_file)
88+
89+
project.close()
90+
assert len(rips_instance.project.cases()) == 0
91+
92+
reopened = rips_instance.project.open(project_file)
93+
cases = reopened.cases()
94+
assert len(cases) == 1
95+
assert cases[0].name == "TEST10K_FLT_LGR_NNC"
96+
97+
98+
def test_views_and_view_lookup(rips_instance, initialize_test):
99+
case_path = dataroot.PATH + "/TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID"
100+
case = rips_instance.project.load_case(case_path)
101+
case.create_view()
102+
103+
project = rips_instance.project
104+
views = project.views()
105+
assert len(views) >= 1
106+
107+
first_view = views[0]
108+
looked_up = project.view(first_view.id)
109+
assert looked_up is not None
110+
assert looked_up.id == first_view.id
111+
assert project.view(999999) is None
112+
113+
114+
def test_well_path_by_name(rips_instance, initialize_test):
115+
well_files = [dataroot.PATH + "/TEST10K_FLT_LGR_NNC/wellpath_a.dev"]
116+
rips_instance.project.import_well_paths(well_path_files=well_files)
117+
118+
project = rips_instance.project
119+
well_path = project.well_path_by_name("Well Path A")
120+
assert well_path is not None
121+
assert well_path.name == "Well Path A"
122+
assert project.well_path_by_name("Nonexistent Well Path") is None
123+
124+
125+
def test_plot_lookup(rips_instance, initialize_test):
126+
project = rips_instance.project.open(
127+
dataroot.PATH + "/TEST10K_FLT_LGR_NNC/10KWithWellLog.rsp"
128+
)
129+
plots = project.plots()
130+
assert len(plots) >= 1
131+
132+
first_plot = plots[0]
133+
looked_up = project.plot(first_plot.id)
134+
assert looked_up is not None
135+
assert looked_up.id == first_plot.id
136+
assert project.plot(999999) is None
137+
138+
139+
def test_export_well_paths(rips_instance, initialize_test):
140+
well_files = [dataroot.PATH + "/TEST10K_FLT_LGR_NNC/wellpath_a.dev"]
141+
rips_instance.project.import_well_paths(well_path_files=well_files)
142+
143+
with tempfile.TemporaryDirectory(prefix="rips") as tmpdirname:
144+
rips_instance.set_export_folder(export_type="WELLPATHS", path=tmpdirname)
145+
rips_instance.project.export_well_paths(
146+
well_paths="Well Path A", md_step_size=10.0
147+
)
148+
exported = os.listdir(tmpdirname)
149+
assert any(name.endswith(".dev") for name in exported)
150+
151+
152+
def test_scale_fracture_template_and_set_containment(rips_instance, initialize_test):
153+
project = rips_instance.project.open(
154+
dataroot.PATH + "/TEST10K_FLT_LGR_NNC/small-completion-export-fractures.rsp"
155+
)
156+
template = project.descendants(rips.FractureTemplate)[0]
157+
assert template.height_scale_factor == 1.0
158+
# The half-length scale factor uses the legacy keyword "WidthScaleFactor".
159+
assert template.width_scale_factor == 1.0
160+
assert template.d_factor_scale_factor == 1.0
161+
assert template.conductivity_factor == 1.0
162+
163+
project.scale_fracture_template(
164+
template_id=0, half_length=2.0, height=3.0, d_factor=4.0, conductivity=5.0
165+
)
166+
167+
after_scale = project.descendants(rips.FractureTemplate)[0]
168+
assert after_scale.width_scale_factor == 2.0
169+
assert after_scale.height_scale_factor == 3.0
170+
assert after_scale.d_factor_scale_factor == 4.0
171+
assert after_scale.conductivity_factor == 5.0
172+
173+
project.set_fracture_containment(template_id=0, top_layer=5, base_layer=10)
174+
175+
# RimFractureContainment fields are not scriptable, so verify the change
176+
# made it through by saving the project and inspecting the .rsp XML.
177+
with tempfile.TemporaryDirectory(prefix="rips") as tmpdirname:
178+
out_path = os.path.join(tmpdirname, "containment.rsp")
179+
project.save(out_path)
180+
with open(out_path) as rsp:
181+
content = rsp.read()
182+
assert "<TopKLayer>5</TopKLayer>" in content
183+
assert "<BaseKLayer>10</BaseKLayer>" in content
184+
185+
186+
def test_summary_cases(rips_instance, initialize_test):
187+
case_path = dataroot.PATH + "/flow_diagnostics_test/SIMPLE_SUMMARY2.SMSPEC"
188+
project = rips_instance.project
189+
assert project.summary_cases() == []
190+
191+
summary_case = project.import_summary_case(case_path)
192+
cases = project.summary_cases()
193+
assert len(cases) == 1
194+
assert cases[0].id == summary_case.id
195+
196+
197+
def test_import_formation_names(rips_instance, initialize_test):
198+
case_path = dataroot.PATH + "/TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID"
199+
case = rips_instance.project.load_case(case_path)
200+
201+
rips_instance.project.import_formation_names(
202+
formation_files=dataroot.PATH + "/20Layers.lyr"
203+
)
204+
205+
available = case.available_properties(rips.PropertyType.FORMATION_NAMES)
206+
assert "Active Formation Names" in available
207+
208+
209+
_MINIMAL_LAS = """~Version Information
210+
VERS. 2.0 : CWLS log ASCII Standard - VERSION 2.0
211+
WRAP. NO : One line per depth step
212+
~Well Information
213+
#MNEM.UNIT Value Description
214+
#--------- ----------- ---------------
215+
STRT.M 1000.0 : Start Depth
216+
STOP.M 1002.0 : Stop Depth
217+
STEP.M 1.0 : Step
218+
NULL. -999.25 : Null Value
219+
WELL. RIPS_TEST : WELL
220+
~Curve Information
221+
DEPT.M : Depth
222+
GR.GAPI : Gamma Ray
223+
~ASCII
224+
1000.0 50.0
225+
1001.0 55.0
226+
1002.0 60.0
227+
"""
228+
229+
230+
def test_import_well_log_files(rips_instance, initialize_test):
231+
with tempfile.TemporaryDirectory(prefix="rips") as tmpdirname:
232+
las_path = os.path.join(tmpdirname, "rips_test.las")
233+
with open(las_path, "w") as las_file:
234+
las_file.write(_MINIMAL_LAS)
235+
236+
well_path_names = rips_instance.project.import_well_log_files(
237+
well_log_folder=tmpdirname
238+
)
239+
assert "RIPS_TEST" in well_path_names
240+
69241

70242
def test_exportSnapshots(rips_instance, initialize_test):
71243
if not rips_instance.is_gui():

docs/rips/tests/test_properties.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,42 @@ def test_10k_property_strings(rips_instance, initialize_test):
184184
assert len(round_trip) == len(integer_values)
185185

186186

187+
def test_10k_grid_property_async(rips_instance, initialize_test):
188+
casePath = dataroot.PATH + "/TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID"
189+
case = rips_instance.project.load_case(path=casePath)
190+
191+
chunks = case.grid_property_async(rips.PropertyType.STATIC_NATIVE, "PORO", 0)
192+
accumulated = []
193+
chunk_count = 0
194+
for chunk in chunks:
195+
accumulated.extend(chunk.values)
196+
chunk_count += 1
197+
assert chunk_count > 0
198+
199+
sync_values = case.grid_property(rips.PropertyType.STATIC_NATIVE, "PORO", 0)
200+
assert len(accumulated) == len(sync_values)
201+
for async_value, sync_value in zip(accumulated, sync_values):
202+
assert async_value == pytest.approx(sync_value)
203+
204+
205+
def test_10k_available_properties_categories(rips_instance, initialize_test):
206+
casePath = dataroot.PATH + "/TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID"
207+
case = rips_instance.project.load_case(path=casePath)
208+
209+
dynamic = case.available_properties(rips.PropertyType.DYNAMIC_NATIVE)
210+
assert "SOIL" in dynamic
211+
assert "PRESSURE" in dynamic
212+
213+
cell_count_info = case.cell_count()
214+
zeros = [0.0] * cell_count_info.active_cell_count
215+
case.set_active_cell_property(
216+
zeros, rips.PropertyType.GENERATED, "AVAILABLE_PROBE", 0
217+
)
218+
219+
generated = case.available_properties(rips.PropertyType.GENERATED)
220+
assert "AVAILABLE_PROBE" in generated
221+
222+
187223
def test_exportPropertyInView(rips_instance, initialize_test):
188224
case_path = dataroot.PATH + "/TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID"
189225
case = rips_instance.project.load_case(case_path)

0 commit comments

Comments
 (0)