From 950adc24c1cfc8d49b280f3b86da16ff26937b59 Mon Sep 17 00:00:00 2001 From: "Wouter J. de Bruin" Date: Fri, 7 May 2021 10:48:27 +0200 Subject: [PATCH 1/2] Distribute model volume to nearest tube cell midpoint --- src/flownet/data/from_flow.py | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/src/flownet/data/from_flow.py b/src/flownet/data/from_flow.py index bbdae8ef7..f110be293 100644 --- a/src/flownet/data/from_flow.py +++ b/src/flownet/data/from_flow.py @@ -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. @@ -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)] ) @@ -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 ( From 91bdf3a49aae9aba6b90aeadfe1c23b395c3af59 Mon Sep 17 00:00:00 2001 From: "Wouter J. de Bruin" Date: Fri, 7 May 2021 10:53:59 +0200 Subject: [PATCH 2/2] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1879985d5..750287421 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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.