39 m_deltaG_formation_tr_pr(0.0),
40 m_deltaH_formation_tr_pr(0.0),
53 m_domega_jdT_prtr(0.0),
69 m_deltaG_formation_tr_pr(0.0),
70 m_deltaH_formation_tr_pr(0.0),
83 m_domega_jdT_prtr(0.0),
93 const XML_Node& phaseRoot,
bool spInstalled) :
100 m_deltaG_formation_tr_pr(0.0),
101 m_deltaH_formation_tr_pr(0.0),
114 m_domega_jdT_prtr(0.0),
129 m_born_coeff_j(-1.0),
131 m_deltaG_formation_tr_pr(0.0),
132 m_deltaH_formation_tr_pr(0.0),
145 m_domega_jdT_prtr(0.0),
227 doublereal h = GG +
m_temp * SS;
229 #ifdef DEBUG_MODE_NOT
230 doublereal h2 = enthalpy_mole2();
231 if (fabs(h - h2) > 1.0E-1) {
232 printf(
"we are here, h = %g, h2 = %g, k = %d, T = %g, P = %g p0 = %g\n",
248 doublereal PDSS_HKFT::enthalpy_mole2()
const
250 doublereal delH = deltaH();
252 double res = delH + enthTRPR;
265 return (hh - mv *
m_pres);
274 doublereal delS =
deltaS();
284 doublereal delG =
deltaG();
295 doublereal pbar =
m_pres * 1.0E-5;
296 doublereal c1term =
m_c1;
306 doublereal domega_jdT;
307 doublereal d2omega_jdT2;
313 doublereal nu = 166027;
321 doublereal r_e_j = r_e_j_pr_tr + fabs(
m_charge_j) * gval;
322 doublereal dr_e_jdT = fabs(
m_charge_j) * dgvaldT;
323 doublereal d2r_e_jdT2 = fabs(
m_charge_j) * d2gvaldT2;
325 doublereal r_e_j2 = r_e_j * r_e_j;
329 doublereal r_e_H = 3.082 + gval;
330 doublereal r_e_H2 = r_e_H * r_e_H;
332 omega_j = nu * (charge2 / r_e_j - m_charge_j / r_e_H);
334 domega_jdT = nu * (-(charge2 / r_e_j2 * dr_e_jdT)
335 +(m_charge_j / r_e_H2 * dgvaldT));
337 d2omega_jdT2 = nu * (2.0*charge2*dr_e_jdT*dr_e_jdT/(r_e_j2*r_e_j) - charge2*d2r_e_jdT2/r_e_j2
338 -2.0*m_charge_j*dgvaldT*dgvaldT/(r_e_H2*r_e_H) + m_charge_j*d2gvaldT2 /r_e_H2);
344 doublereal Y = drelepsilondT / (relepsilon * relepsilon);
348 #ifdef DEBUG_MODE_NOT
351 doublereal d3 = (d2 - d1) / 0.0001;
352 if (fabs(d2relepsilondT2 - d3) > 1.0E-6) {
353 printf(
"we are here\n");
357 doublereal X = d2relepsilondT2 / (relepsilon* relepsilon) - 2.0 * relepsilon * Y * Y;
359 doublereal Z = -1.0 / relepsilon;
361 doublereal yterm = 2.0 *
m_temp * Y * domega_jdT;
363 doublereal xterm = omega_j *
m_temp * X;
365 doublereal otterm =
m_temp * d2omega_jdT2 * (Z + 1.0);
369 doublereal Cp_calgmol = c1term + c2term + a3term + a4term + yterm + xterm + otterm + rterm;
372 doublereal Cp = Cp_calgmol * 1.0E3 * 4.184;
374 #ifdef DEBUG_MODE_NOT
379 double cpd = (e1 - e2) / 0.001;
380 if (fabs(Cp - cpd) > 10.0) {
381 printf(
"Cp difference : raw: %g, delta: %g, k = %d, T = %g, m_pres = %g\n",
395 throw CanteraError(
"PDSS_HKFT::cv_mole()",
"unimplemented");
404 doublereal a1term =
m_a1 * 1.0E-5;
406 doublereal a2term =
m_a2 / (2600.E5 +
m_pres);
408 doublereal a3term =
m_a3 * 1.0E-5/ (
m_temp - 228.);
413 doublereal domega_jdP;
418 doublereal nu = 166027.;
420 doublereal r_e_j_pr_tr = charge2 / (
m_omega_pr_tr/nu + m_charge_j/3.082);
425 doublereal r_e_j = r_e_j_pr_tr + fabs(m_charge_j) * gval;
426 doublereal r_e_H = 3.082 + gval;
428 omega_j = nu * (charge2 / r_e_j - m_charge_j / r_e_H);
430 doublereal dr_e_jdP = fabs(m_charge_j) * dgvaldP;
432 domega_jdP = - nu * (charge2 / (r_e_j * r_e_j) * dr_e_jdP)
433 + nu * m_charge_j / (r_e_H * r_e_H) * dgvaldP;
440 doublereal Q = drelepsilondP / (relepsilon * relepsilon);
442 doublereal Z = -1.0 / relepsilon;
444 doublereal wterm = - domega_jdP * (Z + 1.0);
446 doublereal qterm = - omega_j * Q;
448 doublereal molVol_calgmolPascal = a1term + a2term + a3term + a4term + wterm + qterm;
451 doublereal molVol = molVol_calgmolPascal * 4.184 * 1.0E3;
465 doublereal m_psave =
m_pres;
475 doublereal m_psave =
m_pres;
485 doublereal m_psave =
m_pres;
495 doublereal m_psave =
m_pres;
497 doublereal ee =
cp_R();
505 doublereal m_psave =
m_pres;
549 throw CanteraError(
"PDSS_HKFT::critTemperature()",
"unimplemented");
556 throw CanteraError(
"PDSS_HKFT::critPressure()",
"unimplemented");
563 throw CanteraError(
"PDSS_HKFT::critDensity()",
"unimplemented");
586 m_Y_pr_tr = drelepsilondT / (relepsilon * relepsilon);
603 if (fabs(Hcalc -DHjmol) > 100.* 1.0E3 * 4.184) {
605 "DHjmol is not consistent with G and S: " +
606 fp2str(Hcalc/(4.184E3)) +
" vs "
609 doublereal nu = 166027;
611 doublereal r_e_j_pr_tr;
625 doublereal r_e_j = r_e_j_pr_tr + fabs(
m_charge_j) * gval;
626 doublereal dr_e_jdT = fabs(
m_charge_j) * dgvaldT;
629 + nu *
m_charge_j / (3.082 + gval) / (3.082 + gval) * dgvaldT;
653 const XML_Node& phaseNode,
bool spInstalled)
660 throw CanteraError(
"PDSS_HKFT::constructPDSSXML",
"spInstalled false not handled");
666 "no thermo Node for species " + speciesNode.
name());
668 std::string model =
lowercase((*tn)[
"model"]);
669 if (model !=
"hkft") {
671 "thermo model for species isn't hkft: "
672 + speciesNode.
name());
677 "no Thermo::HKFT Node for species " + speciesNode.
name());
682 std::string p0string = (*hh)[
"Pref"];
683 if (p0string !=
"") {
687 std::string minTstring = (*hh)[
"Tmin"];
688 if (minTstring !=
"") {
692 std::string maxTstring = (*hh)[
"Tmax"];
693 if (maxTstring !=
"") {
698 doublereal val =
getFloat(*hh,
"DG0_f_Pr_Tr");
706 doublereal val =
getFloat(*hh,
"DH0_f_Pr_Tr");
714 doublereal val =
getFloat(*hh,
"S0_Pr_Tr");
724 "no standardState Node for species " + speciesNode.
name());
727 if (model !=
"hkft") {
729 "standardState model for species isn't hkft: "
730 + speciesNode.
name());
733 doublereal val =
getFloat(*ss,
"a1");
736 throw CanteraError(
"PDSS_HKFT::constructPDSSXML",
" missing a1 field");
739 doublereal val =
getFloat(*ss,
"a2");
742 throw CanteraError(
"PDSS_HKFT::constructPDSSXML",
" missing a2 field");
745 doublereal val =
getFloat(*ss,
"a3");
748 throw CanteraError(
"PDSS_HKFT::constructPDSSXML",
" missing a3 field");
751 doublereal val =
getFloat(*ss,
"a4");
754 throw CanteraError(
"PDSS_HKFT::constructPDSSXML",
" missing a4 field");
758 doublereal val =
getFloat(*ss,
"c1");
761 throw CanteraError(
"PDSS_HKFT::constructPDSSXML",
" missing c1 field");
764 doublereal val =
getFloat(*ss,
"c2");
767 throw CanteraError(
"PDSS_HKFT::constructPDSSXML",
" missing c2 field");
770 doublereal val =
getFloat(*ss,
"omega_Pr_Tr");
773 throw CanteraError(
"PDSS_HKFT::constructPDSSXML",
" missing omega_Pr_Tr field");
777 int isum = hasDGO + hasDHO + hasSO;
780 "Missing 2 or more of DG0_f_Pr_Tr, DH0_f_Pr_Tr, or S0_f_Pr_Tr fields. "
781 "Need to supply at least two of these fields");
812 std::string inputFile, std::string
id)
815 if (inputFile.size() == 0) {
817 "input file is null");
820 ifstream fin(path.c_str());
822 throw CanteraError(
"PDSS_HKFT::initThermo",
"could not open "
823 +path+
" for reading.");
835 "ERROR: Can not find phase named " +
836 id +
" in file named " + inputFile);
841 &(fxml_phase->
root()));
850 doublereal PDSS_HKFT::deltaH()
const
853 doublereal pbar =
m_pres * 1.0E-5;
861 doublereal c2term = -
m_c2 * (1.0/(
m_temp - 228.) - 1.0/(298.15 - 228.));
867 doublereal a4term =
m_a4 * a3tmp * log((2600. + pbar)/(2600. +
m_presR_bar));
870 doublereal domega_jdT;
875 doublereal nu = 166027;
878 doublereal r_e_j = r_e_j_pr_tr + fabs(
m_charge_j) * gval;
881 doublereal dr_e_jdT = fabs(
m_charge_j) * dgvaldT;
886 + nu *
m_charge_j / (3.082 + gval) / (3.082 + gval) * dgvaldT;
892 doublereal Y = drelepsilondT / (relepsilon * relepsilon);
894 doublereal Z = -1.0 / relepsilon;
896 doublereal yterm =
m_temp * omega_j * Y;
899 doublereal wterm = - omega_j * (Z + 1.0);
902 doublereal otterm =
m_temp * domega_jdT * (Z + 1.0);
905 doublereal deltaH_calgmol = c1term + a1term + a2term + c2term + a3term + a4term
906 + yterm + yrterm + wterm + wrterm + otterm + otrterm;
909 doublereal deltaH = deltaH_calgmol * 1.0E3 * 4.184;
917 doublereal pbar =
m_pres * 1.0E-5;
927 doublereal c2term = -
m_c2 * ((1.0/(
m_temp - 228.) - 1.0/(298.15 - 228.)) * (228. -
m_temp)/228.
938 doublereal nu = 166027;
941 doublereal r_e_j = r_e_j_pr_tr + fabs(
m_charge_j) * gval;
947 doublereal Z = -1.0 / relepsilon;
949 doublereal wterm = - omega_j * (Z + 1.0);
955 doublereal deltaG_calgmol = sterm + c1term + a1term + a2term + c2term + a3term + a4term + wterm + wrterm + yterm;
958 doublereal
deltaG = deltaG_calgmol * 1.0E3 * 4.184;
966 doublereal pbar =
m_pres * 1.0E-5;
968 doublereal c1term =
m_c1 * log(
m_temp/298.15);
970 doublereal c2term = -
m_c2 / 228. * ((1.0/(
m_temp - 228.) - 1.0/(298.15 - 228.))
971 + 1.0 / 228. * log((298.15*(
m_temp-228.)) / (
m_temp*(298.15-228.))));
978 doublereal domega_jdT;
984 doublereal nu = 166027;
991 doublereal r_e_j = r_e_j_pr_tr + fabs(
m_charge_j) * gval;
992 doublereal dr_e_jdT = fabs(
m_charge_j) * dgvaldT;
997 + nu *
m_charge_j / (3.082 + gval) / (3.082 + gval) * dgvaldT;
1003 doublereal Y = drelepsilondT / (relepsilon * relepsilon);
1005 doublereal Z = -1.0 / relepsilon;
1007 doublereal wterm = omega_j * Y;
1011 doublereal otterm = domega_jdT * (Z + 1.0);
1015 doublereal deltaS_calgmol = c1term + c2term + a3term + a4term + wterm + wrterm + otterm + otrterm;
1018 doublereal
deltaS = deltaS_calgmol * 1.0E3 * 4.184;
1029 static doublereal ag_coeff[3] = { -2.037662, 5.747000E-3, -6.557892E-6};
1031 doublereal t2 = temp * temp;
1032 doublereal val = ag_coeff[0] + ag_coeff[1] * temp + ag_coeff[2] * t2;
1034 }
else if (ifunc == 1) {
1035 return ag_coeff[1] + ag_coeff[2] * 2.0 * temp;
1040 return ag_coeff[2] * 2.0;
1050 static doublereal bg_coeff[3] = { 6.107361, -1.074377E-2, 1.268348E-5};
1052 doublereal t2 = temp * temp;
1053 doublereal val = bg_coeff[0] + bg_coeff[1] * temp + bg_coeff[2] * t2;
1055 }
else if (ifunc == 1) {
1056 return bg_coeff[1] + bg_coeff[2] * 2.0 * temp;
1061 return bg_coeff[2] * 2.0;
1065 doublereal
PDSS_HKFT::f(
const doublereal temp,
const doublereal pres,
const int ifunc)
const
1068 static doublereal af_coeff[3] = { 3.666666E1, -0.1504956E-9, 0.5107997E-13};
1069 doublereal TC = temp - 273.15;
1070 doublereal presBar = pres / 1.0E5;
1078 if (presBar > 1000.) {
1083 doublereal T1 = (TC-155.0)/300.;
1086 doublereal p2 = (1000. - presBar) * (1000. - presBar);
1087 doublereal p3 = (1000. - presBar) * p2;
1088 doublereal p4 = p2 * p2;
1089 doublereal fac2 = af_coeff[1] * p3 + af_coeff[2] * p4;
1091 fac1 = pow(T1,4.8) + af_coeff[0] * pow(T1, 16.0);
1093 }
else if (ifunc == 1) {
1094 fac1 = (4.8 * pow(T1,3.8) + 16.0 * af_coeff[0] * pow(T1, 15.0)) / 300.;
1096 }
else if (ifunc == 2) {
1097 fac1 = (4.8 * 3.8 * pow(T1,2.8) + 16.0 * 15.0 * af_coeff[0] * pow(T1, 14.0)) / (300. * 300.);
1099 }
else if (ifunc == 3) {
1100 fac1 = pow(T1,4.8) + af_coeff[0] * pow(T1, 16.0);
1101 fac2 = - (3.0 * af_coeff[1] * p2 + 4.0 * af_coeff[2] * p3)/ 1.0E5;
1110 doublereal
PDSS_HKFT::g(
const doublereal temp,
const doublereal pres,
const int ifunc)
const
1112 doublereal afunc =
ag(temp, 0);
1113 doublereal bfunc =
bg(temp, 0);
1118 doublereal gval = afunc * pow((1.0-dens), bfunc);
1125 }
else if (ifunc == 1 || ifunc == 2) {
1126 doublereal afuncdT =
ag(temp, 1);
1127 doublereal bfuncdT =
bg(temp, 1);
1130 doublereal fac1 = afuncdT * gval / afunc;
1131 doublereal fac2 = bfuncdT * gval * log(1.0 - dens);
1132 doublereal fac3 = gval * alpha * bfunc * dens / (1.0 - dens);
1134 doublereal dgdt = fac1 + fac2 + fac3;
1139 doublereal afuncdT2 =
ag(temp, 2);
1140 doublereal bfuncdT2 =
bg(temp, 2);
1142 doublereal dfac1dT = dgdt * afuncdT / afunc + afuncdT2 * gval / afunc
1143 - afuncdT * afuncdT * gval / (afunc * afunc);
1145 doublereal ddensdT = - alpha * dens;
1146 doublereal dfac2dT = bfuncdT2 * gval * log(1.0 - dens)
1147 + bfuncdT * dgdt * log(1.0 - dens)
1148 - bfuncdT * gval /(1.0 - dens) * ddensdT;
1152 doublereal dfac3dT = dgdt * alpha * bfunc * dens / (1.0 - dens)
1153 + gval * dalphadT * bfunc * dens / (1.0 - dens)
1154 + gval * alpha * bfuncdT * dens / (1.0 - dens)
1155 + gval * alpha * bfunc * ddensdT / (1.0 - dens)
1156 + gval * alpha * bfunc * dens / ((1.0 - dens) * (1.0 - dens)) * ddensdT;
1158 return dfac1dT + dfac2dT + dfac3dT;
1160 }
else if (ifunc == 3) {
1163 doublereal dgdp = - bfunc * gval * dens * beta / (1.0 - dens);
1173 doublereal
PDSS_HKFT::gstar(
const doublereal temp,
const doublereal pres,
const int ifunc)
const
1175 doublereal gval =
g(temp, pres, ifunc);
1176 doublereal fval =
f(temp, pres, ifunc);
1177 double res = gval - fval;
1178 #ifdef DEBUG_MODE_NOT
1180 double gval1 =
g(temp, pres, 1);
1181 double fval1 =
f(temp, pres, 1);
1182 double gval2 =
g(temp + 0.001, pres, 1);
1183 double fval2 =
f(temp + 0.001, pres, 1);
1184 double gvalT = (gval2 - gval1) / 0.001;
1185 double fvalT = (fval2 - fval1) / 0.001;
1186 if (fabs(gvalT - gval) > 1.0E-9) {
1187 printf(
"we are here\n");
1189 if (fabs(fvalT - fval) > 1.0E-9) {
1190 printf(
"we are here\n");
1216 throw CanteraError(
"PDSS_HKFT::LookupGe",
"element " + elemName +
" not found");
1221 "element " + elemName +
" doesn not have a supplied entropy298");
1223 geValue *= (-298.15);
1237 doublereal totalSum = 0.0;
1238 for (
size_t m = 0; m < ne; m++) {
1243 totalSum += na * ge;
1273 doublereal*
const c,
1274 doublereal& minTemp,
1275 doublereal& maxTemp,
1276 doublereal& refPressure)
const