Skip to content

Commit

Permalink
Update rips folder from main branch
Browse files Browse the repository at this point in the history
Many changes, as type hinting has been introduced
  • Loading branch information
magnesj committed Oct 23, 2023
1 parent b82da4b commit f8431b3
Show file tree
Hide file tree
Showing 33 changed files with 2,448 additions and 733 deletions.
13 changes: 7 additions & 6 deletions docs/rips/PythonExamples/case_grid_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@

resinsight = rips.Instance.find()

test_model_path = "e:/gitroot-second/ResInsight/TestModels"

case_paths = []
case_paths.append(
"C:/Users/lindk/source/repos/ResInsight/TestModels/Case_with_10_timesteps/Real0/BRUGGE_0000.EGRID"
)
case_paths.append(
"C:/Users/lindk/source/repos/ResInsight/TestModels/Case_with_10_timesteps/Real10/BRUGGE_0010.EGRID"
)
case_paths.append(test_model_path + "/Case_with_10_timesteps/Real0/BRUGGE_0000.EGRID")
case_paths.append(test_model_path + "/Case_with_10_timesteps/Real10/BRUGGE_0010.EGRID")
case_paths.append(test_model_path + "/Case_with_10_timesteps/Real30/BRUGGE_0030.EGRID")
case_paths.append(test_model_path + "/Case_with_10_timesteps/Real40/BRUGGE_0040.EGRID")

for case_path in case_paths:
assert os.path.exists(
case_path
Expand Down
66 changes: 66 additions & 0 deletions docs/rips/PythonExamples/case_grid_group_generated_results.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import os
import rips

resinsight = rips.Instance.find()

# ResInsight includes some test models. Adjust this path to fit your system
test_model_path = "e:/gitroot-second/ResInsight/TestModels"

case_paths = []
case_paths.append(test_model_path + "/Case_with_10_timesteps/Real0/BRUGGE_0000.EGRID")
case_paths.append(test_model_path + "/Case_with_10_timesteps/Real10/BRUGGE_0010.EGRID")
case_paths.append(test_model_path + "/Case_with_10_timesteps/Real30/BRUGGE_0030.EGRID")
case_paths.append(test_model_path + "/Case_with_10_timesteps/Real40/BRUGGE_0040.EGRID")

for case_path in case_paths:
assert os.path.exists(
case_path
), "You need to set valid case paths for this script to work"

case_group = resinsight.project.create_grid_case_group(case_paths=case_paths)

cases = case_group.descendants(rips.EclipseCase)
print("Got " + str(len(cases)) + " cases: ")

for case in cases:
time_step_info = case.time_steps()
porv_results = case.active_cell_property("STATIC_NATIVE", "PORV", 0)

for time_step_index in range(0, len(time_step_info)):
pressure_results = case.active_cell_property(
"DYNAMIC_NATIVE", "PRESSURE", time_step_index
)

results = []
for pressure, porv in zip(pressure_results, porv_results):
results.append(pressure * porv)

# set the computed values in the case
case.set_active_cell_property(
results, "GENERATED", "PRESSURE_PORV", time_step_index
)

print(
"Case id: " + str(case.id),
" Case name: " + case.name,
" : Calculation complete",
)


print("Transferred all results back to ResInsight")

# one of "GENERATED", "DYNAMIC_NATIVE", "STATIC_NATIVE", "IMPORTED"
# https://api.resinsight.org/en/main/rips.html#result-definition
property_type = "GENERATED"

property_name = "PRESSURE_PORV"

statistics_case = case_group.create_statistics_case()
statistics_case.set_source_properties(property_type, [property_name])
statistics_case.compute_statistics()

view = statistics_case.create_view()
statistics_property_name = property_name + "_MEAN"
view.apply_cell_result(
result_type=property_type, result_variable=statistics_property_name
)
14 changes: 14 additions & 0 deletions docs/rips/PythonExamples/create_and_export_stim_plan_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,20 @@
non_net_layers.facies = "Shale"
non_net_layers.update()

# Add some pressure table items
pressure_table = stim_plan_model_template.pressure_table()
pressure_table.add_pressure(depth=2800.0, initial_pressure=260.0, pressure=261.0)
pressure_table.add_pressure(depth=3000.0, initial_pressure=270.0, pressure=273.0)
pressure_table.add_pressure(depth=3400.0, initial_pressure=274.0, pressure=276.0)
pressure_table.add_pressure(depth=3800.0, initial_pressure=276.0, pressure=280.0)

print("Pressure table ({} items)".format(len(pressure_table.items())))
for item in pressure_table.items():
print(
"TDVMSL [m]: {} Initial Pressure: {} Pressure: {}".format(
item.depth, item.initial_pressure, item.pressure
)
)

# Add some scaling factors
elastic_properties = stim_plan_model_template.elastic_properties()
Expand Down
13 changes: 13 additions & 0 deletions docs/rips/PythonExamples/modeled_well_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,16 @@
target = geometry.append_well_target(coord)

well_path.append_perforation_interval(3300, 3350, 0.2, 0.76)


# Update skin factor of the perforation
perforation_coll = well_path.completions().perforations()
perforation = perforation_coll.perforations()[0]
new_skin_factor = 0.9
print(
"Changing perforation skin factor from {} to {}.".format(
perforation.skin_factor, new_skin_factor
)
)
perforation.skin_factor = new_skin_factor
perforation.update()
4 changes: 3 additions & 1 deletion docs/rips/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
from .well_log_plot import WellLogPlot
from .simulation_well import SimulationWell

__all__ = []
from typing import List

__all__: List[str] = []
for key in class_dict():
__all__.append(key)

Expand Down
50 changes: 28 additions & 22 deletions docs/rips/case.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@

import builtins
import grpc
from typing import List, Tuple

import Case_pb2
import Case_pb2_grpc
Expand Down Expand Up @@ -74,7 +75,7 @@ def __custom_init__(self, pb2_object, channel):


@add_method(Case)
def __grid_count(self):
def __grid_count(self) -> int:
"""Get number of grids in the case"""
try:
return self.__case_stub.GetGridCount(self.__request()).count
Expand Down Expand Up @@ -125,7 +126,7 @@ def __generate_property_input_chunks(self, array, parameters):


@add_method(Case)
def grid(self, index=0):
def grid(self, index: int = 0) -> Grid:
"""Get Grid of a given index
Arguments:
Expand All @@ -138,7 +139,7 @@ def grid(self, index=0):


@add_method(Case)
def grids(self):
def grids(self) -> List[Grid]:
"""Get a list of all rips Grid objects in the case
Returns:
Expand Down Expand Up @@ -166,7 +167,7 @@ def replace(self, new_grid_file):


@add_method(Case)
def cell_count(self, porosity_model="MATRIX_MODEL"):
def cell_count(self, porosity_model: str = "MATRIX_MODEL") -> int:
"""Get a cell count object containing number of active cells and total number of cells
Arguments:
Expand All @@ -193,7 +194,7 @@ def cell_count(self, porosity_model="MATRIX_MODEL"):


@add_method(Case)
def cell_info_for_active_cells_async(self, porosity_model="MATRIX_MODEL"):
def cell_info_for_active_cells_async(self, porosity_model: str = "MATRIX_MODEL"):
"""Get Stream of cell info objects for current case
Arguments:
Expand All @@ -213,7 +214,7 @@ def cell_info_for_active_cells_async(self, porosity_model="MATRIX_MODEL"):


@add_method(Case)
def cell_info_for_active_cells(self, porosity_model="MATRIX_MODEL"):
def cell_info_for_active_cells(self, porosity_model: str = "MATRIX_MODEL"):
"""Get list of cell info objects for current case
Arguments:
Expand Down Expand Up @@ -298,7 +299,7 @@ def reservoir_boundingbox(self):


@add_method(Case)
def reservoir_depth_range(self):
def reservoir_depth_range(self) -> Tuple[float, float]:
"""Get the reservoir depth range
Returns:
Expand Down Expand Up @@ -604,7 +605,7 @@ def export_flow_characteristics(


@add_method(Case)
def available_properties(self, property_type, porosity_model="MATRIX_MODEL"):
def available_properties(self, property_type, porosity_model: str = "MATRIX_MODEL"):
"""Get a list of available properties
For argument details, see :ref:`Result Definition <result-definition-label>`
Expand All @@ -626,7 +627,7 @@ def available_properties(self, property_type, porosity_model="MATRIX_MODEL"):

@add_method(Case)
def active_cell_property_async(
self, property_type, property_name, time_step, porosity_model="MATRIX_MODEL"
self, property_type, property_name, time_step, porosity_model: str = "MATRIX_MODEL"
):
"""Get a cell property for all active cells. Async, so returns an iterator. For argument details, see :ref:`Result Definition <result-definition-label>`
Expand Down Expand Up @@ -655,7 +656,7 @@ def active_cell_property_async(

@add_method(Case)
def active_cell_property(
self, property_type, property_name, time_step, porosity_model="MATRIX_MODEL"
self, property_type, property_name, time_step, porosity_model: str = "MATRIX_MODEL"
):
"""Get a cell property for all active cells. Sync, so returns a list. For argument details, see :ref:`Result Definition <result-definition-label>`
Expand All @@ -681,7 +682,7 @@ def active_cell_property(

@add_method(Case)
def selected_cell_property_async(
self, property_type, property_name, time_step, porosity_model="MATRIX_MODEL"
self, property_type, property_name, time_step, porosity_model: str = "MATRIX_MODEL"
):
"""Get a cell property for all selected cells. Async, so returns an iterator. For argument details, see :ref:`Result Definition <result-definition-label>`
Expand Down Expand Up @@ -710,7 +711,7 @@ def selected_cell_property_async(

@add_method(Case)
def selected_cell_property(
self, property_type, property_name, time_step, porosity_model="MATRIX_MODEL"
self, property_type, property_name, time_step, porosity_model: str = "MATRIX_MODEL"
):
"""Get a cell property for all selected cells. Sync, so returns a list. For argument details, see :ref:`Result Definition <result-definition-label>`
Expand Down Expand Up @@ -741,7 +742,7 @@ def grid_property_async(
property_name,
time_step,
grid_index=0,
porosity_model="MATRIX_MODEL",
porosity_model: str = "MATRIX_MODEL",
):
"""Get a cell property for all grid cells. Async, so returns an iterator. For argument details, see :ref:`Result Definition <result-definition-label>`
Expand Down Expand Up @@ -777,7 +778,7 @@ def grid_property(
property_name,
time_step,
grid_index=0,
porosity_model="MATRIX_MODEL",
porosity_model: str = "MATRIX_MODEL",
):
"""Get a cell property for all grid cells. Synchronous, so returns a list. For argument details, see :ref:`Result Definition <result-definition-label>`
Expand Down Expand Up @@ -808,7 +809,7 @@ def set_active_cell_property_async(
property_type,
property_name,
time_step,
porosity_model="MATRIX_MODEL",
porosity_model: str = "MATRIX_MODEL",
):
"""Set cell property for all active cells Async. Takes an iterator to the input values. For argument details, see :ref:`Result Definition <result-definition-label>`
Expand All @@ -835,7 +836,12 @@ def set_active_cell_property_async(

@add_method(Case)
def set_active_cell_property(
self, values, property_type, property_name, time_step, porosity_model="MATRIX_MODEL"
self,
values,
property_type,
property_name,
time_step,
porosity_model: str = "MATRIX_MODEL",
):
"""Set a cell property for all active cells. For argument details, see :ref:`Result Definition <result-definition-label>`
Expand Down Expand Up @@ -869,7 +875,7 @@ def set_grid_property(
property_name,
time_step,
grid_index=0,
porosity_model="MATRIX_MODEL",
porosity_model: str = "MATRIX_MODEL",
):
"""Set a cell property for all grid cells. For argument details, see :ref:`Result Definition <result-definition-label>`
Expand Down Expand Up @@ -989,7 +995,7 @@ def simulation_wells(self):


@add_method(Case)
def active_cell_centers_async(self, porosity_model="MATRIX_MODEL"):
def active_cell_centers_async(self, porosity_model: str = "MATRIX_MODEL"):
"""Get a cell centers for all active cells. Async, so returns an iterator
Arguments:
Expand All @@ -1007,7 +1013,7 @@ def active_cell_centers_async(self, porosity_model="MATRIX_MODEL"):


@add_method(Case)
def active_cell_centers(self, porosity_model="MATRIX_MODEL"):
def active_cell_centers(self, porosity_model: str = "MATRIX_MODEL"):
"""Get a cell centers for all active cells. Synchronous, so returns a list.
Arguments:
Expand All @@ -1025,7 +1031,7 @@ def active_cell_centers(self, porosity_model="MATRIX_MODEL"):


@add_method(Case)
def active_cell_corners_async(self, porosity_model="MATRIX_MODEL"):
def active_cell_corners_async(self, porosity_model: str = "MATRIX_MODEL"):
"""Get a cell corners for all active cells. Async, so returns an iterator
Arguments:
Expand All @@ -1043,7 +1049,7 @@ def active_cell_corners_async(self, porosity_model="MATRIX_MODEL"):


@add_method(Case)
def active_cell_corners(self, porosity_model="MATRIX_MODEL"):
def active_cell_corners(self, porosity_model: str = "MATRIX_MODEL"):
"""Get a cell corners for all active cells. Synchronous, so returns a list.
Arguments:
Expand Down Expand Up @@ -1287,7 +1293,7 @@ def __generate_nnc_property_input_chunks(self, array, parameters):

@add_method(Case)
def set_nnc_connections_values(
self, values, property_name, time_step, porosity_model="MATRIX_MODEL"
self, values, property_name, time_step, porosity_model: str = "MATRIX_MODEL"
):
"""Set nnc connection values for all connections..
Expand Down
20 changes: 10 additions & 10 deletions docs/rips/contour_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@

@add_method(EclipseContourMap)
def export_to_text(
self,
export_file_name="",
export_local_coordinates=False,
undefined_value_label="NaN",
exclude_undefined_values=False,
self: EclipseContourMap,
export_file_name: str = "",
export_local_coordinates: bool = False,
undefined_value_label: str = "NaN",
exclude_undefined_values: bool = False,
):
"""Export snapshot for the current view
Expand All @@ -37,11 +37,11 @@ def export_to_text(

@add_method(GeoMechContourMap)
def export_to_text(
self,
export_file_name="",
export_local_coordinates=False,
undefined_value_label="NaN",
exclude_undefined_values=False,
self: GeoMechContourMap,
export_file_name: str = "",
export_local_coordinates: bool = False,
undefined_value_label: str = "NaN",
exclude_undefined_values: bool = False,
):
"""Export snapshot for the current view
Expand Down
Loading

0 comments on commit f8431b3

Please sign in to comment.