Esempio n. 1
0
static ecl_subsidence_survey_type * ecl_subsidence_survey_alloc_empty(const ecl_subsidence_type * sub,
                                                                      const char * name) {
  ecl_subsidence_survey_type * survey = util_malloc( sizeof * survey );
  UTIL_TYPE_ID_INIT( survey , ECL_SUBSIDENCE_SURVEY_ID );
  survey->grid_cache   = sub->grid_cache;
  survey->aquifer_cell = sub->aquifer_cell;
  survey->name         = util_alloc_string_copy( name );

  survey->porv     = util_calloc( ecl_grid_cache_get_size( sub->grid_cache ) , sizeof * survey->porv     );
  survey->pressure = util_calloc( ecl_grid_cache_get_size( sub->grid_cache ) , sizeof * survey->pressure );

  return survey;
}
Esempio n. 2
0
static double ecl_subsidence_survey_eval( const ecl_subsidence_survey_type * base_survey ,
                                          const ecl_subsidence_survey_type * monitor_survey,
                                          ecl_region_type * region ,
                                          double utm_x , double utm_y , double depth,
                                          double compressibility, double poisson_ratio) {

  const ecl_grid_cache_type * grid_cache = base_survey->grid_cache;
  const int size  = ecl_grid_cache_get_size( grid_cache );
  double * weight = util_calloc( size , sizeof * weight );
  double deltaz;
  int index;

  if (monitor_survey != NULL) {
    for (index = 0; index < size; index++)
      weight[index] = base_survey->porv[index] * (base_survey->pressure[index] - monitor_survey->pressure[index]);
  } else {
    for (index = 0; index < size; index++)
      weight[index] = base_survey->porv[index] * base_survey->pressure[index];
  }

  deltaz = compressibility * 31.83099*(1-poisson_ratio) *
    ecl_grav_common_eval_biot_savart( grid_cache , region , base_survey->aquifer_cell , weight , utm_x , utm_y , depth );

  free( weight );
  return deltaz;
}
Esempio n. 3
0
static double ecl_subsidence_survey_eval_geertsma( const ecl_subsidence_survey_type * base_survey ,
                                                   const ecl_subsidence_survey_type * monitor_survey,
                                                   ecl_region_type * region ,
                                                   double utm_x , double utm_y , double depth,
                                                   double youngs_modulus, double poisson_ratio) {

  const ecl_grid_cache_type * grid_cache = base_survey->grid_cache;
  const double * cell_volume = ecl_grid_cache_get_volume( grid_cache );
  const int size  = ecl_grid_cache_get_size( grid_cache );
  double scale_factor = 1e4 *(1 + poisson_ratio) * ( 1 - 2*poisson_ratio) / ( 4*M_PI*( 1 - poisson_ratio)  * youngs_modulus );
  double * weight = util_calloc( size , sizeof * weight );
  double deltaz;

  for (int index = 0; index < size; index++) {
    if (monitor_survey) {
        weight[index] = - scale_factor * cell_volume[index] * (monitor_survey->pressure[index] - base_survey->pressure[index]);
    } else {
        weight[index] = - scale_factor * cell_volume[index] * (base_survey->pressure[index] );
    }
  }

  deltaz = ecl_grav_common_eval_geertsma( grid_cache , region , base_survey->aquifer_cell , weight , utm_x , utm_y , depth , poisson_ratio);

  free( weight );
  return deltaz;
}
Esempio n. 4
0
static void ecl_grav_survey_assert_RPORV( const ecl_grav_survey_type * survey , const ecl_file_type * init_file ) {
  const ecl_grid_cache_type * grid_cache = survey->grid_cache;
  int   active_size                      = ecl_grid_cache_get_size( grid_cache );
  const ecl_kw_type * init_porv_kw       = ecl_file_iget_named_kw( init_file , PORV_KW , 0);
  int check_points                       = 100;     
  int check_nr                           = 0;
  
  while (check_nr < check_points) {
    int active_index    = rand() % active_size;
    int    global_index = ecl_grid_cache_iget_global_index( grid_cache , active_index );

    double init_porv    = ecl_kw_iget_as_double( init_porv_kw , global_index );    /* NB - this uses global indexing. */
    if (init_porv > 0) {
      double rporv      = survey->porv[ active_index ];                           
      double log_pormod = log10( rporv / init_porv );   
      
      if (fabs( log_pormod ) > 1) {  
        /* Detected as error if the effective pore volume multiplier
           is greater than 10 or less than 0.10. */
        fprintf(stderr,"-----------------------------------------------------------------\n");
        fprintf(stderr,"INIT PORV : %g \n",init_porv);
        fprintf(stderr,"RPORV     : %g \n",rporv);
        fprintf(stderr,"Hmmm - the RPORV values extracted from the restart file seem to be \n");
        fprintf(stderr,"veeery different from the initial porv value. This might indicate \n");
        fprintf(stderr,"an ECLIPSE bug in the RPORV handling. Try using another ECLIPSE version,\n");
        fprintf(stderr,"or alternatively the PORMOD approach instead\n");
        fprintf(stderr,"-----------------------------------------------------------------\n");
        exit(1);
      }
      check_nr++;
    }
  }
}
Esempio n. 5
0
static double ecl_grav_phase_eval( ecl_grav_phase_type * base_phase , 
                                   const ecl_grav_phase_type * monitor_phase,
                                   ecl_region_type * region , 
                                   double utm_x , double utm_y , double depth) {

  ecl_grav_phase_ensure_work( base_phase );
  if ((monitor_phase == NULL) || (base_phase->phase == monitor_phase->phase)) {
    const ecl_grid_cache_type * grid_cache = base_phase->grid_cache;
    const bool   * aquifer   = base_phase->aquifer_cell;
    double * mass_diff       = base_phase->work;
    double deltag;
    /* 
       Initialize a work array to contain the difference in mass for
       every cell.
    */
    {
      int index;
      if (monitor_phase == NULL) {
        for (index = 0; index < ecl_grid_cache_get_size( grid_cache ); index++)
          mass_diff[index] = - base_phase->fluid_mass[index];
      } else {
        for (index = 0; index < ecl_grid_cache_get_size( grid_cache ); index++)
          mass_diff[index] = monitor_phase->fluid_mass[index] - base_phase->fluid_mass[index];
      }
    }
      
    /**
       The Gravitational constant is 6.67E-11 N (m/kg)^2, we
       return the result in microGal, i.e. we scale with 10^2 * 
       10^6 => 6.67E-3.
    */
    deltag = 6.67428E-3 * ecl_grav_common_eval_biot_savart( grid_cache , region , aquifer , mass_diff , utm_x , utm_y , depth);
    
    return deltag;
  } else {
    util_abort("%s comparing different phases ... \n",__func__);
    return -1;
  }
}
Esempio n. 6
0
static ecl_subsidence_survey_type * ecl_subsidence_survey_alloc_PRESSURE(ecl_subsidence_type * ecl_subsidence ,
                                                                         const ecl_file_view_type * restart_view ,
                                                                         const char * name ) {

  ecl_subsidence_survey_type * survey = ecl_subsidence_survey_alloc_empty( ecl_subsidence , name );
  ecl_grid_cache_type * grid_cache = ecl_subsidence->grid_cache;
  const int * global_index = ecl_grid_cache_get_global_index( grid_cache );
  const int size = ecl_grid_cache_get_size( grid_cache );
  int active_index;
  ecl_kw_type * init_porv_kw = ecl_file_iget_named_kw( ecl_subsidence->init_file , PORV_KW , 0); /*Global indexing*/
  ecl_kw_type * pressure_kw = ecl_file_view_iget_named_kw( restart_view , PRESSURE_KW , 0); /*Active indexing*/

  for (active_index = 0; active_index < size; active_index++){
    survey->porv[ active_index ] = ecl_kw_iget_float( init_porv_kw , global_index[active_index] );
    survey->pressure[ active_index ] = ecl_kw_iget_float( pressure_kw , active_index );
  }
  return survey;
}
Esempio n. 7
0
static ecl_grav_survey_type * ecl_grav_survey_alloc_PORMOD(ecl_grav_type * ecl_grav , 
                                                           const ecl_file_type * restart_file , 
                                                           const char * name ) {
  ecl_grid_cache_type * grid_cache = ecl_grav->grid_cache;
  ecl_grav_survey_type * survey = ecl_grav_survey_alloc_empty( ecl_grav , name , GRAV_CALC_PORMOD);
  ecl_kw_type * init_porv_kw    = ecl_file_iget_named_kw( ecl_grav->init_file    , PORV_KW   , 0 );  /* Global indexing */
  ecl_kw_type * pormod_kw       = ecl_file_iget_named_kw( restart_file , PORMOD_KW , 0 );            /* Active indexing */
  const int size                = ecl_grid_cache_get_size( grid_cache ); 
  const int * global_index      = ecl_grid_cache_get_global_index( grid_cache );
  int active_index;

  for (active_index = 0; active_index < size; active_index++) 
    survey->porv[ active_index ] = ecl_kw_iget_float( pormod_kw , active_index ) * ecl_kw_iget_float( init_porv_kw , global_index[active_index] );
  
  ecl_grav_survey_add_phases( ecl_grav , survey , restart_file , GRAV_CALC_PORMOD);
  
  return survey;
}
Esempio n. 8
0
static ecl_grav_survey_type * ecl_grav_survey_alloc_empty(const ecl_grav_type * ecl_grav , 
                                                          const char * name , 
                                                          grav_calc_type calc_type) {
  ecl_grav_survey_type * survey = util_malloc( sizeof * survey );
  UTIL_TYPE_ID_INIT( survey , ECL_GRAV_SURVEY_ID );
  survey->grid_cache   = ecl_grav->grid_cache;
  survey->aquifer_cell = ecl_grav->aquifer_cell;
  survey->name         = util_alloc_string_copy( name );
  survey->phase_list   = vector_alloc_new();
  survey->phase_map    = hash_alloc();

  if (calc_type & GRAV_CALC_USE_PORV)
    survey->porv       = util_calloc( ecl_grid_cache_get_size( ecl_grav->grid_cache ) , sizeof * survey->porv );
  else
    survey->porv       = NULL;

  return survey;
}
Esempio n. 9
0
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;
  }
}
Esempio n. 10
0
static void ecl_grav_phase_ensure_work( ecl_grav_phase_type * grav_phase) {
  if (grav_phase->work == NULL)
    grav_phase->work = util_calloc( ecl_grid_cache_get_size( grav_phase->grid_cache ) , sizeof * grav_phase->work  );
}