WellSet (inherits from dataclass)
Description
Represents a set of Well objects as a dictionary. Each well is accessible by its name string (e.g., "A1") or by integer index in list order. Provides flexible and convenient access to individual wells or slices of wells.
Constructor
python
WellSet(wells: Dict[str, Well])Initializes a set of wells, where the key is the well name and the value is the corresponding Well object.
| Parameter | Type | Description |
|---|---|---|
wells | Dict[str, Well] | Dictionary mapping well names to Well instances. |
Properties
(No additional explicit properties beyond wells, but dynamic list-like access is provided.)
Methods
| Method | Returns | Description |
|---|---|---|
__getitem__(id_: Union[str, int]) | Well or List[Well] | Retrieves a Well by name (string key) or index (integer position). Supports slices. |
__repr__() | str | Returns a string list of all well names contained in the WellSet. |
Short Example
python
# Create a few wells manually
well_a1 = Well(name="A1", depth=10, totalLiquidVolume=360, shape="circular", x=0, y=0, z=0)
well_b1 = Well(name="B1", depth=10, totalLiquidVolume=360, shape="circular", x=10, y=0, z=0)
# Create a WellSet
well_set = WellSet(wells={"A1": well_a1, "B1": well_b1})
# Access wells
a1 = well_set["A1"]
b1 = well_set[1] # Access by list index
# Access multiple wells (slice)
subset = well_set[0:2]
print(subset)Important Notes
- If a well is accessed by an integer index and not a string key, the wells are retrieved according to their order in the dictionary's values list.
- Slice access (e.g.,
well_set[0:3]) returns a list of Well objects, not another WellSet. - The
reprdisplays a list of well names for quick inspection, helpful for debugging or UI displays. - Care must be taken when relying on ordering: dictionary order is preserved only in Python 3.7+ (and effectively 3.6 for CPython).