pycopm.utils.vicinity module#

Extract submodels and map pore volume from outside their boundaries.

class VicinityMaps(selector, shape, cell_mask, min_i, max_i, min_j, max_j, min_k, max_k, layer_min_i, layer_max_i, layer_min_j, layer_max_j, layer_selected_porv, layer_external_porv, well_cells, well_indices=<factory>, active_counts=<factory>, source_indices=<factory>)[source]#

Bases: object

Store a vicinity selection, bounds, and pore-volume mappings.

Global and per-layer bounds are one-based and inclusive.

Parameters:
  • selector (str)

  • shape (str | None)

  • cell_mask (NDArray)

  • min_i (int)

  • max_i (int)

  • min_j (int)

  • max_j (int)

  • min_k (int)

  • max_k (int)

  • layer_min_i (NDArray)

  • layer_max_i (NDArray)

  • layer_min_j (NDArray)

  • layer_max_j (NDArray)

  • layer_selected_porv (NDArray)

  • layer_external_porv (NDArray)

  • well_cells (list[list[int]])

  • well_indices (list[int])

  • active_counts (NDArray)

  • source_indices (NDArray)

selector: str#

Selected well name, or an empty string for polygon and region selections.

shape: str | None#

Well-vicinity shape: box, diamond, or diamondxy. None is used for polygon and region selections.

cell_mask: NDArray#

Boolean mask identifying selected original-grid cells, flattened in (z, y, x) order.

min_i: int#

Minimum selected i index across all layers.

max_i: int#

Maximum selected i index across all layers.

min_j: int#

Minimum selected j index across all layers.

max_j: int#

Maximum selected j index across all layers.

min_k: int#

Minimum selected k index.

max_k: int#

Maximum selected k index.

layer_min_i: NDArray#

Minimum selected i index in each original layer.

layer_max_i: NDArray#

Maximum selected i index in each original layer.

layer_min_j: NDArray#

Minimum selected j index in each original layer.

layer_max_j: NDArray#

Maximum selected j index in each original layer.

layer_selected_porv: NDArray#

Total pore volume of selected active cells in each original layer.

layer_external_porv: NDArray#

Total pore volume outside the selection in each original layer.

well_cells: list[list[int]]#

Zero-based completion coordinates in [i, j, k] order for the selected well.

well_indices: list[int]#

Zero-based output-grid indices of selected well cells. These cells are excluded from boundary source remapping.

active_counts: NDArray#

Number of selected active cells in each output layer.

source_indices: NDArray#

Original-grid source index assigned to each output boundary cell during pore-volume correction. Zero denotes no assigned source.

class _BoundaryMapping(pore_volume, active_count, offsets)[source]#

Bases: object

Store pore-volume mapping results for one submodel boundary.

Parameters:
  • pore_volume (float)

  • active_count (int)

  • offsets (NDArray)

pore_volume: float#

Unassigned pore volume collected along the boundary.

active_count: int#

Number of active cells receiving pore volume from the boundary.

offsets: NDArray#

Distance from the geometric boundary to each receiving cell.

_submodel_index(dck, column, row, layer)[source]#
Parameters:
  • dck (ConfigViaDeck)

  • column (int)

  • row (int)

  • layer (int)

Return type:

int

_original_index(dck, column, row, layer)[source]#
Parameters:
  • dck (ConfigViaDeck)

  • column (int)

  • row (int)

  • layer (int)

Return type:

int

_add_or_collect_porv(dck, submodel_index, pore_volume)[source]#
Parameters:
  • dck (ConfigViaDeck)

  • submodel_index (int)

  • pore_volume (float)

Return type:

float

create_vicinity_maps(dck)[source]#

Select submodel cells and calculate their bounds.

Selections can use region values, an xy polygon, or a well-centred box, diamond, or diamondxy neighbourhood.

Parameters:
dck

Deck configuration containing the vicinity specification and source grid.

Returns:
VicinityMaps

Selection mask, bounds, well cells, and per-layer pore-volume totals.

Parameters:

dck (ConfigViaDeck)

Return type:

VicinityMaps

map_vicinity_properties(dck, vicinity, modified_deck)[source]#

Map reservoir properties into the submodel bounding box.

Cells inside the bounding box but outside the selection are written as inactive. The function updates output pore volume and active cells.

Parameters:
dck

Deck configuration containing source properties and output dimensions.

vicinity

Selection and bounds created by create_vicinity_maps().

modified_deck

Deck lines updated with generated property includes.

Returns:
generated_files

Names of the written include files.

Parameters:
  • dck (ConfigViaDeck)

  • vicinity (VicinityMaps)

  • modified_deck (list[str])

Return type:

list[str]

extract_vicinity_grid(dck, vicinity)[source]#

Extract and write the selected corner-point subgrid.

Parameters:
dck

Deck configuration containing source geometry and axis mappings.

vicinity

Inclusive bounds of the selected submodel.

Parameters:
Return type:

None

_map_south_boundary(dck, vicinity, layer_index, original_layer, column_offset, row_offset, trailing_columns)[source]#
Parameters:
  • dck (ConfigViaDeck)

  • vicinity (VicinityMaps)

  • layer_index (int)

  • original_layer (int)

  • column_offset (int)

  • row_offset (int)

  • trailing_columns (int)

Return type:

_BoundaryMapping

_map_north_boundary(dck, vicinity, layer_index, original_layer, column_offset, trailing_rows, trailing_columns)[source]#
Parameters:
  • dck (ConfigViaDeck)

  • vicinity (VicinityMaps)

  • layer_index (int)

  • original_layer (int)

  • column_offset (int)

  • trailing_rows (int)

  • trailing_columns (int)

Return type:

_BoundaryMapping

_map_east_boundary(dck, vicinity, layer_index, original_layer, column_offset, row_offset, trailing_rows)[source]#
Parameters:
  • dck (ConfigViaDeck)

  • vicinity (VicinityMaps)

  • layer_index (int)

  • original_layer (int)

  • column_offset (int)

  • row_offset (int)

  • trailing_rows (int)

Return type:

_BoundaryMapping

_get_well_completions_for_vicinity(dck, optvic)[source]#

Collect zero-based completions for a selected well.

Parameters:
dck

Deck configuration identifying the source DATA file.

optvic

Well name from the vicinity specification.

Returns:
list[list[int]]

Completion coordinates in [i, j, k] order.

Parameters:

dck (ConfigViaDeck)

Return type:

list

_map_west_boundary(dck, vicinity, layer_index, original_layer, row_offset, trailing_rows, trailing_columns)[source]#
Parameters:
  • dck (ConfigViaDeck)

  • vicinity (VicinityMaps)

  • layer_index (int)

  • original_layer (int)

  • row_offset (int)

  • trailing_rows (int)

  • trailing_columns (int)

Return type:

_BoundaryMapping

_corner_pore_volumes(dck, vicinity, original_layer)[source]#

Calculate excluded pore volume in the four layer corners.

Returns:
southwest, southeast, northwest, northeast

Corner pore-volume totals for the selected original layer.

Parameters:
  • dck (ConfigViaDeck)

  • vicinity (VicinityMaps)

  • original_layer (int)

Return type:

tuple[float, float, float, float]

_apply_layer_pore_volume_correction(dck, vicinity, layer_index, column_offset, row_offset, trailing_columns, trailing_rows, south, north, east, west, corner_porv)[source]#
Parameters:
Return type:

None

_find_nearest_active_corner_cell(dck, layer_index, corner_i, corner_j)[source]#

Return the nearest active cell to a corner in a layer.

Parameters:
  • dck (ConfigViaDeck)

  • layer_index (int)

  • corner_i (int)

  • corner_j (int)

Return type:

int

_distribute_vertical_pore_volume(dck, vicinity)[source]#

Distribute pore volume excluded above and below the submodel.

Parameters:
dck

Deck configuration whose output_porv is updated.

vicinity

Selection bounds and correction settings.

Parameters:
Return type:

None

apply_boundary_pore_volume_correction(dck, vicinity)[source]#

Map pore volume excluded from the submodel onto active cells.

The correction strategy is selected by dck.pore_volume_correction. Depending on the chosen method, excluded pore volume is assigned to corresponding boundary cells, nearest corner cells, all boundary cells, or all active cells.

Parameters:
dck

Deck configuration whose output_porv is updated.

vicinity

Selection bounds and pore-volume mapping arrays.

Parameters:
Return type:

None