Ejemplo n.º 1
0
 double PvtLiveOil::miscible_oil(const double press,
                                 const double* surfvol,
                                 const int pvtTableIdx,
                                 const int item,
                                 const bool deriv) const
 {
     int section;
     double Rval = linearInterpolation(saturated_oil_table_[pvtTableIdx][0],
                                       saturated_oil_table_[pvtTableIdx][3],
                                       press, section);
     double maxR = (surfvol[phase_pos_[Liquid]] == 0.0) ? 0.0 : surfvol[phase_pos_[Vapour]]/surfvol[phase_pos_[Liquid]];
     if (deriv) {
         if (Rval < maxR ) {  // Saturated case
             return linearInterpolationDerivative(saturated_oil_table_[pvtTableIdx][0],
                                                  saturated_oil_table_[pvtTableIdx][item],
                                                  press);
         } else {  // Undersaturated case
             int is = tableIndex(saturated_oil_table_[pvtTableIdx][3], maxR);
             double w = (maxR - saturated_oil_table_[pvtTableIdx][3][is]) /
                 (saturated_oil_table_[pvtTableIdx][3][is+1] - saturated_oil_table_[pvtTableIdx][3][is]);
             assert(undersat_oil_tables_[pvtTableIdx][is][0].size() >= 2);
             assert(undersat_oil_tables_[pvtTableIdx][is+1][0].size() >= 2);
             double val1 =
                 linearInterpolationDerivative(undersat_oil_tables_[pvtTableIdx][is][0],
                                               undersat_oil_tables_[pvtTableIdx][is][item],
                                               press);
             double val2 =
                 linearInterpolationDerivative(undersat_oil_tables_[pvtTableIdx][is+1][0],
                                               undersat_oil_tables_[pvtTableIdx][is+1][item],
                                               press);
             double val = val1 + w*(val2 - val1);
             return val;
         }
     } else {
         if (Rval < maxR ) {  // Saturated case
             return linearInterpolation(saturated_oil_table_[pvtTableIdx][0],
                                        saturated_oil_table_[pvtTableIdx][item],
                                        press);
         } else {  // Undersaturated case
             // Interpolate between table sections
             int is = tableIndex(saturated_oil_table_[pvtTableIdx][3], maxR);
             double w = (maxR - saturated_oil_table_[pvtTableIdx][3][is]) /
                 (saturated_oil_table_[pvtTableIdx][3][is+1] - saturated_oil_table_[pvtTableIdx][3][is]);
             assert(undersat_oil_tables_[pvtTableIdx][is][0].size() >= 2);
             assert(undersat_oil_tables_[pvtTableIdx][is+1][0].size() >= 2);
             double val1 =
                 linearInterpolation(undersat_oil_tables_[pvtTableIdx][is][0],
                                     undersat_oil_tables_[pvtTableIdx][is][item],
                                     press);
             double val2 =
                 linearInterpolation(undersat_oil_tables_[pvtTableIdx][is+1][0],
                                     undersat_oil_tables_[pvtTableIdx][is+1][item],
                                     press);
             double val = val1 + w*(val2 - val1);
             return val;
         }
     }
 }
Ejemplo n.º 2
0
    double SinglePvtLiveOil::miscible_oil(const double press,
                                          const double r,
                                          const PhasePresence& cond,
                                          const int item,
                                          const int deriv) const
    {
        const bool isSat = cond.hasFreeGas();

        // derivative with respect to frist component (pressure)
        if (deriv == 1) {
            if (isSat) {  // Saturated case
                return linearInterpolationDerivative(saturated_oil_table_[0],
                                                saturated_oil_table_[item],
                                                press);
            } else {  // Undersaturated case
                int is = tableIndex(saturated_oil_table_[3], r);
                double w = (r - saturated_oil_table_[3][is]) /
                    (saturated_oil_table_[3][is+1] - saturated_oil_table_[3][is]);
                assert(undersat_oil_tables_[is][0].size() >= 2);
                assert(undersat_oil_tables_[is+1][0].size() >= 2);
                double val1 =
                    linearInterpolationDerivative(undersat_oil_tables_[is][0],
                                             undersat_oil_tables_[is][item],
                                             press);
                double val2 =
                    linearInterpolationDerivative(undersat_oil_tables_[is+1][0],
                                             undersat_oil_tables_[is+1][item],
                                             press);
                double val = val1 + w*(val2 - val1);
                return val;
            }
            // derivative with respect to second component (r)
        } else if (deriv == 2)  {
            if (isSat) {  // Saturated case
                return 0;
            } else {  // Undersaturated case
                int is = tableIndex(saturated_oil_table_[3], r);
                assert(undersat_oil_tables_[is][0].size() >= 2);
                assert(undersat_oil_tables_[is+1][0].size() >= 2);
                double val1 =
                    linearInterpolation(undersat_oil_tables_[is][0],
                                              undersat_oil_tables_[is][item],
                                              press);
                double val2 =
                    linearInterpolation(undersat_oil_tables_[is+1][0],
                                              undersat_oil_tables_[is+1][item],
                                              press);

                double val = (val2 - val1)/(saturated_oil_table_[3][is+1]-saturated_oil_table_[3][is]);
                return val;
            }


            }    else {
            if (isSat) {  // Saturated case
                return linearInterpolation(saturated_oil_table_[0],
                                                 saturated_oil_table_[item],
                                                 press);
            } else {  // Undersaturated case
                // Interpolate between table sections
                int is = tableIndex(saturated_oil_table_[3], r);
                double w = (r - saturated_oil_table_[3][is]) /
                    (saturated_oil_table_[3][is+1] - saturated_oil_table_[3][is]);
                assert(undersat_oil_tables_[is][0].size() >= 2);
                assert(undersat_oil_tables_[is+1][0].size() >= 2);
                double val1 =
                    linearInterpolation(undersat_oil_tables_[is][0],
                                              undersat_oil_tables_[is][item],
                                              press);
                double val2 =
                    linearInterpolation(undersat_oil_tables_[is+1][0],
                                              undersat_oil_tables_[is+1][item],
                                              press);
                double val = val1 + w*(val2 - val1);
                return val;
            }
        }
    }
Ejemplo n.º 3
0
    double PvtLiveOil::miscible_oil(const double press,
                                    const double r,
                                    const int pvtTableIdx,
                                    const int item,
                                    const int deriv) const
    {
        int section;
        double Rval = linearInterpolation(saturated_oil_table_[pvtTableIdx][0],
                                          saturated_oil_table_[pvtTableIdx][3],
                                          press, section);
        // derivative with respect to frist component (pressure)
        if (deriv == 1) {
            if (Rval <= r ) {  // Saturated case
                return linearInterpolationDerivative(saturated_oil_table_[pvtTableIdx][0],
                                                     saturated_oil_table_[pvtTableIdx][item],
                                                     press);
            } else {  // Undersaturated case
                int is = tableIndex(saturated_oil_table_[pvtTableIdx][3], r);
                double w = (r - saturated_oil_table_[pvtTableIdx][3][is]) /
                    (saturated_oil_table_[pvtTableIdx][3][is+1] - saturated_oil_table_[pvtTableIdx][3][is]);
                assert(undersat_oil_tables_[pvtTableIdx][is][0].size() >= 2);
                assert(undersat_oil_tables_[pvtTableIdx][is+1][0].size() >= 2);
                double val1 =
                    linearInterpolationDerivative(undersat_oil_tables_[pvtTableIdx][is][0],
                                             undersat_oil_tables_[pvtTableIdx][is][item],
                                             press);
                double val2 =
                    linearInterpolationDerivative(undersat_oil_tables_[pvtTableIdx][is+1][0],
                                             undersat_oil_tables_[pvtTableIdx][is+1][item],
                                             press);
                double val = val1 + w*(val2 - val1);
                return val;
            }
            // derivative with respect to second component (r)
        } else if (deriv == 2)  {
            if (Rval <= r ) {  // Saturated case
                return 0;
            } else {  // Undersaturated case
                int is = tableIndex(saturated_oil_table_[pvtTableIdx][3], r);
                assert(undersat_oil_tables_[pvtTableIdx][is][0].size() >= 2);
                assert(undersat_oil_tables_[pvtTableIdx][is+1][0].size() >= 2);
                double val1 =
                    linearInterpolation(undersat_oil_tables_[pvtTableIdx][is][0],
                                              undersat_oil_tables_[pvtTableIdx][is][item],
                                              press);
                double val2 =
                    linearInterpolation(undersat_oil_tables_[pvtTableIdx][is+1][0],
                                              undersat_oil_tables_[pvtTableIdx][is+1][item],
                                              press);

                double val = (val2 - val1)/(saturated_oil_table_[pvtTableIdx][3][is+1]-saturated_oil_table_[pvtTableIdx][3][is]);
                return val;
            }


            }    else {
            if (Rval <= r ) {  // Saturated case
                return linearInterpolation(saturated_oil_table_[pvtTableIdx][0],
                                           saturated_oil_table_[pvtTableIdx][item],
                                           press);
            } else {  // Undersaturated case
                // Interpolate between table sections
                int is = tableIndex(saturated_oil_table_[pvtTableIdx][3], r);
                double w = (r - saturated_oil_table_[pvtTableIdx][3][is]) /
                    (saturated_oil_table_[pvtTableIdx][3][is+1] - saturated_oil_table_[pvtTableIdx][3][is]);
                assert(undersat_oil_tables_[pvtTableIdx][is][0].size() >= 2);
                assert(undersat_oil_tables_[pvtTableIdx][is+1][0].size() >= 2);
                double val1 =
                    linearInterpolation(undersat_oil_tables_[pvtTableIdx][is][0],
                                              undersat_oil_tables_[pvtTableIdx][is][item],
                                              press);
                double val2 =
                    linearInterpolation(undersat_oil_tables_[pvtTableIdx][is+1][0],
                                              undersat_oil_tables_[pvtTableIdx][is+1][item],
                                              press);
                double val = val1 + w*(val2 - val1);
                return val;
            }
        }
    }