Protocol Buffer Data Structures ================================= .. note:: This page is automatically generated from the Protocol Buffer definition files. Last updated: Generated by ``generate_protobuf_docs.py`` Overview -------- ResInsight uses Protocol Buffers (protobuf) for efficient data serialization and communication between Python and the ResInsight application via gRPC. The protobuf definitions define the structure of data that can be exchanged with ResInsight. The generated Python classes from these protobuf files are used as return types and parameters in many rips API methods. Source Files ~~~~~~~~~~~~ The Protocol Buffer definition files (.proto) are automatically downloaded from the `ResInsight repository `_ and stored in the ``docs/proto`` directory. The generated Python files are located in ``docs/rips/generated/`` and include: Key Data Structures ------------------- These are the most commonly used Protocol Buffer structures in the ResInsight Python API. .. _simulatortabledata: SimulatorTableData ~~~~~~~~~~~~~~~~~~ **Source:** ``SimulatorTables.proto`` **Repeated Fields:** .. list-table:: :header-rows: 1 :widths: 30 20 50 :class: plain-table * - Field - Type - Description * - compdat - list[SimulatorCompdatEntry] - * - welspecs - list[SimulatorWelspecsEntry] - * - welsegs - list[SimulatorWelsegsEntry] - * - compsegs - list[SimulatorCompsegsEntry] - * - wsegvalv - list[SimulatorWsegvalvEntry] - * - wsegaicd - list[SimulatorWsegaicdEntry] - * - wpimult - list[SimulatorWpimultEntry] - .. _simulatorcompdatentry: SimulatorCompdatEntry ~~~~~~~~~~~~~~~~~~~~~ **Source:** ``SimulatorTables.proto`` **Attributes:** .. list-table:: :header-rows: 1 :widths: 30 20 50 :class: plain-table * - Field - Type - Description * - well_name - str - * - grid_i - int - * - grid_j - int - * - upper_k - int - * - lower_k - int - * - open_shut_flag - str - **Optional Attributes:** .. list-table:: :header-rows: 1 :widths: 30 20 50 :class: plain-table * - Field - Type - Description * - saturation - float | None - * - transmissibility - float | None - * - diameter - float | None - * - kh - float | None - * - skin_factor - float | None - * - d_factor - float | None - * - direction - str | None - * - start_md - float | None - * - end_md - float | None - * - comment - str | None - * - grid_name - str | None - * - completion_number - int | None - .. _simulatorwelspecsentry: SimulatorWelspecsEntry ~~~~~~~~~~~~~~~~~~~~~~ **Source:** ``SimulatorTables.proto`` **Attributes:** .. list-table:: :header-rows: 1 :widths: 30 20 50 :class: plain-table * - Field - Type - Description * - well_name - str - * - group_name - str - * - grid_i - int - * - grid_j - int - * - phase - str - **Optional Attributes:** .. list-table:: :header-rows: 1 :widths: 30 20 50 :class: plain-table * - Field - Type - Description * - bhp_depth - float | None - * - drainage_radius - float | None - * - inflow_equation - str | None - * - auto_shut_in - str | None - * - cross_flow - str | None - * - pvt_num - int | None - * - hydrostatic_density_calc - str | None - * - fip_region - int | None - * - grid_name - str | None - .. _simulatortablerequest: SimulatorTableRequest ~~~~~~~~~~~~~~~~~~~~~ **Source:** ``SimulatorTables.proto`` **Attributes:** .. list-table:: :header-rows: 1 :widths: 30 20 50 :class: plain-table * - Field - Type - Description * - wellpath_name - str - * - case_id - int - .. _vec3d: Vec3d ~~~~~ **Source:** ``Definitions.proto`` **Attributes:** .. list-table:: :header-rows: 1 :widths: 30 20 50 :class: plain-table * - Field - Type - Description * - x - float - * - y - float - * - z - float - .. _vec3i: Vec3i ~~~~~ **Source:** ``Definitions.proto`` **Attributes:** .. list-table:: :header-rows: 1 :widths: 30 20 50 :class: plain-table * - Field - Type - Description * - i - int - * - j - int - * - k - int - .. _cellcenters: CellCenters ~~~~~~~~~~~ **Source:** ``Definitions.proto`` .. _cellcorners: CellCorners ~~~~~~~~~~~ **Source:** ``Definitions.proto`` **Attributes:** .. list-table:: :header-rows: 1 :widths: 30 20 50 :class: plain-table * - Field - Type - Description * - c0 - Vec3d - * - c1 - Vec3d - * - c2 - Vec3d - * - c3 - Vec3d - * - c4 - Vec3d - * - c5 - Vec3d - * - c6 - Vec3d - * - c7 - Vec3d - Complete Structure Reference ----------------------------- Definitions.proto ~~~~~~~~~~~~~~~~~ Empty """"" **Source:** ``Definitions.proto`` ClientToServerStreamReply """"""""""""""""""""""""" **Source:** ``Definitions.proto`` CellCornersArray """""""""""""""" **Source:** ``Definitions.proto`` SimulatorTables.proto ~~~~~~~~~~~~~~~~~~~~~ SimulatorTableUnifiedRequest """""""""""""""""""""""""""" **Source:** ``SimulatorTables.proto`` **Attributes:** .. list-table:: :header-rows: 1 :widths: 30 20 50 :class: plain-table * - Field - Type - Description * - case_id - int - **Repeated Fields:** .. list-table:: :header-rows: 1 :widths: 30 20 50 :class: plain-table * - Field - Type - Description * - wellpath_names - list[str] - SimulatorWelsegsHeaderEntry """"""""""""""""""""""""""" **Source:** ``SimulatorTables.proto`` **Attributes:** .. list-table:: :header-rows: 1 :widths: 30 20 50 :class: plain-table * - Field - Type - Description * - well_name - str - * - top_depth - float - * - top_length - float - * - info_type - str - **Optional Attributes:** .. list-table:: :header-rows: 1 :widths: 30 20 50 :class: plain-table * - Field - Type - Description * - wellbore_volume - float | None - * - pressure_components - str | None - * - flow_model - str | None - SimulatorWelsegsRowEntry """""""""""""""""""""""" **Source:** ``SimulatorTables.proto`` **Attributes:** .. list-table:: :header-rows: 1 :widths: 30 20 50 :class: plain-table * - Field - Type - Description * - segment_1 - int - * - segment_2 - int - * - branch - int - * - join_segment - int - * - length - float - * - depth - float - **Optional Attributes:** .. list-table:: :header-rows: 1 :widths: 30 20 50 :class: plain-table * - Field - Type - Description * - diameter - float | None - * - roughness - float | None - * - description - str | None - SimulatorWelsegsEntry """"""""""""""""""""" **Source:** ``SimulatorTables.proto`` **Attributes:** .. list-table:: :header-rows: 1 :widths: 30 20 50 :class: plain-table * - Field - Type - Description * - header - SimulatorWelsegsHeaderEntry - **Repeated Fields:** .. list-table:: :header-rows: 1 :widths: 30 20 50 :class: plain-table * - Field - Type - Description * - row - list[SimulatorWelsegsRowEntry] - SimulatorCompsegsEntry """""""""""""""""""""" **Source:** ``SimulatorTables.proto`` **Attributes:** .. list-table:: :header-rows: 1 :widths: 30 20 50 :class: plain-table * - Field - Type - Description * - i - int - * - j - int - * - k - int - * - branch - int - * - distance_start - float - * - distance_end - float - **Optional Attributes:** .. list-table:: :header-rows: 1 :widths: 30 20 50 :class: plain-table * - Field - Type - Description * - grid_name - str | None - SimulatorWsegvalvEntry """""""""""""""""""""" **Source:** ``SimulatorTables.proto`` **Attributes:** .. list-table:: :header-rows: 1 :widths: 30 20 50 :class: plain-table * - Field - Type - Description * - well_name - str - * - segment_number - int - * - cv - float - * - area - float - **Optional Attributes:** .. list-table:: :header-rows: 1 :widths: 30 20 50 :class: plain-table * - Field - Type - Description * - extra_length - float | None - * - pipe_d - float | None - * - roughness - float | None - * - pipe_a - float | None - * - status - str | None - * - max_a - float | None - SimulatorWsegaicdEntry """""""""""""""""""""" **Source:** ``SimulatorTables.proto`` **Attributes:** .. list-table:: :header-rows: 1 :widths: 30 20 50 :class: plain-table * - Field - Type - Description * - well_name - str - * - segment_1 - int - * - segment_2 - int - * - strength - float - * - max_abs_rate - float - * - flow_rate_exponent - float - * - visc_exponent - float - **Optional Attributes:** .. list-table:: :header-rows: 1 :widths: 30 20 50 :class: plain-table * - Field - Type - Description * - length - float | None - * - density_cali - float | None - * - viscosity_cali - float | None - * - critical_value - float | None - * - width_trans - float | None - * - max_visc_ratio - float | None - * - method_scaling_factor - int | None - * - status - str | None - * - oil_flow_fraction - float | None - * - water_flow_fraction - float | None - * - gas_flow_fraction - float | None - * - oil_visc_fraction - float | None - * - water_visc_fraction - float | None - * - gas_visc_fraction - float | None - * - description - str | None - SimulatorWpimultEntry """"""""""""""""""""" **Source:** ``SimulatorTables.proto`` **Attributes:** .. list-table:: :header-rows: 1 :widths: 30 20 50 :class: plain-table * - Field - Type - Description * - well_name - str - * - pimult - float - * - i - int - * - j - int - * - k - int - **Optional Attributes:** .. list-table:: :header-rows: 1 :widths: 30 20 50 :class: plain-table * - Field - Type - Description * - grid_name - str | None - WellPath Service """""""""""""""" Usage Examples -------------- Working with SimulatorTableData ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The :meth:`rips.WellPath.completion_data` method returns a ``SimulatorTableData`` object containing well completion information: .. code-block:: python import rips # Connect to ResInsight resinsight = rips.Instance.find() project = resinsight.project # Get a case case = project.cases()[0] # Get well path well_path = project.well_paths()[0] # Get completion data completion_data = well_path.completion_data(case.id) # Access COMPDAT entries for compdat_entry in completion_data.compdat: print(f"Well: {compdat_entry.well_name}") print(f" Grid location: i={compdat_entry.grid_i}, j={compdat_entry.grid_j}") print(f" K layers: {compdat_entry.upper_k} to {compdat_entry.lower_k}") print(f" Status: {compdat_entry.open_shut_flag}") if compdat_entry.HasField('transmissibility'): print(f" Transmissibility: {compdat_entry.transmissibility}") if compdat_entry.HasField('diameter'): print(f" Diameter: {compdat_entry.diameter}") # Access WELSPECS entries for welspecs_entry in completion_data.welspecs: print(f"Well: {welspecs_entry.well_name}") print(f" Group: {welspecs_entry.group_name}") print(f" Phase: {welspecs_entry.phase}") print(f" Grid location: i={welspecs_entry.grid_i}, j={welspecs_entry.grid_j}") if welspecs_entry.HasField('bhp_depth'): print(f" BHP Depth: {welspecs_entry.bhp_depth}") Working with Optional Fields ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Many protobuf messages contain optional fields. Use the ``HasField()`` method to check if an optional field is set: .. code-block:: python # Check if optional field is set before accessing if entry.HasField('saturation'): saturation_value = entry.saturation else: saturation_value = "1*" Working with Vec3d and Vec3i ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Many protobuf messages use ``Vec3d`` (3D double vector) or ``Vec3i`` (3D integer vector) for coordinates: .. code-block:: python # Vec3d example (cell centers, coordinates) cell_centers = grid.cell_centers() for center in cell_centers.centers: print(f"Center: x={center.x}, y={center.y}, z={center.z}") # Vec3i example (grid indices) grid_dims = grid.dimensions() print(f"Grid dimensions: i={grid_dims.i}, j={grid_dims.j}, k={grid_dims.k}") See Also -------- * :doc:`rips` - Main API documentation * :doc:`GeneratedClasses` - Auto-generated class documentation * :doc:`PythonExamples` - Python code examples External Resources ~~~~~~~~~~~~~~~~~~ * `Protocol Buffers Documentation `_ * `gRPC Python Documentation `_ * `ResInsight Source Repository `_