void well_rate_eval_stat( well_rate_type * well_rate ) { for (int i = 0; i < stringlist_get_size( well_rate->mean_shift_string ); i++) { double mean_shift = sscanfp( double_vector_safe_iget( well_rate->base_value , i ) , stringlist_iget( well_rate->mean_shift_string , i)); double std_shift = sscanfp( double_vector_safe_iget( well_rate->base_value , i ) , stringlist_iget( well_rate->std_shift_string , i)); double_vector_iset( well_rate->mean_shift , i , mean_shift ); double_vector_iset( well_rate->std_shift , i , std_shift); } }
void well_rate_ishift( well_rate_type * well_rate , int index, double new_shift) { if (sched_history_well_open( well_rate->sched_history , well_rate->name , index)) { double base_rate = double_vector_safe_iget( well_rate->base_value , index); double shift = double_vector_safe_iget( well_rate->shift , index) + new_shift; if ((base_rate + shift) < 0) shift = -base_rate; double_vector_iset( well_rate->shift , index , shift ); } }
void group_rate_init( group_rate_type * group_rate ) { for (int iw = 0; iw < vector_get_size( group_rate->well_rates ); iw++) { const well_rate_type * well_rate = vector_iget( group_rate->well_rates , iw ); for (int tstep = 0; tstep < well_rate_get_length( well_rate ); tstep++) double_vector_iadd( group_rate->base_rate , tstep , well_rate_iget_rate( well_rate , tstep )); } for (int i = 0; i < stringlist_get_size( group_rate->min_shift_string ); i++) { double_vector_iset( group_rate->min_shift , i , sscanfp( double_vector_safe_iget( group_rate->base_rate , i ) , stringlist_iget( group_rate->min_shift_string , i))); double_vector_iset( group_rate->max_shift , i , sscanfp( double_vector_safe_iget( group_rate->base_rate , i ) , stringlist_iget( group_rate->max_shift_string , i))); } }
void well_rate_sample_shift( well_rate_type * well_rate ) { int size = time_t_vector_size( well_rate->time_vector ); double * R = util_malloc( size * sizeof * R , __func__); int i; rand_stdnormal_vector( size , R ); for (i=0; i < size; i++) R[i] = R[i] * double_vector_iget( well_rate->std_shift , i ) + double_vector_iget( well_rate->mean_shift , i ); double_vector_iset( well_rate->shift , 0 , R[0]); for (i=1; i < size; i++) { double dt = 1.0 * (time_t_vector_iget( well_rate->time_vector , i ) - time_t_vector_iget( well_rate->time_vector , i - 1)) / (24 * 3600); /* Days */ double a = exp(-dt / well_rate->corr_length ); double shift = a * double_vector_iget( well_rate->shift , i - 1 ) + (1 - a) * R[i]; double base_rate = double_vector_safe_iget( well_rate->base_value , i); /* The time series is sampled - irrespective of whether the well is open or not. */ if ((shift + base_rate) < 0) shift = -base_rate; if (sched_history_well_open( well_rate->sched_history , well_rate->name , i)) double_vector_iset( well_rate->shift , i , shift ); else double_vector_iset( well_rate->shift , i , 0); } free( R ); }
static ecl_grav_phase_type * ecl_grav_phase_alloc( ecl_grav_type * ecl_grav , ecl_grav_survey_type * survey , ecl_phase_enum phase , const ecl_file_type * restart_file, grav_calc_type calc_type) { const ecl_file_type * init_file = ecl_grav->init_file; const ecl_grid_cache_type * grid_cache = ecl_grav->grid_cache; const char * sat_kw_name = ecl_util_get_phase_name( phase ); { ecl_grav_phase_type * grav_phase = util_malloc( sizeof * grav_phase ); const int size = ecl_grid_cache_get_size( grid_cache ); UTIL_TYPE_ID_INIT( grav_phase , ECL_GRAV_PHASE_TYPE_ID ); grav_phase->grid_cache = grid_cache; grav_phase->aquifer_cell = ecl_grav->aquifer_cell; grav_phase->fluid_mass = util_calloc( size , sizeof * grav_phase->fluid_mass ); grav_phase->phase = phase; grav_phase->work = NULL; if (calc_type == GRAV_CALC_FIP) { ecl_kw_type * pvtnum_kw = ecl_file_iget_named_kw( init_file , PVTNUM_KW , 0 ); double_vector_type * std_density = hash_get( ecl_grav->std_density , ecl_util_get_phase_name( phase )); ecl_kw_type * fip_kw; if ( phase == ECL_OIL_PHASE) fip_kw = ecl_file_iget_named_kw( restart_file , FIPOIL_KW , 0 ); else if (phase == ECL_GAS_PHASE) fip_kw = ecl_file_iget_named_kw( restart_file , FIPGAS_KW , 0 ); else fip_kw = ecl_file_iget_named_kw( restart_file , FIPWAT_KW , 0 ); { int iactive; for (iactive=0; iactive < size; iactive++) { double fip = ecl_kw_iget_as_double( fip_kw , iactive ); int pvtnum = ecl_kw_iget_int( pvtnum_kw , iactive ); grav_phase->fluid_mass[ iactive ] = fip * double_vector_safe_iget( std_density , pvtnum ); } } } else { ecl_version_enum ecl_version = ecl_file_get_ecl_version( init_file ); const char * den_kw_name = get_den_kw( phase , ecl_version ); const ecl_kw_type * den_kw = ecl_file_iget_named_kw( restart_file , den_kw_name , 0 ); if (calc_type == GRAV_CALC_RFIP) { ecl_kw_type * rfip_kw; if ( phase == ECL_OIL_PHASE) rfip_kw = ecl_file_iget_named_kw( restart_file , RFIPOIL_KW , 0 ); else if (phase == ECL_GAS_PHASE) rfip_kw = ecl_file_iget_named_kw( restart_file , RFIPGAS_KW , 0 ); else rfip_kw = ecl_file_iget_named_kw( restart_file , RFIPWAT_KW , 0 ); { int iactive; for (iactive=0; iactive < size; iactive++) { double rho = ecl_kw_iget_as_double( den_kw , iactive ); double rfip = ecl_kw_iget_as_double( rfip_kw , iactive ); grav_phase->fluid_mass[ iactive ] = rho * rfip; } } } else { /* (calc_type == GRAV_CALC_RPORV) || (calc_type == GRAV_CALC_PORMOD) */ ecl_kw_type * sat_kw; bool private_sat_kw = false; if (ecl_file_has_kw( restart_file , sat_kw_name )) sat_kw = ecl_file_iget_named_kw( restart_file , sat_kw_name , 0 ); else { /* We are targeting the residual phase, e.g. the OIL phase in a three phase system. */ const ecl_kw_type * swat_kw = ecl_file_iget_named_kw( restart_file , "SWAT" , 0 ); sat_kw = ecl_kw_alloc_copy( swat_kw ); ecl_kw_scalar_set_float( sat_kw , 1.0 ); ecl_kw_inplace_sub( sat_kw , swat_kw ); /* sat = 1 - SWAT */ if (ecl_file_has_kw( restart_file , "SGAS" )) { const ecl_kw_type * sgas_kw = ecl_file_iget_named_kw( restart_file , "SGAS" , 0 ); ecl_kw_inplace_sub( sat_kw , sgas_kw ); /* sat -= SGAS */ } private_sat_kw = true; } { int iactive; for (iactive=0; iactive < size; iactive++) { double rho = ecl_kw_iget_as_double( den_kw , iactive ); double sat = ecl_kw_iget_as_double( sat_kw , iactive ); grav_phase->fluid_mass[ iactive ] = rho * sat * survey->porv[ iactive ]; } } if (private_sat_kw) ecl_kw_free( sat_kw ); } } return grav_phase; } }
double well_rate_iget_rate( const well_rate_type * well_rate , int report_step ) { return double_vector_safe_iget( well_rate->base_value , report_step ); }