示例#1
0
 void PolymerProperties::effectiveInvViscBoth(const double c, const double* visc,
                                              double& inv_mu_w_eff,
                                              double& dinv_mu_w_eff_dc,
                                              bool if_with_der) const {
     double cbar = c/c_max_;
     double mu_w = visc[0];
     double mu_m;
     double omega = mix_param_;
     double dmu_m_dc;
     if (if_with_der) {
         mu_m = viscMultWithDer(c, &dmu_m_dc)*mu_w;
         dmu_m_dc *= mu_w;
     } else {
         mu_m = viscMult(c)*mu_w;
     }
     double mu_p = viscMult(c_max_)*mu_w;
     double inv_mu_m_omega = std::pow(mu_m, -omega);
     double inv_mu_w_e   = inv_mu_m_omega*std::pow(mu_w, omega - 1.);
     double inv_mu_p_eff = inv_mu_m_omega*std::pow(mu_p, omega - 1.);
     inv_mu_w_eff = (1.0 - cbar)*inv_mu_w_e + cbar*inv_mu_p_eff;
     if (if_with_der) {
         double dinv_mu_w_e_dc = -omega*dmu_m_dc*std::pow(mu_m, -omega - 1)*std::pow(mu_w, omega - 1);
         double dinv_mu_p_eff_dc = -omega*dmu_m_dc*std::pow(mu_m, -omega - 1)*std::pow(mu_p, omega - 1);
         dinv_mu_w_eff_dc = (1 - cbar)*dinv_mu_w_e_dc + cbar*dinv_mu_p_eff_dc +
             1/c_max_*(inv_mu_p_eff - inv_mu_w_e);
     }
 }
示例#2
0
 void PolymerProperties::computeMcBoth(const double& c, double& mc,
                                       double& dmc_dc, bool if_with_der) const
 {
     double cbar = c/c_max_;
     double omega = mix_param_;
     double r = std::pow(viscMult(c_max_), 1 - omega); // viscMult(c_max_)=mu_p/mu_w
     mc = c/(cbar + (1 - cbar)*r);
     if (if_with_der) {
         dmc_dc = r/std::pow(cbar + (1 - cbar)*r, 2);
     } else {
         dmc_dc = 0.;
     }
 }
bool PolymerProperties::computeShearMultLog(std::vector<double>& water_vel, std::vector<double>& visc_mult, std::vector<double>& shear_mult) const
{

    double refConcentration = plyshlogRefConc();
    double refViscMult = viscMult(refConcentration);

    std::vector<double> shear_water_vel = shearWaterVelocity();
    std::vector<double> shear_vrf = shearViscosityReductionFactor();

    std::vector<double> logShearWaterVel;
    std::vector<double> logShearVRF;

    logShearWaterVel.resize(shear_water_vel.size());
    logShearVRF.resize(shear_water_vel.size());

    // converting the table using the reference condition
    for (size_t i = 0; i < shear_vrf.size(); ++i) {
        shear_vrf[i] = (refViscMult * shear_vrf[i] - 1.) / (refViscMult - 1);
        logShearWaterVel[i] = std::log(shear_water_vel[i]);
    }

    shear_mult.resize(water_vel.size());

    // the mimum velocity to apply the shear-thinning
    const double minShearVel = shear_water_vel[0];
    const double maxShearVel = shear_water_vel.back();
    const double epsilon = std::sqrt(std::numeric_limits<double>::epsilon());

    for (size_t i = 0; i < water_vel.size(); ++i) {

        if (visc_mult[i] - 1. < epsilon || std::abs(water_vel[i]) < minShearVel) {
            shear_mult[i] = 1.0;
            continue;
        }

        for (size_t j = 0; j < shear_vrf.size(); ++j) {
            logShearVRF[j] = (1 + (visc_mult[i] - 1.0) * shear_vrf[j]) / visc_mult[i];
            logShearVRF[j] = std::log(logShearVRF[j]);
        }

        // const double logWaterVelO = std::log(water_vel[i]);
        const double logWaterVelO = std::log(std::abs(water_vel[i]));

        size_t iIntersection; // finding the intersection on the iIntersectionth table segment
        bool foundSegment = false;

        for (iIntersection = 0; iIntersection < shear_vrf.size() - 1; ++iIntersection) {

            double temp1 = logShearVRF[iIntersection] + logShearWaterVel[iIntersection] - logWaterVelO;
            double temp2 = logShearVRF[iIntersection + 1] + logShearWaterVel[iIntersection + 1] - logWaterVelO;

            // ignore the cases the temp1 or temp2 is zero first for simplicity.
            // several more complicated cases remain to be implemented.
            if( temp1 * temp2 < 0.) {
                foundSegment = true;
                break;
            }
        }

        if (foundSegment == true) {
            detail::Point2D lineSegment[2];
            lineSegment[0] = detail::Point2D{logShearWaterVel[iIntersection], logShearVRF[iIntersection]};
            lineSegment[1] = detail::Point2D{logShearWaterVel[iIntersection + 1], logShearVRF[iIntersection + 1]};

            detail::Point2D line[2];
            line[0] = detail::Point2D{0, logWaterVelO};
            line[1] = detail::Point2D{logWaterVelO, 0};

            detail::Point2D intersectionPoint;

            bool foundIntersection = detail::Point2D::findIntersection(lineSegment, line, intersectionPoint);

            if (foundIntersection) {
                shear_mult[i] = std::exp(intersectionPoint.getY());
            } else {
                std::cerr << " failed in finding the solution for shear-thinning multiplier " << std::endl;
                return false; // failed in finding the solution.
            }
        } else {
            if (std::abs(water_vel[i]) < maxShearVel) {
                std::cout << " the veclocity is " << water_vel[i] << std::endl;
                std::cout << " max shear velocity is " << maxShearVel << std::endl;
                std::cerr << " something wrong happend in finding segment" << std::endl;
                return false;
            } else {
                shear_mult[i] = std::exp(logShearVRF.back());
            }
        }

    }

    return true;
}