29 static const doublereal
T_c = 647.096;
30 static const doublereal
P_c = 22.064E6;
31 static const doublereal
Rho_c = 322.;
32 static const doublereal
M_water = 18.015268;
44 static const doublereal ni0[9] = {
46 -8.32044648201 - 0.000000001739715,
47 6.6832105268 + 0.000000000793232,
56 static const doublereal gammi0[9] = {
68 static const int ciR[56] = {
127 static const int diR[55] = {
185 static const int tiR[55] = {
242 static const doublereal ni[57] = {
244 +0.12533547935523E-1,
249 -0.78199751687981E-2,
250 +0.88089493102134E-2,
253 -0.66212605039687E-4,
257 -0.40092828925807E-1,
258 +0.39343422603254E-6,
259 -0.75941377088144E-5,
260 +0.56250979351888E-3,
261 -0.15608652257135E-4,
262 +0.11537996422951E-8,
263 +0.36582165144204E-6,
264 -0.13251180074668E-11,
265 -0.62639586912454E-9,
267 +0.17611491008752E-1,
271 +0.49969146990806E-2,
272 -0.31358700712549E-1,
275 +0.20527940895948E-1,
277 +0.14180634400617E-1,
278 +0.83326504880713E-2,
279 -0.29052336009585E-1,
280 +0.38615085574206E-1,
281 -0.20393486513704E-1,
282 -0.16554050063734E-2,
283 +0.19955571979541E-2,
284 +0.15870308324157E-3,
285 -0.16388568342530E-4,
286 +0.43613615723811E-1,
287 +0.34994005463765E-1,
288 -0.76788197844621E-1,
289 +0.22446277332006E-1,
290 -0.62689710414685E-4,
291 -0.55711118565645E-9,
303 static const doublereal alphai[3] = {
309 static const doublereal betai[3] = {
315 static const doublereal gammai[3] = {
321 static const doublereal epsi[3] = {
327 static const doublereal ai[2] = {
332 static const doublereal bi[2] = {
337 static const doublereal Bi[2] = {
342 static const doublereal Ci[2] = {
347 static const doublereal Di[2] = {
352 static const doublereal Ai[2] = {
357 static const doublereal Bbetai[2] = {
371 for (
int i = 0; i < 52; i++) {
374 for (
int i = 0; i < 16; i++) {
387 doublereal nau =
phi0();
388 doublereal res =
phiR();
389 doublereal res_d =
phiR_d();
390 doublereal nau_d =
phi0_d();
393 doublereal res_t =
phiR_t();
394 doublereal nau_t =
phi0_t();
400 std::printf(
"nau = %20.12e\t\tres = %20.12e\n", nau, res);
401 std::printf(
"nau_d = %20.12e\t\tres_d = %20.12e\n", nau_d, res_d);
402 printf(
"nau_dd = %20.12e\t\tres_dd = %20.12e\n", nau_dd, res_dd);
403 printf(
"nau_t = %20.12e\t\tres_t = %20.12e\n", nau_t, res_t);
404 printf(
"nau_tt = %20.12e\t\tres_tt = %20.12e\n", nau_tt, res_tt);
405 printf(
"nau_dt = %20.12e\t\tres_dt = %20.12e\n", nau_dt, res_dt);
411 doublereal rho = 838.025;
412 doublereal tau =
T_c/T;
413 doublereal delta = rho /
Rho_c;
414 printf(
" T = 500 K, rho = 838.025 kg m-3\n");
421 doublereal rho = 358.0;
422 doublereal tau =
T_c/T;
423 doublereal delta = rho /
Rho_c;
424 printf(
" T = 647 K, rho = 358.0 kg m-3\n");
438 for (
int i = 1; i < 51; i++) {
445 for (
int i = 1; i <= 15; i++) {
459 doublereal retn = log(delta) + ni0[1] + ni0[2]*tau + ni0[3]*log(tau);
461 retn += ni0[4] * log(1.0 - exp(-gammi0[4]*tau));
462 retn += ni0[5] * log(1.0 - exp(-gammi0[5]*tau));
463 retn += ni0[6] * log(1.0 - exp(-gammi0[6]*tau));
464 retn += ni0[7] * log(1.0 - exp(-gammi0[7]*tau));
465 retn += ni0[8] * log(1.0 - exp(-gammi0[8]*tau));
485 doublereal T375 = pow(tau, 0.375);
486 doublereal val = (ni[1] * delta /
TAUsqrt +
487 ni[2] * delta *
TAUsqrt * T375 +
488 ni[3] * delta * tau +
490 ni[5] *
DELTAp[2] * T375 * T375 +
491 ni[6] *
DELTAp[3] * T375 +
496 for (i = 8; i <= 51; i++) {
503 for (j = 0; j < 3; j++) {
505 doublereal dtmp = delta - epsi[j];
506 doublereal ttmp = tau - gammai[j];
507 val += (ni[i] *
DELTAp[diR[i]] *
TAUp[tiR[i]] *
508 exp(-alphai[j]*dtmp*dtmp - betai[j]*ttmp*ttmp));
514 for (j = 0; j < 2; j++) {
516 doublereal deltam1 = delta - 1.0;
517 doublereal dtmp2 = deltam1 * deltam1;
518 doublereal atmp = 0.5 / Bbetai[j];
519 doublereal theta = (1.0 - tau) + Ai[j] * pow(dtmp2, atmp);
520 doublereal triag = theta * theta + Bi[j] * pow(dtmp2, ai[j]);
521 doublereal ttmp = tau - 1.0;
523 doublereal triagtmp = pow(triag, bi[j]);
525 doublereal
phi = exp(-Ci[j]*dtmp2 - Di[j]*ttmp*ttmp);
526 val += (ni[i] * triagtmp * delta *
phi);
539 doublereal nau =
phi0();
540 doublereal res =
phiR();
541 doublereal retn = nau + res;
562 doublereal T375 = pow(tau, 0.375);
563 doublereal val = (ni[1] /
TAUsqrt +
566 ni[4] * 2.0 * delta *
TAUsqrt +
567 ni[5] * 2.0 * delta * T375 * T375 +
568 ni[6] * 3.0 *
DELTAp[2] * T375 +
569 ni[7] * 4.0 *
DELTAp[3] * tau);
573 for (i = 8; i <= 51; i++) {
574 val += ((ni[i] * exp(-
DELTAp[ciR[i]]) *
DELTAp[diR[i] - 1] *
575 TAUp[tiR[i]]) * (diR[i] - ciR[i]*
DELTAp[ciR[i]]));
581 for (j = 0; j < 3; j++) {
583 doublereal dtmp = delta - epsi[j];
584 doublereal ttmp = tau - gammai[j];
585 doublereal tmp = (ni[i] *
DELTAp[diR[i]] *
TAUp[tiR[i]] *
586 exp(-alphai[j]*dtmp*dtmp - betai[j]*ttmp*ttmp));
587 val += tmp * (diR[i]/delta - 2.0 * alphai[j] * dtmp);
593 for (j = 0; j < 2; j++) {
595 doublereal deltam1 = delta - 1.0;
596 doublereal dtmp2 = deltam1 * deltam1;
597 doublereal atmp = 0.5 / Bbetai[j];
598 doublereal theta = (1.0 - tau) + Ai[j] * pow(dtmp2, atmp);
599 doublereal triag = theta * theta + Bi[j] * pow(dtmp2, ai[j]);
600 doublereal ttmp = tau - 1.0;
602 doublereal triagtmp = pow(triag, bi[j]);
603 doublereal triagtmpm1 = pow(triag, bi[j]-1.0);
604 doublereal atmpM1 = atmp - 1.0;
605 doublereal ptmp = pow(dtmp2,atmpM1);
606 doublereal p2tmp = pow(dtmp2, ai[j]-1.0);
607 doublereal dtriagddelta =
608 deltam1 *(Ai[j] * theta * 2.0 / Bbetai[j] * ptmp +
609 2.0*Bi[j]*ai[j]*p2tmp);
611 doublereal
phi = exp(-Ci[j]*dtmp2 - Di[j]*ttmp*ttmp);
612 doublereal dphiddelta = -2.0*Ci[j]*deltam1*
phi;
613 doublereal dtriagtmpddelta = bi[j] * triagtmpm1 * dtriagddelta;
615 doublereal tmp = ni[i] * (triagtmp * (phi + delta*dphiddelta) +
616 dtriagtmpddelta * delta * phi);
644 doublereal nau =
phi0_d();
645 doublereal res =
phiR_d();
646 doublereal retn = nau + res;
660 doublereal res =
phiR_d();
661 doublereal retn = 1.0 + delta * res;
682 doublereal T375 = pow(tau, 0.375);
683 doublereal val = (ni[4] * 2.0 *
TAUsqrt +
684 ni[5] * 2.0 * T375 * T375 +
685 ni[6] * 6.0 * delta * T375 +
686 ni[7] * 12.0 *
DELTAp[2] * tau);
690 for (i = 8; i <= 51; i++) {
691 doublereal dtmp =
DELTAp[ciR[i]];
692 doublereal tmp = ni[i] * exp(-dtmp) *
TAUp[tiR[i]];
696 atmp =
DELTAp[diR[i] - 2];
698 tmp *= atmp *((diR[i] - ciR[i]*dtmp)*(diR[i]-1.0-ciR[i]*dtmp) -
706 for (j = 0; j < 3; j++) {
708 doublereal dtmp = delta - epsi[j];
709 doublereal ttmp = tau - gammai[j];
710 doublereal tmp = (ni[i] *
TAUp[tiR[i]] *
711 exp(-alphai[j]*dtmp*dtmp - betai[j]*ttmp*ttmp));
712 doublereal deltmp =
DELTAp[diR[i]];
713 doublereal deltmpM1 = deltmp/delta;
714 doublereal deltmpM2 = deltmpM1 / delta;
715 doublereal d2tmp = dtmp * dtmp;
717 val += tmp * (-2.0*alphai[j]*deltmp +
718 4.0 * alphai[j] * alphai[j] * deltmp * d2tmp -
719 4.0 * diR[i] * alphai[j] * deltmpM1 * dtmp +
720 diR[i] * (diR[i] - 1.0) * deltmpM2);
726 for (j = 0; j < 2; j++) {
728 doublereal deltam1 = delta - 1.0;
729 doublereal dtmp2 = deltam1 * deltam1;
730 atmp = 0.5 / Bbetai[j];
731 doublereal theta = (1.0 - tau) + Ai[j] * pow(dtmp2, atmp);
732 doublereal triag = theta * theta + Bi[j] * pow(dtmp2, ai[j]);
733 doublereal ttmp = tau - 1.0;
735 doublereal triagtmp = pow(triag, bi[j]);
736 doublereal triagtmpm1 = pow(triag, bi[j]-1.0);
737 doublereal atmpM1 = atmp - 1.0;
738 doublereal ptmp = pow(dtmp2,atmpM1);
739 doublereal p2tmp = pow(dtmp2, ai[j]-1.0);
740 doublereal dtriagddelta =
741 deltam1 *(Ai[j] * theta * 2.0 / Bbetai[j] * ptmp +
742 2.0*Bi[j]*ai[j]*p2tmp);
744 doublereal
phi = exp(-Ci[j]*dtmp2 - Di[j]*ttmp*ttmp);
745 doublereal dphiddelta = -2.0*Ci[j]*deltam1*
phi;
746 doublereal dtriagtmpddelta = bi[j] * triagtmpm1 * dtriagddelta;
749 doublereal d2phiddelta2 = 2.0 * Ci[j] * phi * (2.0*Ci[j]*dtmp2 - 1.0);
751 doublereal pptmp = ptmp / dtmp2;
752 doublereal d2triagddelta2 = dtriagddelta / deltam1;
754 dtmp2 *(4.0*Bi[j]*ai[j]*(ai[j]-1.0)*pow(dtmp2,ai[j]-2.0) +
755 2.0*Ai[j]*Ai[j]/(Bbetai[j]*Bbetai[j])*ptmp*ptmp +
756 Ai[j]*theta*4.0/Bbetai[j]*(atmp-1.0)*pptmp);
758 doublereal d2triagtmpd2delta =
759 bi[j] * (triagtmpm1 * d2triagddelta2 +
760 (bi[j]-1.0)*triagtmpm1/triag*dtriagddelta*dtriagddelta);
762 doublereal ctmp = (triagtmp * (2.0*dphiddelta + delta*d2phiddelta2) +
763 2.0*dtriagtmpddelta*(phi + delta * dphiddelta) +
764 d2triagtmpd2delta * delta *
phi);
782 return (-1.0/(delta*delta));
795 doublereal retn = nau + res;
802 doublereal res1 =
phiR_d();
804 doublereal retn = 1.0 + delta * (2.0*res1 + delta*res2);
811 doublereal res1 =
phiR_d();
813 doublereal retn = (1.0 + delta * res1) - tau * delta * (res2);
823 doublereal retn = ni0[2] + ni0[3]/tau;
824 retn += (ni0[4] * gammi0[4] * (1.0/(1.0 - exp(-gammi0[4]*tau)) - 1.0));
825 retn += (ni0[5] * gammi0[5] * (1.0/(1.0 - exp(-gammi0[5]*tau)) - 1.0));
826 retn += (ni0[6] * gammi0[6] * (1.0/(1.0 - exp(-gammi0[6]*tau)) - 1.0));
827 retn += (ni0[7] * gammi0[7] * (1.0/(1.0 - exp(-gammi0[7]*tau)) - 1.0));
828 retn += (ni0[8] * gammi0[8] * (1.0/(1.0 - exp(-gammi0[8]*tau)) - 1.0));
844 doublereal atmp, tmp;
849 doublereal T375 = pow(tau, 0.375);
850 doublereal val = ((-0.5) *ni[1] * delta /
TAUsqrt / tau +
851 ni[2] * delta * 0.875 /
TAUsqrt * T375 +
854 ni[5] *
DELTAp[2] * 0.75 * T375 * T375 / tau +
855 ni[6] *
DELTAp[3] * 0.375 * T375 / tau +
860 for (i = 8; i <= 51; i++) {
868 for (j = 0; j < 3; j++) {
870 doublereal dtmp = delta - epsi[j];
871 doublereal ttmp = tau - gammai[j];
872 tmp = (ni[i] *
DELTAp[diR[i]] *
TAUp[tiR[i]] *
873 exp(-alphai[j]*dtmp*dtmp - betai[j]*ttmp*ttmp));
874 val += tmp *(tiR[i]/tau - 2.0 * betai[j]*ttmp);
880 for (j = 0; j < 2; j++) {
882 doublereal deltam1 = delta - 1.0;
883 doublereal dtmp2 = deltam1 * deltam1;
884 atmp = 0.5 / Bbetai[j];
885 doublereal theta = (1.0 - tau) + Ai[j] * pow(dtmp2, atmp);
886 doublereal triag = theta * theta + Bi[j] * pow(dtmp2, ai[j]);
887 doublereal ttmp = tau - 1.0;
889 doublereal triagtmp = pow(triag, bi[j]);
891 doublereal
phi = exp(-Ci[j]*dtmp2 - Di[j]*ttmp*ttmp);
894 doublereal dtriagtmpdtau = -2.0*theta * bi[j] * triagtmp / triag;
896 doublereal dphidtau = - 2.0 * Di[j] * ttmp *
phi;
898 val += ni[i] * delta * (dtriagtmpdtau * phi + triagtmp * dphidtau);
912 doublereal nau =
phi0_t();
913 doublereal res =
phiR_t();
914 doublereal retn = nau + res;
924 doublereal tmp, itmp;
925 doublereal retn = - ni0[3]/(tau * tau);
926 for (
int i = 4; i <= 8; i++) {
927 tmp = exp(-gammi0[i]*tau);
929 retn -= (ni0[i] * gammi0[i] * gammi0[i] * tmp / (itmp * itmp));
946 doublereal atmp, tmp;
951 doublereal T375 = pow(tau, 0.375);
952 doublereal val = ((-0.5) * (-1.5) * ni[1] * delta / (
TAUsqrt * tau * tau) +
953 ni[2] * delta * 0.875 * (-0.125) * T375 / (
TAUsqrt * tau) +
955 ni[5] *
DELTAp[2] * 0.75 *(-0.25) * T375 * T375 / (tau * tau) +
956 ni[6] *
DELTAp[3] * 0.375 *(-0.625) * T375 / (tau * tau));
960 for (i = 8; i <= 51; i++) {
963 val += tiR[i] * (tiR[i] - 1.0) * tmp;
970 for (j = 0; j < 3; j++) {
972 doublereal dtmp = delta - epsi[j];
973 doublereal ttmp = tau - gammai[j];
974 tmp = (ni[i] *
DELTAp[diR[i]] *
TAUp[tiR[i]] *
975 exp(-alphai[j]*dtmp*dtmp - betai[j]*ttmp*ttmp));
976 atmp = tiR[i]/tau - 2.0 * betai[j]*ttmp;
977 val += tmp *(atmp * atmp - tiR[i]/(tau*tau) - 2.0*betai[j]);
983 for (j = 0; j < 2; j++) {
985 doublereal deltam1 = delta - 1.0;
986 doublereal dtmp2 = deltam1 * deltam1;
987 atmp = 0.5 / Bbetai[j];
988 doublereal theta = (1.0 - tau) + Ai[j] * pow(dtmp2, atmp);
989 doublereal triag = theta * theta + Bi[j] * pow(dtmp2, ai[j]);
990 doublereal ttmp = tau - 1.0;
992 doublereal triagtmp = pow(triag, bi[j]);
993 doublereal triagtmpM1 = triagtmp / triag;
995 doublereal
phi = exp(-Ci[j]*dtmp2 - Di[j]*ttmp*ttmp);
998 doublereal dtriagtmpdtau = -2.0*theta * bi[j] * triagtmp / triag;
1000 doublereal dphidtau = - 2.0 * Di[j] * ttmp *
phi;
1002 doublereal d2triagtmpdtau2 =
1003 (2 * bi[j] * triagtmpM1 +
1004 4 * theta * theta * bi[j] * (bi[j]-1.0) * triagtmpM1 / triag);
1006 doublereal d2phidtau2 = 2.0*Di[j]*phi *(2.0*Di[j]*ttmp*ttmp - 1.0);
1008 tmp = (d2triagtmpdtau2 * phi +
1009 2 * dtriagtmpdtau * dphidtau +
1010 triagtmp * d2phidtau2);
1011 val += ni[i] * delta * tmp;
1027 doublereal retn = nau + res;
1055 doublereal T375 = pow(tau, 0.375);
1056 doublereal val = (ni[1] * (-0.5) / (
TAUsqrt * tau) +
1057 ni[2] * (0.875) * T375 /
TAUsqrt +
1059 ni[4] * 2.0 * delta * (0.5) /
TAUsqrt +
1060 ni[5] * 2.0 * delta * (0.75) * T375 * T375 / tau +
1061 ni[6] * 3.0 *
DELTAp[2] * 0.375 * T375 / tau +
1062 ni[7] * 4.0 *
DELTAp[3]);
1066 for (i = 8; i <= 51; i++) {
1067 tmp = (ni[i] * tiR[i] * exp(-
DELTAp[ciR[i]]) *
DELTAp[diR[i] - 1] *
1069 val += tmp * (diR[i] - ciR[i] *
DELTAp[ciR[i]]);
1075 for (j = 0; j < 3; j++) {
1077 doublereal dtmp = delta - epsi[j];
1078 doublereal ttmp = tau - gammai[j];
1079 tmp = (ni[i] *
DELTAp[diR[i]] *
TAUp[tiR[i]] *
1080 exp(-alphai[j]*dtmp*dtmp - betai[j]*ttmp*ttmp));
1081 val += tmp * ((diR[i]/delta - 2.0 * alphai[j] * dtmp) *
1082 (tiR[i]/tau - 2.0 * betai[j] * ttmp));
1088 for (j = 0; j < 2; j++) {
1090 doublereal deltam1 = delta - 1.0;
1091 doublereal dtmp2 = deltam1 * deltam1;
1092 doublereal atmp = 0.5 / Bbetai[j];
1093 doublereal theta = (1.0 - tau) + Ai[j] * pow(dtmp2, atmp);
1094 doublereal triag = theta * theta + Bi[j] * pow(dtmp2, ai[j]);
1095 doublereal ttmp = tau - 1.0;
1097 doublereal triagtmp = pow(triag, bi[j]);
1098 doublereal triagtmpm1 = pow(triag, bi[j]-1.0);
1099 doublereal atmpM1 = atmp - 1.0;
1100 doublereal ptmp = pow(dtmp2,atmpM1);
1101 doublereal p2tmp = pow(dtmp2, ai[j]-1.0);
1102 doublereal dtriagddelta =
1103 deltam1 *(Ai[j] * theta * 2.0 / Bbetai[j] * ptmp +
1104 2.0*Bi[j]*ai[j]*p2tmp);
1106 doublereal
phi = exp(-Ci[j]*dtmp2 - Di[j]*ttmp*ttmp);
1107 doublereal dphiddelta = -2.0*Ci[j]*deltam1*
phi;
1108 doublereal dtriagtmpddelta = bi[j] * triagtmpm1 * dtriagddelta;
1111 doublereal dtriagtmpdtau = -2.0*theta * bi[j] * triagtmp / triag;
1113 doublereal dphidtau = - 2.0 * Di[j] * ttmp *
phi;
1115 doublereal d2phiddeltadtau = 4.0 * Ci[j] * Di[j] * deltam1 * ttmp *
phi;
1117 doublereal d2triagtmpddeltadtau =
1118 (-Ai[j] * bi[j] * 2.0 / Bbetai[j] * triagtmpm1 * deltam1 * ptmp
1119 -2.0 * theta * bi[j] * (bi[j] - 1.0) * triagtmpm1 / triag * dtriagddelta);
1122 doublereal tmp = ni[i] * (triagtmp * (dphidtau + delta*d2phiddeltadtau) +
1123 delta * dtriagtmpddelta * dphidtau +
1124 dtriagtmpdtau * (phi + delta * dphiddelta) +
1125 d2triagtmpddeltadtau * delta *
phi);
1141 doublereal dd = deltaGuess;
1143 doublereal deldd = dd;
1144 doublereal pcheck = 1.0E-30 + 1.0E-8 * p_red;
1145 for (
int n = 0; n < 200; n++) {
1151 doublereal q1 =
phiR_d();
1158 doublereal pred0 = dd + dd * dd * q1;
1163 doublereal dpddelta = 1.0 + 2.0 * dd * q1 + dd * dd * q2;
1169 if (dpddelta <= 0.0) {
1170 if (deltaGuess > 1.0) {
1173 if (deltaGuess < 1.0) {
1181 if (fabs(pred0-p_red) < pcheck) {
1189 doublereal dpdx = dpddelta;
1191 dpdx = dpddelta * 1.1;
1202 deldd = - (pred0 - p_red) / dpdx;
1203 if (fabs(deldd) > 0.05) {
1204 deldd = deldd * 0.05 / fabs(deldd);
1210 if (fabs(deldd/dd) < 1.0E-14) {
1236 doublereal rd =
phiR_d();
1237 doublereal g = 1.0 +
phi0() +
phiR() + delta * rd;
1248 doublereal rd =
phiR_d();
1249 doublereal nt =
phi0_t();
1250 doublereal rt =
phiR_t();
1251 doublereal hRT = 1.0 + tau * (nt + rt) + delta * rd;
1261 doublereal nt =
phi0_t();
1262 doublereal rt =
phiR_t();
1263 doublereal p0 =
phi0();
1264 doublereal pR =
phiR();
1265 doublereal sR = tau * (nt + rt) - p0 - pR;
1275 doublereal nt =
phi0_t();
1276 doublereal rt =
phiR_t();
1277 doublereal uR = tau * (nt + rt);
1289 doublereal cvR = - tau * tau * (ntt + rtt);
1300 doublereal cvR =
cv_R();
1302 doublereal rd =
phiR_d();
1305 doublereal num = (1.0 + delta * rd - delta * tau * rdt);
1306 doublereal cpR = cvR + (num * num /
1307 (1.0 + 2.0 * delta * rd + delta * delta * rdd));