diff --git a/GrpcInterface/Python/rips/PythonExamples/case_grid_group.py b/GrpcInterface/Python/rips/PythonExamples/case_grid_group.py index c33c1c7781..96af7fc38e 100644 --- a/GrpcInterface/Python/rips/PythonExamples/case_grid_group.py +++ b/GrpcInterface/Python/rips/PythonExamples/case_grid_group.py @@ -3,13 +3,14 @@ import rips 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 diff --git a/GrpcInterface/Python/rips/PythonExamples/case_grid_group_generated_results.py b/GrpcInterface/Python/rips/PythonExamples/case_grid_group_generated_results.py new file mode 100644 index 0000000000..a89cf06436 --- /dev/null +++ b/GrpcInterface/Python/rips/PythonExamples/case_grid_group_generated_results.py @@ -0,0 +1,58 @@ +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") + +# The API does not support configuration of a computation +# Suggested next steps +# - open ResInsight +# - select the statistics object +# - select the generated result(PRESSURE_PORV) as source for computations +# - compute statistics +# - create a view and investigate the statistics of the generated data (PRESSURE_PORV)