Files

86 lines
2.7 KiB
Python
Raw Permalink Normal View History

"""
ResInsight SimulationWell
"""
import grpc
2020-08-19 07:30:51 +02:00
import SimulationWell_pb2
import SimulationWell_pb2_grpc
2023-07-12 11:42:17 +02:00
import PdmObject_pb2
from .resinsight_classes import SimulationWell
2023-07-12 11:42:17 +02:00
from .case import Case
from .view import View
2025-05-16 15:46:45 +02:00
from .pdmobject import add_method
2023-07-12 11:42:17 +02:00
from typing import List, Optional
2020-04-16 16:06:18 +02:00
@add_method(SimulationWell)
2023-07-12 11:42:17 +02:00
def __custom_init__(
self: SimulationWell, pb2_object: PdmObject_pb2.PdmObject, channel: grpc.Channel
) -> None:
self.__simulation_well_stub = SimulationWell_pb2_grpc.SimulationWellStub(channel)
2020-04-16 16:06:18 +02:00
@add_method(SimulationWell)
2023-07-12 11:42:17 +02:00
def status(
self: SimulationWell, timestep: int
) -> List[SimulationWell_pb2.SimulationWellStatus]:
2020-04-16 16:06:18 +02:00
"""Get simulation well status
**SimulationWellStatus class description**::
Parameter | Description | Type
----------- | ------------------------------------------------------------- | -----
well_type | Well type as string | string
2021-01-26 20:48:01 +01:00
is_open | True if simulation well is open at the specified time step | bool
2020-04-16 16:06:18 +02:00
Arguments:
timestep(int): Time step index
"""
2021-01-26 20:48:01 +01:00
sim_well_request = SimulationWell_pb2.SimulationWellRequest(
case_id=self.case().id, well_name=self.name, timestep=timestep
)
2023-07-12 11:42:17 +02:00
return self.__simulation_well_stub.GetSimulationWellStatus(sim_well_request)
2020-04-16 16:06:18 +02:00
@add_method(SimulationWell)
2023-07-12 11:42:17 +02:00
def cells(
self: SimulationWell, timestep: int
) -> List[SimulationWell_pb2.SimulationWellCellInfo]:
2020-04-16 16:06:18 +02:00
"""Get reservoir cells the simulation well is defined for
**SimulationWellCellInfo class description**::
Parameter | Description | Type
----------- | --------------------------------------------------------- | -----
ijk | Cell IJK location | Vec3i
grid_index | Grid index | int
2021-01-26 20:48:01 +01:00
is_open | True if connection to is open at the specified time step | bool
2020-04-16 16:06:18 +02:00
branch_id | | int
segment_id | | int
Arguments:
timestep(int): Time step index
Returns:
List of SimulationWellCellInfo
"""
2021-01-26 20:48:01 +01:00
sim_well_request = SimulationWell_pb2.SimulationWellRequest(
case_id=self.case().id, well_name=self.name, timestep=timestep
)
2023-07-12 11:42:17 +02:00
return self.__simulation_well_stub.GetSimulationWellCells(sim_well_request).data
2020-04-16 16:06:18 +02:00
@add_method(SimulationWell)
2023-07-12 11:42:17 +02:00
def case(self: SimulationWell) -> Optional[Case]:
view = self.ancestor(View)
if view:
return view.case()
else:
return None