WaterPropsIAPWSphi.cpp

Go to the documentation of this file.
00001 /**
00002  * @file WaterPropsIAPWSphi.cpp
00003  *  Definitions for Lowest level of the classes which support a real water model
00004  *  (see class \link Cantera::WaterPropsIAPWS WaterPropsIAPWS\endlink and class  #WaterPropsIAPWSphi).
00005  */
00006 /*
00007  * Copywrite (2006) Sandia Corporation. Under the terms of
00008  * Contract DE-AC04-94AL85000 with Sandia Corporation, the
00009  * U.S. Government retains certain rights in this software.
00010  */
00011 /*
00012  * $Id: WaterPropsIAPWSphi.cpp 311 2009-12-11 01:32:26Z hkmoffa $
00013  */
00014 
00015 #include "WaterPropsIAPWSphi.h"
00016 
00017 #include <cstdio>
00018 #include <cmath>
00019 
00020 using std::printf;
00021 using std::sqrt;
00022 using std::log;
00023 using std::exp;
00024 using std::pow;
00025 using std::fabs;
00026 
00027 /*
00028  * Critical Point values in mks units: Note, these aren't used in this 
00029  * routine, except for internal checks. All calculations here are done
00030  * in dimensionless units.
00031  */
00032 static const doublereal  T_c = 647.096;  // Kelvin
00033 static const doublereal  P_c = 22.064E6; // Pascals
00034 static const doublereal  Rho_c = 322.;    // kg m-3
00035 static const doublereal  M_water = 18.015268; // kg kmol-1
00036 
00037 /*
00038  * The added constants were calculated so that u = s = 0
00039  * for liquid at the triple point. These where determined
00040  * by the program testPress. I'm not quite satisfied with
00041  * the result, but will let it stand for the moment.
00042  * H didn't turn out to be .611872 J/kg, but .611782 J/kg.
00043  * There may be a slight error here somehow.
00044  */
00045 static const doublereal  ni0[9] = {
00046   0.0,
00047   -8.32044648201 - 0.000000001739715,
00048   6.6832105268   + 0.000000000793232,
00049   3.00632,
00050   0.012436,
00051   0.97315,
00052   1.27950,
00053   0.96956,
00054   0.24873
00055 };
00056 
00057 static const doublereal  gammi0[9] = {
00058   0.0,
00059   0.0,
00060   0.0,
00061   0.0,
00062   1.28728967,
00063   3.53734222,
00064   7.74073708,
00065   9.24437796,
00066   27.5075105
00067 };
00068 
00069 static const int ciR[56] = {
00070   0,  //  0
00071   0,  //  1
00072   0,
00073   0,
00074   0,
00075   0,  //  5
00076   0,
00077   0,
00078   1,
00079   1,
00080   1,  // 10
00081   1,
00082   1,
00083   1,
00084   1,
00085   1,  // 15
00086   1,
00087   1,
00088   1,
00089   1,
00090   1,  // 20
00091   1,   
00092   1,
00093   2,
00094   2,
00095   2,  // 25
00096   2,
00097   2,
00098   2,
00099   2,
00100   2,  // 30
00101   2,
00102   2,
00103   2,
00104   2,
00105   2,  // 35
00106   2,
00107   2,
00108   2,
00109   2,
00110   2,  // 40
00111   2,
00112   2,
00113   3,
00114   3,
00115   3,  // 45
00116   3,
00117   4,
00118   6,
00119   6,
00120   6,  // 50
00121   6,
00122   0,
00123   0,
00124   0,
00125   0   // 55
00126 };
00127 
00128 static const int diR[55] = {
00129   0,  //  0
00130   1,  //  1
00131   1,
00132   1,
00133   2,
00134   2,  //  5
00135   3,
00136   4,
00137   1,
00138   1,
00139   1,  // 10
00140   2,
00141   2,
00142   3,
00143   4,
00144   4,  // 15
00145   5,
00146   7,
00147   9,
00148   10,
00149   11, // 20
00150   13,   
00151   15,
00152   1,
00153   2,
00154   2,  // 25
00155   2,
00156   3,
00157   4,
00158   4,
00159   4,  // 30
00160   5,
00161   6,
00162   6,
00163   7,
00164   9,  // 35
00165   9,
00166   9,
00167   9,
00168   9,
00169   10, // 40
00170   10,
00171   12,
00172   3,
00173   4,
00174   4,  // 45
00175   5,
00176   14,
00177   3,
00178   6,
00179   6,  // 50
00180   6,
00181   3,
00182   3,
00183   3   // 54
00184 };
00185 
00186 static const int tiR[55] = {
00187   0,  //  0
00188   0,  //  1
00189   0,
00190   0,
00191   0,
00192   0,  //  5
00193   0,
00194   0,
00195   4,  //  8
00196   6,
00197   12, // 10
00198   1,
00199   5,
00200   4,
00201   2,
00202   13, // 15
00203   9,
00204   3,
00205   4,
00206   11,
00207   4,  // 20
00208   13,   
00209   1,
00210   7,
00211   1,
00212   9,  // 25
00213   10,
00214   10,
00215   3,
00216   7,
00217   10,  // 30
00218   10,
00219   6,
00220   10,
00221   10,
00222   1,  // 35
00223   2,
00224   3,
00225   4,
00226   8,
00227   6, // 40
00228   9,
00229   8,
00230   16,
00231   22,
00232   23,  // 45
00233   23,
00234   10,
00235   50,
00236   44,
00237   46,  // 50
00238   50,
00239   0,
00240   1,
00241   4   // 54
00242 };
00243 
00244 static const doublereal  ni[57] = {
00245   +0.0,
00246   +0.12533547935523E-1, //  1
00247   +0.78957634722828E1,  //  2
00248   -0.87803203303561E1,  //  3
00249   +0.31802509345418E0,  //  4
00250   -0.26145533859358E0,  //  5
00251   -0.78199751687981E-2, //  6
00252   +0.88089493102134E-2, //  7
00253   -0.66856572307965E0,  //  8
00254   +0.20433810950965,    //  9
00255   -0.66212605039687E-4, // 10
00256   -0.19232721156002E0,  // 11
00257   -0.25709043003438E0,  // 12
00258   +0.16074868486251E0,  // 13
00259   -0.40092828925807E-1, // 14
00260   +0.39343422603254E-6, // 15
00261   -0.75941377088144E-5, // 16
00262   +0.56250979351888E-3, // 17
00263   -0.15608652257135E-4, // 18
00264   +0.11537996422951E-8, // 19
00265   +0.36582165144204E-6, // 20
00266   -0.13251180074668E-11,// 21
00267   -0.62639586912454E-9, // 22
00268   -0.10793600908932E0,  // 23
00269   +0.17611491008752E-1, // 24
00270   +0.22132295167546E0,  // 25
00271   -0.40247669763528E0,  // 26
00272   +0.58083399985759E0,  // 27
00273   +0.49969146990806E-2, // 28
00274   -0.31358700712549E-1, // 29
00275   -0.74315929710341E0,  // 30
00276   +0.47807329915480E0,  // 31
00277   +0.20527940895948E-1, // 32
00278   -0.13636435110343E0,  // 33
00279   +0.14180634400617E-1, // 34
00280   +0.83326504880713E-2, // 35
00281   -0.29052336009585E-1, // 36
00282   +0.38615085574206E-1, // 37
00283   -0.20393486513704E-1, // 38
00284   -0.16554050063734E-2, // 39
00285   +0.19955571979541E-2, // 40
00286   +0.15870308324157E-3, // 41
00287   -0.16388568342530E-4, // 42
00288   +0.43613615723811E-1, // 43
00289   +0.34994005463765E-1, // 44
00290   -0.76788197844621E-1, // 45
00291   +0.22446277332006E-1, // 46
00292   -0.62689710414685E-4, // 47
00293   -0.55711118565645E-9, // 48
00294   -0.19905718354408E0,  // 49
00295   +0.31777497330738E0,  // 50
00296   -0.11841182425981E0,  // 51
00297   -0.31306260323435E2,  // 52
00298   +0.31546140237781E2,  // 53
00299   -0.25213154341695E4,  // 54
00300   -0.14874640856724E0,  // 55
00301   +0.31806110878444E0   // 56
00302 };
00303 
00304 
00305 static const doublereal  alphai[3] = {
00306   +20.,
00307   +20.,
00308   +20.
00309 };
00310 
00311 static const doublereal  betai[3] = {
00312   +150.,
00313   +150.,
00314   +250.
00315 };
00316 
00317 static const doublereal  gammai[3] = {
00318   +1.21,
00319   +1.21,
00320   +1.25
00321 };
00322 
00323 static const doublereal  epsi[3] = {
00324   +1.0,
00325   +1.0,
00326   +1.0
00327 };
00328 
00329 static const doublereal  ai[2] = {
00330   +3.5,
00331   +3.5
00332 };
00333 
00334 static const doublereal  bi[2] = {
00335   +0.85,
00336   +0.95
00337 };
00338 
00339 static const doublereal  Bi[2] = {
00340   +0.2,
00341   +0.2
00342 };
00343 
00344 static const doublereal  Ci[2] = {
00345   +28.0,
00346   +32.0
00347 };
00348 
00349 static const doublereal  Di[2] = {
00350   +700.,
00351   +800.
00352 };
00353 
00354 static const doublereal  Ai[2] = {
00355   +0.32,
00356   +0.32
00357 };
00358 
00359 static const doublereal  Bbetai[2] = {
00360   +0.3,
00361   +0.3
00362 };
00363 
00364 /**
00365  * Constructor for the object. 
00366  */
00367 WaterPropsIAPWSphi::WaterPropsIAPWSphi() :
00368   TAUsave(-1.0),
00369   TAUsqrt(-1.0),
00370   DELTAsave(-1.0)
00371 {
00372   for (int i = 0; i < 52; i++) {
00373     TAUp[i] = 1.0;
00374   }
00375   for (int i = 0; i < 16; i++) {
00376     DELTAp[i] = 1.0;
00377   }
00378 }
00379 
00380 /*
00381  * intCheck() calculates all of the functions at a one point and
00382  * prints out the result. It's used for conducting the internal
00383  * check.
00384  */
00385 void WaterPropsIAPWSphi::intCheck(doublereal  tau, doublereal  delta) {
00386   tdpolycalc(tau, delta);
00387   doublereal  nau    = phi0();
00388   doublereal  res    = phiR();
00389   doublereal  res_d  = phiR_d();
00390   doublereal  nau_d  = phi0_d();
00391   doublereal  res_dd = phiR_dd();
00392   doublereal  nau_dd = phi0_dd();
00393   doublereal  res_t  = phiR_t();
00394   doublereal  nau_t  = phi0_t();
00395   doublereal  res_tt = phiR_tt();
00396   doublereal  nau_tt = phi0_tt();
00397   doublereal  res_dt = phiR_dt();
00398   doublereal  nau_dt = phi0_dt();
00399 
00400   std::printf("nau    = %20.12e\t\tres    = %20.12e\n", nau,    res);
00401   std::printf("nau_d  = %20.12e\t\tres_d  = %20.12e\n", nau_d,  res_d);
00402   printf("nau_dd = %20.12e\t\tres_dd = %20.12e\n", nau_dd, res_dd);
00403   printf("nau_t  = %20.12e\t\tres_t  = %20.12e\n", nau_t,  res_t);
00404   printf("nau_tt = %20.12e\t\tres_tt = %20.12e\n", nau_tt, res_tt);
00405   printf("nau_dt = %20.12e\t\tres_dt = %20.12e\n", nau_dt, res_dt);
00406 }
00407 
00408 void WaterPropsIAPWSphi::check1() {
00409   doublereal  T = 500.;
00410   doublereal  rho = 838.025;
00411   doublereal  tau = T_c/T;
00412   doublereal  delta = rho / Rho_c;
00413   printf(" T = 500 K, rho = 838.025 kg m-3\n");
00414   intCheck(tau, delta);
00415 }
00416 
00417 void WaterPropsIAPWSphi::check2() {
00418   doublereal  T = 647;
00419   doublereal  rho = 358.0;
00420   doublereal  tau = T_c/T;
00421   doublereal  delta = rho / Rho_c;
00422   printf(" T = 647 K, rho = 358.0 kg m-3\n");
00423   intCheck(tau, delta);
00424 }
00425 
00426 /*
00427  * Calculate the polynomials in tau and delta, and store them in static 
00428  * storage.
00429  */
00430 void WaterPropsIAPWSphi::tdpolycalc(doublereal  tau, doublereal  delta) {
00431   if ((tau != TAUsave) || 1) {
00432     TAUsave = tau;
00433     TAUsqrt = sqrt(tau);
00434     TAUp[0] = 1.0;
00435     for (int i = 1; i < 51; i++) {
00436       TAUp[i] = TAUp[i-1] * tau;
00437     }
00438   }
00439   if ((delta != DELTAsave) || 1) {
00440     DELTAsave = delta;
00441     DELTAp[0] = 1.0;
00442     for (int i = 1; i <= 15; i++) {
00443       DELTAp[i] = DELTAp[i-1] * delta;
00444     }
00445   }
00446 }
00447 
00448 /*
00449  * Calculate Eqn. 6.5 for phi0, the ideal gas part of the
00450  * dimensionless Helmholtz free energy.
00451  */
00452 doublereal  WaterPropsIAPWSphi::phi0() const {
00453   doublereal  tau = TAUsave;
00454   doublereal  delta = DELTAsave;
00455   doublereal  retn = log(delta) + ni0[1] + ni0[2]*tau + ni0[3]*log(tau);
00456 
00457   retn += ni0[4] * log(1.0 - exp(-gammi0[4]*tau));
00458   retn += ni0[5] * log(1.0 - exp(-gammi0[5]*tau));
00459   retn += ni0[6] * log(1.0 - exp(-gammi0[6]*tau));
00460   retn += ni0[7] * log(1.0 - exp(-gammi0[7]*tau));
00461   retn += ni0[8] * log(1.0 - exp(-gammi0[8]*tau));
00462   return retn;
00463 }
00464 
00465 /*
00466  * Calculate Eqn. 6.6 for phiR, the residual part of the
00467  * dimensionless Helmholtz free energy.
00468  *
00469  *  tau = dimensionless temperature
00470  *  delta = dimensionless pressure
00471  */
00472 doublereal  WaterPropsIAPWSphi::phiR() const {
00473   doublereal  tau = TAUsave;
00474   doublereal  delta = DELTAsave;
00475   int i, j;
00476     
00477   /*
00478    * Write out the first seven polynomials in the expression
00479    */
00480   doublereal  T375 = pow(tau, 0.375);
00481   doublereal  val = (ni[1] * delta / TAUsqrt +
00482                 ni[2] * delta * TAUsqrt * T375 +
00483                 ni[3] * delta * tau +
00484                 ni[4] * DELTAp[2] * TAUsqrt +
00485                 ni[5] * DELTAp[2] * T375 * T375 +
00486                 ni[6] * DELTAp[3] * T375 +
00487                 ni[7] * DELTAp[4] * tau);
00488   /*
00489    * Next, do polynomial contributions 8 to 51
00490    */
00491   for (i = 8; i <= 51; i++) {
00492     val += (ni[i] * DELTAp[diR[i]] * TAUp[tiR[i]] * exp(-DELTAp[ciR[i]]));
00493   }
00494 
00495   /*
00496    * Next do contributions 52 to 54
00497    */
00498   for (j = 0; j < 3; j++) {
00499     i = 52 + j;
00500     doublereal  dtmp = delta - epsi[j];
00501     doublereal  ttmp = tau - gammai[j];
00502     val += (ni[i] * DELTAp[diR[i]] * TAUp[tiR[i]] * 
00503             exp(-alphai[j]*dtmp*dtmp - betai[j]*ttmp*ttmp));
00504   }
00505 
00506   /*
00507    * Next do contributions 55 and 56
00508    */
00509   for (j = 0; j < 2; j++) {
00510     i = 55 + j;
00511     doublereal  deltam1 = delta - 1.0;
00512     doublereal  dtmp2 = deltam1 * deltam1;
00513     doublereal  atmp = 0.5 / Bbetai[j];
00514     doublereal  theta = (1.0 - tau) + Ai[j] * pow(dtmp2, atmp);
00515     doublereal  triag = theta * theta + Bi[j] * pow(dtmp2, ai[j]);
00516     doublereal  ttmp = tau - 1.0;
00517    
00518     doublereal  triagtmp = pow(triag, bi[j]);
00519       
00520     doublereal  phi = exp(-Ci[j]*dtmp2 - Di[j]*ttmp*ttmp);
00521     val += (ni[i] * triagtmp * delta * phi);
00522   }
00523 
00524   return val;
00525 }
00526 
00527 /*
00528  * Calculate the Phi function, which is basically the helmholtz free energy
00529  * Eqn. (6.4)
00530  */
00531 doublereal  WaterPropsIAPWSphi::phi(doublereal  tau, doublereal  delta) {
00532   tdpolycalc(tau, delta);
00533   doublereal  nau = phi0();
00534   doublereal  res = phiR();
00535   doublereal  retn = nau + res;
00536   return retn;
00537 }
00538 
00539 
00540 /*
00541  * Calculate d_phiR_d(delta), the first derivative of phiR
00542  * wrt delta
00543  *
00544  *  tau = dimensionless temperature
00545  *  delta = dimensionless pressure
00546  */
00547 doublereal  WaterPropsIAPWSphi::phiR_d() const {
00548   doublereal  tau = TAUsave;
00549   doublereal  delta = DELTAsave;
00550   int i, j;
00551     
00552   /*
00553    * Write out the first seven polynomials in the expression
00554    */
00555   doublereal  T375 = pow(tau, 0.375);
00556   doublereal  val = (ni[1] / TAUsqrt +
00557                 ni[2] * TAUsqrt * T375 +
00558                 ni[3] * tau +
00559                 ni[4] * 2.0 * delta * TAUsqrt +
00560                 ni[5] * 2.0 * delta * T375 * T375 +
00561                 ni[6] * 3.0 * DELTAp[2] * T375 +
00562                 ni[7] * 4.0 * DELTAp[3] * tau);
00563   /*
00564    * Next, do polynomial contributions 8 to 51
00565    */
00566   for (i = 8; i <= 51; i++) {
00567     val += ( (ni[i] * exp(-DELTAp[ciR[i]]) *  DELTAp[diR[i] - 1] *
00568               TAUp[tiR[i]]) * (diR[i] - ciR[i]* DELTAp[ciR[i]]));
00569   }
00570 
00571   /*
00572    * Next do contributions 52 to 54
00573    */
00574   for (j = 0; j < 3; j++) {
00575     i = 52 + j;
00576     doublereal  dtmp = delta - epsi[j];
00577     doublereal  ttmp = tau - gammai[j];
00578     doublereal  tmp = (ni[i] * DELTAp[diR[i]] * TAUp[tiR[i]] * 
00579                   exp(-alphai[j]*dtmp*dtmp - betai[j]*ttmp*ttmp));
00580     val += tmp * (diR[i]/delta - 2.0 * alphai[j] * dtmp);
00581   }
00582 
00583   /*
00584    * Next do contributions 55 and 56
00585    */
00586   for (j = 0; j < 2; j++) {
00587     i = 55 + j;
00588     doublereal  deltam1 = delta - 1.0;
00589     doublereal  dtmp2 = deltam1 * deltam1;
00590     doublereal  atmp = 0.5 / Bbetai[j];
00591     doublereal  theta = (1.0 - tau) + Ai[j] * pow(dtmp2, atmp);
00592     doublereal  triag = theta * theta + Bi[j] * pow(dtmp2, ai[j]);
00593     doublereal  ttmp = tau - 1.0;
00594    
00595     doublereal  triagtmp = pow(triag, bi[j]);
00596     doublereal  triagtmpm1 = pow(triag, bi[j]-1.0);
00597     doublereal  atmpM1 = atmp - 1.0;
00598     doublereal  ptmp = pow(dtmp2,atmpM1); 
00599     doublereal  p2tmp = pow(dtmp2, ai[j]-1.0);
00600     doublereal  dtriagddelta = 
00601       deltam1 *(Ai[j] * theta * 2.0 / Bbetai[j] * ptmp +
00602                 2.0*Bi[j]*ai[j]*p2tmp);
00603 
00604     doublereal  phi = exp(-Ci[j]*dtmp2 - Di[j]*ttmp*ttmp);
00605     doublereal  dphiddelta = -2.0*Ci[j]*deltam1*phi;
00606     doublereal  dtriagtmpddelta = bi[j] * triagtmpm1 * dtriagddelta;
00607 
00608     doublereal  tmp = ni[i] * (triagtmp * (phi + delta*dphiddelta) +
00609                           dtriagtmpddelta * delta * phi);
00610     val += tmp;
00611   }
00612 
00613   return val;
00614 }
00615 
00616 /*
00617  * Calculate d_phi0_d(delta), the first derivative of phi0
00618  * wrt delta
00619  *
00620  *  tau = dimensionless temperature
00621  *  delta = dimensionless pressure
00622  */
00623 doublereal  WaterPropsIAPWSphi::phi0_d() const {
00624   doublereal  delta = DELTAsave;
00625   return (1.0/delta);
00626 }
00627 
00628 /*
00629  * Calculate the dPhidDelta function, which is basically the derivative
00630  * of helmholtz free energy wrt delta
00631  * Eqn. (6.4)
00632  */
00633 doublereal  WaterPropsIAPWSphi::phi_d(doublereal  tau, doublereal  delta) {
00634   tdpolycalc(tau, delta);
00635   doublereal  nau = phi0_d();
00636   doublereal  res = phiR_d();
00637   doublereal  retn = nau + res;
00638   return retn;
00639 }
00640 
00641 /*
00642  * Calculate the dimensionless pressure at tau and delta;
00643  *
00644  *       p/(rhoRT) = delta * phi_d()
00645  *
00646  * note: this is done so much, we have a seperate routine.
00647  */
00648 doublereal  WaterPropsIAPWSphi::pressureM_rhoRT(doublereal  tau, doublereal  delta) {
00649   tdpolycalc(tau, delta);
00650   doublereal  res = phiR_d();
00651   doublereal  retn = 1.0 + delta * res; 
00652   return retn;
00653 }
00654 
00655 /*
00656  * Calculate d2_phiR_dd(delta), the second derivative of phiR
00657  * wrt delta
00658  *
00659  *  tau = dimensionless temperature
00660  *  delta = dimensionless pressure
00661  */
00662 doublereal  WaterPropsIAPWSphi::phiR_dd() const {
00663   doublereal  tau = TAUsave;
00664   doublereal  delta = DELTAsave;
00665   int i, j;
00666   doublereal  atmp;
00667     
00668   /*
00669    * Write out the first seven polynomials in the expression
00670    */
00671   doublereal  T375 = pow(tau, 0.375);
00672   doublereal  val = (ni[4] * 2.0 * TAUsqrt +
00673                 ni[5] * 2.0 * T375 * T375 +
00674                 ni[6] * 6.0 * delta * T375 +
00675                 ni[7] * 12.0 * DELTAp[2] * tau);
00676   /*
00677    * Next, do polynomial contributions 8 to 51
00678    */
00679   for (i = 8; i <= 51; i++) {
00680     doublereal  dtmp = DELTAp[ciR[i]];
00681     doublereal  tmp = ni[i] * exp(-dtmp) * TAUp[tiR[i]];
00682     if (diR[i] == 1) {
00683       atmp = 1.0/delta;
00684     } else {
00685       atmp = DELTAp[diR[i] - 2];
00686     }
00687     tmp *= atmp *((diR[i] - ciR[i]*dtmp)*(diR[i]-1.0-ciR[i]*dtmp) -
00688                   ciR[i]*ciR[i]*dtmp);
00689     val += tmp;
00690   }
00691 
00692   /*
00693    * Next do contributions 52 to 54
00694    */
00695   for (j = 0; j < 3; j++) {
00696     i = 52 + j;
00697     doublereal  dtmp = delta - epsi[j];
00698     doublereal  ttmp = tau - gammai[j];
00699     doublereal  tmp = (ni[i] * TAUp[tiR[i]] * 
00700                   exp(-alphai[j]*dtmp*dtmp - betai[j]*ttmp*ttmp));
00701     doublereal  deltmp =  DELTAp[diR[i]];
00702     doublereal  deltmpM1 = deltmp/delta;
00703     doublereal  deltmpM2 = deltmpM1 / delta;
00704     doublereal  d2tmp = dtmp * dtmp;
00705       
00706     val += tmp * (-2.0*alphai[j]*deltmp +
00707                   4.0 * alphai[j] * alphai[j] * deltmp * d2tmp -
00708                   4.0 * diR[i] * alphai[j] * deltmpM1 * dtmp +
00709                   diR[i] * (diR[i] - 1.0) * deltmpM2);
00710   }
00711 
00712   /*
00713    * Next do contributions 55 and 56
00714    */
00715   for (j = 0; j < 2; j++) {
00716     i = 55 + j;
00717     doublereal  deltam1 = delta - 1.0;
00718     doublereal  dtmp2 = deltam1 * deltam1;
00719     atmp = 0.5 / Bbetai[j];
00720     doublereal  theta = (1.0 - tau) + Ai[j] * pow(dtmp2, atmp);
00721     doublereal  triag = theta * theta + Bi[j] * pow(dtmp2, ai[j]);
00722     doublereal  ttmp = tau - 1.0;
00723    
00724     doublereal  triagtmp = pow(triag, bi[j]);
00725     doublereal  triagtmpm1 = pow(triag, bi[j]-1.0);
00726     doublereal  atmpM1 = atmp - 1.0;
00727     doublereal  ptmp = pow(dtmp2,atmpM1);
00728     doublereal  p2tmp = pow(dtmp2, ai[j]-1.0);
00729     doublereal  dtriagddelta = 
00730       deltam1 *(Ai[j] * theta * 2.0 / Bbetai[j] * ptmp +
00731                 2.0*Bi[j]*ai[j]*p2tmp);
00732 
00733     doublereal  phi = exp(-Ci[j]*dtmp2 - Di[j]*ttmp*ttmp);
00734     doublereal  dphiddelta = -2.0*Ci[j]*deltam1*phi;
00735     doublereal  dtriagtmpddelta = bi[j] * triagtmpm1 * dtriagddelta;
00736 
00737 
00738     doublereal  d2phiddelta2 = 2.0 * Ci[j] * phi * (2.0*Ci[j]*dtmp2 - 1.0);
00739 
00740     doublereal  pptmp = ptmp / dtmp2;
00741     doublereal  d2triagddelta2 = dtriagddelta / deltam1;
00742     d2triagddelta2 += 
00743       dtmp2 *(4.0*Bi[j]*ai[j]*(ai[j]-1.0)*pow(dtmp2,ai[j]-2.0) +
00744               2.0*Ai[j]*Ai[j]/(Bbetai[j]*Bbetai[j])*ptmp*ptmp +
00745               Ai[j]*theta*4.0/Bbetai[j]*(atmp-1.0)*pptmp);
00746 
00747     doublereal   d2triagtmpd2delta = 
00748       bi[j] * (triagtmpm1 * d2triagddelta2 +
00749                (bi[j]-1.0)*triagtmpm1/triag*dtriagddelta*dtriagddelta);
00750 
00751     doublereal  ctmp = (triagtmp * (2.0*dphiddelta + delta*d2phiddelta2) +
00752                    2.0*dtriagtmpddelta*(phi + delta * dphiddelta) +
00753                    d2triagtmpd2delta * delta * phi);
00754  
00755     val += ni[i] * ctmp;
00756   }
00757 
00758   return val;
00759 }
00760 
00761 /*
00762  * Calculate d2_phi0_dd(delta), the second derivative of phi0
00763  * wrt delta
00764  *
00765  *  tau = dimensionless temperature
00766  *  delta = dimensionless pressure
00767  */
00768 doublereal  WaterPropsIAPWSphi::phi0_dd() const {
00769   doublereal  delta = DELTAsave;
00770   return (-1.0/(delta*delta));
00771 }
00772 
00773 /*
00774  * Calculate the d2_PhidDelta2 function, which is the second derivative
00775  * of helmholtz free energy wrt delta
00776  * Eqn. (6.4)
00777  */
00778 doublereal  WaterPropsIAPWSphi::phi_dd(doublereal  tau, doublereal  delta) {
00779   tdpolycalc(tau, delta);
00780   doublereal  nau = phi0_dd();
00781   doublereal  res = phiR_dd();
00782   doublereal  retn = nau + res;
00783   return retn;
00784 }
00785 
00786 doublereal  WaterPropsIAPWSphi::dimdpdrho(doublereal  tau, doublereal  delta) {
00787   tdpolycalc(tau, delta);
00788   doublereal  res1 = phiR_d();
00789   doublereal  res2 = phiR_dd();
00790   doublereal  retn = 1.0 + delta * (2.0*res1 + delta*res2);
00791   return retn;
00792 }
00793 
00794 doublereal  WaterPropsIAPWSphi::dimdpdT(doublereal  tau, doublereal  delta) {
00795   tdpolycalc(tau, delta);
00796   doublereal  res1 = phiR_d();
00797   doublereal  res2 = phiR_dt();
00798   doublereal  retn = (1.0 + delta * res1) - tau * delta * (res2);
00799   return retn;
00800 }
00801 
00802 /*
00803  * Calculate d_phi0/d(tau)
00804  */
00805 doublereal  WaterPropsIAPWSphi::phi0_t() const {
00806   doublereal  tau = TAUsave;
00807   doublereal  retn = ni0[2] + ni0[3]/tau;;
00808   retn += (ni0[4] * gammi0[4] * (1.0/(1.0 - exp(-gammi0[4]*tau)) - 1.0));
00809   retn += (ni0[5] * gammi0[5] * (1.0/(1.0 - exp(-gammi0[5]*tau)) - 1.0));
00810   retn += (ni0[6] * gammi0[6] * (1.0/(1.0 - exp(-gammi0[6]*tau)) - 1.0));
00811   retn += (ni0[7] * gammi0[7] * (1.0/(1.0 - exp(-gammi0[7]*tau)) - 1.0));
00812   retn += (ni0[8] * gammi0[8] * (1.0/(1.0 - exp(-gammi0[8]*tau)) - 1.0));
00813   return retn;
00814 }
00815 
00816 /*
00817  * Calculate Eqn. 6.6 for dphiRdtau, the derivative residual part of the
00818  * dimensionless Helmholtz free energy wrt temperature
00819  *
00820  *  tau = dimensionless temperature
00821  *  delta = dimensionless pressure
00822  */
00823 doublereal  WaterPropsIAPWSphi::phiR_t() const {
00824   doublereal  tau = TAUsave;
00825   doublereal  delta = DELTAsave;
00826   int i, j;
00827   doublereal  atmp, tmp;
00828     
00829   /*
00830    * Write out the first seven polynomials in the expression
00831    */
00832   doublereal  T375 = pow(tau, 0.375);
00833   doublereal  val = ((-0.5) *ni[1] * delta / TAUsqrt / tau +
00834                 ni[2] * delta * 0.875 / TAUsqrt * T375 +
00835                 ni[3] * delta +
00836                 ni[4] * DELTAp[2] * 0.5 / TAUsqrt +
00837                 ni[5] * DELTAp[2] * 0.75 * T375 * T375 / tau +
00838                 ni[6] * DELTAp[3] * 0.375 * T375 / tau +
00839                 ni[7] * DELTAp[4]);
00840   /*
00841    * Next, do polynomial contributions 8 to 51
00842    */
00843   for (i = 8; i <= 51; i++) {
00844     tmp = (ni[i] * DELTAp[diR[i]] * TAUp[tiR[i]-1] * exp(-DELTAp[ciR[i]]));
00845     val += tiR[i] * tmp;
00846   }
00847 
00848   /*
00849    * Next do contributions 52 to 54
00850    */
00851   for (j = 0; j < 3; j++) {
00852     i = 52 + j;
00853     doublereal  dtmp = delta - epsi[j];
00854     doublereal  ttmp = tau - gammai[j];
00855     tmp = (ni[i] * DELTAp[diR[i]] * TAUp[tiR[i]] * 
00856            exp(-alphai[j]*dtmp*dtmp - betai[j]*ttmp*ttmp));
00857     val += tmp *(tiR[i]/tau - 2.0 * betai[j]*ttmp);
00858   }
00859 
00860   /*
00861    * Next do contributions 55 and 56
00862    */
00863   for (j = 0; j < 2; j++) {
00864     i = 55 + j;
00865     doublereal  deltam1 = delta - 1.0;
00866     doublereal  dtmp2 = deltam1 * deltam1;
00867     atmp = 0.5 / Bbetai[j];
00868     doublereal  theta = (1.0 - tau) + Ai[j] * pow(dtmp2, atmp);
00869     doublereal  triag = theta * theta + Bi[j] * pow(dtmp2, ai[j]);
00870     doublereal  ttmp = tau - 1.0;
00871    
00872     doublereal  triagtmp = pow(triag, bi[j]);
00873       
00874     doublereal  phi = exp(-Ci[j]*dtmp2 - Di[j]*ttmp*ttmp);
00875  
00876 
00877     doublereal  dtriagtmpdtau = -2.0*theta * bi[j] * triagtmp / triag;
00878 
00879     doublereal  dphidtau = - 2.0 * Di[j] * ttmp * phi;
00880       
00881     val += ni[i] * delta * (dtriagtmpdtau * phi + triagtmp * dphidtau);
00882   }
00883 
00884   return val;
00885 }
00886 
00887 /*
00888  * Calculate the dPhidtau function, which is basically the derivative
00889  * of helmholtz free energy wrt tau
00890  * Eqn. (6.4)
00891  */
00892 doublereal  WaterPropsIAPWSphi::phi_t(doublereal  tau, doublereal  delta) {
00893   tdpolycalc(tau, delta);
00894   doublereal  nau = phi0_t();
00895   doublereal  res = phiR_t();
00896   doublereal  retn = nau + res;
00897   return retn;
00898 }
00899 
00900 /*
00901  * Calculate d2_phi0/dtau2
00902  */
00903 doublereal  WaterPropsIAPWSphi::phi0_tt() const {
00904   doublereal  tau = TAUsave;
00905   doublereal  tmp, itmp;
00906   doublereal  retn = - ni0[3]/(tau * tau);
00907   for (int i = 4; i <= 8; i++) {
00908     tmp = exp(-gammi0[i]*tau);
00909     itmp = 1.0 - tmp;
00910     retn -= (ni0[i] * gammi0[i] * gammi0[i] * tmp / (itmp * itmp));
00911   }
00912   return retn;
00913 }
00914 
00915 /*
00916  * Calculate Eqn. 6.6 for dphiRdtau, the second derivative residual part of the
00917  * dimensionless Helmholtz free energy wrt temperature
00918  *
00919  *  tau = dimensionless temperature
00920  *  delta = dimensionless pressure
00921  */
00922 doublereal  WaterPropsIAPWSphi::phiR_tt() const {
00923   doublereal  tau = TAUsave;
00924   doublereal  delta = DELTAsave;
00925   int i, j;
00926   doublereal  atmp, tmp;
00927     
00928   /*
00929    * Write out the first seven polynomials in the expression
00930    */
00931   doublereal  T375 = pow(tau, 0.375);
00932   doublereal  val = ((-0.5) * (-1.5) * ni[1] * delta / (TAUsqrt * tau * tau) +
00933                 ni[2] * delta * 0.875 * (-0.125) * T375 / (TAUsqrt * tau) +
00934                 ni[4] * DELTAp[2] * 0.5 * (-0.5)/ (TAUsqrt * tau) +
00935                 ni[5] * DELTAp[2] * 0.75 *(-0.25) * T375 * T375 / (tau * tau) +
00936                 ni[6] * DELTAp[3] * 0.375 *(-0.625) * T375 / (tau * tau));
00937   /*
00938    * Next, do polynomial contributions 8 to 51
00939    */
00940   for (i = 8; i <= 51; i++) {
00941     if (tiR[i] > 1) {
00942       tmp = (ni[i] * DELTAp[diR[i]] * TAUp[tiR[i]-2] * exp(-DELTAp[ciR[i]]));
00943       val += tiR[i] *  (tiR[i] - 1.0) * tmp;
00944     }
00945   }
00946 
00947   /*
00948    * Next do contributions 52 to 54
00949    */
00950   for (j = 0; j < 3; j++) {
00951     i = 52 + j;
00952     doublereal  dtmp = delta - epsi[j];
00953     doublereal  ttmp = tau - gammai[j];
00954     tmp = (ni[i] * DELTAp[diR[i]] * TAUp[tiR[i]] * 
00955            exp(-alphai[j]*dtmp*dtmp - betai[j]*ttmp*ttmp));
00956     atmp = tiR[i]/tau - 2.0 * betai[j]*ttmp;
00957     val += tmp *(atmp * atmp - tiR[i]/(tau*tau) - 2.0*betai[j]);
00958   }
00959 
00960   /*
00961    * Next do contributions 55 and 56
00962    */
00963   for (j = 0; j < 2; j++) {
00964     i = 55 + j;
00965     doublereal  deltam1 = delta - 1.0;
00966     doublereal  dtmp2 = deltam1 * deltam1;
00967     atmp = 0.5 / Bbetai[j];
00968     doublereal  theta = (1.0 - tau) + Ai[j] * pow(dtmp2, atmp);
00969     doublereal  triag = theta * theta + Bi[j] * pow(dtmp2, ai[j]);
00970     doublereal  ttmp = tau - 1.0;
00971    
00972     doublereal  triagtmp = pow(triag, bi[j]);
00973     doublereal  triagtmpM1 = triagtmp / triag;
00974       
00975     doublereal  phi = exp(-Ci[j]*dtmp2 - Di[j]*ttmp*ttmp);
00976  
00977 
00978     doublereal  dtriagtmpdtau = -2.0*theta * bi[j] * triagtmp / triag;
00979 
00980     doublereal  dphidtau = - 2.0 * Di[j] * ttmp * phi;
00981 
00982     doublereal  d2triagtmpdtau2 = 
00983       (2 * bi[j] * triagtmpM1 +
00984        4 * theta * theta  * bi[j] * (bi[j]-1.0) * triagtmpM1 / triag);
00985 
00986     doublereal  d2phidtau2 = 2.0*Di[j]*phi *(2.0*Di[j]*ttmp*ttmp - 1.0);
00987 
00988     tmp =  (d2triagtmpdtau2 * phi +
00989             2 * dtriagtmpdtau * dphidtau +
00990             triagtmp * d2phidtau2);
00991     val += ni[i] * delta * tmp;
00992   }
00993 
00994   return val;
00995 }
00996 
00997 /*
00998  * Calculate the d2Phidtau2 function, which is basically the second derivative
00999  * of helmholtz free energy wrt tau
01000  * Eqn. (6.4)
01001  */
01002 doublereal  WaterPropsIAPWSphi::phi_tt(doublereal  tau, doublereal  delta) {
01003   tdpolycalc(tau, delta);
01004   doublereal  nau = phi0_tt();
01005   doublereal  res = phiR_tt();
01006   doublereal  retn = nau + res;
01007   return retn;
01008 }
01009 
01010 /**
01011  * Calculate d2_phi0/dtauddelta
01012  */
01013 doublereal  WaterPropsIAPWSphi::phi0_dt() const {
01014   return 0.0;
01015 }
01016 
01017 /*
01018  * Calculate d2_phiR_d(delta)d(tau), the mixed derivative of phi
01019  * wrt delta and tau.
01020  *
01021  *  tau = dimensionless temperature
01022  *  delta = dimensionless pressure
01023  */
01024 doublereal  WaterPropsIAPWSphi::phiR_dt() const {
01025   doublereal  tau = TAUsave;
01026   doublereal  delta = DELTAsave;
01027   int i, j;
01028   doublereal  tmp;
01029   /*
01030    * Write out the first seven polynomials in the expression
01031    */
01032   doublereal  T375 = pow(tau, 0.375);
01033   doublereal  val = (ni[1] * (-0.5) / (TAUsqrt * tau) +
01034                 ni[2] * (0.875) * T375 / TAUsqrt +
01035                 ni[3] +
01036                 ni[4] * 2.0 * delta * (0.5) / TAUsqrt +
01037                 ni[5] * 2.0 * delta * (0.75) * T375 * T375 / tau +
01038                 ni[6] * 3.0 * DELTAp[2] * 0.375 * T375 / tau +
01039                 ni[7] * 4.0 * DELTAp[3]);
01040   /*
01041    * Next, do polynomial contributions 8 to 51
01042    */
01043   for (i = 8; i <= 51; i++) {
01044     tmp = (ni[i] * tiR[i] * exp(-DELTAp[ciR[i]]) *  DELTAp[diR[i] - 1] *
01045            TAUp[tiR[i] - 1]);
01046     val += tmp * (diR[i] - ciR[i] * DELTAp[ciR[i]]);
01047   }
01048 
01049   /*
01050    * Next do contributions 52 to 54
01051    */
01052   for (j = 0; j < 3; j++) {
01053     i = 52 + j;
01054     doublereal  dtmp = delta - epsi[j];
01055     doublereal  ttmp = tau - gammai[j];
01056     tmp = (ni[i] * DELTAp[diR[i]] * TAUp[tiR[i]] * 
01057            exp(-alphai[j]*dtmp*dtmp - betai[j]*ttmp*ttmp));
01058     val += tmp * ((diR[i]/delta - 2.0 * alphai[j] * dtmp) * 
01059                   (tiR[i]/tau   - 2.0 * betai[j]  * ttmp));
01060   }
01061 
01062   /*
01063    * Next do contributions 55 and 56
01064    */
01065   for (j = 0; j < 2; j++) {
01066     i = 55 + j;
01067     doublereal  deltam1 = delta - 1.0;
01068     doublereal  dtmp2 = deltam1 * deltam1;
01069     doublereal  atmp = 0.5 / Bbetai[j];
01070     doublereal  theta = (1.0 - tau) + Ai[j] * pow(dtmp2, atmp);
01071     doublereal  triag = theta * theta + Bi[j] * pow(dtmp2, ai[j]);
01072     doublereal  ttmp = tau - 1.0;
01073    
01074     doublereal  triagtmp = pow(triag, bi[j]);
01075     doublereal  triagtmpm1 = pow(triag, bi[j]-1.0);
01076     doublereal  atmpM1 = atmp - 1.0;
01077     doublereal  ptmp = pow(dtmp2,atmpM1); 
01078     doublereal  p2tmp = pow(dtmp2, ai[j]-1.0);
01079     doublereal  dtriagddelta = 
01080       deltam1 *(Ai[j] * theta * 2.0 / Bbetai[j] * ptmp +
01081                 2.0*Bi[j]*ai[j]*p2tmp);
01082 
01083     doublereal  phi = exp(-Ci[j]*dtmp2 - Di[j]*ttmp*ttmp);
01084     doublereal  dphiddelta = -2.0*Ci[j]*deltam1*phi;
01085     doublereal  dtriagtmpddelta = bi[j] * triagtmpm1 * dtriagddelta;
01086 
01087 
01088     doublereal  dtriagtmpdtau = -2.0*theta * bi[j] * triagtmp / triag;
01089 
01090     doublereal  dphidtau = - 2.0 * Di[j] * ttmp * phi;
01091 
01092     doublereal  d2phiddeltadtau = 4.0 * Ci[j] * Di[j] * deltam1 * ttmp * phi;
01093 
01094     doublereal   d2triagtmpddeltadtau =
01095       ( -Ai[j] * bi[j] * 2.0 / Bbetai[j] * triagtmpm1 * deltam1 * ptmp
01096         -2.0 * theta * bi[j] * (bi[j] - 1.0) * triagtmpm1 / triag * dtriagddelta);
01097               
01098 
01099     doublereal  tmp = ni[i] * (triagtmp * (dphidtau + delta*d2phiddeltadtau) +
01100                           delta * dtriagtmpddelta * dphidtau +
01101                           dtriagtmpdtau * (phi + delta * dphiddelta) +
01102                           d2triagtmpddeltadtau * delta * phi);
01103     val += tmp;
01104   }
01105 
01106   return val;
01107 }
01108 
01109 /**
01110  * This program computes the reduced density, given the reduced pressure
01111  * and the reduced temperature, tau. It takes an initial guess, deltaGuess.
01112  * DeltaGuess is important as this is a multivalued function below the
01113  * critical point.
01114  * 
01115  */
01116 doublereal  WaterPropsIAPWSphi::dfind(doublereal  p_red, doublereal  tau, doublereal  deltaGuess) {
01117   doublereal  dd = deltaGuess;
01118   bool conv = false;
01119   doublereal  deldd = dd;
01120   doublereal  pcheck = 1.0E-30 + 1.0E-8 * p_red;
01121   for (int n = 0; n < 200; n++) {
01122     /*
01123      * Calculate the internal polynomials, and then calculate the
01124      * phi deriv functions needed by this routine.
01125      */
01126     tdpolycalc(tau, dd);
01127     doublereal  q1 = phiR_d();
01128     doublereal  q2 = phiR_dd();
01129 
01130     /*
01131      * Calculate the predicted reduced pressure, pred0, based on the
01132      * current tau and dd. 
01133      */
01134     doublereal  pred0 = dd + dd * dd * q1;
01135     /*
01136      * Calculate the derivative of the predicted reduced pressure
01137      * wrt the reduced density, dd, This is dpddelta
01138      */
01139     doublereal  dpddelta = 1.0 + 2.0 * dd * q1 + dd * dd * q2; 
01140     /*
01141      * If dpddelta is negative, then we are in the middle of the
01142      * 2 phase region, beyond the stability curve. We need to adjust
01143      * the initial guess outwards and start a new iteration.
01144      */
01145     if (dpddelta <= 0.0) {
01146       if (deltaGuess > 1.0) dd = dd * 1.05;
01147       if (deltaGuess < 1.0) dd = dd * 0.95;
01148       continue;
01149     }
01150     /*
01151      * Check for convergence
01152      */
01153     if (fabs(pred0-p_red) < pcheck) {
01154       conv = true;
01155       break;
01156     }
01157 
01158     /*
01159      * Dampen and crop the update
01160      */
01161     doublereal  dpdx = dpddelta;
01162     if (n < 10) {
01163       dpdx = dpddelta * 1.1;
01164     }
01165     if (dpdx < 0.001) dpdx = 0.001;
01166       
01167     /*
01168      * Formulate the update to reduced density using 
01169      * Newton's method. Then, crop it to a max value
01170      * of 0.02
01171      */
01172     deldd = - (pred0 - p_red) / dpdx;
01173     if (fabs(deldd) > 0.05) {
01174       deldd = deldd * 0.05 / fabs(deldd);
01175     }
01176     /*
01177      * updated the reduced density value
01178      */
01179     dd = dd + deldd;
01180     if (fabs(deldd/dd) < 1.0E-14) {
01181       conv = true;
01182       break;
01183     }
01184     /*
01185      * Check for negative densities
01186      */
01187     if (dd <= 0.0) {
01188       dd = 1.0E-24;
01189     }
01190   }
01191   /*
01192    * Check for convergence, and return 0.0 if it wasn't achieved.
01193    */
01194   if (! conv) {
01195     dd = 0.0;
01196   }
01197   return dd;
01198 }
01199 
01200 /**
01201  * Calculate the dimensionless gibbs free energy g/RT.
01202  */
01203 doublereal  WaterPropsIAPWSphi::gibbs_RT() const {
01204   doublereal  delta = DELTAsave;
01205   doublereal  rd = phiR_d();
01206   doublereal  g = 1.0 + phi0() + phiR() + delta * rd;
01207   return g;
01208 }
01209 
01210 /**
01211  * Calculate the dimensionless enthalpy h/RT.
01212  */
01213 doublereal  WaterPropsIAPWSphi::enthalpy_RT() const {
01214   doublereal  delta = DELTAsave;
01215   doublereal  tau   = TAUsave;
01216   doublereal  rd = phiR_d();
01217   doublereal  nt = phi0_t();
01218   doublereal  rt = phiR_t();
01219   doublereal  hRT = 1.0 + tau * (nt + rt) + delta * rd;
01220   return hRT;
01221 }
01222 
01223 /*
01224  * Calculate the dimensionless entropy s/R.
01225  */
01226 doublereal  WaterPropsIAPWSphi::entropy_R() const {
01227   doublereal  tau   = TAUsave;
01228   doublereal  nt = phi0_t();
01229   doublereal  rt = phiR_t();
01230   doublereal  p0 = phi0();
01231   doublereal  pR = phiR();
01232   doublereal  sR = tau * (nt + rt) - p0 - pR;
01233   return sR;
01234 }
01235 
01236 /*
01237  * Calculate the dimensionless internal energy, u/RT.
01238  */
01239 doublereal  WaterPropsIAPWSphi::intEnergy_RT() const {
01240   doublereal  tau   = TAUsave;
01241   doublereal  nt = phi0_t();
01242   doublereal  rt = phiR_t();
01243   doublereal  uR = tau * (nt + rt);
01244   return uR;
01245 }
01246 
01247 /*
01248  * Calculate the dimensionless constant volume Heat Capacity, Cv/R
01249  */
01250 doublereal  WaterPropsIAPWSphi::cv_R() const {
01251   doublereal  tau   = TAUsave;
01252   doublereal  ntt = phi0_tt();
01253   doublereal  rtt = phiR_tt();
01254   doublereal  cvR = - tau * tau * (ntt + rtt);
01255   return cvR;
01256 }
01257 
01258 /*
01259  * Calculate the dimensionless constant pressure Heat Capacity, Cp/R
01260  */
01261 doublereal  WaterPropsIAPWSphi::cp_R() const {
01262   doublereal  tau   = TAUsave;
01263   doublereal  delta = DELTAsave;
01264   doublereal  cvR = cv_R();
01265   //doublereal  nd = phi0_d();
01266   doublereal  rd = phiR_d();
01267   doublereal  rdd = phiR_dd();
01268   doublereal  rdt = phiR_dt();
01269   doublereal  num = (1.0 + delta * rd - delta * tau * rdt);
01270   doublereal  cpR = cvR + (num * num / 
01271                       (1.0 + 2.0 * delta * rd + delta * delta * rdd));
01272   return cpR;
01273 }
01274 
Generated by  doxygen 1.6.3