32static const double ni0[9] = {
34 -8.32044648201 - 0.000000001739715,
35 6.6832105268 + 0.000000000793232,
44static const double gammi0[9] = {
56static const int ciR[56] = {
115static const int diR[55] = {
173static const int tiR[55] = {
231static const double ni[57] = {
233 +0.12533547935523E-1,
238 -0.78199751687981E-2,
239 +0.88089493102134E-2,
242 -0.66212605039687E-4,
246 -0.40092828925807E-1,
247 +0.39343422603254E-6,
248 -0.75941377088144E-5,
249 +0.56250979351888E-3,
250 -0.15608652257135E-4,
251 +0.11537996422951E-8,
252 +0.36582165144204E-6,
253 -0.13251180074668E-11,
254 -0.62639586912454E-9,
256 +0.17611491008752E-1,
260 +0.49969146990806E-2,
261 -0.31358700712549E-1,
264 +0.20527940895948E-1,
266 +0.14180634400617E-1,
267 +0.83326504880713E-2,
268 -0.29052336009585E-1,
269 +0.38615085574206E-1,
270 -0.20393486513704E-1,
271 -0.16554050063734E-2,
272 +0.19955571979541E-2,
273 +0.15870308324157E-3,
274 -0.16388568342530E-4,
275 +0.43613615723811E-1,
276 +0.34994005463765E-1,
277 -0.76788197844621E-1,
278 +0.22446277332006E-1,
279 -0.62689710414685E-4,
280 -0.55711118565645E-9,
291static const double alphai[3] = {
297static const double betai[3] = {
303static const double gammai[3] = {
309static const double epsi[3] = {
315static const double ai[2] = {
320static const double bi[2] = {
325static const double Bi[2] = {
330static const double Ci[2] = {
335static const double Di[2] = {
340static const double Ai[2] = {
345static const double Bbetai[2] = {
353 for (
int i = 0; i < 52; i++) {
356 for (
int i = 0; i < 16; i++) {
367 for (
int i = 1; i < 51; i++) {
374 for (
int i = 1; i <= 15; i++) {
384 double retn = log(delta) + ni0[1] + ni0[2]*tau + ni0[3]*log(tau);
386 retn += ni0[4] * log(1.0 - exp(-gammi0[4]*tau));
387 retn += ni0[5] * log(1.0 - exp(-gammi0[5]*tau));
388 retn += ni0[6] * log(1.0 - exp(-gammi0[6]*tau));
389 retn += ni0[7] * log(1.0 - exp(-gammi0[7]*tau));
390 retn += ni0[8] * log(1.0 - exp(-gammi0[8]*tau));
401 double T375 = pow(tau, 0.375);
402 double val = (ni[1] * delta /
TAUsqrt +
403 ni[2] * delta *
TAUsqrt * T375 +
404 ni[3] * delta * tau +
406 ni[5] *
DELTAp[2] * T375 * T375 +
407 ni[6] *
DELTAp[3] * T375 +
410 for (i = 8; i <= 51; i++) {
415 for (j = 0; j < 3; j++) {
417 double dtmp = delta - epsi[j];
418 double ttmp = tau - gammai[j];
419 val += (ni[i] *
DELTAp[diR[i]] *
TAUp[tiR[i]] *
420 exp(-alphai[j]*dtmp*dtmp - betai[j]*ttmp*ttmp));
424 for (j = 0; j < 2; j++) {
426 double deltam1 = delta - 1.0;
427 double dtmp2 = deltam1 * deltam1;
428 double atmp = 0.5 / Bbetai[j];
429 double theta = (1.0 - tau) + Ai[j] * pow(dtmp2, atmp);
430 double triag = theta * theta + Bi[j] * pow(dtmp2, ai[j]);
431 double ttmp = tau - 1.0;
432 double triagtmp = pow(triag, bi[j]);
433 double phi = exp(-Ci[j]*dtmp2 - Di[j]*ttmp*ttmp);
434 val += (ni[i] * triagtmp * delta *
phi);
455 double T375 = pow(tau, 0.375);
456 double val = (ni[1] /
TAUsqrt +
459 ni[4] * 2.0 * delta *
TAUsqrt +
460 ni[5] * 2.0 * delta * T375 * T375 +
461 ni[6] * 3.0 *
DELTAp[2] * T375 +
462 ni[7] * 4.0 *
DELTAp[3] * tau);
464 for (i = 8; i <= 51; i++) {
465 val += ((ni[i] * exp(-
DELTAp[ciR[i]]) *
DELTAp[diR[i] - 1] *
466 TAUp[tiR[i]]) * (diR[i] - ciR[i]*
DELTAp[ciR[i]]));
470 for (j = 0; j < 3; j++) {
472 double dtmp = delta - epsi[j];
473 double ttmp = tau - gammai[j];
474 double tmp = (ni[i] *
DELTAp[diR[i]] *
TAUp[tiR[i]] *
475 exp(-alphai[j]*dtmp*dtmp - betai[j]*ttmp*ttmp));
476 val += tmp * (diR[i]/delta - 2.0 * alphai[j] * dtmp);
480 for (j = 0; j < 2; j++) {
482 double deltam1 = delta - 1.0;
483 double dtmp2 = deltam1 * deltam1;
484 double atmp = 0.5 / Bbetai[j];
485 double theta = (1.0 - tau) + Ai[j] * pow(dtmp2, atmp);
486 double triag = theta * theta + Bi[j] * pow(dtmp2, ai[j]);
487 double ttmp = tau - 1.0;
488 double triagtmp = pow(triag, bi[j]);
489 double triagtmpm1 = pow(triag, bi[j]-1.0);
490 double atmpM1 = atmp - 1.0;
491 double ptmp = pow(dtmp2,atmpM1);
492 double p2tmp = pow(dtmp2, ai[j]-1.0);
493 double dtriagddelta =
494 deltam1 *(Ai[j] * theta * 2.0 / Bbetai[j] * ptmp +
495 2.0*Bi[j]*ai[j]*p2tmp);
496 double phi = exp(-Ci[j]*dtmp2 - Di[j]*ttmp*ttmp);
497 double dphiddelta = -2.0*Ci[j]*deltam1*
phi;
498 double dtriagtmpddelta = bi[j] * triagtmpm1 * dtriagddelta;
499 double tmp = ni[i] * (triagtmp * (
phi + delta*dphiddelta) +
500 dtriagtmpddelta * delta *
phi);
524 return 1.0 + delta * res;
535 double T375 = pow(tau, 0.375);
536 double val = (ni[4] * 2.0 *
TAUsqrt +
537 ni[5] * 2.0 * T375 * T375 +
538 ni[6] * 6.0 * delta * T375 +
539 ni[7] * 12.0 *
DELTAp[2] * tau);
541 for (i = 8; i <= 51; i++) {
542 double dtmp =
DELTAp[ciR[i]];
543 double tmp = ni[i] * exp(-dtmp) *
TAUp[tiR[i]];
547 atmp =
DELTAp[diR[i] - 2];
549 tmp *= atmp *((diR[i] - ciR[i]*dtmp)*(diR[i]-1.0-ciR[i]*dtmp) -
555 for (j = 0; j < 3; j++) {
557 double dtmp = delta - epsi[j];
558 double ttmp = tau - gammai[j];
559 double tmp = (ni[i] *
TAUp[tiR[i]] *
560 exp(-alphai[j]*dtmp*dtmp - betai[j]*ttmp*ttmp));
561 double deltmp =
DELTAp[diR[i]];
562 double deltmpM1 = deltmp/delta;
563 double deltmpM2 = deltmpM1 / delta;
564 double d2tmp = dtmp * dtmp;
566 val += tmp * (-2.0*alphai[j]*deltmp +
567 4.0 * alphai[j] * alphai[j] * deltmp * d2tmp -
568 4.0 * diR[i] * alphai[j] * deltmpM1 * dtmp +
569 diR[i] * (diR[i] - 1.0) * deltmpM2);
573 for (j = 0; j < 2; j++) {
575 double deltam1 = delta - 1.0;
576 double dtmp2 = deltam1 * deltam1;
577 atmp = 0.5 / Bbetai[j];
578 double theta = (1.0 - tau) + Ai[j] * pow(dtmp2, atmp);
579 double triag = theta * theta + Bi[j] * pow(dtmp2, ai[j]);
580 double ttmp = tau - 1.0;
581 double triagtmp = pow(triag, bi[j]);
582 double triagtmpm1 = pow(triag, bi[j]-1.0);
583 double atmpM1 = atmp - 1.0;
584 double ptmp = pow(dtmp2,atmpM1);
585 double p2tmp = pow(dtmp2, ai[j]-1.0);
586 double dtriagddelta =
587 deltam1 *(Ai[j] * theta * 2.0 / Bbetai[j] * ptmp +
588 2.0*Bi[j]*ai[j]*p2tmp);
589 double phi = exp(-Ci[j]*dtmp2 - Di[j]*ttmp*ttmp);
590 double dphiddelta = -2.0*Ci[j]*deltam1*
phi;
591 double dtriagtmpddelta = bi[j] * triagtmpm1 * dtriagddelta;
592 double d2phiddelta2 = 2.0 * Ci[j] *
phi * (2.0*Ci[j]*dtmp2 - 1.0);
593 double pptmp = ptmp / dtmp2;
594 double d2triagddelta2 = dtriagddelta / deltam1;
596 dtmp2 *(4.0*Bi[j]*ai[j]*(ai[j]-1.0)*pow(dtmp2,ai[j]-2.0) +
597 2.0*Ai[j]*Ai[j]/(Bbetai[j]*Bbetai[j])*ptmp*ptmp +
598 Ai[j]*theta*4.0/Bbetai[j]*(atmp-1.0)*pptmp);
599 double d2triagtmpd2delta =
600 bi[j] * (triagtmpm1 * d2triagddelta2 +
601 (bi[j]-1.0)*triagtmpm1/triag*dtriagddelta*dtriagddelta);
602 double ctmp = (triagtmp * (2.0*dphiddelta + delta*d2phiddelta2) +
603 2.0*dtriagtmpddelta*(
phi + delta * dphiddelta) +
604 d2triagtmpd2delta * delta *
phi);
613 return -1.0/(delta*delta);
629 return 1.0 + delta * (2.0*res1 + delta*res2);
637 return (1.0 + delta * res1) - tau * delta * (res2);
643 double retn = ni0[2] + ni0[3]/tau;
644 retn += (ni0[4] * gammi0[4] * (1.0/(1.0 - exp(-gammi0[4]*tau)) - 1.0));
645 retn += (ni0[5] * gammi0[5] * (1.0/(1.0 - exp(-gammi0[5]*tau)) - 1.0));
646 retn += (ni0[6] * gammi0[6] * (1.0/(1.0 - exp(-gammi0[6]*tau)) - 1.0));
647 retn += (ni0[7] * gammi0[7] * (1.0/(1.0 - exp(-gammi0[7]*tau)) - 1.0));
648 retn += (ni0[8] * gammi0[8] * (1.0/(1.0 - exp(-gammi0[8]*tau)) - 1.0));
660 double T375 = pow(tau, 0.375);
661 double val = ((-0.5) *ni[1] * delta /
TAUsqrt / tau +
662 ni[2] * delta * 0.875 /
TAUsqrt * T375 +
665 ni[5] *
DELTAp[2] * 0.75 * T375 * T375 / tau +
666 ni[6] *
DELTAp[3] * 0.375 * T375 / tau +
669 for (i = 8; i <= 51; i++) {
675 for (j = 0; j < 3; j++) {
677 double dtmp = delta - epsi[j];
678 double ttmp = tau - gammai[j];
679 tmp = (ni[i] *
DELTAp[diR[i]] *
TAUp[tiR[i]] *
680 exp(-alphai[j]*dtmp*dtmp - betai[j]*ttmp*ttmp));
681 val += tmp *(tiR[i]/tau - 2.0 * betai[j]*ttmp);
685 for (j = 0; j < 2; j++) {
687 double deltam1 = delta - 1.0;
688 double dtmp2 = deltam1 * deltam1;
689 atmp = 0.5 / Bbetai[j];
690 double theta = (1.0 - tau) + Ai[j] * pow(dtmp2, atmp);
691 double triag = theta * theta + Bi[j] * pow(dtmp2, ai[j]);
692 double ttmp = tau - 1.0;
693 double triagtmp = pow(triag, bi[j]);
694 double phi = exp(-Ci[j]*dtmp2 - Di[j]*ttmp*ttmp);
695 double dtriagtmpdtau = -2.0*theta * bi[j] * triagtmp / triag;
696 double dphidtau = - 2.0 * Di[j] * ttmp *
phi;
697 val += ni[i] * delta * (dtriagtmpdtau *
phi + triagtmp * dphidtau);
714 double retn = - ni0[3]/(tau * tau);
715 for (
int i = 4; i <= 8; i++) {
716 tmp = exp(-gammi0[i]*tau);
718 retn -= (ni0[i] * gammi0[i] * gammi0[i] * tmp / (itmp * itmp));
731 double T375 = pow(tau, 0.375);
732 double val = ((-0.5) * (-1.5) * ni[1] * delta / (
TAUsqrt * tau * tau) +
733 ni[2] * delta * 0.875 * (-0.125) * T375 / (
TAUsqrt * tau) +
735 ni[5] *
DELTAp[2] * 0.75 *(-0.25) * T375 * T375 / (tau * tau) +
736 ni[6] *
DELTAp[3] * 0.375 *(-0.625) * T375 / (tau * tau));
738 for (i = 8; i <= 51; i++) {
741 val += tiR[i] * (tiR[i] - 1.0) * tmp;
746 for (j = 0; j < 3; j++) {
748 double dtmp = delta - epsi[j];
749 double ttmp = tau - gammai[j];
750 tmp = (ni[i] *
DELTAp[diR[i]] *
TAUp[tiR[i]] *
751 exp(-alphai[j]*dtmp*dtmp - betai[j]*ttmp*ttmp));
752 atmp = tiR[i]/tau - 2.0 * betai[j]*ttmp;
753 val += tmp *(atmp * atmp - tiR[i]/(tau*tau) - 2.0*betai[j]);
757 for (j = 0; j < 2; j++) {
759 double deltam1 = delta - 1.0;
760 double dtmp2 = deltam1 * deltam1;
761 atmp = 0.5 / Bbetai[j];
762 double theta = (1.0 - tau) + Ai[j] * pow(dtmp2, atmp);
763 double triag = theta * theta + Bi[j] * pow(dtmp2, ai[j]);
764 double ttmp = tau - 1.0;
765 double triagtmp = pow(triag, bi[j]);
766 double triagtmpM1 = triagtmp / triag;
767 double phi = exp(-Ci[j]*dtmp2 - Di[j]*ttmp*ttmp);
768 double dtriagtmpdtau = -2.0*theta * bi[j] * triagtmp / triag;
769 double dphidtau = - 2.0 * Di[j] * ttmp *
phi;
770 double d2triagtmpdtau2 =
771 (2 * bi[j] * triagtmpM1 +
772 4 * theta * theta * bi[j] * (bi[j]-1.0) * triagtmpM1 / triag);
773 double d2phidtau2 = 2.0*Di[j]*
phi *(2.0*Di[j]*ttmp*ttmp - 1.0);
774 tmp = (d2triagtmpdtau2 *
phi +
775 2 * dtriagtmpdtau * dphidtau +
776 triagtmp * d2phidtau2);
777 val += ni[i] * delta * tmp;
803 double T375 = pow(tau, 0.375);
804 double val = (ni[1] * (-0.5) / (
TAUsqrt * tau) +
805 ni[2] * (0.875) * T375 /
TAUsqrt +
807 ni[4] * 2.0 * delta * (0.5) /
TAUsqrt +
808 ni[5] * 2.0 * delta * (0.75) * T375 * T375 / tau +
809 ni[6] * 3.0 *
DELTAp[2] * 0.375 * T375 / tau +
812 for (i = 8; i <= 51; i++) {
813 tmp = (ni[i] * tiR[i] * exp(-
DELTAp[ciR[i]]) *
DELTAp[diR[i] - 1] *
815 val += tmp * (diR[i] - ciR[i] *
DELTAp[ciR[i]]);
819 for (j = 0; j < 3; j++) {
821 double dtmp = delta - epsi[j];
822 double ttmp = tau - gammai[j];
823 tmp = (ni[i] *
DELTAp[diR[i]] *
TAUp[tiR[i]] *
824 exp(-alphai[j]*dtmp*dtmp - betai[j]*ttmp*ttmp));
825 val += tmp * ((diR[i]/delta - 2.0 * alphai[j] * dtmp) *
826 (tiR[i]/tau - 2.0 * betai[j] * ttmp));
830 for (j = 0; j < 2; j++) {
832 double deltam1 = delta - 1.0;
833 double dtmp2 = deltam1 * deltam1;
834 double atmp = 0.5 / Bbetai[j];
835 double theta = (1.0 - tau) + Ai[j] * pow(dtmp2, atmp);
836 double triag = theta * theta + Bi[j] * pow(dtmp2, ai[j]);
837 double ttmp = tau - 1.0;
838 double triagtmp = pow(triag, bi[j]);
839 double triagtmpm1 = pow(triag, bi[j]-1.0);
840 double atmpM1 = atmp - 1.0;
841 double ptmp = pow(dtmp2,atmpM1);
842 double p2tmp = pow(dtmp2, ai[j]-1.0);
843 double dtriagddelta =
844 deltam1 *(Ai[j] * theta * 2.0 / Bbetai[j] * ptmp +
845 2.0*Bi[j]*ai[j]*p2tmp);
846 double phi = exp(-Ci[j]*dtmp2 - Di[j]*ttmp*ttmp);
847 double dphiddelta = -2.0*Ci[j]*deltam1*
phi;
848 double dtriagtmpddelta = bi[j] * triagtmpm1 * dtriagddelta;
849 double dtriagtmpdtau = -2.0*theta * bi[j] * triagtmp / triag;
850 double dphidtau = - 2.0 * Di[j] * ttmp *
phi;
851 double d2phiddeltadtau = 4.0 * Ci[j] * Di[j] * deltam1 * ttmp *
phi;
852 double d2triagtmpddeltadtau =
853 (-Ai[j] * bi[j] * 2.0 / Bbetai[j] * triagtmpm1 * deltam1 * ptmp
854 -2.0 * theta * bi[j] * (bi[j] - 1.0) * triagtmpm1 / triag * dtriagddelta);
855 double tmp = ni[i] * (triagtmp * (dphidtau + delta*d2phiddeltadtau) +
856 delta * dtriagtmpddelta * dphidtau +
857 dtriagtmpdtau * (
phi + delta * dphiddelta) +
858 d2triagtmpddeltadtau * delta *
phi);
866 double dd = deltaGuess;
869 double pcheck = 1.0E-30 + 1.0E-14 * p_red;
870 for (
int n = 0; n < 200; n++) {
880 double pred0 = dd + dd * dd * q1;
884 double dpddelta = 1.0 + 2.0 * dd * q1 + dd * dd * q2;
889 if (dpddelta <= 0.0) {
890 if (deltaGuess > 1.0) {
893 if (deltaGuess < 1.0) {
900 if (fabs(pred0-p_red) < pcheck) {
906 double dpdx = dpddelta;
908 dpdx = dpddelta * 1.1;
910 dpdx = std::max(dpdx, 0.001);
914 deldd = - (pred0 - p_red) / dpdx;
915 if (fabs(deldd) > 0.05) {
916 deldd = deldd * 0.05 / fabs(deldd);
921 if (fabs(deldd/dd) < 1.0E-14) {
943 return 1.0 +
phi0() +
phiR() + delta * rd;
953 return 1.0 + tau * (nt + rt) + delta * rd;
963 return tau * (nt + rt) - p0 - pR;
971 return tau * (nt + rt);
979 return - tau * tau * (ntt + rtt);
990 double num = (1.0 + delta * rd - delta * tau * rdt);
991 double cpR = cvR + (num * num /
992 (1.0 + 2.0 * delta * rd + delta * delta * rdd));
Header for Lowest level of the classes which support a real water model (see class WaterPropsIAPWS an...
double phiR_dt() const
Calculate the mixed derivative d2_phiR/(dtau ddelta)
double phi_tt(double tau, double delta)
Second derivative of phi wrt tau.
double phi_dd(double tau, double delta)
2nd derivative of phi wrt delta
double phi0_d() const
Calculate d_phi0_d(delta), the first derivative of phi0 wrt delta.
double phiR_dd() const
Calculate d2_phiR_dd(delta), the second derivative of phiR wrt delta.
double gibbs_RT() const
Calculate the dimensionless Gibbs free energy.
double phi0() const
Calculate Equation 6.5 for phi0, the ideal gas part of the dimensionless Helmholtz free energy.
double TAUp[52]
Value of internally calculated polynomials of powers of TAU.
double phi0_dt() const
Calculate the mixed derivative d2_phi0/(dtau ddelta)
double phi_d(double tau, double delta)
Calculate derivative of phi wrt delta.
double phi0_tt() const
Calculate d2_phi0/dtau2.
double phi0_t() const
Calculate d_phi0/d(tau)
WaterPropsIAPWSphi()
Base constructor.
double DELTAsave
Last delta that was used to calculate polynomials.
double cv_R() const
Calculate the dimensionless constant volume heat capacity, Cv/R.
double intEnergy_RT() const
Calculate the dimensionless internal energy, u/RT.
double TAUsave
Last tau that was used to calculate polynomials.
double phiR_t() const
Calculate Equation 6.6 for dphiRdtau, the derivative residual part of the dimensionless Helmholtz fre...
double enthalpy_RT() const
Calculate the dimensionless enthalpy, h/RT.
double TAUsqrt
sqrt of TAU
double phi(double tau, double delta)
Calculate the Phi function, which is the base function.
double entropy_R() const
Calculate the dimensionless entropy, s/R.
double phi0_dd() const
Calculate d2_phi0_dd(delta), the second derivative of phi0 wrt delta.
double phiR() const
Calculate Equation 6.6 for phiR, the residual part of the dimensionless Helmholtz free energy.
double pressureM_rhoRT(double tau, double delta)
Calculate the dimensionless pressure at tau and delta;.
double dimdpdrho(double tau, double delta)
Dimensionless derivative of p wrt rho at constant T.
double phiR_tt() const
Calculate Equation 6.6 for dphiRdtau, the second derivative residual part of the dimensionless Helmho...
double dfind(double p_red, double tau, double deltaGuess)
This function computes the reduced density, given the reduced pressure and the reduced temperature,...
double dimdpdT(double tau, double delta)
Dimensionless derivative of p wrt T at constant rho.
double cp_R() const
Calculate the dimensionless constant pressure heat capacity, Cv/R.
double DELTAp[16]
Value of internally calculated polynomials of powers of delta.
double phi_t(double tau, double delta)
First derivative of phi wrt tau.
void tdpolycalc(double tau, double delta)
Calculates internal polynomials in tau and delta.
double phiR_d() const
Calculate d_phiR_d(delta), the first derivative of phiR wrt delta.
This file contains definitions for utility functions and text for modules, inputfiles and logging,...
Namespace for the Cantera kernel.