29 m_formPitzerTemp(PITZER_TEMP_CONSTANT),
31 m_IionicMolality(0.0),
32 m_maxIionicStrength(100.0),
33 m_TempPitzerRef(298.15),
34 m_IionicMolalityStoich(0.0),
35 m_form_A_Debye(A_DEBYE_WATER),
39 m_molalitiesAreCropped(false),
42 IMS_gamma_o_min_(1.0E-5),
43 IMS_gamma_k_min_(10.0),
63 CROP_ln_gamma_o_min(-6.0),
64 CROP_ln_gamma_o_max(3.0),
65 CROP_ln_gamma_k_min(-5.0),
66 CROP_ln_gamma_k_max(15.0),
74 m_formPitzerTemp(PITZER_TEMP_CONSTANT),
76 m_IionicMolality(0.0),
77 m_maxIionicStrength(100.0),
78 m_TempPitzerRef(298.15),
79 m_IionicMolalityStoich(0.0),
80 m_form_A_Debye(A_DEBYE_WATER),
84 m_molalitiesAreCropped(false),
87 IMS_gamma_o_min_(1.0E-5),
88 IMS_gamma_k_min_(10.0),
108 CROP_ln_gamma_o_min(-6.0),
109 CROP_ln_gamma_o_max(3.0),
110 CROP_ln_gamma_k_min(-5.0),
111 CROP_ln_gamma_k_max(15.0),
120 m_formPitzerTemp(PITZER_TEMP_CONSTANT),
122 m_IionicMolality(0.0),
123 m_maxIionicStrength(100.0),
124 m_TempPitzerRef(298.15),
125 m_IionicMolalityStoich(0.0),
126 m_form_A_Debye(A_DEBYE_WATER),
129 m_densWaterSS(1000.),
130 m_molalitiesAreCropped(false),
132 IMS_X_o_cutoff_(0.2),
133 IMS_gamma_o_min_(1.0E-5),
134 IMS_gamma_k_min_(10.0),
154 CROP_ln_gamma_o_min(-6.0),
155 CROP_ln_gamma_o_max(3.0),
156 CROP_ln_gamma_k_min(-5.0),
157 CROP_ln_gamma_k_max(15.0),
166 m_formPitzerTemp(PITZER_TEMP_CONSTANT),
168 m_IionicMolality(0.0),
169 m_maxIionicStrength(100.0),
170 m_TempPitzerRef(298.15),
171 m_IionicMolalityStoich(0.0),
172 m_form_A_Debye(A_DEBYE_WATER),
175 m_densWaterSS(1000.),
176 m_molalitiesAreCropped(false),
178 IMS_X_o_cutoff_(0.2),
179 IMS_gamma_o_min_(1.0E-5),
180 IMS_gamma_k_min_(10.0),
200 CROP_ln_gamma_o_min(-6.0),
201 CROP_ln_gamma_o_max(3.0),
202 CROP_ln_gamma_k_min(-5.0),
203 CROP_ln_gamma_k_max(15.0),
212 HMWSoln& HMWSoln::operator=(
const HMWSoln& b)
215 MolalityVPSSTP::operator=(b);
230 throw CanteraError(
"HMWSoln::operator=()",
"Dynamic cast to PDSS_Water failed");
236 if (b.m_waterProps) {
257 m_Alpha1MX_ij = b.m_Alpha1MX_ij;
336 IMS_dfCut_ = b.IMS_dfCut_;
337 IMS_efCut_ = b.IMS_efCut_;
338 IMS_afCut_ = b.IMS_afCut_;
339 IMS_bfCut_ = b.IMS_bfCut_;
341 IMS_dgCut_ = b.IMS_dgCut_;
342 IMS_egCut_ = b.IMS_egCut_;
343 IMS_agCut_ = b.IMS_agCut_;
344 IMS_bgCut_ = b.IMS_bgCut_;
348 MC_dpCut_ = b.MC_dpCut_;
349 MC_epCut_ = b.MC_epCut_;
350 MC_apCut_ = b.MC_apCut_;
351 MC_bpCut_ = b.MC_bpCut_;
352 MC_cpCut_ = b.MC_cpCut_;
353 CROP_ln_gamma_o_min = b.CROP_ln_gamma_o_min;
354 CROP_ln_gamma_o_max = b.CROP_ln_gamma_o_max;
355 CROP_ln_gamma_k_min = b.CROP_ln_gamma_k_min;
356 CROP_ln_gamma_k_max = b.CROP_ln_gamma_k_max;
375 "To be removed after Cantera 2.3.");
406 for (
size_t k = 0; k <
m_kk; k++) {
418 size_t kcation =
npos;
419 double xcation = 0.0;
420 size_t kanion =
npos;
421 for (
size_t k = 0; k <
m_kk; k++) {
427 }
else if (
charge(k) < 0.0) {
428 if (
m_tmpV[k] > xcation) {
434 if (kcation ==
npos || kanion ==
npos) {
437 double xuse = xcation;
439 if (xanion < xcation) {
441 if (
charge(kcation) != 1.0) {
445 if (
charge(kanion) != 1.0) {
449 xuse = xuse / factor;
478 return cp - beta * beta * tt * molarV / kappa_t;
505 if (rho != dens_old) {
507 "Density is not an independent variable");
514 "Density is not an independent variable");
526 for (
size_t k = 1; k <
m_kk; k++) {
539 return 1.0 / mvSolvent;
548 s_update_lnMolalityActCoeff();
551 for (
size_t k = 0; k <
m_kk; k++) {
565 s_update_lnMolalityActCoeff();
567 for (
size_t k = 0; k <
m_kk; k++) {
568 acMolality[k] = exp(acMolality[k]);
584 s_update_lnMolalityActCoeff();
586 for (
size_t k = 0; k <
m_kk; k++) {
603 for (
size_t k = 0; k <
m_kk; k++) {
609 s_update_lnMolalityActCoeff();
611 for (
size_t k = 0; k <
m_kk; k++) {
623 for (
size_t k = 0; k <
m_kk; k++) {
629 s_update_lnMolalityActCoeff();
634 for (
size_t k = 0; k <
m_kk; k++) {
648 for (
size_t k = 0; k <
m_kk; k++) {
659 s_update_lnMolalityActCoeff();
661 for (
size_t k = 0; k <
m_kk; k++) {
669 for (
size_t k = 0; k <
m_kk; k++) {
675 s_update_lnMolalityActCoeff();
678 for (
size_t k = 0; k <
m_kk; k++) {
700 if (tempArg != -1.0) {
704 if (presArg != -1.0) {
723 throw CanteraError(
"HMWSoln::A_Debye_TP",
"shouldn't be here");
731 if (tempArg != -1.0) {
735 if (presArg != -1.0) {
747 throw CanteraError(
"HMWSoln::dA_DebyedT_TP",
"shouldn't be here");
755 if (tempArg != -1.0) {
759 if (presArg != -1.0) {
779 throw CanteraError(
"HMWSoln::dA_DebyedP_TP",
"shouldn't be here");
787 double dAphidT = dAdT /3.0;
789 if (tempArg != -1.0) {
798 double dAphidP = dAdP /3.0;
800 if (tempArg != -1.0) {
809 if (tempArg != -1.0) {
814 double d2Aphi = d2 / 3.0;
815 return 2.0 * A_L / T + 4.0 *
GasConstant * T * T *d2Aphi;
821 if (tempArg != -1.0) {
825 if (presArg != -1.0) {
837 throw CanteraError(
"HMWSoln::d2A_DebyedT2_TP",
"shouldn't be here");
861 size_t maxCounterIJlen = 1 + (
m_kk-1) * (
m_kk-2) / 2;
864 int TCoeffLength = 1;
895 m_Alpha1MX_ij.resize(maxCounterIJlen, 2.0);
936 m_BMX_IJ.resize(maxCounterIJlen, 0.0);
948 m_Phi_IJ.resize(maxCounterIJlen, 0.0);
957 m_CMX_IJ.resize(maxCounterIJlen, 0.0);
969 void HMWSoln::s_update_lnMolalityActCoeff()
const 988 for (
size_t k = 0; k <
m_kk; k++) {
994 double zs_k2 = z_k - zs_k1;
1011 double lnActCoeffMolal0 = - log(xx) + (xx - 1.0)/xx;
1012 double lnxs = log(xx);
1014 for (
size_t k = 1; k <
m_kk; k++) {
1049 doublereal Imax = 0.0;
1052 for (
size_t k = 0; k <
m_kk; k++) {
1058 if (cropMethod == 0) {
1065 for (
size_t i = 1; i < (
m_kk - 1); i++) {
1066 double charge_i =
charge(i);
1067 double abs_charge_i = fabs(charge_i);
1068 if (charge_i == 0.0) {
1071 for (
size_t j = (i+1); j <
m_kk; j++) {
1072 double charge_j =
charge(j);
1073 double abs_charge_j = fabs(charge_j);
1076 if (charge_i * charge_j < 0) {
1081 if (Imax > Iac_max) {
1085 if (Imax > Iac_max) {
1090 if (Imax > Iac_max) {
1094 if (Imax > Iac_max) {
1104 for (
int times = 0; times< 10; times++) {
1105 double anion_charge = 0.0;
1106 double cation_charge = 0.0;
1107 size_t anion_contrib_max_i =
npos;
1108 double anion_contrib_max = -1.0;
1109 size_t cation_contrib_max_i =
npos;
1110 double cation_contrib_max = -1.0;
1111 for (
size_t i = 0; i <
m_kk; i++) {
1112 double charge_i =
charge(i);
1113 if (charge_i < 0.0) {
1115 anion_charge += anion_contrib;
1116 if (anion_contrib > anion_contrib_max) {
1117 anion_contrib_max = anion_contrib;
1118 anion_contrib_max_i = i;
1120 }
else if (charge_i > 0.0) {
1122 cation_charge += cation_contrib;
1123 if (cation_contrib > cation_contrib_max) {
1124 cation_contrib_max = cation_contrib;
1125 cation_contrib_max_i = i;
1129 double total_charge = cation_charge - anion_charge;
1130 if (total_charge > 1.0E-8) {
1131 double desiredCrop = total_charge/
charge(cation_contrib_max_i);
1133 if (desiredCrop < maxCrop) {
1139 }
else if (total_charge < -1.0E-8) {
1140 double desiredCrop = total_charge/
charge(anion_contrib_max_i);
1142 if (desiredCrop < maxCrop) {
1154 if (cropMethod == 1) {
1163 double poly = MC_apCut_ + MC_bpCut_ * xmolSolvent + MC_dpCut_* xmolSolvent * xmolSolvent;
1164 double p = xmolSolvent + MC_epCut_ + exp(- xmolSolvent/ MC_cpCut_) * poly;
1166 for (
size_t k = 0; k <
m_kk; k++) {
1174 for (
size_t k = 0; k <
m_kk; k++) {
1179 for (
size_t k = 0; k <
m_kk; k++) {
1192 for (
size_t i = 0; i <
m_kk; i++) {
1194 size_t nc =
m_kk * i;
1198 for (
size_t i = 1; i < (
m_kk - 1); i++) {
1199 size_t n =
m_kk * i + i;
1201 for (
size_t j = (i+1); j <
m_kk; j++) {
1203 size_t nc =
m_kk * i + j;
1214 const double twoT = 2.0 * T;
1215 const double invT = 1.0 / T;
1216 const double invT2 = invT * invT;
1217 const double twoinvT3 = 2.0 * invT * invT2;
1218 double tinv = 0.0, tln = 0.0, tlin = 0.0, tquad = 0.0;
1228 for (
size_t i = 1; i < (
m_kk - 1); i++) {
1229 for (
size_t j = (i+1); j <
m_kk; j++) {
1231 size_t n =
m_kk*i + j;
1241 case PITZER_TEMP_CONSTANT:
1243 case PITZER_TEMP_LINEAR:
1246 + beta0MX_coeff[1]*tlin;
1250 + beta1MX_coeff[1]*tlin;
1254 + beta2MX_coeff[1]*tlin;
1258 + CphiMX_coeff[1]*tlin;
1261 m_Theta_ij[counterIJ] = Theta_coeff[0] + Theta_coeff[1]*tlin;
1266 case PITZER_TEMP_COMPLEX1:
1268 + beta0MX_coeff[1]*tlin
1269 + beta0MX_coeff[2]*tquad
1270 + beta0MX_coeff[3]*tinv
1271 + beta0MX_coeff[4]*tln;
1273 + beta1MX_coeff[1]*tlin
1274 + beta1MX_coeff[2]*tquad
1275 + beta1MX_coeff[3]*tinv
1276 + beta1MX_coeff[4]*tln;
1278 + beta2MX_coeff[1]*tlin
1279 + beta2MX_coeff[2]*tquad
1280 + beta2MX_coeff[3]*tinv
1281 + beta2MX_coeff[4]*tln;
1283 + CphiMX_coeff[1]*tlin
1284 + CphiMX_coeff[2]*tquad
1285 + CphiMX_coeff[3]*tinv
1286 + CphiMX_coeff[4]*tln;
1288 + Theta_coeff[1]*tlin
1289 + Theta_coeff[2]*tquad
1290 + Theta_coeff[3]*tinv
1291 + Theta_coeff[4]*tln;
1293 + beta0MX_coeff[2]*twoT
1294 - beta0MX_coeff[3]*invT2
1295 + beta0MX_coeff[4]*invT;
1297 + beta1MX_coeff[2]*twoT
1298 - beta1MX_coeff[3]*invT2
1299 + beta1MX_coeff[4]*invT;
1301 + beta2MX_coeff[2]*twoT
1302 - beta2MX_coeff[3]*invT2
1303 + beta2MX_coeff[4]*invT;
1305 + CphiMX_coeff[2]*twoT
1306 - CphiMX_coeff[3]*invT2
1307 + CphiMX_coeff[4]*invT;
1309 + Theta_coeff[2]*twoT
1310 - Theta_coeff[3]*invT2
1311 + Theta_coeff[4]*invT;
1315 + beta0MX_coeff[2]*2.0
1316 + beta0MX_coeff[3]*twoinvT3
1317 - beta0MX_coeff[4]*invT2;
1319 + beta1MX_coeff[2]*2.0
1320 + beta1MX_coeff[3]*twoinvT3
1321 - beta1MX_coeff[4]*invT2;
1323 + beta2MX_coeff[2]*2.0
1324 + beta2MX_coeff[3]*twoinvT3
1325 - beta2MX_coeff[4]*invT2;
1327 + CphiMX_coeff[2]*2.0
1328 + CphiMX_coeff[3]*twoinvT3
1329 - CphiMX_coeff[4]*invT2;
1331 + Theta_coeff[2]*2.0
1332 + Theta_coeff[3]*twoinvT3
1333 - Theta_coeff[4]*invT2;
1343 for (
size_t i = 1; i <
m_kk; i++) {
1345 for (
size_t j = 1; j <
m_kk; j++) {
1346 size_t n = i *
m_kk + j;
1349 case PITZER_TEMP_CONSTANT:
1352 case PITZER_TEMP_LINEAR:
1353 m_Lambda_nj(i,j) = Lambda_coeff[0] + Lambda_coeff[1]*tlin;
1357 case PITZER_TEMP_COMPLEX1:
1359 + Lambda_coeff[1]*tlin
1360 + Lambda_coeff[2]*tquad
1361 + Lambda_coeff[3]*tinv
1362 + Lambda_coeff[4]*tln;
1365 + Lambda_coeff[2]*twoT
1366 - Lambda_coeff[3]*invT2
1367 + Lambda_coeff[4]*invT;
1371 + Lambda_coeff[3]*twoinvT3
1372 - Lambda_coeff[4]*invT2;
1378 case PITZER_TEMP_CONSTANT:
1381 case PITZER_TEMP_LINEAR:
1382 m_Mu_nnn[i] = Mu_coeff[0] + Mu_coeff[1]*tlin;
1386 case PITZER_TEMP_COMPLEX1:
1398 + Mu_coeff[3]*twoinvT3
1399 - Mu_coeff[4]*invT2;
1407 case PITZER_TEMP_CONSTANT:
1408 for (
size_t i = 1; i <
m_kk; i++) {
1409 for (
size_t j = 1; j <
m_kk; j++) {
1410 for (
size_t k = 1; k <
m_kk; k++) {
1418 case PITZER_TEMP_LINEAR:
1419 for (
size_t i = 1; i <
m_kk; i++) {
1420 for (
size_t j = 1; j <
m_kk; j++) {
1421 for (
size_t k = 1; k <
m_kk; k++) {
1424 m_Psi_ijk[n] = Psi_coeff[0] + Psi_coeff[1]*tlin;
1431 case PITZER_TEMP_COMPLEX1:
1432 for (
size_t i = 1; i <
m_kk; i++) {
1433 for (
size_t j = 1; j <
m_kk; j++) {
1434 for (
size_t k = 1; k <
m_kk; k++) {
1439 + Psi_coeff[2]*tquad
1444 - Psi_coeff[3]*invT2
1445 + Psi_coeff[4]*invT;
1448 + Psi_coeff[3]*twoinvT3
1449 - Psi_coeff[4]*invT2;
1461 throw CanteraError(
"HMWSoln::s_updatePitzer_lnMolalityActCoeff",
1462 "Wrong index solvent value!");
1473 double etheta[5][5], etheta_prime[5][5], sqrtIs;
1480 double molarcharge = 0.0;
1484 double molalitysumUncropped = 0.0;
1491 for (
size_t n = 1; n <
m_kk; n++) {
1495 molarcharge += fabs(
charge(n)) * molality[n];
1505 writelogf(
" ionic strenth = %14.7le \n total molar " 1506 "charge = %14.7le \n", Is, molarcharge);
1516 for (
int z1 = 1; z1 <=4; z1++) {
1517 for (
int z2 =1; z2 <=4; z2++) {
1518 calc_thetas(z1, z2, ðeta[z1][z2], ðeta_prime[z1][z2]);
1520 writelogf(
" z1=%3d z2=%3d E-theta(I) = %f, E-thetaprime(I) = %f\n",
1521 z1, z2, etheta[z1][z2], etheta_prime[z1][z2]);
1527 " Species Species g(x) hfunc(x)\n",
1533 for (
size_t i = 1; i < (
m_kk - 1); i++) {
1534 for (
size_t j = (i+1); j <
m_kk; j++) {
1536 size_t n =
m_kk*i + j;
1542 double x1 = sqrtIs * m_Alpha1MX_ij[counterIJ];
1543 if (x1 > 1.0E-100) {
1544 m_gfunc_IJ[counterIJ] = 2.0*(1.0-(1.0 + x1) * exp(-x1)) / (x1 * x1);
1546 (1.0-(1.0 + x1 + 0.5 * x1 * x1) * exp(-x1)) / (x1 * x1);
1554 if (x2 > 1.0E-100) {
1555 m_g2func_IJ[counterIJ] = 2.0*(1.0-(1.0 + x2) * exp(-x2)) / (x2 * x2);
1557 (1.0-(1.0 + x2 + 0.5 * x2 * x2) * exp(-x2)) / (x2 * x2);
1577 " Species Species BMX BprimeMX BphiMX\n",
1580 for (
size_t i = 1; i <
m_kk - 1; i++) {
1581 for (
size_t j = i+1; j <
m_kk; j++) {
1583 size_t n =
m_kk*i + j;
1598 if (Is > 1.0E-150) {
1611 writelogf(
" %-16s %-16s %11.7f %11.7f %11.7f \n",
1622 for (
size_t i = 1; i <
m_kk-1; i++) {
1623 for (
size_t j = i+1; j <
m_kk; j++) {
1625 size_t n =
m_kk*i + j;
1646 " Species Species Phi_ij Phiprime_ij Phi^phi_ij \n",
1648 for (
size_t i = 1; i <
m_kk-1; i++) {
1649 for (
size_t j = i+1; j <
m_kk; j++) {
1651 size_t n =
m_kk*i + j;
1657 int z1 = (int) fabs(
charge(i));
1658 int z2 = (int) fabs(
charge(j));
1668 writelogf(
" %-16s %-16s %10.6f %10.6f %10.6f \n",
1679 double F = -Aphi * (sqrt(Is) / (1.0 + 1.2*sqrt(Is))
1680 + (2.0/1.2) * log(1.0+1.2*(sqrtIs)));
1682 writelogf(
" initial value of F = %10.6f \n", F);
1684 for (
size_t i = 1; i <
m_kk-1; i++) {
1685 for (
size_t j = i+1; j <
m_kk; j++) {
1687 size_t n =
m_kk*i + j;
1706 debuglog(
" Step 8: Summing in All Contributions to Activity Coefficients \n",
1709 for (
size_t i = 1; i <
m_kk; i++) {
1721 writelogf(
" Unary term: z*z*F = %10.5f\n", zsqF);
1728 for (
size_t j = 1; j <
m_kk; j++) {
1730 size_t n =
m_kk*i + j;
1735 sum1 += molality[j] *
1739 writelogf(
" Bin term with %-13s 2 m_j BMX = %10.5f\n", snj,
1740 molality[j]*2.0*
m_BMX_IJ[counterIJ]);
1742 molality[j]* molarcharge*
m_CMX_IJ[counterIJ]);
1748 for (
size_t k = j+1; k <
m_kk; k++) {
1752 sum3 += molality[j]*molality[k]*
m_Psi_ijk[n];
1755 writelogf(
" Psi term on %-16s m_j m_k psi_ijk = %10.5f\n", snj,
1766 sum2 += molality[j]*(2.0*
m_Phi_IJ[counterIJ]);
1769 writelogf(
" Phi term with %-12s 2 m_j Phi_cc = %10.5f\n", snj,
1770 molality[j]*(2.0*
m_Phi_IJ[counterIJ]));
1773 for (
size_t k = 1; k <
m_kk; k++) {
1777 sum2 += molality[j]*molality[k]*
m_Psi_ijk[n];
1780 writelogf(
" Psi term on %-16s m_j m_k psi_ijk = %10.5f\n", snj,
1787 sum4 += (fabs(
charge(i))*
1788 molality[j]*molality[k]*
m_CMX_IJ[counterIJ2]);
1791 writelogf(
" Tern CMX term on %-16s abs(z_i) m_j m_k CMX = %10.5f\n", snj,
1803 writelogf(
" Lambda term with %-12s 2 m_j lam_ji = %10.5f\n", snj,
1808 for (
size_t k = 1; k <
m_kk; k++) {
1815 sum5 += molality[j]*molality[k]*zeta;
1818 writelogf(
" Zeta term on %-16s m_n m_a zeta_nMa = %10.5f\n", snj,
1832 writelogf(
" Net %-16s lngamma[i] = %9.5f gamma[i]=%10.6f \n",
1847 writelogf(
" Unary term: z*z*F = %10.5f\n", zsqF);
1854 for (
size_t j = 1; j <
m_kk; j++) {
1856 size_t n =
m_kk*i + j;
1861 sum1 += molality[j]*
1865 writelogf(
" Bin term with %-13s 2 m_j BMX = %10.5f\n", snj,
1866 molality[j]*2.0*
m_BMX_IJ[counterIJ]);
1868 molality[j]* molarcharge*
m_CMX_IJ[counterIJ]);
1871 for (
size_t k = j+1; k <
m_kk; k++) {
1875 sum3 += molality[j]*molality[k]*
m_Psi_ijk[n];
1878 writelogf(
" Psi term on %-16s m_j m_k psi_ijk = %10.5f\n", snj,
1890 sum2 += molality[j]*(2.0*
m_Phi_IJ[counterIJ]);
1893 writelogf(
" Phi term with %-12s 2 m_j Phi_aa = %10.5f\n", snj,
1894 molality[j]*(2.0*
m_Phi_IJ[counterIJ]));
1897 for (
size_t k = 1; k <
m_kk; k++) {
1901 sum2 += molality[j]*molality[k]*
m_Psi_ijk[n];
1904 writelogf(
" Psi term on %-16s m_j m_k psi_ijk = %10.5f\n", snj,
1911 molality[j]*molality[k]*
m_CMX_IJ[counterIJ2];
1914 writelogf(
" Tern CMX term on %-16s abs(z_i) m_j m_k CMX = %10.5f\n", snj,
1926 writelogf(
" Lambda term with %-12s 2 m_j lam_ji = %10.5f\n", snj,
1930 for (
size_t k = 1; k <
m_kk; k++) {
1938 sum5 += molality[j]*molality[k]*zeta;
1941 writelogf(
" Zeta term on %-16s m_n m_c zeta_ncX = %10.5f\n", snj,
1952 writelogf(
" Net %-16s lngamma[i] = %9.5f gamma[i]=%10.6f\n",
1966 for (
size_t j = 1; j <
m_kk; j++) {
1970 writelogf(
" Lambda_n term on %-16s 2 m_j lambda_n_j = %10.5f\n", snj,
1975 for (
size_t k = 1; k <
m_kk; k++) {
1978 sum3 += molality[j]*molality[k]*
m_Psi_ijk[n];
1981 writelogf(
" Zeta term on %-16s m_j m_k psi_ijk = %10.5f\n", snj,
1988 double sum2 = 3.0 * molality[i]* molality[i] *
m_Mu_nnn[i];
1990 writelogf(
" Mu_nnn term 3 m_n m_n Mu_n_n = %10.5f\n",
1991 3.0 * molality[i]* molality[i] *
m_Mu_nnn[i]);
1996 writelogf(
" Net %-16s lngamma[i] = %9.5f gamma[i]=%10.6f\n",
2019 double term1 = -Aphi * pow(Is,1.5) / (1.0 + 1.2 * sqrt(Is));
2021 for (
size_t j = 1; j <
m_kk; j++) {
2024 for (
size_t k = 1; k <
m_kk; k++) {
2027 size_t n =
m_kk*j + k;
2030 sum1 += molality[j]*molality[k]*
2035 for (
size_t k = j+1; k <
m_kk; k++) {
2036 if (j == (
m_kk-1)) {
2038 throw CanteraError(
"HMWSoln::s_updatePitzer_lnMolalityActCoeff",
2039 "logic error 1 in Step 9 of hmw_act");
2044 size_t n =
m_kk*j + k;
2046 sum2 += molality[j]*molality[k]*
m_PhiPhi_IJ[counterIJ];
2047 for (
size_t m = 1; m <
m_kk; m++) {
2051 sum2 += molality[j]*molality[k]*molality[m]*
m_Psi_ijk[n];
2060 for (
size_t k = j+1; k <
m_kk; k++) {
2063 throw CanteraError(
"HMWSoln::s_updatePitzer_lnMolalityActCoeff",
2064 "logic error 2 in Step 9 of hmw_act");
2069 size_t n =
m_kk*j + k;
2071 sum3 += molality[j]*molality[k]*
m_PhiPhi_IJ[counterIJ];
2072 for (
size_t m = 1; m <
m_kk; m++) {
2075 sum3 += molality[j]*molality[k]*molality[m]*
m_Psi_ijk[n];
2084 for (
size_t k = 1; k <
m_kk; k++) {
2094 }
else if (k == j) {
2095 sum6 += 0.5 * molality[j]*molality[k]*
m_Lambda_nj(j,k);
2100 for (
size_t m = 1; m <
m_kk; m++) {
2106 sum7 += molality[izeta]*molality[jzeta]*molality[k]*zeta;
2112 sum7 += molality[j]*molality[j]*molality[j]*
m_Mu_nnn[j];
2115 double sum_m_phi_minus_1 = 2.0 *
2116 (term1 + sum1 + sum2 + sum3 + sum4 + sum5 + sum6 + sum7);
2119 double osmotic_coef;
2120 if (molalitysumUncropped > 1.0E-150) {
2121 osmotic_coef = 1.0 + (sum_m_phi_minus_1 / molalitysumUncropped);
2126 writelogf(
" term1=%10.6f sum1=%10.6f sum2=%10.6f " 2127 "sum3=%10.6f sum4=%10.6f sum5=%10.6f\n",
2128 term1, sum1, sum2, sum3, sum4, sum5);
2129 writelogf(
" sum_m_phi_minus_1=%10.6f osmotic_coef=%10.6f\n",
2130 sum_m_phi_minus_1, osmotic_coef);
2133 double lnwateract = -(
m_weightSolvent/1000.0) * molalitysumUncropped * osmotic_coef;
2145 double wateract = exp(lnwateract);
2147 writelogf(
" molalitySumUncropped = %16.7g\n", molalitysumUncropped);
2148 writelogf(
" ln_a_water=%10.6f a_water=%10.6f\n\n",
2149 lnwateract, wateract);
2167 for (
size_t k = 1; k <
m_kk; k++) {
2189 throw CanteraError(
"HMWSoln::s_updatePitzer_dlnMolalityActCoeff_dT",
2190 "Wrong index solvent value!");
2197 double etheta[5][5], etheta_prime[5][5], sqrtIs;
2204 double molarcharge = 0.0;
2208 double molalitysum = 0.0;
2210 debuglog(
"\n Debugging information from s_Pitzer_dlnMolalityActCoeff_dT()\n",
2217 for (
size_t n = 1; n <
m_kk; n++) {
2221 molarcharge += fabs(
charge(n)) * molality[n];
2222 molalitysum += molality[n];
2231 writelogf(
" ionic strenth = %14.7le \n total molar " 2232 "charge = %14.7le \n", Is, molarcharge);
2242 for (
int z1 = 1; z1 <=4; z1++) {
2243 for (
int z2 =1; z2 <=4; z2++) {
2244 calc_thetas(z1, z2, ðeta[z1][z2], ðeta_prime[z1][z2]);
2246 writelogf(
" z1=%3d z2=%3d E-theta(I) = %f, E-thetaprime(I) = %f\n",
2247 z1, z2, etheta[z1][z2], etheta_prime[z1][z2]);
2253 " Species Species g(x) hfunc(x) \n",
2259 for (
size_t i = 1; i < (
m_kk - 1); i++) {
2260 for (
size_t j = (i+1); j <
m_kk; j++) {
2262 size_t n =
m_kk*i + j;
2268 double x1 = sqrtIs * m_Alpha1MX_ij[counterIJ];
2269 if (x1 > 1.0E-100) {
2270 m_gfunc_IJ[counterIJ] = 2.0*(1.0-(1.0 + x1) * exp(-x1)) / (x1 * x1);
2272 (1.0-(1.0 + x1 + 0.5 * x1 *x1) * exp(-x1)) / (x1 * x1);
2280 if (x2 > 1.0E-100) {
2281 m_g2func_IJ[counterIJ] = 2.0*(1.0-(1.0 + x2) * exp(-x2)) / (x2 * x2);
2283 (1.0-(1.0 + x2 + 0.5 * x2 * x2) * exp(-x2)) / (x2 * x2);
2296 writelogf(
" %-16s %-16s %9.5f %9.5f \n", sni.c_str(), snj.c_str(),
2306 " Species Species BMX BprimeMX BphiMX \n",
2309 for (
size_t i = 1; i <
m_kk - 1; i++) {
2310 for (
size_t j = i+1; j <
m_kk; j++) {
2312 size_t n =
m_kk*i + j;
2326 if (Is > 1.0E-150) {
2339 writelogf(
" %-16s %-16s %11.7f %11.7f %11.7f \n",
2349 for (
size_t i = 1; i <
m_kk-1; i++) {
2350 for (
size_t j = i+1; j <
m_kk; j++) {
2352 size_t n =
m_kk*i + j;
2372 " Species Species Phi_ij Phiprime_ij Phi^phi_ij \n",
2374 for (
size_t i = 1; i <
m_kk-1; i++) {
2375 for (
size_t j = i+1; j <
m_kk; j++) {
2377 size_t n =
m_kk*i + j;
2392 writelogf(
" %-16s %-16s %10.6f %10.6f %10.6f \n",
2402 double dAphidT = dA_DebyedT /3.0;
2403 double dFdT = -dAphidT * (sqrt(Is) / (1.0 + 1.2*sqrt(Is))
2404 + (2.0/1.2) * log(1.0+1.2*(sqrtIs)));
2406 writelogf(
" initial value of dFdT = %10.6f \n", dFdT);
2408 for (
size_t i = 1; i <
m_kk-1; i++) {
2409 for (
size_t j = i+1; j <
m_kk; j++) {
2411 size_t n =
m_kk*i + j;
2432 for (
size_t i = 1; i <
m_kk; i++) {
2442 for (
size_t j = 1; j <
m_kk; j++) {
2444 size_t n =
m_kk*i + j;
2449 sum1 += molality[j]*
2455 for (
size_t k = j+1; k <
m_kk; k++) {
2468 sum2 += molality[j]*(2.0*
m_Phi_IJ_L[counterIJ]);
2470 for (
size_t k = 1; k <
m_kk; k++) {
2480 molality[j]*molality[k]*
m_CMX_IJ_L[counterIJ2];
2491 for (
size_t k = 1; k <
m_kk; k++) {
2497 if (zeta_L != 0.0) {
2498 sum5 += molality[j]*molality[k]*zeta_L;
2507 zsqdFdT + sum1 + sum2 + sum3 + sum4 + sum5;
2510 writelogf(
" %-16s lngamma[i]=%10.6f gamma[i]=%10.6f \n",
2512 writelogf(
" %12g %12g %12g %12g %12g %12g\n",
2513 zsqdFdT, sum1, sum2, sum3, sum4, sum5);
2526 for (
size_t j = 1; j <
m_kk; j++) {
2528 size_t n =
m_kk*i + j;
2533 sum1 += molality[j]*
2536 for (
size_t k = j+1; k <
m_kk; k++) {
2550 sum2 += molality[j]*(2.0*
m_Phi_IJ_L[counterIJ]);
2552 for (
size_t k = 1; k <
m_kk; k++) {
2560 sum4 += fabs(
charge(i)) *
2561 molality[j]*molality[k]*
m_CMX_IJ_L[counterIJ2];
2569 for (
size_t k = 1; k <
m_kk; k++) {
2576 if (zeta_L != 0.0) {
2577 sum5 += molality[j]*molality[k]*zeta_L;
2584 zsqdFdT + sum1 + sum2 + sum3 + sum4 + sum5;
2587 writelogf(
" %-16s lngamma[i]=%10.6f gamma[i]=%10.6f\n",
2589 writelogf(
" %12g %12g %12g %12g %12g %12g\n",
2590 zsqdFdT, sum1, sum2, sum3, sum4, sum5);
2600 for (
size_t j = 1; j <
m_kk; j++) {
2604 for (
size_t k = 1; k <
m_kk; k++) {
2612 double sum2 = 3.0 * molality[i] * molality[i] *
m_Mu_nnn_L[i];
2616 writelogf(
" %-16s lngamma[i]=%10.6f gamma[i]=%10.6f \n",
2637 double term1 = -dAphidT * Is * sqrt(Is) / (1.0 + 1.2 * sqrt(Is));
2639 for (
size_t j = 1; j <
m_kk; j++) {
2642 for (
size_t k = 1; k <
m_kk; k++) {
2645 size_t n =
m_kk*j + k;
2647 sum1 += molality[j]*molality[k]*
2652 for (
size_t k = j+1; k <
m_kk; k++) {
2653 if (j == (
m_kk-1)) {
2655 throw CanteraError(
"HMWSoln::s_updatePitzer_dlnMolalityActCoeff_dT",
2656 "logic error 1 in Step 9 of hmw_act");
2661 size_t n =
m_kk*j + k;
2664 for (
size_t m = 1; m <
m_kk; m++) {
2668 sum2 += molality[j]*molality[k]*molality[m]*
m_Psi_ijk_L[n];
2677 for (
size_t k = j+1; k <
m_kk; k++) {
2680 throw CanteraError(
"HMWSoln::s_updatePitzer_dlnMolalityActCoeff_dT",
2681 "logic error 2 in Step 9 of hmw_act");
2686 size_t n =
m_kk*j + k;
2689 for (
size_t m = 1; m <
m_kk; m++) {
2692 sum3 += molality[j]*molality[k]*molality[m]*
m_Psi_ijk_L[n];
2701 for (
size_t k = 1; k <
m_kk; k++) {
2711 }
else if (k == j) {
2717 for (
size_t m = 1; m <
m_kk; m++) {
2722 if (zeta_L != 0.0) {
2723 sum7 += molality[izeta]*molality[jzeta]*molality[k]*zeta_L;
2729 sum7 += molality[j]*molality[j]*molality[j]*
m_Mu_nnn_L[j];
2732 double sum_m_phi_minus_1 = 2.0 *
2733 (term1 + sum1 + sum2 + sum3 + sum4 + sum5 + sum6 + sum7);
2736 double d_osmotic_coef_dT;
2737 if (molalitysum > 1.0E-150) {
2738 d_osmotic_coef_dT = 0.0 + (sum_m_phi_minus_1 / molalitysum);
2740 d_osmotic_coef_dT = 0.0;
2744 writelogf(
" term1=%10.6f sum1=%10.6f sum2=%10.6f " 2745 "sum3=%10.6f sum4=%10.6f sum5=%10.6f\n",
2746 term1, sum1, sum2, sum3, sum4, sum5);
2747 writelogf(
" sum_m_phi_minus_1=%10.6f d_osmotic_coef_dT =%10.6f\n",
2748 sum_m_phi_minus_1, d_osmotic_coef_dT);
2751 double d_lnwateract_dT = -(
m_weightSolvent/1000.0) * molalitysum * d_osmotic_coef_dT;
2761 double d_wateract_dT = exp(d_lnwateract_dT);
2762 writelogf(
" d_ln_a_water_dT = %10.6f d_a_water_dT=%10.6f\n\n",
2763 d_lnwateract_dT, d_wateract_dT);
2781 for (
size_t k = 1; k <
m_kk; k++) {
2799 throw CanteraError(
"HMWSoln::s_updatePitzer_d2lnMolalityActCoeff_dT2",
2800 "Wrong index solvent value!");
2806 double etheta[5][5], etheta_prime[5][5], sqrtIs;
2813 double molarcharge = 0.0;
2817 double molalitysum = 0.0;
2819 debuglog(
"\n Debugging information from s_Pitzer_d2lnMolalityActCoeff_dT2()\n",
2826 for (
size_t n = 1; n <
m_kk; n++) {
2830 molarcharge += fabs(
charge(n)) * molality[n];
2831 molalitysum += molality[n];
2840 writelogf(
" ionic strenth = %14.7le \n total molar " 2841 "charge = %14.7le \n", Is, molarcharge);
2851 for (
int z1 = 1; z1 <=4; z1++) {
2852 for (
int z2 =1; z2 <=4; z2++) {
2853 calc_thetas(z1, z2, ðeta[z1][z2], ðeta_prime[z1][z2]);
2855 writelogf(
" z1=%3d z2=%3d E-theta(I) = %f, E-thetaprime(I) = %f\n",
2856 z1, z2, etheta[z1][z2], etheta_prime[z1][z2]);
2862 " Species Species g(x) hfunc(x) \n",
2868 for (
size_t i = 1; i < (
m_kk - 1); i++) {
2869 for (
size_t j = (i+1); j <
m_kk; j++) {
2871 size_t n =
m_kk*i + j;
2877 double x1 = sqrtIs * m_Alpha1MX_ij[counterIJ];
2878 if (x1 > 1.0E-100) {
2879 m_gfunc_IJ[counterIJ] = 2.0*(1.0-(1.0 + x1) * exp(-x1)) / (x1 *x1);
2881 (1.0-(1.0 + x1 + 0.5*x1 * x1) * exp(-x1)) / (x1 * x1);
2889 if (x2 > 1.0E-100) {
2890 m_g2func_IJ[counterIJ] = 2.0*(1.0-(1.0 + x2) * exp(-x2)) / (x2 * x2);
2892 (1.0-(1.0 + x2 + 0.5 * x2 * x2) * exp(-x2)) / (x2 * x2);
2913 " Species Species BMX BprimeMX BphiMX \n",
2916 for (
size_t i = 1; i <
m_kk - 1; i++) {
2917 for (
size_t j = i+1; j <
m_kk; j++) {
2919 size_t n =
m_kk*i + j;
2933 if (Is > 1.0E-150) {
2946 writelogf(
" %-16s %-16s %11.7f %11.7f %11.7f \n",
2956 for (
size_t i = 1; i <
m_kk-1; i++) {
2957 for (
size_t j = i+1; j <
m_kk; j++) {
2959 size_t n =
m_kk*i + j;
2979 " Species Species Phi_ij Phiprime_ij Phi^phi_ij \n",
2981 for (
size_t i = 1; i <
m_kk-1; i++) {
2982 for (
size_t j = i+1; j <
m_kk; j++) {
2984 size_t n =
m_kk*i + j;
2999 writelogf(
" %-16s %-16s %10.6f %10.6f %10.6f \n",
3009 double d2FdT2 = -d2AphidT2 * (sqrt(Is) / (1.0 + 1.2*sqrt(Is))
3010 + (2.0/1.2) * log(1.0+1.2*(sqrtIs)));
3012 writelogf(
" initial value of d2FdT2 = %10.6f \n", d2FdT2);
3014 for (
size_t i = 1; i <
m_kk-1; i++) {
3015 for (
size_t j = i+1; j <
m_kk; j++) {
3017 size_t n =
m_kk*i + j;
3029 d2FdT2 += molality[i]*molality[j] *
m_Phiprime_IJ[counterIJ];
3032 writelogf(
" d2FdT2 = %10.6f \n", d2FdT2);
3038 for (
size_t i = 1; i <
m_kk; i++) {
3048 for (
size_t j = 1; j <
m_kk; j++) {
3050 size_t n =
m_kk*i + j;
3055 sum1 += molality[j]*
3061 for (
size_t k = j+1; k <
m_kk; k++) {
3076 for (
size_t k = 1; k <
m_kk; k++) {
3085 sum4 += fabs(
charge(i)) *
3095 for (
size_t k = 1; k <
m_kk; k++) {
3101 if (zeta_LL != 0.0) {
3102 sum5 += molality[j]*molality[k]*zeta_LL;
3111 zsqd2FdT2 + sum1 + sum2 + sum3 + sum4 + sum5;
3113 writelogf(
" %-16s d2lngammadT2[i]=%10.6f \n",
3115 writelogf(
" %12g %12g %12g %12g %12g %12g\n",
3116 zsqd2FdT2, sum1, sum2, sum3, sum4, sum5);
3129 for (
size_t j = 1; j <
m_kk; j++) {
3131 size_t n =
m_kk*i + j;
3136 sum1 += molality[j]*
3139 for (
size_t k = j+1; k <
m_kk; k++) {
3155 for (
size_t k = 1; k <
m_kk; k++) {
3163 sum4 += fabs(
charge(i)) *
3173 for (
size_t k = 1; k <
m_kk; k++) {
3180 if (zeta_LL != 0.0) {
3181 sum5 += molality[j]*molality[k]*zeta_LL;
3188 zsqd2FdT2 + sum1 + sum2 + sum3 + sum4 + sum5;
3190 writelogf(
" %-16s d2lngammadT2[i]=%10.6f\n",
3192 writelogf(
" %12g %12g %12g %12g %12g %12g\n",
3193 zsqd2FdT2, sum1, sum2, sum3, sum4, sum5);
3203 for (
size_t j = 1; j <
m_kk; j++) {
3207 for (
size_t k = 1; k <
m_kk; k++) {
3215 double sum2 = 3.0 * molality[i] * molality[i] *
m_Mu_nnn_LL[i];
3218 writelog(
" %-16s d2lngammadT2[i]=%10.6f \n",
3240 double term1 = -d2AphidT2 * Is * sqrt(Is) / (1.0 + 1.2 * sqrt(Is));
3242 for (
size_t j = 1; j <
m_kk; j++) {
3245 for (
size_t k = 1; k <
m_kk; k++) {
3248 size_t n =
m_kk*j + k;
3251 sum1 += molality[j]*molality[k] *
3256 for (
size_t k = j+1; k <
m_kk; k++) {
3257 if (j == (
m_kk-1)) {
3259 throw CanteraError(
"HMWSoln::s_updatePitzer_d2lnMolalityActCoeff_dT2",
3260 "logic error 1 in Step 9 of hmw_act");
3265 size_t n =
m_kk*j + k;
3268 for (
size_t m = 1; m <
m_kk; m++) {
3272 sum2 += molality[j]*molality[k]*molality[m]*
m_Psi_ijk_LL[n];
3281 for (
size_t k = j+1; k <
m_kk; k++) {
3284 throw CanteraError(
"HMWSoln::s_updatePitzer_d2lnMolalityActCoeff_dT2",
3285 "logic error 2 in Step 9 of hmw_act");
3290 size_t n =
m_kk*j + k;
3294 for (
size_t m = 1; m <
m_kk; m++) {
3297 sum3 += molality[j]*molality[k]*molality[m]*
m_Psi_ijk_LL[n];
3306 for (
size_t k = 1; k <
m_kk; k++) {
3316 }
else if (k == j) {
3322 for (
size_t m = 1; m <
m_kk; m++) {
3327 if (zeta_LL != 0.0) {
3328 sum7 += molality[izeta]*molality[jzeta]*molality[k]*zeta_LL;
3335 sum7 += molality[j] * molality[j] * molality[j] *
m_Mu_nnn_LL[j];
3338 double sum_m_phi_minus_1 = 2.0 *
3339 (term1 + sum1 + sum2 + sum3 + sum4 + sum5 + sum6 + sum7);
3342 double d2_osmotic_coef_dT2;
3343 if (molalitysum > 1.0E-150) {
3344 d2_osmotic_coef_dT2 = 0.0 + (sum_m_phi_minus_1 / molalitysum);
3346 d2_osmotic_coef_dT2 = 0.0;
3349 writelogf(
" term1=%10.6f sum1=%10.6f sum2=%10.6f " 3350 "sum3=%10.6f sum4=%10.6f sum5=%10.6f\n",
3351 term1, sum1, sum2, sum3, sum4, sum5);
3352 writelogf(
" sum_m_phi_minus_1=%10.6f d2_osmotic_coef_dT2=%10.6f\n",
3353 sum_m_phi_minus_1, d2_osmotic_coef_dT2);
3356 double d2_lnwateract_dT2 = -(
m_weightSolvent/1000.0) * molalitysum * d2_osmotic_coef_dT2;
3367 double d2_wateract_dT2 = exp(d2_lnwateract_dT2);
3368 writelogf(
" d2_ln_a_water_dT2 = %10.6f d2_a_water_dT2=%10.6f\n\n",
3369 d2_lnwateract_dT2, d2_wateract_dT2);
3384 for (
size_t k = 1; k <
m_kk; k++) {
3401 throw CanteraError(
"HMWSoln::s_updatePitzer_dlnMolalityActCoeff_dP",
3402 "Wrong index solvent value!");
3408 double etheta[5][5], etheta_prime[5][5], sqrtIs;
3415 double molarcharge = 0.0;
3419 double molalitysum = 0.0;
3423 debuglog(
"\n Debugging information from s_Pitzer_dlnMolalityActCoeff_dP()\n",
3430 for (
size_t n = 1; n <
m_kk; n++) {
3434 molarcharge += fabs(
charge(n)) * molality[n];
3435 molalitysum += molality[n];
3444 writelogf(
" ionic strenth = %14.7le \n total molar " 3445 "charge = %14.7le \n", Is, molarcharge);
3456 for (
int z1 = 1; z1 <=4; z1++) {
3457 for (
int z2 =1; z2 <=4; z2++) {
3458 calc_thetas(z1, z2, ðeta[z1][z2], ðeta_prime[z1][z2]);
3460 writelogf(
" z1=%3d z2=%3d E-theta(I) = %f, E-thetaprime(I) = %f\n",
3461 z1, z2, etheta[z1][z2], etheta_prime[z1][z2]);
3467 " Species Species g(x) hfunc(x)\n",
3473 for (
size_t i = 1; i < (
m_kk - 1); i++) {
3474 for (
size_t j = (i+1); j <
m_kk; j++) {
3476 size_t n =
m_kk*i + j;
3482 double x1 = sqrtIs * m_Alpha1MX_ij[counterIJ];
3483 if (x1 > 1.0E-100) {
3484 m_gfunc_IJ[counterIJ] = 2.0*(1.0-(1.0 + x1) * exp(-x1)) / (x1 * x1);
3486 (1.0-(1.0 + x1 + 0.5 * x1 * x1) * exp(-x1)) / (x1 * x1);
3494 if (x2 > 1.0E-100) {
3495 m_g2func_IJ[counterIJ] = 2.0*(1.0-(1.0 + x2) * exp(-x2)) / (x2 * x2);
3497 (1.0-(1.0 + x2 + 0.5 * x2 * x2) * exp(-x2)) / (x2 * x2);
3518 " Species Species BMX BprimeMX BphiMX \n",
3521 for (
size_t i = 1; i <
m_kk - 1; i++) {
3522 for (
size_t j = i+1; j <
m_kk; j++) {
3524 size_t n =
m_kk*i + j;
3538 if (Is > 1.0E-150) {
3551 writelogf(
" %-16s %-16s %11.7f %11.7f %11.7f \n",
3561 for (
size_t i = 1; i <
m_kk-1; i++) {
3562 for (
size_t j = i+1; j <
m_kk; j++) {
3564 size_t n =
m_kk*i + j;
3584 " Species Species Phi_ij Phiprime_ij Phi^phi_ij \n",
3586 for (
size_t i = 1; i <
m_kk-1; i++) {
3587 for (
size_t j = i+1; j <
m_kk; j++) {
3589 size_t n =
m_kk*i + j;
3604 writelogf(
" %-16s %-16s %10.6f %10.6f %10.6f \n",
3614 double dAphidP = dA_DebyedP /3.0;
3615 double dFdP = -dAphidP * (sqrt(Is) / (1.0 + 1.2*sqrt(Is))
3616 + (2.0/1.2) * log(1.0+1.2*(sqrtIs)));
3618 writelogf(
" initial value of dFdP = %10.6f \n", dFdP);
3620 for (
size_t i = 1; i <
m_kk-1; i++) {
3621 for (
size_t j = i+1; j <
m_kk; j++) {
3623 size_t n =
m_kk*i + j;
3644 for (
size_t i = 1; i <
m_kk; i++) {
3654 for (
size_t j = 1; j <
m_kk; j++) {
3656 size_t n =
m_kk*i + j;
3661 sum1 += molality[j]*
3667 for (
size_t k = j+1; k <
m_kk; k++) {
3680 sum2 += molality[j]*(2.0*
m_Phi_IJ_P[counterIJ]);
3682 for (
size_t k = 1; k <
m_kk; k++) {
3691 sum4 += fabs(
charge(i)) *
3692 molality[j]*molality[k]*
m_CMX_IJ_P[counterIJ2];
3701 for (
size_t k = 1; k <
m_kk; k++) {
3707 if (zeta_P != 0.0) {
3708 sum5 += molality[j]*molality[k]*zeta_P;
3718 zsqdFdP + sum1 + sum2 + sum3 + sum4 + sum5;
3721 writelogf(
" %-16s lngamma[i]=%10.6f \n",
3723 writelogf(
" %12g %12g %12g %12g %12g %12g\n",
3724 zsqdFdP, sum1, sum2, sum3, sum4, sum5);
3737 for (
size_t j = 1; j <
m_kk; j++) {
3739 size_t n =
m_kk*i + j;
3744 sum1 += molality[j] *
3747 for (
size_t k = j+1; k <
m_kk; k++) {
3761 sum2 += molality[j]*(2.0*
m_Phi_IJ_P[counterIJ]);
3763 for (
size_t k = 1; k <
m_kk; k++) {
3772 molality[j]*molality[k]*
m_CMX_IJ_P[counterIJ2];
3781 for (
size_t k = 1; k <
m_kk; k++) {
3788 if (zeta_P != 0.0) {
3789 sum5 += molality[j]*molality[k]*zeta_P;
3796 zsqdFdP + sum1 + sum2 + sum3 + sum4 + sum5;
3798 writelogf(
" %-16s lndactcoeffmolaldP[i]=%10.6f \n",
3800 writelogf(
" %12g %12g %12g %12g %12g %12g\n",
3801 zsqdFdP, sum1, sum2, sum3, sum4, sum5);
3809 for (
size_t j = 1; j <
m_kk; j++) {
3813 for (
size_t k = 1; k <
m_kk; k++) {
3821 double sum2 = 3.0 * molality[i] * molality[i] *
m_Mu_nnn_P[i];
3824 writelogf(
" %-16s dlnActCoeffMolaldP[i]=%10.6f \n",
3845 double term1 = -dAphidP * Is * sqrt(Is) / (1.0 + 1.2 * sqrt(Is));
3847 for (
size_t j = 1; j <
m_kk; j++) {
3850 for (
size_t k = 1; k <
m_kk; k++) {
3853 size_t n =
m_kk*j + k;
3855 sum1 += molality[j]*molality[k]*
3860 for (
size_t k = j+1; k <
m_kk; k++) {
3861 if (j == (
m_kk-1)) {
3863 throw CanteraError(
"HMWSoln::s_updatePitzer_dlnMolalityActCoeff_dP",
3864 "logic error 1 in Step 9 of hmw_act");
3869 size_t n =
m_kk*j + k;
3872 for (
size_t m = 1; m <
m_kk; m++) {
3876 sum2 += molality[j]*molality[k]*molality[m]*
m_Psi_ijk_P[n];
3885 for (
size_t k = j+1; k <
m_kk; k++) {
3888 throw CanteraError(
"HMWSoln::s_updatePitzer_dlnMolalityActCoeff_dP",
3889 "logic error 2 in Step 9 of hmw_act");
3894 size_t n =
m_kk*j + k;
3898 for (
size_t m = 1; m <
m_kk; m++) {
3901 sum3 += molality[j]*molality[k]*molality[m]*
m_Psi_ijk_P[n];
3910 for (
size_t k = 1; k <
m_kk; k++) {
3920 }
else if (k == j) {
3926 for (
size_t m = 1; m <
m_kk; m++) {
3931 if (zeta_P != 0.0) {
3932 sum7 += molality[izeta]*molality[jzeta]*molality[k]*zeta_P;
3939 sum7 += molality[j] * molality[j] * molality[j] *
m_Mu_nnn_P[j];
3942 double sum_m_phi_minus_1 = 2.0 *
3943 (term1 + sum1 + sum2 + sum3 + sum4 + sum5 + sum6 + sum7);
3947 double d_osmotic_coef_dP;
3948 if (molalitysum > 1.0E-150) {
3949 d_osmotic_coef_dP = 0.0 + (sum_m_phi_minus_1 / molalitysum);
3951 d_osmotic_coef_dP = 0.0;
3954 writelogf(
" term1=%10.6f sum1=%10.6f sum2=%10.6f " 3955 "sum3=%10.6f sum4=%10.6f sum5=%10.6f\n",
3956 term1, sum1, sum2, sum3, sum4, sum5);
3957 writelogf(
" sum_m_phi_minus_1=%10.6f d_osmotic_coef_dP =%10.6f\n",
3958 sum_m_phi_minus_1, d_osmotic_coef_dP);
3961 double d_lnwateract_dP = -(
m_weightSolvent/1000.0) * molalitysum * d_osmotic_coef_dP;
3971 writelogf(
" d_ln_a_water_dP = %10.6f d_a_water_dP=%10.6f\n\n",
3972 d_lnwateract_dP, exp(d_lnwateract_dP));
3978 if( m_last_is == is ) {
3985 double c1 = 4.581, c2 = 0.7237, c3 = 0.0120, c4 = 0.528;
3986 double aphi = 0.392;
3990 if (is < 1.0E-150) {
3991 for (
int i = 0; i < 17; i++) {
4000 for (
int i=1; i<=4; i++) {
4001 for (
int j=i; j<=4; j++) {
4005 double zprod = (double)ij;
4008 double x = 6.0* zprod * aphi * sqrt(is);
4010 double jfunc = x / (4.0 + c1*pow(x,-c2)*exp(-c3*pow(x,c4)));
4012 double t = c3 * c4 * pow(x,c4);
4013 double dj = c1* pow(x,(-c2-1.0)) * (c2+t) * exp(-c3*pow(x,c4));
4014 double jprime = (jfunc/x)*(1.0 + jfunc*dj);
4016 elambda[ij] = zprod*jfunc / (4.0*is);
4017 elambda1[ij] = (3.0*zprod*zprod*aphi*jprime/(4.0*sqrt(is))
4020 writelogf(
" ij = %d, elambda = %g, elambda1 = %g\n",
4028 double* etheta,
double* etheta_prime)
const 4035 "we shouldn't be here");
4037 "called with one species being neutral");
4043 *etheta_prime = 0.0;
4046 double f1 = (double)i / (2.0 * j);
4047 double f2 = (double)j / (2.0 * i);
4061 for (
size_t k = 1; k <
m_kk; k++) {
4068 for (
size_t k = 1; k <
m_kk; k++) {
4075 for (
size_t k = 1; k <
m_kk; k++) {
4083 double xminus2 = xminus * xminus;
4084 double xminus3 = xminus2 * xminus;
4088 double h2 = 3.5 * xminus2 /
IMS_X_o_cutoff_ - 2.0 * xminus3 / x_o_cut2;
4089 double h2_prime = 7.0 * xminus /
IMS_X_o_cutoff_ - 6.0 * xminus2 / x_o_cut2;
4091 double h1 = (1.0 - 3.0 * xminus2 / x_o_cut2 + 2.0 * xminus3/ x_o_cut3);
4092 double h1_prime = (- 6.0 * xminus / x_o_cut2 + 6.0 * xminus2/ x_o_cut3);
4098 double h1_f = h1 * alpha;
4099 double h1_f_prime = h1_prime * alpha;
4101 double f = h2 + h1_f;
4102 double f_prime = h2_prime + h1_f_prime;
4104 double g = h2 + h1_g;
4105 double g_prime = h2_prime + h1_g_prime;
4107 double tmp = (xmolSolvent/ g * g_prime + (1.0-xmolSolvent) / f * f_prime);
4108 double lngammak = -1.0 - log(f) + tmp * xmolSolvent;
4109 double lngammao =-log(g) - tmp * (1.0-xmolSolvent);
4111 tmp = log(xmolSolvent) + lngammak;
4112 for (
size_t k = 1; k <
m_kk; k++) {
4120 for (
size_t k = 1; k <
m_kk; k++) {
4127 double eterm = std::exp(-xoverc);
4129 double fptmp = IMS_bfCut_ - IMS_afCut_ /
IMS_cCut_ - IMS_bfCut_*xoverc
4130 + 2.0*IMS_dfCut_*xmolSolvent - IMS_dfCut_*xmolSolvent*xoverc;
4131 double f_prime = 1.0 + eterm*fptmp;
4132 double f = xmolSolvent + IMS_efCut_
4133 + eterm * (IMS_afCut_ + xmolSolvent * (IMS_bfCut_ + IMS_dfCut_*xmolSolvent));
4135 double gptmp = IMS_bgCut_ - IMS_agCut_ /
IMS_cCut_ - IMS_bgCut_*xoverc
4136 + 2.0*IMS_dgCut_*xmolSolvent - IMS_dgCut_*xmolSolvent*xoverc;
4137 double g_prime = 1.0 + eterm*gptmp;
4138 double g = xmolSolvent + IMS_egCut_
4139 + eterm * (IMS_agCut_ + xmolSolvent * (IMS_bgCut_ + IMS_dgCut_*xmolSolvent));
4141 double tmp = (xmolSolvent / g * g_prime + (1.0 - xmolSolvent) / f * f_prime);
4142 double lngammak = -1.0 - log(f) + tmp * xmolSolvent;
4143 double lngammao =-log(g) - tmp * (1.0-xmolSolvent);
4145 tmp = log(xx) + lngammak;
4146 for (
size_t k = 1; k <
m_kk; k++) {
4164 writelog(
"Index Name MoleF MolalityCropped Charge\n");
4165 for (
size_t k = 0; k <
m_kk; k++) {
4166 writelogf(
"%2d %-16s %14.7le %14.7le %5.1f \n",
4170 writelog(
"\n Species Species beta0MX " 4171 "beta1MX beta2MX CphiMX alphaMX thetaij\n");
4172 for (
size_t i = 1; i <
m_kk - 1; i++) {
4173 for (
size_t j = i+1; j <
m_kk; j++) {
4174 size_t n = i *
m_kk + j;
4176 writelogf(
" %-16s %-16s %9.5f %9.5f %9.5f %9.5f %9.5f %9.5f \n",
4184 writelog(
"\n Species Species Species psi \n");
4185 for (
size_t i = 1; i <
m_kk; i++) {
4186 for (
size_t j = 1; j <
m_kk; j++) {
4187 for (
size_t k = 1; k <
m_kk; k++) {
4190 writelogf(
" %-16s %-16s %-16s %9.5f \n",
4207 doublereal afac = -1.0 *(lnGammaClMs2 - lnGammaCLMs1);
4208 for (
size_t k = 0; k <
m_kk; k++) {
4209 acMolality[k] *= exp(
charge(k) * afac);
4222 doublereal afac = -1.0 *(lnGammaClMs2 - lnGammaCLMs1);
4223 for (
size_t k = 0; k <
m_kk; k++) {
4237 doublereal afac = -1.0 *(dlnGammaClM_dT_s2 - dlnGammaCLM_dT_s1);
4238 for (
size_t k = 0; k <
m_kk; k++) {
4252 doublereal afac = -1.0 *(d2lnGammaClM_dT2_s2 - d2lnGammaCLM_dT2_s1);
4253 for (
size_t k = 0; k <
m_kk; k++) {
4267 doublereal afac = -1.0 *(dlnGammaClM_dP_s2 - dlnGammaCLM_dP_s1);
4268 for (
size_t k = 0; k <
m_kk; k++) {
4277 doublereal lnGammaClMs2 = - A * sqrtIs /(1.0 + 1.5 * sqrtIs);
4278 return lnGammaClMs2;
4285 return - dAdT * sqrtIs /(1.0 + 1.5 * sqrtIs);
4292 return - d2AdT2 * sqrtIs /(1.0 + 1.5 * sqrtIs);
4299 return - dAdP * sqrtIs /(1.0 + 1.5 * sqrtIs);
vector_fp m_Theta_ij_P
Derivative of Theta_ij[i][j] wrt P. Vector index is counterIJ.
vector_fp m_BMX_IJ_L
Derivative of BMX_IJ wrt T. Vector index is counterIJ.
vector_fp m_PhiPhi_IJ_P
Derivative of m_PhiPhi_IJ wrt P. Vector index is counterIJ.
virtual void updateStandardStateThermo() const
Updates the standard state thermodynamic functions at the current T and P of the solution.
void calcMolalitiesCropped() const
Calculate the cropped molalities.
virtual void getChemPotentials(doublereal *mu) const
Get the species chemical potentials. Units: J/kmol.
void s_updateScaling_pHScaling() const
Apply the current phScale to a set of activity Coefficients.
vector_fp m_CphiMX_ij_LL
Derivative of Cphi_ij[i][j] wrt TT. Vector index is counterIJ.
doublereal molarVolume() const
Molar volume (m^3/kmol).
void s_update_dlnMolalityActCoeff_dT() const
This function calculates the temperature derivative of the natural logarithm of the molality activity...
vector_fp m_Theta_ij_L
Derivative of Theta_ij[i][j] wrt T. Vector index is counterIJ.
vector_fp m_speciesCharge_Stoich
Stoichiometric species charge -> This is for calculations of the ionic strength which ignore ion-ion ...
vector_fp m_CMX_IJ_P
Derivative of m_CMX_IJ wrt P. Vector index is counterIJ.
vector_fp m_gfunc_IJ
Various temporary arrays used in the calculation of the Pitzer activity coefficients.
virtual doublereal cp_mole() const
Molar heat capacity at constant pressure. Units: J/kmol/K.
int getId()
Get a unique id for a cached value.
vector_fp m_Beta2MX_ij_L
Derivative of Beta2_ij[i][j] wrt T. Vector index is counterIJ.
vector_fp m_d2lnActCoeffMolaldT2_Unscaled
Derivative of the Logarithm of the activity coefficients on the molality scale wrt TT...
virtual doublereal thermalExpansionCoeff() const
Return the volumetric thermal expansion coefficient. Units: 1/K.
doublereal MC_X_o_cutoff_
value of the solvent mole fraction that centers the cutoff polynomials for the cutoff =1 process; ...
virtual void applyphScale(doublereal *acMolality) const
Apply the current phScale to a set of activity Coefficients or activities.
vector_fp IMS_lnActCoeffMolal_
Logarithm of the molal activity coefficients.
doublereal temperature() const
Temperature (K).
void resize(size_t n, size_t m, doublereal v=0.0)
Resize the array, and fill the new entries with 'v'.
Array2D m_Lambda_nj_coeff
Array of coefficients for Lambda_nj[i][j] in the Pitzer/HMW formulation.
double m_maxIionicStrength
Maximum value of the ionic strength allowed in the calculation of the activity coefficients.
virtual doublereal entropy_mole() const
Molar entropy. Units: J/kmol/K.
vector_fp m_Beta1MX_ij_LL
Derivative of Beta1_ij[i][j] wrt TT. Vector index is counterIJ.
doublereal m_Mnaught
This is the multiplication factor that goes inside log expressions involving the molalities of specie...
doublereal s_NBS_CLM_dlnMolalityActCoeff_dP() const
Calculate the pressure derivative of the Chlorine activity coefficient.
vector_fp m_Mu_nnn_L
Mu coefficient temperature derivative for the self-ternary neutral coefficient.
vector_fp m_dlnActCoeffMolaldP_Unscaled
Derivative of the Logarithm of the activity coefficients on the molality scale wrt P...
Array2D m_Beta0MX_ij_coeff
Array of coefficients for Beta0, a variable in Pitzer's papers.
vector_fp m_Beta2MX_ij_P
Derivative of Beta2_ij[i][j] wrt P. Vector index is counterIJ.
double AionicRadius(int k=0) const
Reports the ionic radius of the kth species.
vector_fp m_Beta2MX_ij
Array of 2D data used in the Pitzer/HMW formulation.
doublereal moleFraction(size_t k) const
Return the mole fraction of a single species.
Array2D m_Lambda_nj_P
Derivative of Lambda_nj[i][j] wrt P.
const size_t npos
index returned by functions to indicate "no position"
virtual int eosType() const
Equation of state type flag.
vector_fp m_PhiPhi_IJ
Intermediate variable called PhiPhi in Pitzer's paper.
virtual doublereal density() const
Return the standard state density at standard state.
vector_fp m_Phi_IJ_L
Derivative of m_Phi_IJ wrt T. Vector index is counterIJ.
Header file for a common definitions used in electrolytes thermodynamics.
int IMS_typeCutoff_
IMS Cutoff type.
Headers for the factory class that can create known ThermoPhase objects (see Thermodynamic Properties...
virtual void getPartialMolarEntropies(doublereal *sbar) const
Returns an array of partial molar entropies of the species in the solution.
vector_fp m_dlnActCoeffMolaldT_Scaled
Derivative of the Logarithm of the activity coefficients on the molality scale wrt T...
virtual doublereal satPressure(doublereal T)
saturation pressure
virtual void setMolarDensity(const doublereal conc)
Set the internally stored molar density (kmol/m^3) for the phase.
void counterIJ_setup() const
Set up a counter variable for keeping track of symmetric binary interactions amongst the solute speci...
size_t m_indexCLM
Index of the phScale species.
void writelog(const std::string &fmt, const Args &... args)
Write a formatted message to the screen.
vector_fp m_BMX_IJ_P
Derivative of BMX_IJ wrt P. Vector index is counterIJ.
void s_updateIMS_lnMolalityActCoeff() const
This function will be called to update the internally stored natural logarithm of the molality activi...
virtual doublereal isothermalCompressibility() const
Returns the isothermal compressibility. Units: 1/Pa.
vector_fp m_Beta0MX_ij_L
Derivative of Beta0_ij[i][j] wrt T. Vector index is counterIJ.
double elambda[17]
This is elambda, MEC.
Class XML_Node is a tree-based representation of the contents of an XML file.
Implementation of a pressure dependent standard state virtual function for a Pure Water Phase (see Sp...
vector_fp m_dlnActCoeffMolaldP_Scaled
Derivative of the Logarithm of the activity coefficients on the molality scale wrt P...
int debugPrinting()
Return int specifying the amount of debug printing.
vector_fp m_Mu_nnn_P
Mu coefficient pressure derivative for the self-ternary neutral coefficient.
doublereal s_NBS_CLM_dlnMolalityActCoeff_dT() const
Calculate the temperature derivative of the Chlorine activity coefficient on the NBS scale...
Array2D m_Lambda_nj_L
Derivative of Lambda_nj[i][j] wrt T. see m_Lambda_ij.
virtual void getCp_R(doublereal *cpr) const
Get the nondimensional Heat Capacities at constant pressure for the species standard states at the cu...
virtual void setDensity(const doublereal rho)
Set the internally stored density (kg/m^3) of the phase.
vector_fp m_BprimeMX_IJ_P
Derivative of BprimeMX wrt P. Vector index is counterIJ.
vector_fp m_CphiMX_ij_P
Derivative of Cphi_ij[i][j] wrt P. Vector index is counterIJ.
void warn_deprecated(const std::string &method, const std::string &extra)
Print a warning indicating that method is deprecated.
vector_fp m_speciesSize
Vector of species sizes.
virtual doublereal density() const
Density (kg/m^3).
vector_fp m_Psi_ijk_L
Derivative of Psi_ijk[n] wrt T.
doublereal m_xmolSolventMIN
vector_fp m_lnActCoeffMolal_Unscaled
Logarithm of the activity coefficients on the molality scale.
doublereal * ptrColumn(size_t j)
Return a pointer to the top of column j, columns are contiguous in memory.
void s_updatePitzer_d2lnMolalityActCoeff_dT2() const
This function calculates the temperature second derivative of the natural logarithm of the molality a...
vector_fp m_Theta_ij
Array of 2D data for Theta_ij[i][j] in the Pitzer/HMW formulation.
vector_fp m_hfunc_IJ
hfunc, was called gprime in Pitzer's paper.
double elambda1[17]
This is elambda1, MEC.
vector_fp m_Beta1MX_ij_P
Derivative of Beta1_ij[i][j] wrt P. Vector index is counterIJ.
vector_fp m_BprimeMX_IJ_LL
Derivative of BprimeMX wrt TT. Vector index is counterIJ.
double ADebye_V(double temperature=-1.0, double pressure=-1.0) const
Return Pitzer's definition of A_V.
vector_fp m_PhiPhi_IJ_LL
Derivative of m_PhiPhi_IJ wrt TT. Vector index is counterIJ.
doublereal IMS_cCut_
Parameter in the polyExp cutoff treatment having to do with rate of exp decay.
vector_fp m_Psi_ijk_LL
Derivative of Psi_ijk[n] wrt TT.
double m_IionicMolality
Current value of the ionic strength on the molality scale Associated Salts, if present in the mechani...
virtual ThermoPhase * duplMyselfAsThermoPhase() const
Duplication routine for objects which inherit from ThermoPhase.
vector_fp m_Phi_IJ
Intermediate variable called Phi in Pitzer's paper.
vector_fp m_BphiMX_IJ
Intermediate variable called BphiMX in Pitzer's paper.
Array2D m_CphiMX_ij_coeff
Array of coefficients for CphiMX, a parameter in the activity coefficient formulation.
virtual void getPartialMolarVolumes(doublereal *vbar) const
Return an array of partial molar volumes for the species in the mixture.
void s_updateScaling_pHScaling_dP() const
Apply the current phScale to a set of derivatives of the activity Coefficients wrt pressure...
doublereal mean_X(const doublereal *const Q) const
Evaluate the mole-fraction-weighted mean of an array Q.
vector_fp m_Beta1MX_ij
Array of 2D data used in the Pitzer/HMW formulation.
vector_fp m_tmpV
vector of size m_kk, used as a temporary holding area.
doublereal RT() const
Return the Gas Constant multiplied by the current temperature.
virtual void getPartialMolarCp(doublereal *cpbar) const
Return an array of partial molar heat capacities for the species in the mixture.
Base class for a phase with thermodynamic properties.
HMWSoln()
Default Constructor.
vector_fp m_lnActCoeffMolal_Scaled
Logarithm of the activity coefficients on the molality scale.
doublereal MC_X_o_min_
gamma_o value for the cutoff process at the zero solvent point
vector_fp m_Phi_IJ_P
Derivative of m_Phi_IJ wrt P. Vector index is counterIJ.
PDSS * m_waterSS
Water standard state calculator.
vector_fp m_Phiprime_IJ
Intermediate variable called Phiprime in Pitzer's paper.
vector_fp m_h2func_IJ
hfunc2, was called gprime in Pitzer's paper.
void printCoeffs() const
Print out all of the input Pitzer coefficients.
vector_fp m_Psi_ijk_P
Derivative of Psi_ijk[n] wrt P.
vector_fp m_CMX_IJ_L
Derivative of m_CMX_IJ wrt T. Vector index is counterIJ.
bool m_molalitiesAreCropped
Boolean indicating whether the molalities are cropped or are modified.
vector_fp m_dlnActCoeffMolaldT_Unscaled
Derivative of the Logarithm of the activity coefficients on the molality scale wrt T...
Array2D m_Psi_ijk_coeff
Array of coefficients for Psi_ijk[n] in the Pitzer/HMW formulation.
doublereal s_NBS_CLM_lnMolalityActCoeff() const
Calculate the Chlorine activity coefficient on the NBS scale.
Headers for the HMWSoln ThermoPhase object, which models concentrated electrolyte solutions (see Ther...
std::unique_ptr< WaterProps > m_waterProps
Pointer to the water property calculator.
virtual doublereal relative_enthalpy() const
Excess molar enthalpy of the solution from the mixing process.
void calc_thetas(int z1, int z2, double *etheta, double *etheta_prime) const
Calculate etheta and etheta_prime.
vector_fp m_Mu_nnn
Mu coefficient for the self-ternary neutral coefficient.
vector_fp m_molalitiesCropped
Cropped and modified values of the molalities used in activity coefficient calculations.
#define PITZERFORM_BASE
Major Parameters: The form of the Pitzer expression refers to the form of the Gibbs free energy expre...
vector_fp m_Beta2MX_ij_LL
Derivative of Beta2_ij[i][j] wrt TT. Vector index is counterIJ.
void s_updatePitzer_dlnMolalityActCoeff_dT() const
Calculates the temperature derivative of the natural logarithm of the molality activity coefficients...
CachedScalar getScalar(int id)
Get a reference to a CachedValue object representing a scalar (doublereal) with the given id...
vector_int CROP_speciesCropped_
This is a boolean-type vector indicating whether a species's activity coefficient is in the cropped r...
std::string speciesName(size_t k) const
Name of the species with index k.
vector_fp m_CMX_IJ_LL
Derivative of m_CMX_IJ wrt TT. Vector index is counterIJ.
Array2D m_Beta2MX_ij_coeff
Array of coefficients for Beta2, a variable in Pitzer's papers.
Array2D m_Lambda_nj_LL
Derivative of Lambda_nj[i][j] wrt TT.
void getUnscaledMolalityActivityCoefficients(doublereal *acMolality) const
Get the array of unscaled non-dimensional molality based activity coefficients at the current solutio...
doublereal IMS_slopegCut_
Parameter in the polyExp cutoff treatment.
doublereal IMS_slopefCut_
Parameter in the polyExp cutoff treatment.
vector_fp m_Beta0MX_ij_LL
Derivative of Beta0_ij[i][j] wrt TT. Vector index is counterIJ.
void s_updatePitzer_CoeffWRTemp(int doDerivs=2) const
Calculates the Pitzer coefficients' dependence on the temperature.
const int PHSCALE_NBS
Scale to be used for evaluation of single-ion activity coefficients is that used by the NBS standard ...
int m_form_A_Debye
Form of the constant outside the Debye-Huckel term called A.
ValueCache m_cache
Cached for saved calculations within each ThermoPhase.
doublereal s_NBS_CLM_d2lnMolalityActCoeff_dT2() const
Calculate the second temperature derivative of the Chlorine activity coefficient on the NBS scale...
virtual doublereal enthalpy_mole() const
Molar enthalpy. Units: J/kmol.
vector_int m_CounterIJ
a counter variable for keeping track of symmetric binary interactions amongst the solute species...
doublereal MC_slopepCut_
Parameter in the Molality Exp cutoff treatment.
virtual void getStandardChemPotentials(doublereal *mu) const
Get the array of chemical potentials at unit activity for the species at their standard states at the...
Base class for exceptions thrown by Cantera classes.
vector_fp m_CMX_IJ
Intermediate variable called CMX in Pitzer's paper.
int stateMFNumber() const
Return the State Mole Fraction Number.
virtual void getPartialMolarEnthalpies(doublereal *hbar) const
Returns an array of partial molar enthalpies for the species in the mixture.
double m_TempPitzerRef
Reference Temperature for the Pitzer formulations.
vector_fp m_CphiMX_ij_L
Derivative of Cphi_ij[i][j] wrt T. Vector index is counterIJ.
const int PHSCALE_PITZER
Scale to be used for the output of single-ion activity coefficients is that used by Pitzer...
vector_fp m_BphiMX_IJ_L
Derivative of BphiMX_IJ wrt T. Vector index is counterIJ.
vector_fp m_g2func_IJ
This is the value of g2(x2) in Pitzer's papers. Vector index is counterIJ.
int m_pHScalingType
Scaling to be used for output of single-ion species activity coefficients.
virtual double d2A_DebyedT2_TP(double temperature=-1.0, double pressure=-1.0) const
Value of the 2nd derivative of the Debye Huckel constant with respect to temperature as a function of...
double m_densWaterSS
density of standard-state water
void getMoleFractions(doublereal *const x) const
Get the species mole fraction vector.
Array2D m_Lambda_nj
Lambda coefficient for the ij interaction.
void s_update_d2lnMolalityActCoeff_dT2() const
This function calculates the temperature second derivative of the natural logarithm of the molality a...
virtual doublereal cv_mole() const
Molar heat capacity at constant volume. Units: J/kmol/K.
void importPhase(XML_Node &phase, ThermoPhase *th)
Import a phase information into an empty ThermoPhase object.
vector_fp m_Phi_IJ_LL
Derivative of m_Phi_IJ wrt TT. Vector index is counterIJ.
int m_formPitzer
This is the form of the Pitzer parameterization used in this model.
virtual doublereal pressure() const
Returns the current pressure of the phase.
doublereal IMS_gamma_k_min_
gamma_k minimum for the cutoff process at the zero solvent point
virtual void getActivityConcentrations(doublereal *c) const
This method returns an array of generalized activity concentrations.
vector_fp m_Alpha2MX_ij
Array of 2D data used in the Pitzer/HMW formulation.
vector_int m_electrolyteSpeciesType
Vector containing the electrolyte species type.
void debuglog(const std::string &msg, int loglevel)
Write a message to the log only if loglevel > 0.
vector_fp m_Beta0MX_ij
Array of 2D data used in the Pitzer/HMW formulation.
vector_fp m_BprimeMX_IJ_L
Derivative of BprimeMX wrt T. Vector index is counterIJ.
void writelogf(const char *fmt, const Args &... args)
Write a formatted message to the screen.
const int cHMWSoln0
eosTypes returned for this ThermoPhase Object
doublereal IMS_gamma_o_min_
gamma_o value for the cutoff process at the zero solvent point
#define AssertTrace(expr)
Assertion must be true or an error is thrown.
#define AssertThrowMsg(expr, procedure,...)
Assertion must be true or an error is thrown.
vector_fp m_BMX_IJ_LL
Derivative of BMX_IJ wrt TT. Vector index is counterIJ.
int m_formGC
Format for the generalized concentration:
vector_fp m_molalities
Current value of the molalities of the species in the phase.
double m_A_Debye
A_Debye: this expression appears on the top of the ln actCoeff term in the general Debye-Huckel expre...
virtual doublereal standardConcentration(size_t k=0) const
Return the standard concentration for the kth species.
void initLengths()
Initialize all of the species-dependent lengths in the object.
const doublereal SmallNumber
smallest number to compare to zero.
std::vector< double > vector_fp
Turn on the use of stl vectors for the basic array type within cantera Vector of doubles.
doublereal meanMolecularWeight() const
The mean molecular weight. Units: (kg/kmol)
virtual doublereal relative_molal_enthalpy() const
Excess molar enthalpy of the solution from the mixing process on a molality basis.
bool validate(double state1New)
Check whether the currently cached value is valid based on a single state variable.
void calcDensity()
Calculate the density of the mixture using the partial molar volumes and mole fractions as input...
vector_fp m_gamma_tmp
Intermediate storage of the activity coefficient itself.
const doublereal GasConstant
Universal Gas Constant. [J/kmol/K].
void s_update_dlnMolalityActCoeff_dP() const
This function calculates the pressure derivative of the natural logarithm of the molality activity co...
Contains declarations for string manipulation functions within Cantera.
virtual void getActivities(doublereal *ac) const
Get the array of non-dimensional activities at the current solution temperature, pressure, and solution concentration.
doublereal m_weightSolvent
Molecular weight of the Solvent.
doublereal IMS_X_o_cutoff_
value of the solute mole fraction that centers the cutoff polynomials for the cutoff =1 process; ...
vector_fp m_Psi_ijk
Array of 3D data used in the Pitzer/HMW formulation.
Class HMWSoln represents a dilute or concentrated liquid electrolyte phase which obeys the Pitzer for...
void s_updatePitzer_dlnMolalityActCoeff_dP() const
Calculates the Pressure derivative of the natural logarithm of the molality activity coefficients...
vector_fp m_BMX_IJ
Intermediate variable called BMX in Pitzer's paper.
void s_updateScaling_pHScaling_dT() const
Apply the current phScale to a set of derivatives of the activity Coefficients wrt temperature...
size_t m_kk
Number of species in the phase.
virtual void getEntropy_R(doublereal *sr) const
Get the array of nondimensional Entropy functions for the standard state species at the current T and...
virtual double dA_DebyedP_TP(double temperature=-1.0, double pressure=-1.0) const
Value of the derivative of the Debye Huckel constant with respect to pressure, as a function of tempe...
virtual double dA_DebyedT_TP(double temperature=-1.0, double pressure=-1.0) const
Value of the derivative of the Debye Huckel constant with respect to temperature as a function of tem...
double m_IionicMolalityStoich
Stoichiometric ionic strength on the molality scale.
void s_updateScaling_pHScaling_dT2() const
Apply the current phScale to a set of 2nd derivatives of the activity Coefficients wrt temperature...
int m_debugCalc
Turn on copious debug printing when this is true.
virtual void initThermoFile(const std::string &inputFile, const std::string &id)
vector_fp m_BprimeMX_IJ
Intermediate variable called BprimeMX in Pitzer's paper.
T value
The value of the cached property.
vector_fp m_d2lnActCoeffMolaldT2_Scaled
Derivative of the Logarithm of the activity coefficients on the molality scale wrt TT...
void calcMolalities() const
Calculates the molality of all species and stores the result internally.
Namespace for the Cantera kernel.
vector_fp m_CphiMX_ij
Array of 2D data used in the Pitzer/HMW formulation.
size_t m_indexSolvent
Index of the solvent.
int m_formPitzerTemp
This is the form of the temperature dependence of Pitzer parameterization used in the model...
void calc_lambdas(double is) const
Calculate the lambda interactions.
vector_fp m_Beta1MX_ij_L
Derivative of Beta1_ij[i][j] wrt T. Vector index is counterIJ.
double ADebye_J(double temperature=-1.0, double pressure=-1.0) const
Return Pitzer's definition of A_J.
vector_fp m_Theta_ij_LL
Derivative of Theta_ij[i][j] wrt TT. Vector index is counterIJ.
virtual void setState_TP(doublereal temp, doublereal pres)
Set the internal temperature and pressure.
Array2D m_Theta_ij_coeff
Array of coefficients for Theta_ij[i][j] in the Pitzer/HMW formulation.
virtual doublereal satPressure(doublereal T)
Get the saturation pressure for a given temperature.
Array2D m_Mu_nnn_coeff
Array of coefficients form_Mu_nnn term.
vector_fp m_Mu_nnn_LL
Mu coefficient 2nd temperature derivative for the self-ternary neutral coefficient.
void s_updatePitzer_lnMolalityActCoeff() const
Calculate the Pitzer portion of the activity coefficients.
vector_fp m_Aionic
a_k = Size of the ionic species in the DH formulation. units = meters
virtual void getEnthalpy_RT(doublereal *hrt) const
Get the nondimensional Enthalpy functions for the species at their standard states at the current T a...
doublereal charge(size_t k) const
Dimensionless electrical charge of a single molecule of species k The charge is normalized by the the...
vector_fp m_BphiMX_IJ_P
Derivative of BphiMX_IJ wrt P. Vector index is counterIJ.
virtual double A_Debye_TP(double temperature=-1.0, double pressure=-1.0) const
Value of the Debye Huckel constant as a function of temperature and pressure.
virtual void getStandardVolumes(doublereal *vol) const
Get the molar volumes of the species standard states at the current T and P of the solution...
Array2D m_Beta1MX_ij_coeff
Array of coefficients for Beta1, a variable in Pitzer's papers.
vector_fp m_PhiPhi_IJ_L
Derivative of m_PhiPhi_IJ wrt T. Vector index is counterIJ.
virtual void setDensity(const doublereal density_)
Set the internally stored density (kg/m^3) of the phase.
double ADebye_L(double temperature=-1.0, double pressure=-1.0) const
Return Pitzer's definition of A_L.
vector_fp m_Beta0MX_ij_P
Derivative of Beta0_ij[i][j] wrt P. Vector index is counterIJ.
vector_fp m_BphiMX_IJ_LL
Derivative of BphiMX_IJ wrt TT. Vector index is counterIJ.
virtual doublereal gibbs_mole() const
Molar Gibbs function. Units: J/kmol.