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

Make regional multipliers for bulkvolume, porosity and permeability #404

Merged
merged 12 commits into from
May 28, 2021
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ This project adheres to [Semantic Versioning](https://semver.org/).
## Unreleased

### Added
- [#404](https://github.com/equinor/flownet/pull/404) Added possibility for regional multipliers for permeability, porosity and bulkvolume multiplier. Current implementation allows for defining either one global multiplier, or a regional multipliers based on a region parameter extracted from an existing simulation model (typically FIPNUM, EQLNUM, SATNUM etc). The regional multiplier will be in addition to the per tube multipliers. New keys in config yaml are: porosity_regional_scheme (global, individual or regions_from_sim), porosity_regional (define prior same way as for other model parameters) and porosity_parameter_from_sim_model (name of region parameter in simulation model). The same three keys exists for permeability and bulkvolume_mult.
- [#383](https://github.com/equinor/flownet/pull/383) Added option to either define a prior distribution for KRWMAX directly by using krwmax in the config yaml, or to let KRWMAX be calculated as KRWEND + delta. To do the latter, set krwmax_add_to_krwend to true, and then the prior distribution definition in the config yaml for krwmax will be interpreted as a prior distribution for the delta value to be added to KRWEND to get the KRWMAX.
- [#386](https://github.com/equinor/flownet/pull/386) Expose FlowNet timeout to user.
- [#356](https://github.com/equinor/flownet/pull/356) Added option to distribute the original volume over the FlowNet tubes in a Voronoi-diagram style. I.e., areas with a high density of FlowNet tubes get a lower volume per tube.
Expand Down
93 changes: 92 additions & 1 deletion src/flownet/ahm/_run_ahm.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import argparse
from typing import Union, List, Optional, Dict
from typing import Union, List, Optional, Dict, Tuple
import json
import pathlib
from operator import add
Expand Down Expand Up @@ -198,6 +198,78 @@ def _get_distribution(
return df


def _get_regional_distribution(
parameters: Union[str, List[str]],
parameters_config: dict,
network: NetworkModel,
field_data: FlowData,
ti2ci: pd.DataFrame,
) -> Tuple[pd.DataFrame, pd.DataFrame]:
"""
Create:
1) The distribution with min, mean, base, stddev, max for one or more regional parameter
multipliers
2) A dataframe linking region model index to cell model index for each regional multiplier

Args:
parameters: which parameter(s) should be outputted in the dataframe
parameters_config: the parameters definition from the configuration file
network: FlowNet network instance
field_data: FlowData class with information from simulation model data source
ti2ci: A dataframe with index equal to tube model index, and one column which equals cell indices.

Returns:
tuple: a tuple containing:
ci2ri (pd.DataFrame): A dataframe with index equal to cell model index, and one column containing
region index for each of the requested regional multiplier(s).
df_dist_values (pd.DataFrame): A dataframe with distributions for the requested regional multiplier(s)
"""
if not isinstance(parameters, list):
parameters = [parameters]

df = pd.DataFrame(index=ti2ci.index.unique())
df_dist_values = pd.DataFrame(index=[0])
ci2ri = pd.DataFrame(index=network.grid.index)

for parameter in parameters:
if (
getattr(parameters_config, parameter + "_regional_scheme")
== "regions_from_sim"
):
df[parameter + "_regional"] = pd.DataFrame(
_from_regions_to_flow_tubes(
network,
field_data,
ti2ci,
getattr(parameters_config, parameter + "_parameter_from_sim_model"),
)
)
elif getattr(parameters_config, parameter + "_regional_scheme") == "global":
df[parameter + "_regional"] = pd.DataFrame(
[1] * len(network.grid.model.unique())
)

ci2ri_index = ti2ci.index.values.copy()
for idx in np.unique(ti2ci.index.values):
ci2ri_index[ti2ci.index.values == idx] = df.loc[
idx, parameter + "_regional"
]
ci2ri[parameter + "_regional"] = ci2ri_index

parameter_config_regional = getattr(parameters_config, parameter + "_regional")
df_dist_values[f"minimum_{parameter}_regional"] = parameter_config_regional.min
df_dist_values[f"maximum_{parameter}_regional"] = parameter_config_regional.max
df_dist_values[f"mean_{parameter}_regional"] = parameter_config_regional.mean
df_dist_values[f"base_{parameter}_regional"] = parameter_config_regional.base
df_dist_values[
f"stddev_{parameter}_regional"
] = parameter_config_regional.stddev
df_dist_values[
f"distribution_{parameter}_regional"
] = parameter_config_regional.distribution
return ci2ri, df_dist_values


def _constrain_using_well_logs(
porv_poro_trans_dist_values: pd.DataFrame,
data: np.ndarray,
Expand Down Expand Up @@ -771,6 +843,23 @@ def run_flownet_history_matching(

equil_dist_values = equil_dist_values[equil_dist_values.isnull().sum(axis=1) < 5]

#########################################
# Region volume multipliers #
#########################################

regional_parameters = [
param
for param in {"bulkvolume_mult", "porosity", "permeability"}
if getattr(config.model_parameters, param + "_regional_scheme") != "individual"
]
(ci2ri, regional_porv_poro_trans_dist_values,) = _get_regional_distribution(
regional_parameters,
config.model_parameters,
network,
field_data,
ti2ci,
)

#########################################
# Fault transmissibility #
#########################################
Expand Down Expand Up @@ -832,7 +921,9 @@ def run_flownet_history_matching(
parameters = [
PorvPoroTrans(
porv_poro_trans_dist_values,
regional_porv_poro_trans_dist_values,
ti2ci,
ci2ri,
network,
config.flownet.min_permeability,
),
Expand Down
Loading