flownet.ahm._run_ahm module

flownet.ahm._run_ahm._constrain_using_well_logs(porv_poro_trans_dist_values: pandas.core.frame.DataFrame, data: numpy.ndarray, network: flownet.network_model._network_model.NetworkModel, measurement_type: str, config: <property object at 0x7f15b0f78830>) pandas.core.frame.DataFrame

Function to constrain permeability and porosity distributions of flow tubes by using 3D kriging of porosity and permeability values from well logs.

Parameters
  • porv_poro_trans_dist_values – pre-constraining dataframe

  • data – well log data

  • network – FlowNet network model

  • measurement_type – ‘prorosity’ or ‘permeability’ (always log10)

  • config – FlowNet configparser snapshot

Returns

Well-log constrained “porv_poro_trans_dist_values” DataFrame

flownet.ahm._run_ahm._find_training_set_fraction(schedule: flownet.realization._schedule.Schedule, config: <property object at 0x7f15b0f78830>) float
Parameters
  • schedule – FlowNet Schedule instance

  • config – Information from the FlowNet config yaml

Returns

Fraction of the observations to be used as a training set

flownet.ahm._run_ahm._from_regions_to_flow_tubes(network: flownet.network_model._network_model.NetworkModel, field_data: flownet.data.from_flow.FlowData, ti2ci: pandas.core.frame.DataFrame, region_name: str) List[int]

The function loops through each cell in all flow tubes, and checks what region the corresponding position (cell midpoint) in the data source simulation model has. If different cells in one flow tube are located in different regions of the original model, the mode is used. If flow tubes are entirely outside of the data source simulation grid, the region of the closest flow tube which has already been assigned to a region will be used. The distance between two flow tubes is calculated as the distance between the mid points of the two flow tubes.

Parameters
  • 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.

  • region_name – The name of the region parameter

Returns

A list with values for ‘name’ region for each tube in the FlowNet model

flownet.ahm._run_ahm._get_distribution(parameters: Union[str, List[str]], parameters_config: dict, index: list) pandas.core.frame.DataFrame

Create the distribution min, mean, base, stddev, max for one or more parameters

Parameters
  • parameters – which parameter(s) should be outputted in the dataframe

  • parameters_config – the parameters definition from the configuration file

  • index – listing used to determine how many times to repeat the distribution

Returns

A dataframe with distributions for the requested parameter(s)

flownet.ahm._run_ahm._get_regional_distribution(parameters: Union[str, List[str]], parameters_config: dict, network: flownet.network_model._network_model.NetworkModel, field_data: flownet.data.from_flow.FlowData, ti2ci: pandas.core.frame.DataFrame) Tuple[pandas.core.frame.DataFrame, pandas.core.frame.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

Parameters
  • 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

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)

Return type

tuple

flownet.ahm._run_ahm._set_up_ahm_and_run_ert(network: flownet.network_model._network_model.NetworkModel, schedule: flownet.realization._schedule.Schedule, parameters: typing.List[flownet.parameters._base_parameter.Parameter], config: <property object at 0x7f15b0f78830>, args: argparse.Namespace)

This function creates the AssistedHistoryMatching class, creates the ERT setup, and runs ERT.

Parameters
  • network – NetworkModel instance

  • schedule – Schedule instance

  • parameters – List of Parameter objects

  • config – Information from the FlowNet config YAML

  • args – Argparse parsed command line arguments.

Returns

Nothing

flownet.ahm._run_ahm.run_flownet_history_matching(config: <property object at 0x7f15b0f78830>, args: argparse.Namespace)

Creates and runs an ERT setup, given user configuration.

Parameters
  • config – Configsuite parsed user provided configuration.

  • args – Argparse parsed command line arguments.

Returns

Nothing

flownet.ahm._run_ahm.run_flownet_history_matching_from_restart(config: <property object at 0x7f15b0f78830>, args: argparse.Namespace)

Creates and runs an ERT setup, based on a previously performed ERT run, given user configuration.

Parameters
  • config – Configsuite parsed user provided configuration.

  • args – Argparse parsed command line arguments.

Returns

Nothing

flownet.ahm._run_ahm.update_distribution(parameters: List[flownet.parameters._base_parameter.Parameter], ahm_case: pathlib.Path) List[flownet.parameters._base_parameter.Parameter]

Update the prior distribution for one or more parameters based on the mean and standard deviation of the posterior distribution. It is assumed that the prior min and max values cannot be exceeded. The type of distribution will also be kept.

For the distributions with a min/max:
  • If the mean value in the posterior is less than in the prior, the minimum value (and the mode) will be kept

    and the maximum value and the mean will be updated.

  • If the mean value in the posterior is larger than in the prior, the maximum value (and the mode) will be

    kept and the minimum value and the mean will be updated.

For distributions defined by a mean and standard deviation the mean and standard deviation will be updated based on the values from the posterior

Parameters
  • parameters – which parameter(s) should be updated

  • ahm_case – path to a previous HM experiment folder

Returns

The parameters list with updated distributions.