Esempio n. 1
0
doublereal WaterProps::ADebye(doublereal T, doublereal P_input, int ifunc)
{
    doublereal psat = satPressure(T);
    doublereal P;
    if (psat > P_input) {
        P = psat;
    } else {
        P = P_input;
    }
    doublereal epsRelWater = relEpsilon(T, P, 0);
    doublereal epsilon = epsilon_0 * epsRelWater;
    doublereal dw = density_IAPWS(T, P);
    doublereal tmp = sqrt(2.0 * Avogadro * dw / 1000.);
    doublereal tmp2 = ElectronCharge * ElectronCharge * Avogadro /
                      (epsilon * GasConstant * T);
    doublereal tmp3 = tmp2 * sqrt(tmp2);
    doublereal A_Debye = tmp * tmp3 / (8.0 * Pi);

    // dAdT = - 3/2 Ad/T + 1/2 Ad/dw d(dw)/dT - 3/2 Ad/eps d(eps)/dT
    // dAdT = - 3/2 Ad/T - 1/2 Ad/Vw d(Vw)/dT - 3/2 Ad/eps d(eps)/dT
    if (ifunc == 1 || ifunc == 2) {
        doublereal dAdT = - 1.5 * A_Debye / T;

        doublereal depsRelWaterdT = relEpsilon(T, P, 1);
        dAdT -= A_Debye * (1.5 * depsRelWaterdT / epsRelWater);

        // calculate d(lnV)/dT _constantP, i.e., the cte
        doublereal cte = coeffThermalExp_IAPWS(T, P);
        doublereal contrib2 = - A_Debye * (0.5 * cte);
        dAdT += contrib2;

        if (ifunc == 1) {
            return dAdT;
        }

        if (ifunc == 2) {
            // Get the second derivative of the dielectric constant wrt T
            // -> we will take each of the terms in dAdT and differentiate
            //    it again.
            doublereal d2AdT2 = 1.5 / T * (A_Debye/T - dAdT);
            doublereal d2epsRelWaterdT2 = relEpsilon(T, P, 2);
            d2AdT2 += 1.5 * (- dAdT * depsRelWaterdT / epsRelWater
                             - A_Debye / epsRelWater *
                             (d2epsRelWaterdT2 - depsRelWaterdT * depsRelWaterdT / epsRelWater));
            doublereal deltaT = -0.1;
            doublereal Tdel = T + deltaT;
            doublereal cte_del = coeffThermalExp_IAPWS(Tdel, P);
            doublereal dctedT = (cte_del - cte) / Tdel;
            doublereal contrib3 = 0.5 * (-(dAdT * cte) -(A_Debye * dctedT));
            d2AdT2 += contrib3;
            return d2AdT2;
        }
    }

    // A_Debye = (1/(8 Pi)) sqrt(2 Na dw / 1000)
    //                          (e e/(epsilon R T))^3/2
    //
    // dAdP =  + 1/2 Ad/dw d(dw)/dP - 3/2 Ad/eps d(eps)/dP
    // dAdP =  - 1/2 Ad/Vw d(Vw)/dP - 3/2 Ad/eps d(eps)/dP
    // dAdP =  + 1/2 Ad * kappa  - 3/2 Ad/eps d(eps)/dP
    //
    // where kappa = - 1/Vw d(Vw)/dP_T (isothermal compressibility)
    if (ifunc == 3) {
        doublereal dAdP = 0.0;
        doublereal depsRelWaterdP = relEpsilon(T, P, 3);
        dAdP -= A_Debye * (1.5 * depsRelWaterdP / epsRelWater);
        doublereal kappa = isothermalCompressibility_IAPWS(T,P);
        dAdP += A_Debye * (0.5 * kappa);
        return dAdP;
    }
    return A_Debye;
}
Esempio n. 2
0
  /**
   * ADebye calculates the value of A_Debye as a function
   * of temperature and pressure according to relations
   * that take into account the temperature and pressure
   * dependence of the water density and dieletric constant.
   *
   * A_Debye -> this expression appears on the top of the
   *            ln actCoeff term in the general Debye-Huckel
   *            expression
   *            It depends on temperature. And, therefore,
   *            most be recalculated whenever T or P changes.
   *            
   *            A_Debye = (1/(8 Pi)) sqrt(2 Na dw / 1000) 
   *                          (e e/(epsilon R T))^3/2
   *
   *            Units = sqrt(kg/gmol) ~ sqrt(1/I)
   *
   *            Nominal value = 1.172576 sqrt(kg/gmol)
   *                  based on:
   *                    epsilon/epsilon_0 = 78.54
   *                           (water at 25C)
   *                    epsilon_0 = 8.854187817E-12 C2 N-1 m-2
   *                    e = 1.60217653E-19 C
   *                    F = 9.6485309E7 C kmol-1
   *                    R = 8.314472E3 kg m2 s-2 kmol-1 K-1
   *                    T = 298.15 K
   *                    B_Debye = 3.28640E9 sqrt(kg/gmol)/m
   *                    Na = 6.0221415E26
   *
   * ifunc = 0 return value
   * ifunc = 1 return temperature derivative
   * ifunc = 2 return temperature second derivative
   * ifunc = 3 return pressure first derivative
   *
   *  Verification:
   *    With the epsRelWater value from the BP relation,
   *    and the water density from the WaterDens function,
   *    The A_Debye computed with this function agrees with
   *    the Pitzer table p. 99 to 4 significant digits at 25C.
   *    and 20C. (Aphi = ADebye/3)
   * 
   * (statically defined within the object)
   */
  double WaterProps::ADebye(double T, double P_input, int ifunc) {
    const double e =  1.60217653E-19;
    const double epsilon0 =  8.854187817E-12;
    const double R = 8.314472E3;
    double psat = satPressure(T);
    double P;
    if (psat > P_input) {
      //printf("ADebye WARNING: p_input < psat: %g %g\n",
      // P_input, psat);
      P = psat;
    } else {
      P = P_input;
    }
    double epsRelWater = relEpsilon(T, P, 0);
    //printf("releps calc = %g, compare to 78.38\n", epsRelWater);
    //double B_Debye = 3.28640E9;
    const double Na = 6.0221415E26;

    double epsilon = epsilon0 * epsRelWater;
    double dw = density_IAPWS(T, P);
    double tmp = sqrt( 2.0 * Na * dw / 1000.);
    double tmp2 = e * e * Na / (epsilon * R * T);
    double tmp3 = tmp2 * sqrt(tmp2);
    double A_Debye = tmp * tmp3 / (8.0 * Pi);


    /*
     *  dAdT = - 3/2 Ad/T + 1/2 Ad/dw d(dw)/dT - 3/2 Ad/eps d(eps)/dT
     *
     *  dAdT = - 3/2 Ad/T - 1/2 Ad/Vw d(Vw)/dT - 3/2 Ad/eps d(eps)/dT
     */
    if (ifunc == 1 || ifunc == 2) {
      double dAdT = - 1.5 * A_Debye / T;

      double depsRelWaterdT = relEpsilon(T, P, 1);
      dAdT -= A_Debye * (1.5 * depsRelWaterdT / epsRelWater);

      //int methodD = 1;
      //double ddwdT = density_T_new(T, P, 1);
      // double contrib1 = A_Debye * (0.5 * ddwdT / dw);
         
      /*
       * calculate d(lnV)/dT _constantP, i.e., the cte
       */
      double cte = coeffThermalExp_IAPWS(T, P);
      double contrib2 =  - A_Debye * (0.5 * cte);

      //dAdT += A_Debye * (0.5 * ddwdT / dw);
      dAdT += contrib2;

#ifdef DEBUG_HKM
      //printf("dAdT = %g, contrib1 = %g, contrib2 = %g\n", 
      //	 dAdT, contrib1, contrib2);
#endif
 
      if (ifunc == 1) {
	return dAdT;
      }

      if (ifunc == 2) {
	/*
	 * Get the second derivative of the dielectric constant wrt T
	 * -> we will take each of the terms in dAdT and differentiate
	 *    it again.
	 */
	double d2AdT2 = 1.5 / T * (A_Debye/T - dAdT);

	double d2epsRelWaterdT2 = relEpsilon(T, P, 2);

	//double dT = -0.01;
	//double TT = T + dT;
	//double depsRelWaterdTdel = relEpsilon(TT, P, 1);
	//double d2alt = (depsRelWaterdTdel- depsRelWaterdT ) / dT;
	//printf("diff %g %g\n",d2epsRelWaterdT2, d2alt); 
	// HKM -> checks out, i.e., they are the same.

	d2AdT2 += 1.5 * (- dAdT * depsRelWaterdT / epsRelWater 
			 - A_Debye / epsRelWater * 
			 (d2epsRelWaterdT2 - depsRelWaterdT * depsRelWaterdT / epsRelWater));
	    
	double deltaT = -0.1;
	double Tdel = T + deltaT;
	double cte_del =  coeffThermalExp_IAPWS(Tdel, P);
	double dctedT = (cte_del - cte) / Tdel;
	    
	   
	//double d2dwdT2 = density_T_new(T, P, 2);

	double contrib3 = 0.5 * ( -(dAdT * cte) -(A_Debye * dctedT));
	d2AdT2 += contrib3;

	return d2AdT2;
      }
    }
    /*
     *  A_Debye = (1/(8 Pi)) sqrt(2 Na dw / 1000) 
     *                          (e e/(epsilon R T))^3/2
     *
     *  dAdP =  + 1/2 Ad/dw d(dw)/dP - 3/2 Ad/eps d(eps)/dP
     *
     *  dAdP =  - 1/2 Ad/Vw d(Vw)/dP - 3/2 Ad/eps d(eps)/dP
     *
     *  dAdP =  + 1/2 Ad * kappa  - 3/2 Ad/eps d(eps)/dP
     *
     *  where kappa = - 1/Vw d(Vw)/dP_T (isothermal compressibility)
     */
    if (ifunc == 3) {
	  
      double dAdP = 0.0;
	  
      double depsRelWaterdP = relEpsilon(T, P, 3);
      dAdP -=  A_Debye * (1.5 * depsRelWaterdP / epsRelWater);
	  
      double kappa = isothermalCompressibility_IAPWS(T,P);

      //double ddwdP = density_T_new(T, P, 3);
      dAdP += A_Debye * (0.5 * kappa);

      return dAdP;
    }

    return A_Debye;
  }