Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Distribute model volume to nearest tube cell midpoint #401

Merged
merged 2 commits into from
May 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ This project adheres to [Semantic Versioning](https://semver.org/).
- [#374](https://github.com/equinor/flownet/pull/374) Fix for memory leak in result plotting script.

### Changes
- [#401](https://github.com/equinor/flownet/pull/401) When distributing volume from a simulation model to a FlowNet, the voronoi_per_tube distribution method now distributes first to tube cells, sums these values, and then redistributes the summed tube volume equally over the tube cells.
- [#396](https://github.com/equinor/flownet/pull/396) When using scheme regions_from_sim for equilibrium regions, the user can supply which region to base the generation of FlowNet model's EQLNUM parameter on. The default region is EQLNUM, but other region parameters (such as FIPNUM or SATNUM) can be used by setting region_parameter_from_sim_model for equil in the config yaml file.
- [#392](https://github.com/equinor/flownet/pull/392) When using scheme regions_from_sim for relative permeability, the user can supply which region to base the generation of FlowNet model's SATNUM parameter on. The default region is SATNUM, but other region parameters (such as FIPNUM or EQLNUM) can be used by setting region_parameter_from_sim_model for relative permeability in the config yaml file to e.g. EQLNUM.
- [#383](https://github.com/equinor/flownet/pull/383) KRWMAX now defaulted to 1, but exposed to used. Previously it was hard coded to 1.
Expand Down
29 changes: 19 additions & 10 deletions src/flownet/data/from_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,8 @@ def bulk_volume_per_flownet_cell_based_on_voronoi_of_input_model(
"""Generate bulk volume distribution per grid cell in the FlowNet model based on the geometrical
distribution of the volume in the original (full field) simulation model. I.e., the original model's
volume will be distributed over the FlowNet's tubes by assigning original model grid cell
volumes to the nearest FlowNet tube midpoint.
volumes to the nearest FlowNet tube cell midpoint. Finally, the volume distributed to all cells in a tube
will be summed and evenly redistributed over the tube.

Args:
network: FlowNet network instance.
Expand All @@ -399,7 +400,7 @@ def bulk_volume_per_flownet_cell_based_on_voronoi_of_input_model(
An array with volumes per flownetcell.

"""
flownet_tube_midpoints = np.array(network.get_connection_midpoints())
flownet_cell_midpoints = np.array(network.cell_midpoints).T
model_cell_mid_points = np.array(
[cell.coordinate for cell in self._grid.cells(active=True)]
)
Expand All @@ -408,25 +409,33 @@ def bulk_volume_per_flownet_cell_based_on_voronoi_of_input_model(
for cell in self._grid.cells(active=True)
]

# Determine nearest flow tube for each cell in the original model
tree = KDTree(flownet_tube_midpoints)
# Determine nearest flow tube cell for each cell in the original model
tree = KDTree(flownet_cell_midpoints)
_, matched_indices = tree.query(model_cell_mid_points, k=[1])

# Distribute the original model's volume per cell to flownet tubes that are nearest.
tube_volumes = np.zeros(len(flownet_tube_midpoints))
# Distribute the original model's volume per cell to flownet tubes cells that are nearest.
tube_cell_volumes = np.zeros(len(flownet_cell_midpoints))

for cell_i, tube_id in enumerate(matched_indices):
tube_volumes[tube_id[0]] += model_cell_volume[cell_i]
for cell_i, tube_cell_id in enumerate(matched_indices):
tube_cell_volumes[tube_cell_id[0]] += model_cell_volume[cell_i]

# Distribute tube volume over the active cells of the flownet.
# The last cell of each each tube is inactive and thefore gets 0 volume assigned.
# Get a mapping from tube cells to tubes
properties_per_cell = pd.DataFrame(
pd.DataFrame(data=network.grid.index, index=network.grid.model).index
)

# Sum all tube cell volumes in a tube
properties_per_cell["distributed_volume"] = tube_cell_volumes
tube_volumes = properties_per_cell.groupby(by="model").sum().values

# Get the active cells per tube
active_cells_per_tube = (
properties_per_cell.reset_index().groupby(["model"]).size() - 1
)

# Distribute tube volume over the active cells of the flownet.
# The last cell of each each tube is inactive and thefore gets 0 volume assigned.
# Evenly distribute the volume over cells of the tube
cell_volumes = np.zeros(len(properties_per_cell["model"].values))
for i, tube in enumerate(properties_per_cell["model"].values[:-1]):
if (
Expand Down