33 m_formPitzerTemp(PITZER_TEMP_CONSTANT),
35 m_IionicMolality(0.0),
36 m_maxIionicStrength(100.0),
37 m_TempPitzerRef(298.15),
38 m_IionicMolalityStoich(0.0),
39 m_form_A_Debye(A_DEBYE_WATER),
44 m_molalitiesAreCropped(false),
47 IMS_gamma_o_min_(1.0E-5),
48 IMS_gamma_k_min_(10.0),
68 CROP_ln_gamma_o_min(-6.0),
69 CROP_ln_gamma_o_max(3.0),
70 CROP_ln_gamma_k_min(-5.0),
71 CROP_ln_gamma_k_max(15.0),
75 for (
size_t i = 0; i < 17; i++) {
83 m_formPitzerTemp(PITZER_TEMP_CONSTANT),
85 m_IionicMolality(0.0),
86 m_maxIionicStrength(100.0),
87 m_TempPitzerRef(298.15),
88 m_IionicMolalityStoich(0.0),
89 m_form_A_Debye(A_DEBYE_WATER),
94 m_molalitiesAreCropped(false),
97 IMS_gamma_o_min_(1.0E-5),
98 IMS_gamma_k_min_(10.0),
118 CROP_ln_gamma_o_min(-6.0),
119 CROP_ln_gamma_o_max(3.0),
120 CROP_ln_gamma_k_min(-5.0),
121 CROP_ln_gamma_k_max(15.0),
125 for (
int i = 0; i < 17; i++) {
134 m_formPitzerTemp(PITZER_TEMP_CONSTANT),
136 m_IionicMolality(0.0),
137 m_maxIionicStrength(100.0),
138 m_TempPitzerRef(298.15),
139 m_IionicMolalityStoich(0.0),
140 m_form_A_Debye(A_DEBYE_WATER),
143 m_densWaterSS(1000.),
145 m_molalitiesAreCropped(false),
147 IMS_X_o_cutoff_(0.2),
148 IMS_gamma_o_min_(1.0E-5),
149 IMS_gamma_k_min_(10.0),
169 CROP_ln_gamma_o_min(-6.0),
170 CROP_ln_gamma_o_max(3.0),
171 CROP_ln_gamma_k_min(-5.0),
172 CROP_ln_gamma_k_max(15.0),
176 for (
int i = 0; i < 17; i++) {
185 m_formPitzerTemp(PITZER_TEMP_CONSTANT),
187 m_IionicMolality(0.0),
188 m_maxIionicStrength(100.0),
189 m_TempPitzerRef(298.15),
190 m_IionicMolalityStoich(0.0),
191 m_form_A_Debye(A_DEBYE_WATER),
194 m_densWaterSS(1000.),
196 m_molalitiesAreCropped(false),
198 IMS_X_o_cutoff_(0.2),
199 IMS_gamma_o_min_(1.0E-5),
200 IMS_gamma_k_min_(10.0),
220 CROP_ln_gamma_o_min(-6.0),
221 CROP_ln_gamma_o_max(3.0),
222 CROP_ln_gamma_k_min(-5.0),
223 CROP_ln_gamma_k_max(15.0),
252 throw CanteraError(
"HMWSoln::operator=()",
"Dynamic cast to PDSS_Water failed");
364 IMS_dfCut_ = b.IMS_dfCut_;
365 IMS_efCut_ = b.IMS_efCut_;
366 IMS_afCut_ = b.IMS_afCut_;
367 IMS_bfCut_ = b.IMS_bfCut_;
369 IMS_dgCut_ = b.IMS_dgCut_;
370 IMS_egCut_ = b.IMS_egCut_;
371 IMS_agCut_ = b.IMS_agCut_;
372 IMS_bgCut_ = b.IMS_bgCut_;
376 MC_dpCut_ = b.MC_dpCut_;
377 MC_epCut_ = b.MC_epCut_;
378 MC_apCut_ = b.MC_apCut_;
379 MC_bpCut_ = b.MC_bpCut_;
380 MC_cpCut_ = b.MC_cpCut_;
381 CROP_ln_gamma_o_min = b.CROP_ln_gamma_o_min;
382 CROP_ln_gamma_o_max = b.CROP_ln_gamma_o_max;
383 CROP_ln_gamma_k_min = b.CROP_ln_gamma_k_min;
384 CROP_ln_gamma_k_max = b.CROP_ln_gamma_k_max;
438 for (
size_t k = 0; k <
m_kk; k++) {
450 size_t kcation =
npos;
451 double xcation = 0.0;
452 size_t kanion =
npos;
453 for (
size_t k = 0; k <
m_kk; k++) {
459 }
else if (
charge(k) < 0.0) {
460 if (
m_tmpV[k] > xcation) {
466 if (kcation ==
npos || kanion ==
npos) {
469 double xuse = xcation;
471 if (xanion < xcation) {
473 if (
charge(kcation) != 1.0) {
477 if (
charge(kanion) != 1.0) {
481 xuse = xuse / factor;
510 return cp - beta * beta * tt * molarV / kappa_t;
535 double* vbar = &
m_pp[0];
539 doublereal vtotal = 0.0;
540 for (
size_t i = 0; i <
m_kk; i++) {
541 vtotal += vbar[i] * x[i];
556 if (rho != dens_old) {
558 "Density is not an independent variable");
565 "Density is not an independent variable");
611 for (
size_t k = 1; k <
m_kk; k++) {
624 return 1.0 / mvSolvent;
630 "To be removed after Cantera 2.2.");
631 for (
int i = 0; i < sizeUA; i++) {
636 uA[1] = -int(
nDim());
660 s_update_lnMolalityActCoeff();
664 for (
size_t k = 0; k <
m_kk; k++) {
678 s_update_lnMolalityActCoeff();
680 for (
size_t k = 0; k <
m_kk; k++) {
681 acMolality[k] = exp(acMolality[k]);
703 s_update_lnMolalityActCoeff();
706 for (
size_t k = 0; k <
m_kk; k++) {
728 for (
size_t k = 0; k <
m_kk; k++) {
735 s_update_lnMolalityActCoeff();
738 for (
size_t k = 0; k <
m_kk; k++) {
754 for (
size_t k = 0; k <
m_kk; k++) {
761 s_update_lnMolalityActCoeff();
767 for (
size_t k = 0; k <
m_kk; k++) {
783 for (
size_t k = 0; k <
m_kk; k++) {
797 s_update_lnMolalityActCoeff();
801 for (
size_t k = 0; k <
m_kk; k++) {
814 for (
size_t k = 0; k <
m_kk; k++) {
821 s_update_lnMolalityActCoeff();
827 for (
size_t k = 0; k <
m_kk; k++) {
852 if (tempArg != -1.0) {
856 if (presArg != -1.0) {
875 throw CanteraError(
"HMWSoln::A_Debye_TP",
"shouldn't be here");
883 if (tempArg != -1.0) {
887 if (presArg != -1.0) {
899 throw CanteraError(
"HMWSoln::dA_DebyedT_TP",
"shouldn't be here");
907 if (tempArg != -1.0) {
911 if (presArg != -1.0) {
931 throw CanteraError(
"HMWSoln::dA_DebyedP_TP",
"shouldn't be here");
939 double dAphidT = dAdT /3.0;
941 if (tempArg != -1.0) {
950 double dAphidP = dAdP /3.0;
952 if (tempArg != -1.0) {
961 if (tempArg != -1.0) {
966 double d2Aphi = d2 / 3.0;
967 return 2.0 * A_L / T + 4.0 *
GasConstant * T * T *d2Aphi;
973 if (tempArg != -1.0) {
977 if (presArg != -1.0) {
989 throw CanteraError(
"HMWSoln::d2A_DebyedT2_TP",
"shouldn't be here");
1021 size_t maxCounterIJlen = 1 + (
m_kk-1) * (
m_kk-2) / 2;
1027 int TCoeffLength = 1;
1101 m_BMX_IJ.resize(maxCounterIJlen, 0.0);
1113 m_Phi_IJ.resize(maxCounterIJlen, 0.0);
1122 m_CMX_IJ.resize(maxCounterIJlen, 0.0);
1135 void HMWSoln::s_update_lnMolalityActCoeff()
const
1160 for (
size_t k = 0; k <
m_kk; k++) {
1166 double zs_k2 = z_k - zs_k1;
1190 double lnActCoeffMolal0 = - log(xx) + (xx - 1.0)/xx;
1191 double lnxs = log(xx);
1193 for (
size_t k = 1; k <
m_kk; k++) {
1230 doublereal Imax = 0.0;
1233 for (
size_t k = 0; k <
m_kk; k++) {
1241 if (cropMethod == 0) {
1252 for (
size_t i = 1; i < (m_kk - 1); i++) {
1253 double charge_i =
charge(i);
1254 double abs_charge_i = fabs(charge_i);
1255 if (charge_i == 0.0) {
1258 for (
size_t j = (i+1); j <
m_kk; j++) {
1259 double charge_j =
charge(j);
1260 double abs_charge_j = fabs(charge_j);
1264 if (charge_i * charge_j < 0) {
1269 if (Imax > Iac_max) {
1273 if (Imax > Iac_max) {
1278 if (Imax > Iac_max) {
1282 if (Imax > Iac_max) {
1294 for (
int times = 0; times< 10; times++) {
1295 double anion_charge = 0.0;
1296 double cation_charge = 0.0;
1297 size_t anion_contrib_max_i =
npos;
1298 double anion_contrib_max = -1.0;
1299 size_t cation_contrib_max_i =
npos;
1300 double cation_contrib_max = -1.0;
1301 for (
size_t i = 0; i <
m_kk; i++) {
1302 double charge_i =
charge(i);
1303 if (charge_i < 0.0) {
1305 anion_charge += anion_contrib ;
1306 if (anion_contrib > anion_contrib_max) {
1307 anion_contrib_max = anion_contrib;
1308 anion_contrib_max_i = i;
1310 }
else if (charge_i > 0.0) {
1312 cation_charge += cation_contrib ;
1313 if (cation_contrib > cation_contrib_max) {
1314 cation_contrib_max = cation_contrib;
1315 cation_contrib_max_i = i;
1319 double total_charge = cation_charge - anion_charge;
1320 if (total_charge > 1.0E-8) {
1321 double desiredCrop = total_charge/
charge(cation_contrib_max_i);
1323 if (desiredCrop < maxCrop) {
1329 }
else if (total_charge < -1.0E-8) {
1330 double desiredCrop = total_charge/
charge(anion_contrib_max_i);
1332 if (desiredCrop < maxCrop) {
1344 if (cropMethod == 1) {
1354 double poly = MC_apCut_ + MC_bpCut_ * xmolSolvent + MC_dpCut_* xmolSolvent * xmolSolvent;
1355 double p = xmolSolvent + MC_epCut_ + exp(- xmolSolvent/ MC_cpCut_) * poly;
1358 for (
size_t k = 0; k <
m_kk; k++) {
1366 for (
size_t k = 0; k <
m_kk; k++) {
1371 for (
size_t k = 0; k <
m_kk; k++) {
1385 for (
size_t i = 0; i <
m_kk; i++) {
1387 size_t nc = m_kk * i;
1391 for (
size_t i = 1; i < (m_kk - 1); i++) {
1392 size_t n = m_kk * i + i;
1394 for (
size_t j = (i+1); j <
m_kk; j++) {
1396 size_t nc = m_kk * i + j;
1407 const double twoT = 2.0 * T;
1408 const double invT = 1.0 / T;
1409 const double invT2 = invT * invT;
1410 const double twoinvT3 = 2.0 * invT * invT2;
1412 double tinv = 0.0, tln = 0.0, tlin = 0.0, tquad = 0.0;
1417 tquad = T * T - Tr * Tr;
1419 tinv = 1.0/T - 1.0/Tr;
1422 for (
size_t i = 1; i < (m_kk - 1); i++) {
1423 for (
size_t j = (i+1); j <
m_kk; j++) {
1428 size_t n = m_kk*i + j;
1438 case PITZER_TEMP_CONSTANT:
1440 case PITZER_TEMP_LINEAR:
1443 + beta0MX_coeff[1]*tlin;
1448 + beta1MX_coeff[1]*tlin;
1453 + beta2MX_coeff[1]*tlin;
1458 + CphiMX_coeff[1]*tlin;
1462 m_Theta_ij[counterIJ] = Theta_coeff[0] + Theta_coeff[1]*tlin;
1468 case PITZER_TEMP_COMPLEX1:
1470 + beta0MX_coeff[1]*tlin
1471 + beta0MX_coeff[2]*tquad
1472 + beta0MX_coeff[3]*tinv
1473 + beta0MX_coeff[4]*tln;
1476 + beta1MX_coeff[1]*tlin
1477 + beta1MX_coeff[2]*tquad
1478 + beta1MX_coeff[3]*tinv
1479 + beta1MX_coeff[4]*tln;
1482 + beta2MX_coeff[1]*tlin
1483 + beta2MX_coeff[2]*tquad
1484 + beta2MX_coeff[3]*tinv
1485 + beta2MX_coeff[4]*tln;
1488 + CphiMX_coeff[1]*tlin
1489 + CphiMX_coeff[2]*tquad
1490 + CphiMX_coeff[3]*tinv
1491 + CphiMX_coeff[4]*tln;
1494 + Theta_coeff[1]*tlin
1495 + Theta_coeff[2]*tquad
1496 + Theta_coeff[3]*tinv
1497 + Theta_coeff[4]*tln;
1500 + beta0MX_coeff[2]*twoT
1501 - beta0MX_coeff[3]*invT2
1502 + beta0MX_coeff[4]*invT;
1505 + beta1MX_coeff[2]*twoT
1506 - beta1MX_coeff[3]*invT2
1507 + beta1MX_coeff[4]*invT;
1510 + beta2MX_coeff[2]*twoT
1511 - beta2MX_coeff[3]*invT2
1512 + beta2MX_coeff[4]*invT;
1515 + CphiMX_coeff[2]*twoT
1516 - CphiMX_coeff[3]*invT2
1517 + CphiMX_coeff[4]*invT;
1520 + Theta_coeff[2]*twoT
1521 - Theta_coeff[3]*invT2
1522 + Theta_coeff[4]*invT;
1527 + beta0MX_coeff[2]*2.0
1528 + beta0MX_coeff[3]*twoinvT3
1529 - beta0MX_coeff[4]*invT2;
1532 + beta1MX_coeff[2]*2.0
1533 + beta1MX_coeff[3]*twoinvT3
1534 - beta1MX_coeff[4]*invT2;
1537 + beta2MX_coeff[2]*2.0
1538 + beta2MX_coeff[3]*twoinvT3
1539 - beta2MX_coeff[4]*invT2;
1542 + CphiMX_coeff[2]*2.0
1543 + CphiMX_coeff[3]*twoinvT3
1544 - CphiMX_coeff[4]*invT2;
1547 + Theta_coeff[2]*2.0
1548 + Theta_coeff[3]*twoinvT3
1549 - Theta_coeff[4]*invT2;
1559 for (
size_t i = 1; i <
m_kk; i++) {
1561 for (
size_t j = 1; j <
m_kk; j++) {
1562 size_t n = i * m_kk + j;
1565 case PITZER_TEMP_CONSTANT:
1568 case PITZER_TEMP_LINEAR:
1569 m_Lambda_nj(i,j) = Lambda_coeff[0] + Lambda_coeff[1]*tlin;
1573 case PITZER_TEMP_COMPLEX1:
1575 + Lambda_coeff[1]*tlin
1576 + Lambda_coeff[2]*tquad
1577 + Lambda_coeff[3]*tinv
1578 + Lambda_coeff[4]*tln;
1581 + Lambda_coeff[2]*twoT
1582 - Lambda_coeff[3]*invT2
1583 + Lambda_coeff[4]*invT;
1587 + Lambda_coeff[3]*twoinvT3
1588 - Lambda_coeff[4]*invT2;
1594 case PITZER_TEMP_CONSTANT:
1597 case PITZER_TEMP_LINEAR:
1598 m_Mu_nnn[i] = Mu_coeff[0] + Mu_coeff[1]*tlin;
1602 case PITZER_TEMP_COMPLEX1:
1616 + Mu_coeff[3]*twoinvT3
1617 - Mu_coeff[4]*invT2;
1625 case PITZER_TEMP_CONSTANT:
1626 for (
size_t i = 1; i <
m_kk; i++) {
1627 for (
size_t j = 1; j <
m_kk; j++) {
1628 for (
size_t k = 1; k <
m_kk; k++) {
1629 size_t n = i * m_kk *m_kk + j * m_kk + k ;
1636 case PITZER_TEMP_LINEAR:
1637 for (
size_t i = 1; i <
m_kk; i++) {
1638 for (
size_t j = 1; j <
m_kk; j++) {
1639 for (
size_t k = 1; k <
m_kk; k++) {
1640 size_t n = i * m_kk *m_kk + j * m_kk + k ;
1642 m_Psi_ijk[n] = Psi_coeff[0] + Psi_coeff[1]*tlin;
1649 case PITZER_TEMP_COMPLEX1:
1650 for (
size_t i = 1; i <
m_kk; i++) {
1651 for (
size_t j = 1; j <
m_kk; j++) {
1652 for (
size_t k = 1; k <
m_kk; k++) {
1653 size_t n = i * m_kk *m_kk + j * m_kk + k ;
1657 + Psi_coeff[2]*tquad
1663 - Psi_coeff[3]*invT2
1664 + Psi_coeff[4]*invT;
1668 + Psi_coeff[3]*twoinvT3
1669 - Psi_coeff[4]*invT2;
1685 throw CanteraError(
"HMWSoln::s_updatePitzer_lnMolalityActCoeff",
1686 "Wrong index solvent value!");
1714 double etheta[5][5], etheta_prime[5][5], sqrtIs;
1723 double molarcharge = 0.0;
1728 double molalitysumUncropped = 0.0;
1743 printf(
"\n Debugging information from hmw_act \n");
1753 for (
size_t n = 1; n <
m_kk; n++) {
1757 molarcharge += fabs(
charge(n)) * molality[n];
1768 printf(
" Step 1: \n");
1769 printf(
" ionic strenth = %14.7le \n total molar "
1770 "charge = %14.7le \n", Is, molarcharge);
1786 printf(
" Step 2: \n");
1788 for (
int z1 = 1; z1 <=4; z1++) {
1789 for (
int z2 =1; z2 <=4; z2++) {
1790 calc_thetas(z1, z2, ðeta[z1][z2], ðeta_prime[z1][z2]);
1792 printf(
" z1=%3d z2=%3d E-theta(I) = %f, E-thetaprime(I) = %f\n",
1793 z1, z2, etheta[z1][z2], etheta_prime[z1][z2]);
1799 printf(
" Step 3: \n");
1800 printf(
" Species Species g(x) "
1809 for (
size_t i = 1; i < (m_kk - 1); i++) {
1810 for (
size_t j = (i+1); j <
m_kk; j++) {
1814 size_t n = m_kk*i + j;
1824 double x1 = sqrtIs * alpha1MX[counterIJ];
1825 if (x1 > 1.0E-100) {
1826 gfunc[counterIJ] = 2.0*(1.0-(1.0 + x1) * exp(-x1)) / (x1 * x1);
1827 hfunc[counterIJ] = -2.0 *
1828 (1.0-(1.0 + x1 + 0.5 * x1 * x1) * exp(-x1)) / (x1 * x1);
1830 gfunc[counterIJ] = 0.0;
1831 hfunc[counterIJ] = 0.0;
1834 if (beta2MX[counterIJ] != 0.0) {
1835 double x2 = sqrtIs * alpha2MX[counterIJ];
1836 if (x2 > 1.0E-100) {
1837 g2func[counterIJ] = 2.0*(1.0-(1.0 + x2) * exp(-x2)) / (x2 * x2);
1838 h2func[counterIJ] = -2.0 *
1839 (1.0-(1.0 + x2 + 0.5 * x2 * x2) * exp(-x2)) / (x2 * x2);
1841 g2func[counterIJ] = 0.0;
1842 h2func[counterIJ] = 0.0;
1846 gfunc[counterIJ] = 0.0;
1847 hfunc[counterIJ] = 0.0;
1852 printf(
" %-16s %-16s %9.5f %9.5f \n", sni.c_str(), snj.c_str(),
1853 gfunc[counterIJ], hfunc[counterIJ]);
1863 printf(
" Step 4: \n");
1864 printf(
" Species Species BMX "
1865 "BprimeMX BphiMX \n");
1868 for (
size_t i = 1; i < m_kk - 1; i++) {
1869 for (
size_t j = i+1; j <
m_kk; j++) {
1873 size_t n = m_kk*i + j;
1881 BMX[counterIJ] = beta0MX[counterIJ]
1882 + beta1MX[counterIJ] * gfunc[counterIJ]
1883 + beta2MX[counterIJ] * g2func[counterIJ];
1886 printf(
"%d %g: %g %g %g %g\n",
1887 (
int) counterIJ, BMX[counterIJ], beta0MX[counterIJ],
1888 beta1MX[counterIJ], beta2MX[counterIJ], gfunc[counterIJ]);
1890 if (Is > 1.0E-150) {
1891 BprimeMX[counterIJ] = (beta1MX[counterIJ] * hfunc[counterIJ]/Is +
1892 beta2MX[counterIJ] * h2func[counterIJ]/Is);
1894 BprimeMX[counterIJ] = 0.0;
1896 BphiMX[counterIJ] = BMX[counterIJ] + Is*BprimeMX[counterIJ];
1898 BMX[counterIJ] = 0.0;
1899 BprimeMX[counterIJ] = 0.0;
1900 BphiMX[counterIJ] = 0.0;
1905 printf(
" %-16s %-16s %11.7f %11.7f %11.7f \n",
1906 sni.c_str(), snj.c_str(),
1907 BMX[counterIJ], BprimeMX[counterIJ], BphiMX[counterIJ]);
1917 printf(
" Step 5: \n");
1918 printf(
" Species Species CMX \n");
1920 for (
size_t i = 1; i < m_kk-1; i++) {
1921 for (
size_t j = i+1; j <
m_kk; j++) {
1925 size_t n = m_kk*i + j;
1932 CMX[counterIJ] = CphiMX[counterIJ]/
1935 CMX[counterIJ] = 0.0;
1940 printf(
" %-16s %-16s %11.7f \n", sni.c_str(), snj.c_str(),
1951 printf(
" Step 6: \n");
1952 printf(
" Species Species Phi_ij "
1953 " Phiprime_ij Phi^phi_ij \n");
1955 for (
size_t i = 1; i < m_kk-1; i++) {
1956 for (
size_t j = i+1; j <
m_kk; j++) {
1960 size_t n = m_kk*i + j;
1967 int z1 = (int) fabs(
charge(i));
1968 int z2 = (int) fabs(
charge(j));
1969 Phi[counterIJ] = thetaij[counterIJ] + etheta[z1][z2];
1970 Phiprime[counterIJ] = etheta_prime[z1][z2];
1971 Phiphi[counterIJ] = Phi[counterIJ] + Is * Phiprime[counterIJ];
1973 Phi[counterIJ] = 0.0;
1974 Phiprime[counterIJ] = 0.0;
1975 Phiphi[counterIJ] = 0.0;
1980 printf(
" %-16s %-16s %10.6f %10.6f %10.6f \n",
1981 sni.c_str(), snj.c_str(),
1982 Phi[counterIJ], Phiprime[counterIJ], Phiphi[counterIJ]);
1992 printf(
" Step 7: \n");
1995 double F = -Aphi * (sqrt(Is) / (1.0 + 1.2*sqrt(Is))
1996 + (2.0/1.2) * log(1.0+1.2*(sqrtIs)));
1998 printf(
" initial value of F = %10.6f \n", F);
2000 for (
size_t i = 1; i < m_kk-1; i++) {
2001 for (
size_t j = i+1; j <
m_kk; j++) {
2005 size_t n = m_kk*i + j;
2012 F = F + molality[i]*molality[j] * BprimeMX[counterIJ];
2019 F = F + molality[i]*molality[j] * Phiprime[counterIJ];
2022 printf(
" F = %10.6f \n", F);
2027 printf(
" Step 8: Summing in All Contributions to Activity Coefficients \n");
2030 for (
size_t i = 1; i <
m_kk; i++) {
2040 printf(
" Contributions to ln(ActCoeff_%s):\n", sni.c_str());
2045 printf(
" Unary term: z*z*F = %10.5f\n", zsqF);
2052 for (
size_t j = 1; j <
m_kk; j++) {
2056 size_t n = m_kk*i + j;
2061 sum1 = sum1 + molality[j]*
2062 (2.0*BMX[counterIJ] + molarcharge*CMX[counterIJ]);
2065 printf(
" Bin term with %-13s 2 m_j BMX = %10.5f\n", snj.c_str(),
2066 molality[j]*2.0*BMX[counterIJ]);
2067 printf(
" m_j Z CMX = %10.5f\n",
2068 molality[j]* molarcharge*CMX[counterIJ]);
2076 for (
size_t k = j+1; k <
m_kk; k++) {
2079 n = k + j * m_kk + i * m_kk *
m_kk;
2080 sum3 = sum3 + molality[j]*molality[k]*psi_ijk[n];
2082 if (psi_ijk[n] != 0.0) {
2084 printf(
" Psi term on %-16s m_j m_k psi_ijk = %10.5f\n", snj.c_str(),
2085 molality[j]*molality[k]*psi_ijk[n]);
2097 sum2 = sum2 + molality[j]*(2.0*Phi[counterIJ]);
2099 if ((molality[j] * Phi[counterIJ])!= 0.0) {
2101 printf(
" Phi term with %-12s 2 m_j Phi_cc = %10.5f\n", snj.c_str(),
2102 molality[j]*(2.0*Phi[counterIJ]));
2106 for (
size_t k = 1; k <
m_kk; k++) {
2110 n = k + j * m_kk + i * m_kk *
m_kk;
2111 sum2 = sum2 + molality[j]*molality[k]*psi_ijk[n];
2113 if (psi_ijk[n] != 0.0) {
2115 printf(
" Psi term on %-16s m_j m_k psi_ijk = %10.5f\n", snj.c_str(),
2116 molality[j]*molality[k]*psi_ijk[n]);
2124 sum4 = sum4 + (fabs(
charge(i))*
2125 molality[j]*molality[k]*CMX[counterIJ2]);
2127 if ((molality[j]*molality[k]*CMX[counterIJ2]) != 0.0) {
2129 printf(
" Tern CMX term on %-16s abs(z_i) m_j m_k CMX = %10.5f\n", snj.c_str(),
2130 fabs(
charge(i))* molality[j]*molality[k]*CMX[counterIJ2]);
2145 printf(
" Lambda term with %-12s 2 m_j lam_ji = %10.5f\n", snj.c_str(),
2152 for (
size_t k = 1; k <
m_kk; k++) {
2156 n = izeta * m_kk * m_kk + jzeta * m_kk + k;
2157 double zeta = psi_ijk[n];
2159 sum5 = sum5 + molality[j]*molality[k]*zeta;
2162 printf(
" Zeta term on %-16s m_n m_a zeta_nMa = %10.5f\n", snj.c_str(),
2163 molality[j]*molality[k]*psi_ijk[n]);
2178 printf(
" Net %-16s lngamma[i] = %9.5f gamma[i]=%10.6f \n",
2191 printf(
" Contributions to ln(ActCoeff_%s):\n", sni.c_str());
2196 printf(
" Unary term: z*z*F = %10.5f\n", zsqF);
2203 for (
size_t j = 1; j <
m_kk; j++) {
2207 size_t n = m_kk*i + j;
2214 sum1 = sum1 + molality[j]*
2215 (2.0*BMX[counterIJ]+molarcharge*CMX[counterIJ]);
2218 printf(
" Bin term with %-13s 2 m_j BMX = %10.5f\n", snj.c_str(),
2219 molality[j]*2.0*BMX[counterIJ]);
2220 printf(
" m_j Z CMX = %10.5f\n",
2221 molality[j]* molarcharge*CMX[counterIJ]);
2224 for (
size_t k = j+1; k <
m_kk; k++) {
2227 n = k + j * m_kk + i * m_kk *
m_kk;
2228 sum3 = sum3 + molality[j]*molality[k]*psi_ijk[n];
2230 if (psi_ijk[n] != 0.0) {
2232 printf(
" Psi term on %-16s m_j m_k psi_ijk = %10.5f\n", snj.c_str(),
2233 molality[j]*molality[k]*psi_ijk[n]);
2247 sum2 = sum2 + molality[j]*(2.0*Phi[counterIJ]);
2249 if ((molality[j] * Phi[counterIJ])!= 0.0) {
2251 printf(
" Phi term with %-12s 2 m_j Phi_aa = %10.5f\n", snj.c_str(),
2252 molality[j]*(2.0*Phi[counterIJ]));
2256 for (
size_t k = 1; k <
m_kk; k++) {
2259 n = k + j * m_kk + i * m_kk *
m_kk;
2260 sum2 = sum2 + molality[j]*molality[k]*psi_ijk[n];
2262 if (psi_ijk[n] != 0.0) {
2264 printf(
" Psi term on %-16s m_j m_k psi_ijk = %10.5f\n", snj.c_str(),
2265 molality[j]*molality[k]*psi_ijk[n]);
2275 molality[j]*molality[k]*CMX[counterIJ2]);
2277 if ((molality[j]*molality[k]*CMX[counterIJ2]) != 0.0) {
2279 printf(
" Tern CMX term on %-16s abs(z_i) m_j m_k CMX = %10.5f\n", snj.c_str(),
2280 fabs(
charge(i))* molality[j]*molality[k]*CMX[counterIJ2]);
2295 printf(
" Lambda term with %-12s 2 m_j lam_ji = %10.5f\n", snj.c_str(),
2302 for (
size_t k = 1; k <
m_kk; k++) {
2307 n = izeta * m_kk * m_kk + jzeta * m_kk + kzeta;
2308 double zeta = psi_ijk[n];
2310 sum5 = sum5 + molality[j]*molality[k]*zeta;
2313 printf(
" Zeta term on %-16s m_n m_c zeta_ncX = %10.5f\n", snj.c_str(),
2314 molality[j]*molality[k]*psi_ijk[n]);
2325 printf(
" Net %-16s lngamma[i] = %9.5f gamma[i]=%10.6f\n",
2337 printf(
" Contributions to ln(ActCoeff_%s):\n", sni.c_str());
2341 for (
size_t j = 1; j <
m_kk; j++) {
2346 printf(
" Lambda_n term on %-16s 2 m_j lambda_n_j = %10.5f\n", snj.c_str(),
2354 for (
size_t k = 1; k <
m_kk; k++) {
2356 size_t n = k + j * m_kk + i * m_kk *
m_kk;
2357 sum3 = sum3 + molality[j]*molality[k]*psi_ijk[n];
2359 if (psi_ijk[n] != 0.0) {
2361 printf(
" Zeta term on %-16s m_j m_k psi_ijk = %10.5f\n", snj.c_str(),
2362 molality[j]*molality[k]*psi_ijk[n]);
2369 double sum2 = 3.0 * molality[i]* molality[i] *
m_Mu_nnn[i];
2371 if (m_Mu_nnn[i] != 0.0) {
2372 printf(
" Mu_nnn term 3 m_n m_n Mu_n_n = %10.5f\n",
2373 3.0 * molality[i]* molality[i] * m_Mu_nnn[i]);
2380 printf(
" Net %-16s lngamma[i] = %9.5f gamma[i]=%10.6f\n",
2387 printf(
" Step 9: \n");
2408 double term1 = -Aphi * pow(Is,1.5) / (1.0 + 1.2 * sqrt(Is));
2410 for (
size_t j = 1; j <
m_kk; j++) {
2415 for (
size_t k = 1; k <
m_kk; k++) {
2420 size_t n = m_kk*j + k;
2423 sum1 = sum1 + molality[j]*molality[k]*
2424 (BphiMX[counterIJ] + molarcharge*CMX[counterIJ]);
2428 for (
size_t k = j+1; k <
m_kk; k++) {
2429 if (j == (m_kk-1)) {
2431 throw CanteraError(
"HMWSoln::s_updatePitzer_lnMolalityActCoeff",
2432 "logic error 1 in Step 9 of hmw_act");
2439 size_t n = m_kk*j + k;
2441 sum2 = sum2 + molality[j]*molality[k]*Phiphi[counterIJ];
2442 for (
size_t m = 1; m <
m_kk; m++) {
2445 n = m + k * m_kk + j * m_kk *
m_kk;
2447 molality[j]*molality[k]*molality[m]*psi_ijk[n];
2458 for (
size_t k = j+1; k <
m_kk; k++) {
2461 throw CanteraError(
"HMWSoln::s_updatePitzer_lnMolalityActCoeff",
2462 "logic error 2 in Step 9 of hmw_act");
2469 size_t n = m_kk*j + k;
2472 sum3 = sum3 + molality[j]*molality[k]*Phiphi[counterIJ];
2473 for (
size_t m = 1; m <
m_kk; m++) {
2475 n = m + k * m_kk + j * m_kk *
m_kk;
2477 molality[j]*molality[k]*molality[m]*psi_ijk[n];
2488 for (
size_t k = 1; k <
m_kk; k++) {
2490 sum4 = sum4 + molality[j]*molality[k]*
m_Lambda_nj(j,k);
2493 sum5 = sum5 + molality[j]*molality[k]*
m_Lambda_nj(j,k);
2497 sum6 = sum6 + molality[j]*molality[k]*
m_Lambda_nj(j,k);
2498 }
else if (k == j) {
2499 sum6 = sum6 + 0.5 * molality[j]*molality[k]*
m_Lambda_nj(j,k);
2504 for (
size_t m = 1; m <
m_kk; m++) {
2507 size_t n = k + jzeta * m_kk + izeta * m_kk *
m_kk;
2508 double zeta = psi_ijk[n];
2510 sum7 += molality[izeta]*molality[jzeta]*molality[k]*zeta;
2516 sum7 += molality[j]*molality[j]*molality[j]*
m_Mu_nnn[j];
2519 double sum_m_phi_minus_1 = 2.0 *
2520 (term1 + sum1 + sum2 + sum3 + sum4 + sum5 + sum6 + sum7);
2525 double osmotic_coef;
2526 if (molalitysumUncropped > 1.0E-150) {
2527 osmotic_coef = 1.0 + (sum_m_phi_minus_1 / molalitysumUncropped);
2532 printf(
" term1=%10.6f sum1=%10.6f sum2=%10.6f "
2533 "sum3=%10.6f sum4=%10.6f sum5=%10.6f\n",
2534 term1, sum1, sum2, sum3, sum4, sum5);
2535 printf(
" sum_m_phi_minus_1=%10.6f osmotic_coef=%10.6f\n",
2536 sum_m_phi_minus_1, osmotic_coef);
2537 printf(
" Step 10: \n");
2539 double lnwateract = -(
m_weightSolvent/1000.0) * molalitysumUncropped * osmotic_coef;
2553 double wateract = exp(lnwateract);
2555 printf(
" molalitySumUncropped = %16.7g\n", molalitysumUncropped);
2556 printf(
" ln_a_water=%10.6f a_water=%10.6f\n\n",
2557 lnwateract, wateract);
2578 for (
size_t k = 1; k <
m_kk; k++) {
2612 throw CanteraError(
"HMWSoln::s_updatePitzer_dlnMolalityActCoeff_dT",
2613 "Wrong index solvent value!");
2629 double etheta[5][5], etheta_prime[5][5], sqrtIs;
2638 double molarcharge = 0.0;
2643 double molalitysum = 0.0;
2658 printf(
"\n Debugging information from "
2659 "s_Pitzer_dlnMolalityActCoeff_dT()\n");
2669 for (
size_t n = 1; n <
m_kk; n++) {
2673 molarcharge += fabs(
charge(n)) * molality[n];
2674 molalitysum += molality[n];
2684 printf(
" Step 1: \n");
2685 printf(
" ionic strenth = %14.7le \n total molar "
2686 "charge = %14.7le \n", Is, molarcharge);
2702 printf(
" Step 2: \n");
2704 for (
int z1 = 1; z1 <=4; z1++) {
2705 for (
int z2 =1; z2 <=4; z2++) {
2706 calc_thetas(z1, z2, ðeta[z1][z2], ðeta_prime[z1][z2]);
2708 printf(
" z1=%3d z2=%3d E-theta(I) = %f, E-thetaprime(I) = %f\n",
2709 z1, z2, etheta[z1][z2], etheta_prime[z1][z2]);
2715 printf(
" Step 3: \n");
2716 printf(
" Species Species g(x) "
2725 for (
size_t i = 1; i < (m_kk - 1); i++) {
2726 for (
size_t j = (i+1); j <
m_kk; j++) {
2730 size_t n = m_kk*i + j;
2739 double x1 = sqrtIs * alpha1MX[counterIJ];
2740 if (x1 > 1.0E-100) {
2741 gfunc[counterIJ] = 2.0*(1.0-(1.0 + x1) * exp(-x1)) / (x1 * x1);
2742 hfunc[counterIJ] = -2.0 *
2743 (1.0-(1.0 + x1 + 0.5 * x1 *x1) * exp(-x1)) / (x1 * x1);
2745 gfunc[counterIJ] = 0.0;
2746 hfunc[counterIJ] = 0.0;
2749 if (beta2MX_L[counterIJ] != 0.0) {
2750 double x2 = sqrtIs * alpha2MX[counterIJ];
2751 if (x2 > 1.0E-100) {
2752 g2func[counterIJ] = 2.0*(1.0-(1.0 + x2) * exp(-x2)) / (x2 * x2);
2753 h2func[counterIJ] = -2.0 *
2754 (1.0-(1.0 + x2 + 0.5 * x2 * x2) * exp(-x2)) / (x2 * x2);
2756 g2func[counterIJ] = 0.0;
2757 h2func[counterIJ] = 0.0;
2761 gfunc[counterIJ] = 0.0;
2762 hfunc[counterIJ] = 0.0;
2767 printf(
" %-16s %-16s %9.5f %9.5f \n", sni.c_str(), snj.c_str(),
2768 gfunc[counterIJ], hfunc[counterIJ]);
2779 printf(
" Step 4: \n");
2780 printf(
" Species Species BMX "
2781 "BprimeMX BphiMX \n");
2784 for (
size_t i = 1; i < m_kk - 1; i++) {
2785 for (
size_t j = i+1; j <
m_kk; j++) {
2789 size_t n = m_kk*i + j;
2796 BMX_L[counterIJ] = beta0MX_L[counterIJ]
2797 + beta1MX_L[counterIJ] * gfunc[counterIJ]
2798 + beta2MX_L[counterIJ] * gfunc[counterIJ];
2800 printf(
"%d %g: %g %g %g %g\n",
2801 (
int) counterIJ, BMX_L[counterIJ], beta0MX_L[counterIJ],
2802 beta1MX_L[counterIJ], beta2MX_L[counterIJ], gfunc[counterIJ]);
2804 if (Is > 1.0E-150) {
2805 BprimeMX_L[counterIJ] = (beta1MX_L[counterIJ] * hfunc[counterIJ]/Is +
2806 beta2MX_L[counterIJ] * h2func[counterIJ]/Is);
2808 BprimeMX_L[counterIJ] = 0.0;
2810 BphiMX_L[counterIJ] = BMX_L[counterIJ] + Is*BprimeMX_L[counterIJ];
2812 BMX_L[counterIJ] = 0.0;
2813 BprimeMX_L[counterIJ] = 0.0;
2814 BphiMX_L[counterIJ] = 0.0;
2819 printf(
" %-16s %-16s %11.7f %11.7f %11.7f \n",
2820 sni.c_str(), snj.c_str(),
2821 BMX_L[counterIJ], BprimeMX_L[counterIJ], BphiMX_L[counterIJ]);
2831 printf(
" Step 5: \n");
2832 printf(
" Species Species CMX \n");
2834 for (
size_t i = 1; i < m_kk-1; i++) {
2835 for (
size_t j = i+1; j <
m_kk; j++) {
2839 size_t n = m_kk*i + j;
2846 CMX_L[counterIJ] = CphiMX_L[counterIJ]/
2849 CMX_L[counterIJ] = 0.0;
2854 printf(
" %-16s %-16s %11.7f \n", sni.c_str(), snj.c_str(),
2865 printf(
" Step 6: \n");
2866 printf(
" Species Species Phi_ij "
2867 " Phiprime_ij Phi^phi_ij \n");
2869 for (
size_t i = 1; i < m_kk-1; i++) {
2870 for (
size_t j = i+1; j <
m_kk; j++) {
2874 size_t n = m_kk*i + j;
2881 Phi_L[counterIJ] = thetaij_L[counterIJ];
2882 Phiprime[counterIJ] = 0.0;
2883 Phiphi_L[counterIJ] = Phi_L[counterIJ] + Is * Phiprime[counterIJ];
2885 Phi_L[counterIJ] = 0.0;
2886 Phiprime[counterIJ] = 0.0;
2887 Phiphi_L[counterIJ] = 0.0;
2892 printf(
" %-16s %-16s %10.6f %10.6f %10.6f \n",
2893 sni.c_str(), snj.c_str(),
2894 Phi_L[counterIJ], Phiprime[counterIJ], Phiphi_L[counterIJ]);
2903 printf(
" Step 7: \n");
2906 double dAphidT = dA_DebyedT /3.0;
2907 double dFdT = -dAphidT * (sqrt(Is) / (1.0 + 1.2*sqrt(Is))
2908 + (2.0/1.2) * log(1.0+1.2*(sqrtIs)));
2910 printf(
" initial value of dFdT = %10.6f \n", dFdT);
2912 for (
size_t i = 1; i < m_kk-1; i++) {
2913 for (
size_t j = i+1; j <
m_kk; j++) {
2917 size_t n = m_kk*i + j;
2924 dFdT = dFdT + molality[i]*molality[j] * BprimeMX_L[counterIJ];
2931 dFdT = dFdT + molality[i]*molality[j] * Phiprime[counterIJ];
2934 printf(
" dFdT = %10.6f \n", dFdT);
2939 printf(
" Step 8: \n");
2942 for (
size_t i = 1; i <
m_kk; i++) {
2955 for (
size_t j = 1; j <
m_kk; j++) {
2959 size_t n = m_kk*i + j;
2964 sum1 = sum1 + molality[j]*
2965 (2.0*BMX_L[counterIJ] + molarcharge*CMX_L[counterIJ]);
2972 for (
size_t k = j+1; k <
m_kk; k++) {
2975 n = k + j * m_kk + i * m_kk *
m_kk;
2976 sum3 = sum3 + molality[j]*molality[k]*psi_ijk_L[n];
2986 sum2 = sum2 + molality[j]*(2.0*Phi_L[counterIJ]);
2988 for (
size_t k = 1; k <
m_kk; k++) {
2992 n = k + j * m_kk + i * m_kk *
m_kk;
2993 sum2 = sum2 + molality[j]*molality[k]*psi_ijk_L[n];
2999 sum4 = sum4 + (fabs(
charge(i))*
3000 molality[j]*molality[k]*CMX_L[counterIJ2]);
3014 for (
size_t k = 1; k <
m_kk; k++) {
3018 n = izeta * m_kk * m_kk + jzeta * m_kk + k;
3019 double zeta_L = psi_ijk_L[n];
3020 if (zeta_L != 0.0) {
3021 sum5 = sum5 + molality[j]*molality[k]*zeta_L;
3031 zsqdFdT + sum1 + sum2 + sum3 + sum4 + sum5;
3035 printf(
" %-16s lngamma[i]=%10.6f gamma[i]=%10.6f \n",
3037 printf(
" %12g %12g %12g %12g %12g %12g\n",
3038 zsqdFdT, sum1, sum2, sum3, sum4, sum5);
3054 for (
size_t j = 1; j <
m_kk; j++) {
3058 size_t n = m_kk*i + j;
3065 sum1 = sum1 + molality[j]*
3066 (2.0*BMX_L[counterIJ] + molarcharge*CMX_L[counterIJ]);
3068 for (
size_t k = j+1; k <
m_kk; k++) {
3071 n = k + j * m_kk + i * m_kk *
m_kk;
3072 sum3 = sum3 + molality[j]*molality[k]*psi_ijk_L[n];
3084 sum2 = sum2 + molality[j]*(2.0*Phi_L[counterIJ]);
3086 for (
size_t k = 1; k <
m_kk; k++) {
3089 n = k + j * m_kk + i * m_kk *
m_kk;
3090 sum2 = sum2 + molality[j]*molality[k]*psi_ijk_L[n];
3098 molality[j]*molality[k]*CMX_L[counterIJ2]);
3108 for (
size_t k = 1; k <
m_kk; k++) {
3113 n = izeta * m_kk * m_kk + jzeta * m_kk + kzeta;
3114 double zeta_L = psi_ijk_L[n];
3115 if (zeta_L != 0.0) {
3116 sum5 = sum5 + molality[j]*molality[k]*zeta_L;
3123 zsqdFdT + sum1 + sum2 + sum3 + sum4 + sum5;
3127 printf(
" %-16s lngamma[i]=%10.6f gamma[i]=%10.6f\n",
3129 printf(
" %12g %12g %12g %12g %12g %12g\n",
3130 zsqdFdT, sum1, sum2, sum3, sum4, sum5);
3141 for (
size_t j = 1; j <
m_kk; j++) {
3147 for (
size_t k = 1; k <
m_kk; k++) {
3149 size_t n = k + j * m_kk + i * m_kk *
m_kk;
3150 sum3 = sum3 + molality[j]*molality[k]*psi_ijk_L[n];
3155 double sum2 = 3.0 * molality[i] * molality[i] *
m_Mu_nnn_L[i];
3160 printf(
" %-16s lngamma[i]=%10.6f gamma[i]=%10.6f \n",
3167 printf(
" Step 9: \n");
3188 double term1 = -dAphidT * Is * sqrt(Is) / (1.0 + 1.2 * sqrt(Is));
3190 for (
size_t j = 1; j <
m_kk; j++) {
3195 for (
size_t k = 1; k <
m_kk; k++) {
3200 size_t n = m_kk*j + k;
3203 sum1 = sum1 + molality[j]*molality[k]*
3204 (BphiMX_L[counterIJ] + molarcharge*CMX_L[counterIJ]);
3208 for (
size_t k = j+1; k <
m_kk; k++) {
3209 if (j == (m_kk-1)) {
3211 throw CanteraError(
"HMWSoln::s_updatePitzer_dlnMolalityActCoeff_dT",
3212 "logic error 1 in Step 9 of hmw_act");
3219 size_t n = m_kk*j + k;
3221 sum2 = sum2 + molality[j]*molality[k]*Phiphi_L[counterIJ];
3222 for (
size_t m = 1; m <
m_kk; m++) {
3225 n = m + k * m_kk + j * m_kk *
m_kk;
3227 molality[j]*molality[k]*molality[m]*psi_ijk_L[n];
3238 for (
size_t k = j+1; k <
m_kk; k++) {
3241 throw CanteraError(
"HMWSoln::s_updatePitzer_dlnMolalityActCoeff_dT",
3242 "logic error 2 in Step 9 of hmw_act");
3249 size_t n = m_kk*j + k;
3252 sum3 = sum3 + molality[j]*molality[k]*Phiphi_L[counterIJ];
3253 for (
size_t m = 1; m <
m_kk; m++) {
3255 n = m + k * m_kk + j * m_kk *
m_kk;
3257 molality[j]*molality[k]*molality[m]*psi_ijk_L[n];
3268 for (
size_t k = 1; k <
m_kk; k++) {
3278 }
else if (k == j) {
3279 sum6 = sum6 + 0.5 * molality[j]*molality[k]*
m_Lambda_nj_L(j,k);
3284 for (
size_t m = 1; m <
m_kk; m++) {
3287 size_t n = k + jzeta * m_kk + izeta * m_kk *
m_kk;
3288 double zeta_L = psi_ijk_L[n];
3289 if (zeta_L != 0.0) {
3290 sum7 += molality[izeta]*molality[jzeta]*molality[k]*zeta_L;
3296 sum7 += molality[j]*molality[j]*molality[j]*
m_Mu_nnn_L[j];
3299 double sum_m_phi_minus_1 = 2.0 *
3300 (term1 + sum1 + sum2 + sum3 + sum4 + sum5 + sum6 + sum7);
3305 double d_osmotic_coef_dT;
3306 if (molalitysum > 1.0E-150) {
3307 d_osmotic_coef_dT = 0.0 + (sum_m_phi_minus_1 / molalitysum);
3309 d_osmotic_coef_dT = 0.0;
3313 printf(
" term1=%10.6f sum1=%10.6f sum2=%10.6f "
3314 "sum3=%10.6f sum4=%10.6f sum5=%10.6f\n",
3315 term1, sum1, sum2, sum3, sum4, sum5);
3316 printf(
" sum_m_phi_minus_1=%10.6f d_osmotic_coef_dT =%10.6f\n",
3317 sum_m_phi_minus_1, d_osmotic_coef_dT);
3318 printf(
" Step 10: \n");
3320 double d_lnwateract_dT = -(
m_weightSolvent/1000.0) * molalitysum * d_osmotic_coef_dT;
3332 double d_wateract_dT = exp(d_lnwateract_dT);
3333 printf(
" d_ln_a_water_dT = %10.6f d_a_water_dT=%10.6f\n\n",
3334 d_lnwateract_dT, d_wateract_dT);
3355 for (
size_t k = 1; k <
m_kk; k++) {
3380 throw CanteraError(
"HMWSoln::s_updatePitzer_d2lnMolalityActCoeff_dT2",
3381 "Wrong index solvent value!");
3397 double etheta[5][5], etheta_prime[5][5], sqrtIs;
3406 double molarcharge = 0.0;
3411 double molalitysum = 0.0;
3426 printf(
"\n Debugging information from "
3427 "s_Pitzer_d2lnMolalityActCoeff_dT2()\n");
3438 for (
size_t n = 1; n <
m_kk; n++) {
3442 molarcharge += fabs(
charge(n)) * molality[n];
3443 molalitysum += molality[n];
3453 printf(
" Step 1: \n");
3454 printf(
" ionic strenth = %14.7le \n total molar "
3455 "charge = %14.7le \n", Is, molarcharge);
3471 printf(
" Step 2: \n");
3473 for (
int z1 = 1; z1 <=4; z1++) {
3474 for (
int z2 =1; z2 <=4; z2++) {
3475 calc_thetas(z1, z2, ðeta[z1][z2], ðeta_prime[z1][z2]);
3477 printf(
" z1=%3d z2=%3d E-theta(I) = %f, E-thetaprime(I) = %f\n",
3478 z1, z2, etheta[z1][z2], etheta_prime[z1][z2]);
3484 printf(
" Step 3: \n");
3485 printf(
" Species Species g(x) "
3495 for (
size_t i = 1; i < (m_kk - 1); i++) {
3496 for (
size_t j = (i+1); j <
m_kk; j++) {
3500 size_t n = m_kk*i + j;
3509 double x1 = sqrtIs * alpha1MX[counterIJ];
3510 if (x1 > 1.0E-100) {
3511 gfunc[counterIJ] = 2.0*(1.0-(1.0 + x1) * exp(-x1)) / (x1 *x1);
3512 hfunc[counterIJ] = -2.0*
3513 (1.0-(1.0 + x1 + 0.5*x1 * x1) * exp(-x1)) / (x1 * x1);
3515 gfunc[counterIJ] = 0.0;
3516 hfunc[counterIJ] = 0.0;
3519 if (beta2MX_LL[counterIJ] != 0.0) {
3520 double x2 = sqrtIs * alpha2MX[counterIJ];
3521 if (x2 > 1.0E-100) {
3522 g2func[counterIJ] = 2.0*(1.0-(1.0 + x2) * exp(-x2)) / (x2 * x2);
3523 h2func[counterIJ] = -2.0 *
3524 (1.0-(1.0 + x2 + 0.5 * x2 * x2) * exp(-x2)) / (x2 * x2);
3526 g2func[counterIJ] = 0.0;
3527 h2func[counterIJ] = 0.0;
3531 gfunc[counterIJ] = 0.0;
3532 hfunc[counterIJ] = 0.0;
3537 printf(
" %-16s %-16s %9.5f %9.5f \n", sni.c_str(), snj.c_str(),
3538 gfunc[counterIJ], hfunc[counterIJ]);
3548 printf(
" Step 4: \n");
3549 printf(
" Species Species BMX "
3550 "BprimeMX BphiMX \n");
3553 for (
size_t i = 1; i < m_kk - 1; i++) {
3554 for (
size_t j = i+1; j <
m_kk; j++) {
3558 size_t n = m_kk*i + j;
3565 BMX_LL[counterIJ] = beta0MX_LL[counterIJ]
3566 + beta1MX_LL[counterIJ] * gfunc[counterIJ]
3567 + beta2MX_LL[counterIJ] * g2func[counterIJ];
3569 printf(
"%d %g: %g %g %g %g\n",
3570 (
int) counterIJ, BMX_LL[counterIJ], beta0MX_LL[counterIJ],
3571 beta1MX_LL[counterIJ], beta2MX_LL[counterIJ], gfunc[counterIJ]);
3573 if (Is > 1.0E-150) {
3574 BprimeMX_LL[counterIJ] = (beta1MX_LL[counterIJ] * hfunc[counterIJ]/Is +
3575 beta2MX_LL[counterIJ] * h2func[counterIJ]/Is);
3577 BprimeMX_LL[counterIJ] = 0.0;
3579 BphiMX_LL[counterIJ] = BMX_LL[counterIJ] + Is*BprimeMX_LL[counterIJ];
3581 BMX_LL[counterIJ] = 0.0;
3582 BprimeMX_LL[counterIJ] = 0.0;
3583 BphiMX_LL[counterIJ] = 0.0;
3588 printf(
" %-16s %-16s %11.7f %11.7f %11.7f \n",
3589 sni.c_str(), snj.c_str(),
3590 BMX_LL[counterIJ], BprimeMX_LL[counterIJ], BphiMX_LL[counterIJ]);
3600 printf(
" Step 5: \n");
3601 printf(
" Species Species CMX \n");
3603 for (
size_t i = 1; i < m_kk-1; i++) {
3604 for (
size_t j = i+1; j <
m_kk; j++) {
3608 size_t n = m_kk*i + j;
3615 CMX_LL[counterIJ] = CphiMX_LL[counterIJ]/
3618 CMX_LL[counterIJ] = 0.0;
3623 printf(
" %-16s %-16s %11.7f \n", sni.c_str(), snj.c_str(),
3634 printf(
" Step 6: \n");
3635 printf(
" Species Species Phi_ij "
3636 " Phiprime_ij Phi^phi_ij \n");
3638 for (
size_t i = 1; i < m_kk-1; i++) {
3639 for (
size_t j = i+1; j <
m_kk; j++) {
3643 size_t n = m_kk*i + j;
3650 Phi_LL[counterIJ] = thetaij_LL[counterIJ];
3651 Phiprime[counterIJ] = 0.0;
3652 Phiphi_LL[counterIJ] = Phi_LL[counterIJ];
3654 Phi_LL[counterIJ] = 0.0;
3655 Phiprime[counterIJ] = 0.0;
3656 Phiphi_LL[counterIJ] = 0.0;
3661 printf(
" %-16s %-16s %10.6f %10.6f %10.6f \n",
3662 sni.c_str(), snj.c_str(),
3663 Phi_LL[counterIJ], Phiprime[counterIJ], Phiphi_LL[counterIJ]);
3672 printf(
" Step 7: \n");
3675 double d2FdT2 = -d2AphidT2 * (sqrt(Is) / (1.0 + 1.2*sqrt(Is))
3676 + (2.0/1.2) * log(1.0+1.2*(sqrtIs)));
3678 printf(
" initial value of d2FdT2 = %10.6f \n", d2FdT2);
3680 for (
size_t i = 1; i < m_kk-1; i++) {
3681 for (
size_t j = i+1; j <
m_kk; j++) {
3685 size_t n = m_kk*i + j;
3692 d2FdT2 = d2FdT2 + molality[i]*molality[j] * BprimeMX_LL[counterIJ];
3699 d2FdT2 = d2FdT2 + molality[i]*molality[j] * Phiprime[counterIJ];
3702 printf(
" d2FdT2 = %10.6f \n", d2FdT2);
3707 printf(
" Step 8: \n");
3710 for (
size_t i = 1; i <
m_kk; i++) {
3724 for (
size_t j = 1; j <
m_kk; j++) {
3728 size_t n = m_kk*i + j;
3733 sum1 = sum1 + molality[j]*
3734 (2.0*BMX_LL[counterIJ] + molarcharge*CMX_LL[counterIJ]);
3741 for (
size_t k = j+1; k <
m_kk; k++) {
3744 n = k + j * m_kk + i * m_kk *
m_kk;
3745 sum3 = sum3 + molality[j]*molality[k]*psi_ijk_LL[n];
3755 sum2 = sum2 + molality[j]*(2.0*Phi_LL[counterIJ]);
3757 for (
size_t k = 1; k <
m_kk; k++) {
3761 n = k + j * m_kk + i * m_kk *
m_kk;
3762 sum2 = sum2 + molality[j]*molality[k]*psi_ijk_LL[n];
3768 sum4 = sum4 + (fabs(
charge(i))*
3769 molality[j]*molality[k]*CMX_LL[counterIJ2]);
3782 for (
size_t k = 1; k <
m_kk; k++) {
3786 n = izeta * m_kk * m_kk + jzeta * m_kk + k;
3787 double zeta_LL = psi_ijk_LL[n];
3788 if (zeta_LL != 0.0) {
3789 sum5 = sum5 + molality[j]*molality[k]*zeta_LL;
3800 zsqd2FdT2 + sum1 + sum2 + sum3 + sum4 + sum5;
3803 printf(
" %-16s d2lngammadT2[i]=%10.6f \n",
3805 printf(
" %12g %12g %12g %12g %12g %12g\n",
3806 zsqd2FdT2, sum1, sum2, sum3, sum4, sum5);
3823 for (
size_t j = 1; j <
m_kk; j++) {
3827 size_t n = m_kk*i + j;
3834 sum1 = sum1 + molality[j]*
3835 (2.0*BMX_LL[counterIJ] + molarcharge*CMX_LL[counterIJ]);
3837 for (
size_t k = j+1; k <
m_kk; k++) {
3840 n = k + j * m_kk + i * m_kk *
m_kk;
3841 sum3 = sum3 + molality[j]*molality[k]*psi_ijk_LL[n];
3853 sum2 = sum2 + molality[j]*(2.0*Phi_LL[counterIJ]);
3855 for (
size_t k = 1; k <
m_kk; k++) {
3858 n = k + j * m_kk + i * m_kk *
m_kk;
3859 sum2 = sum2 + molality[j]*molality[k]*psi_ijk_LL[n];
3867 molality[j]*molality[k]*CMX_LL[counterIJ2]);
3880 for (
size_t k = 1; k <
m_kk; k++) {
3885 n = izeta * m_kk * m_kk + jzeta * m_kk + kzeta;
3886 double zeta_LL = psi_ijk_LL[n];
3887 if (zeta_LL != 0.0) {
3888 sum5 = sum5 + molality[j]*molality[k]*zeta_LL;
3895 zsqd2FdT2 + sum1 + sum2 + sum3 + sum4 + sum5;
3898 printf(
" %-16s d2lngammadT2[i]=%10.6f\n",
3900 printf(
" %12g %12g %12g %12g %12g %12g\n",
3901 zsqd2FdT2, sum1, sum2, sum3, sum4, sum5);
3912 for (
size_t j = 1; j <
m_kk; j++) {
3918 for (
size_t k = 1; k <
m_kk; k++) {
3920 size_t n = k + j * m_kk + i * m_kk *
m_kk;
3921 sum3 = sum3 + molality[j]*molality[k]*psi_ijk_LL[n];
3926 double sum2 = 3.0 * molality[i] * molality[i] *
m_Mu_nnn_LL[i];
3930 printf(
" %-16s d2lngammadT2[i]=%10.6f \n",
3937 printf(
" Step 9: \n");
3958 double term1 = -d2AphidT2 * Is * sqrt(Is) / (1.0 + 1.2 * sqrt(Is));
3960 for (
size_t j = 1; j <
m_kk; j++) {
3965 for (
size_t k = 1; k <
m_kk; k++) {
3970 size_t n = m_kk*j + k;
3973 sum1 = sum1 + molality[j]*molality[k]*
3974 (BphiMX_LL[counterIJ] + molarcharge*CMX_LL[counterIJ]);
3978 for (
size_t k = j+1; k <
m_kk; k++) {
3979 if (j == (m_kk-1)) {
3981 throw CanteraError(
"HMWSoln::s_updatePitzer_d2lnMolalityActCoeff_dT2",
3982 "logic error 1 in Step 9 of hmw_act");
3989 size_t n = m_kk*j + k;
3991 sum2 = sum2 + molality[j]*molality[k]*Phiphi_LL[counterIJ];
3992 for (
size_t m = 1; m <
m_kk; m++) {
3995 n = m + k * m_kk + j * m_kk *
m_kk;
3997 molality[j]*molality[k]*molality[m]*psi_ijk_LL[n];
4008 for (
size_t k = j+1; k <
m_kk; k++) {
4011 throw CanteraError(
"HMWSoln::s_updatePitzer_d2lnMolalityActCoeff_dT2",
4012 "logic error 2 in Step 9 of hmw_act");
4019 size_t n = m_kk*j + k;
4022 sum3 = sum3 + molality[j]*molality[k]*Phiphi_LL[counterIJ];
4023 for (
size_t m = 1; m <
m_kk; m++) {
4025 n = m + k * m_kk + j * m_kk *
m_kk;
4027 molality[j]*molality[k]*molality[m]*psi_ijk_LL[n];
4038 for (
size_t k = 1; k <
m_kk; k++) {
4048 }
else if (k == j) {
4054 for (
size_t m = 1; m <
m_kk; m++) {
4057 size_t n = k + jzeta * m_kk + izeta * m_kk *
m_kk;
4058 double zeta_LL = psi_ijk_LL[n];
4059 if (zeta_LL != 0.0) {
4060 sum7 += molality[izeta]*molality[jzeta]*molality[k]*zeta_LL;
4067 sum7 += molality[j] * molality[j] * molality[j] *
m_Mu_nnn_LL[j];
4070 double sum_m_phi_minus_1 = 2.0 *
4071 (term1 + sum1 + sum2 + sum3 + sum4 + sum5 + sum6 + sum7);
4076 double d2_osmotic_coef_dT2;
4077 if (molalitysum > 1.0E-150) {
4078 d2_osmotic_coef_dT2 = 0.0 + (sum_m_phi_minus_1 / molalitysum);
4080 d2_osmotic_coef_dT2 = 0.0;
4083 printf(
" term1=%10.6f sum1=%10.6f sum2=%10.6f "
4084 "sum3=%10.6f sum4=%10.6f sum5=%10.6f\n",
4085 term1, sum1, sum2, sum3, sum4, sum5);
4086 printf(
" sum_m_phi_minus_1=%10.6f d2_osmotic_coef_dT2=%10.6f\n",
4087 sum_m_phi_minus_1, d2_osmotic_coef_dT2);
4088 printf(
" Step 10: \n");
4090 double d2_lnwateract_dT2 = -(
m_weightSolvent/1000.0) * molalitysum * d2_osmotic_coef_dT2;
4103 double d2_wateract_dT2 = exp(d2_lnwateract_dT2);
4104 printf(
" d2_ln_a_water_dT2 = %10.6f d2_a_water_dT2=%10.6f\n\n",
4105 d2_lnwateract_dT2, d2_wateract_dT2);
4120 for (
size_t k = 1; k <
m_kk; k++) {
4142 throw CanteraError(
"HMWSoln::s_updatePitzer_dlnMolalityActCoeff_dP",
4143 "Wrong index solvent value!");
4159 double etheta[5][5], etheta_prime[5][5], sqrtIs;
4168 double molarcharge = 0.0;
4173 double molalitysum = 0.0;
4191 printf(
"\n Debugging information from "
4192 "s_Pitzer_dlnMolalityActCoeff_dP()\n");
4202 for (
size_t n = 1; n <
m_kk; n++) {
4206 molarcharge += fabs(
charge(n)) * molality[n];
4207 molalitysum += molality[n];
4217 printf(
" Step 1: \n");
4218 printf(
" ionic strenth = %14.7le \n total molar "
4219 "charge = %14.7le \n", Is, molarcharge);
4236 printf(
" Step 2: \n");
4238 for (
int z1 = 1; z1 <=4; z1++) {
4239 for (
int z2 =1; z2 <=4; z2++) {
4240 calc_thetas(z1, z2, ðeta[z1][z2], ðeta_prime[z1][z2]);
4242 printf(
" z1=%3d z2=%3d E-theta(I) = %f, E-thetaprime(I) = %f\n",
4243 z1, z2, etheta[z1][z2], etheta_prime[z1][z2]);
4249 printf(
" Step 3: \n");
4250 printf(
" Species Species g(x) "
4260 for (
size_t i = 1; i < (m_kk - 1); i++) {
4261 for (
size_t j = (i+1); j <
m_kk; j++) {
4265 size_t n = m_kk*i + j;
4274 double x1 = sqrtIs * alpha1MX[counterIJ];
4275 if (x1 > 1.0E-100) {
4276 gfunc[counterIJ] = 2.0*(1.0-(1.0 + x1) * exp(-x1)) / (x1 * x1);
4277 hfunc[counterIJ] = -2.0*
4278 (1.0-(1.0 + x1 + 0.5 * x1 * x1) * exp(-x1)) / (x1 * x1);
4280 gfunc[counterIJ] = 0.0;
4281 hfunc[counterIJ] = 0.0;
4284 if (beta2MX_P[counterIJ] != 0.0) {
4285 double x2 = sqrtIs * alpha2MX[counterIJ];
4286 if (x2 > 1.0E-100) {
4287 g2func[counterIJ] = 2.0*(1.0-(1.0 + x2) * exp(-x2)) / (x2 * x2);
4288 h2func[counterIJ] = -2.0 *
4289 (1.0-(1.0 + x2 + 0.5 * x2 * x2) * exp(-x2)) / (x2 * x2);
4291 g2func[counterIJ] = 0.0;
4292 h2func[counterIJ] = 0.0;
4296 gfunc[counterIJ] = 0.0;
4297 hfunc[counterIJ] = 0.0;
4302 printf(
" %-16s %-16s %9.5f %9.5f \n", sni.c_str(), snj.c_str(),
4303 gfunc[counterIJ], hfunc[counterIJ]);
4314 printf(
" Step 4: \n");
4315 printf(
" Species Species BMX "
4316 "BprimeMX BphiMX \n");
4319 for (
size_t i = 1; i < m_kk - 1; i++) {
4320 for (
size_t j = i+1; j <
m_kk; j++) {
4324 size_t n = m_kk*i + j;
4331 BMX_P[counterIJ] = beta0MX_P[counterIJ]
4332 + beta1MX_P[counterIJ] * gfunc[counterIJ]
4333 + beta2MX_P[counterIJ] * g2func[counterIJ];
4335 printf(
"%d %g: %g %g %g %g\n",
4336 (
int) counterIJ, BMX_P[counterIJ], beta0MX_P[counterIJ],
4337 beta1MX_P[counterIJ], beta2MX_P[counterIJ], gfunc[counterIJ]);
4339 if (Is > 1.0E-150) {
4340 BprimeMX_P[counterIJ] = (beta1MX_P[counterIJ] * hfunc[counterIJ]/Is +
4341 beta2MX_P[counterIJ] * h2func[counterIJ]/Is);
4343 BprimeMX_P[counterIJ] = 0.0;
4345 BphiMX_P[counterIJ] = BMX_P[counterIJ] + Is*BprimeMX_P[counterIJ];
4347 BMX_P[counterIJ] = 0.0;
4348 BprimeMX_P[counterIJ] = 0.0;
4349 BphiMX_P[counterIJ] = 0.0;
4354 printf(
" %-16s %-16s %11.7f %11.7f %11.7f \n",
4355 sni.c_str(), snj.c_str(),
4356 BMX_P[counterIJ], BprimeMX_P[counterIJ], BphiMX_P[counterIJ]);
4365 printf(
" Step 5: \n");
4366 printf(
" Species Species CMX \n");
4368 for (
size_t i = 1; i < m_kk-1; i++) {
4369 for (
size_t j = i+1; j <
m_kk; j++) {
4373 size_t n = m_kk*i + j;
4380 CMX_P[counterIJ] = CphiMX_P[counterIJ]/
4383 CMX_P[counterIJ] = 0.0;
4388 printf(
" %-16s %-16s %11.7f \n", sni.c_str(), snj.c_str(),
4399 printf(
" Step 6: \n");
4400 printf(
" Species Species Phi_ij "
4401 " Phiprime_ij Phi^phi_ij \n");
4403 for (
size_t i = 1; i < m_kk-1; i++) {
4404 for (
size_t j = i+1; j <
m_kk; j++) {
4408 size_t n = m_kk*i + j;
4415 Phi_P[counterIJ] = thetaij_P[counterIJ];
4416 Phiprime[counterIJ] = 0.0;
4417 Phiphi_P[counterIJ] = Phi_P[counterIJ] + Is * Phiprime[counterIJ];
4419 Phi_P[counterIJ] = 0.0;
4420 Phiprime[counterIJ] = 0.0;
4421 Phiphi_P[counterIJ] = 0.0;
4426 printf(
" %-16s %-16s %10.6f %10.6f %10.6f \n",
4427 sni.c_str(), snj.c_str(),
4428 Phi_P[counterIJ], Phiprime[counterIJ], Phiphi_P[counterIJ]);
4437 printf(
" Step 7: \n");
4440 double dAphidP = dA_DebyedP /3.0;
4441 double dFdP = -dAphidP * (sqrt(Is) / (1.0 + 1.2*sqrt(Is))
4442 + (2.0/1.2) * log(1.0+1.2*(sqrtIs)));
4444 printf(
" initial value of dFdP = %10.6f \n", dFdP);
4446 for (
size_t i = 1; i < m_kk-1; i++) {
4447 for (
size_t j = i+1; j <
m_kk; j++) {
4451 size_t n = m_kk*i + j;
4458 dFdP = dFdP + molality[i]*molality[j] * BprimeMX_P[counterIJ];
4465 dFdP = dFdP + molality[i]*molality[j] * Phiprime[counterIJ];
4468 printf(
" dFdP = %10.6f \n", dFdP);
4473 printf(
" Step 8: \n");
4476 for (
size_t i = 1; i <
m_kk; i++) {
4489 for (
size_t j = 1; j <
m_kk; j++) {
4493 size_t n = m_kk*i + j;
4498 sum1 = sum1 + molality[j]*
4499 (2.0*BMX_P[counterIJ] + molarcharge*CMX_P[counterIJ]);
4506 for (
size_t k = j+1; k <
m_kk; k++) {
4509 n = k + j * m_kk + i * m_kk *
m_kk;
4510 sum3 = sum3 + molality[j]*molality[k]*psi_ijk_P[n];
4520 sum2 = sum2 + molality[j]*(2.0*Phi_P[counterIJ]);
4522 for (
size_t k = 1; k <
m_kk; k++) {
4526 n = k + j * m_kk + i * m_kk *
m_kk;
4527 sum2 = sum2 + molality[j]*molality[k]*psi_ijk_P[n];
4533 sum4 = sum4 + (fabs(
charge(i))*
4534 molality[j]*molality[k]*CMX_P[counterIJ2]);
4547 for (
size_t k = 1; k <
m_kk; k++) {
4551 n = izeta * m_kk * m_kk + jzeta * m_kk + k;
4552 double zeta_P = psi_ijk_P[n];
4553 if (zeta_P != 0.0) {
4554 sum5 = sum5 + molality[j]*molality[k]*zeta_P;
4566 zsqdFdP + sum1 + sum2 + sum3 + sum4 + sum5;
4570 printf(
" %-16s lngamma[i]=%10.6f \n",
4572 printf(
" %12g %12g %12g %12g %12g %12g\n",
4573 zsqdFdP, sum1, sum2, sum3, sum4, sum5);
4589 for (
size_t j = 1; j <
m_kk; j++) {
4593 size_t n = m_kk*i + j;
4600 sum1 = sum1 + molality[j]*
4601 (2.0*BMX_P[counterIJ] + molarcharge*CMX_P[counterIJ]);
4603 for (
size_t k = j+1; k <
m_kk; k++) {
4606 n = k + j * m_kk + i * m_kk *
m_kk;
4607 sum3 = sum3 + molality[j]*molality[k]*psi_ijk_P[n];
4619 sum2 = sum2 + molality[j]*(2.0*Phi_P[counterIJ]);
4621 for (
size_t k = 1; k <
m_kk; k++) {
4624 n = k + j * m_kk + i * m_kk *
m_kk;
4625 sum2 = sum2 + molality[j]*molality[k]*psi_ijk_P[n];
4633 molality[j]*molality[k]*CMX_P[counterIJ2]);
4646 for (
size_t k = 1; k <
m_kk; k++) {
4651 n = izeta * m_kk * m_kk + jzeta * m_kk + kzeta;
4652 double zeta_P = psi_ijk_P[n];
4653 if (zeta_P != 0.0) {
4654 sum5 = sum5 + molality[j]*molality[k]*zeta_P;
4661 zsqdFdP + sum1 + sum2 + sum3 + sum4 + sum5;
4664 printf(
" %-16s lndactcoeffmolaldP[i]=%10.6f \n",
4666 printf(
" %12g %12g %12g %12g %12g %12g\n",
4667 zsqdFdP, sum1, sum2, sum3, sum4, sum5);
4677 for (
size_t j = 1; j <
m_kk; j++) {
4683 for (
size_t k = 1; k <
m_kk; k++) {
4685 size_t n = k + j * m_kk + i * m_kk *
m_kk;
4686 sum3 = sum3 + molality[j]*molality[k]*psi_ijk_P[n];
4691 double sum2 = 3.0 * molality[i] * molality[i] *
m_Mu_nnn_P[i];
4695 printf(
" %-16s dlnActCoeffMolaldP[i]=%10.6f \n",
4702 printf(
" Step 9: \n");
4723 double term1 = -dAphidP * Is * sqrt(Is) / (1.0 + 1.2 * sqrt(Is));
4725 for (
size_t j = 1; j <
m_kk; j++) {
4730 for (
size_t k = 1; k <
m_kk; k++) {
4735 size_t n = m_kk*j + k;
4738 sum1 = sum1 + molality[j]*molality[k]*
4739 (BphiMX_P[counterIJ] + molarcharge*CMX_P[counterIJ]);
4743 for (
size_t k = j+1; k <
m_kk; k++) {
4744 if (j == (m_kk-1)) {
4746 throw CanteraError(
"HMWSoln::s_updatePitzer_dlnMolalityActCoeff_dP",
4747 "logic error 1 in Step 9 of hmw_act");
4754 size_t n = m_kk*j + k;
4756 sum2 = sum2 + molality[j]*molality[k]*Phiphi_P[counterIJ];
4757 for (
size_t m = 1; m <
m_kk; m++) {
4760 n = m + k * m_kk + j * m_kk *
m_kk;
4762 molality[j]*molality[k]*molality[m]*psi_ijk_P[n];
4774 for (
size_t k = j+1; k <
m_kk; k++) {
4777 throw CanteraError(
"HMWSoln::s_updatePitzer_dlnMolalityActCoeff_dP",
4778 "logic error 2 in Step 9 of hmw_act");
4785 size_t n = m_kk*j + k;
4788 sum3 = sum3 + molality[j]*molality[k]*Phiphi_P[counterIJ];
4789 for (
size_t m = 1; m <
m_kk; m++) {
4791 n = m + k * m_kk + j * m_kk *
m_kk;
4793 molality[j]*molality[k]*molality[m]*psi_ijk_P[n];
4804 for (
size_t k = 1; k <
m_kk; k++) {
4814 }
else if (k == j) {
4815 sum6 = sum6 + 0.5 * molality[j]*molality[k]*
m_Lambda_nj_P(j,k);
4820 for (
size_t m = 1; m <
m_kk; m++) {
4823 size_t n = k + jzeta * m_kk + izeta * m_kk *
m_kk;
4824 double zeta_P = psi_ijk_P[n];
4825 if (zeta_P != 0.0) {
4826 sum7 += molality[izeta]*molality[jzeta]*molality[k]*zeta_P;
4833 sum7 += molality[j] * molality[j] * molality[j] *
m_Mu_nnn_P[j];
4836 double sum_m_phi_minus_1 = 2.0 *
4837 (term1 + sum1 + sum2 + sum3 + sum4 + sum5 + sum6 + sum7);
4843 double d_osmotic_coef_dP;
4844 if (molalitysum > 1.0E-150) {
4845 d_osmotic_coef_dP = 0.0 + (sum_m_phi_minus_1 / molalitysum);
4847 d_osmotic_coef_dP = 0.0;
4850 printf(
" term1=%10.6f sum1=%10.6f sum2=%10.6f "
4851 "sum3=%10.6f sum4=%10.6f sum5=%10.6f\n",
4852 term1, sum1, sum2, sum3, sum4, sum5);
4853 printf(
" sum_m_phi_minus_1=%10.6f d_osmotic_coef_dP =%10.6f\n",
4854 sum_m_phi_minus_1, d_osmotic_coef_dP);
4855 printf(
" Step 10: \n");
4857 double d_lnwateract_dP = -(
m_weightSolvent/1000.0) * molalitysum * d_osmotic_coef_dP;
4870 double d_wateract_dP = exp(d_lnwateract_dP);
4871 printf(
" d_ln_a_water_dP = %10.6f d_a_water_dP=%10.6f\n\n",
4872 d_lnwateract_dP, d_wateract_dP);
4878 if( m_last_is == is ) {
4888 double c1 = 4.581, c2 = 0.7237, c3 = 0.0120, c4 = 0.528;
4889 double aphi = 0.392;
4891 printf(
" Is = %g\n", is);
4893 if (is < 1.0E-150) {
4894 for (
int i = 0; i < 17; i++) {
4905 for (
int i=1; i<=4; i++) {
4906 for (
int j=i; j<=4; j++) {
4911 double zprod = (double)ij;
4915 double x = 6.0* zprod * aphi * sqrt(is);
4917 double jfunc = x / (4.0 + c1*pow(x,-c2)*exp(-c3*pow(x,c4)));
4919 double t = c3 * c4 * pow(x,c4);
4920 double dj = c1* pow(x,(-c2-1.0)) * (c2+t) * exp(-c3*pow(x,c4));
4921 double jprime = (jfunc/x)*(1.0 + jfunc*dj);
4923 elambda[ij] = zprod*jfunc / (4.0*is);
4924 elambda1[ij] = (3.0*zprod*zprod*aphi*jprime/(4.0*sqrt(is))
4927 printf(
" ij = %d, elambda = %g, elambda1 = %g\n",
4935 double* etheta,
double* etheta_prime)
const
4945 "we shouldn't be here");
4947 "called with one species being neutral");
4955 *etheta_prime = 0.0;
4961 double f1 = (double)i / (2.0 * j);
4962 double f2 = (double)j / (2.0 * i);
4980 for (
size_t k = 1; k <
m_kk; k++) {
4987 for (
size_t k = 1; k <
m_kk; k++) {
4994 for (
size_t k = 1; k <
m_kk; k++) {
5004 double xminus2 = xminus * xminus;
5005 double xminus3 = xminus2 * xminus;
5009 double h2 = 3.5 * xminus2 / IMS_X_o_cutoff_ - 2.0 * xminus3 / x_o_cut2;
5010 double h2_prime = 7.0 * xminus / IMS_X_o_cutoff_ - 6.0 * xminus2 / x_o_cut2;
5012 double h1 = (1.0 - 3.0 * xminus2 / x_o_cut2 + 2.0 * xminus3/ x_o_cut3);
5013 double h1_prime = (- 6.0 * xminus / x_o_cut2 + 6.0 * xminus2/ x_o_cut3);
5019 double h1_f = h1 * alpha;
5020 double h1_f_prime = h1_prime * alpha;
5022 double f = h2 + h1_f;
5023 double f_prime = h2_prime + h1_f_prime;
5025 double g = h2 + h1_g;
5026 double g_prime = h2_prime + h1_g_prime;
5028 double tmp = (xmolSolvent/ g * g_prime + (1.0-xmolSolvent) / f * f_prime);
5029 double lngammak = -1.0 - log(f) + tmp * xmolSolvent;
5030 double lngammao =-log(g) - tmp * (1.0-xmolSolvent);
5032 tmp = log(xmolSolvent) + lngammak;
5033 for (
size_t k = 1; k <
m_kk; k++) {
5042 for (
size_t k = 1; k <
m_kk; k++) {
5050 double eterm = std::exp(-xoverc);
5052 double fptmp = IMS_bfCut_ - IMS_afCut_ /
IMS_cCut_ - IMS_bfCut_*xoverc
5053 + 2.0*IMS_dfCut_*xmolSolvent - IMS_dfCut_*xmolSolvent*xoverc;
5054 double f_prime = 1.0 + eterm*fptmp;
5055 double f = xmolSolvent + IMS_efCut_
5056 + eterm * (IMS_afCut_ + xmolSolvent * (IMS_bfCut_ + IMS_dfCut_*xmolSolvent));
5058 double gptmp = IMS_bgCut_ - IMS_agCut_ /
IMS_cCut_ - IMS_bgCut_*xoverc
5059 + 2.0*IMS_dgCut_*xmolSolvent - IMS_dgCut_*xmolSolvent*xoverc;
5060 double g_prime = 1.0 + eterm*gptmp;
5061 double g = xmolSolvent + IMS_egCut_
5062 + eterm * (IMS_agCut_ + xmolSolvent * (IMS_bgCut_ + IMS_dgCut_*xmolSolvent));
5064 double tmp = (xmolSolvent / g * g_prime + (1.0 - xmolSolvent) / f * f_prime);
5065 double lngammak = -1.0 - log(f) + tmp * xmolSolvent;
5066 double lngammao =-log(g) - tmp * (1.0-xmolSolvent);
5068 tmp = log(xx) + lngammak;
5069 for (
size_t k = 1; k <
m_kk; k++) {
5090 printf(
"Index Name MoleF MolalityCropped Charge\n");
5091 for (
size_t k = 0; k <
m_kk; k++) {
5093 printf(
"%2s %-16s %14.7le %14.7le %5.1f \n",
5094 int2str(k).c_str(), sni.c_str(), moleF[k], molality[k],
charge(k));
5097 printf(
"\n Species Species beta0MX "
5098 "beta1MX beta2MX CphiMX alphaMX thetaij \n");
5099 for (
size_t i = 1; i < m_kk - 1; i++) {
5101 for (
size_t j = i+1; j <
m_kk; j++) {
5103 size_t n = i * m_kk + j;
5105 printf(
" %-16s %-16s %9.5f %9.5f %9.5f %9.5f %9.5f %9.5f \n",
5106 sni.c_str(), snj.c_str(),
5115 printf(
"\n Species Species Species "
5117 for (
size_t i = 1; i <
m_kk; i++) {
5119 for (
size_t j = 1; j <
m_kk; j++) {
5121 for (
size_t k = 1; k <
m_kk; k++) {
5123 size_t n = k + j * m_kk + i * m_kk *
m_kk;
5125 printf(
" %-16s %-16s %-16s %9.5f \n",
5126 sni.c_str(), snj.c_str(),
5142 doublereal afac = -1.0 *(lnGammaClMs2 - lnGammaCLMs1);
5143 for (
size_t k = 0; k <
m_kk; k++) {
5144 acMolality[k] *= exp(
charge(k) * afac);
5157 doublereal afac = -1.0 *(lnGammaClMs2 - lnGammaCLMs1);
5158 for (
size_t k = 0; k <
m_kk; k++) {
5172 doublereal afac = -1.0 *(dlnGammaClM_dT_s2 - dlnGammaCLM_dT_s1);
5173 for (
size_t k = 0; k <
m_kk; k++) {
5187 doublereal afac = -1.0 *(d2lnGammaClM_dT2_s2 - d2lnGammaCLM_dT2_s1);
5188 for (
size_t k = 0; k <
m_kk; k++) {
5202 doublereal afac = -1.0 *(dlnGammaClM_dP_s2 - dlnGammaCLM_dP_s1);
5203 for (
size_t k = 0; k <
m_kk; k++) {
5212 doublereal lnGammaClMs2 = - A * sqrtIs /(1.0 + 1.5 * sqrtIs);
5213 return lnGammaClMs2;
5220 return - dAdT * sqrtIs /(1.0 + 1.5 * sqrtIs);
5227 return - d2AdT2 * sqrtIs /(1.0 + 1.5 * sqrtIs);
5234 return - dAdP * sqrtIs /(1.0 + 1.5 * sqrtIs);
vector_fp m_Theta_ij_P
Derivative of Theta_ij[i][j] wrt P.
vector_fp m_BMX_IJ_L
Derivative of BMX_IJ wrt T.
vector_fp m_PhiPhi_IJ_P
Derivative of m_PhiPhi_IJ wrt P.
void s_updateIMS_lnMolalityActCoeff() const
This function will be called to update the internally stored natural logarithm of the molality activi...
vector_fp m_CphiMX_ij_LL
Derivative of Cphi_ij[i][j] wrt TT.
void s_update_dlnMolalityActCoeff_dP() const
This function calculates the pressure derivative of the natural logarithm of the molality activity co...
virtual doublereal pressure() const
Pressure.
virtual doublereal density() const
Density (kg/m^3).
vector_fp m_Theta_ij_L
Derivative of Theta_ij[i][j] wrt T.
std::string int2str(const int n, const std::string &fmt)
Convert an int to a string using a format converter.
vector_fp m_speciesCharge_Stoich
Stoichiometric species charge -> This is for calculations of the ionic strength which ignore ion-ion ...
WaterProps * m_waterProps
Pointer to the water property calculator.
vector_fp m_CMX_IJ_P
Derivative of m_CMX_IJ wrt P.
vector_fp m_gfunc_IJ
Various temporary arrays used in the calculation of the Pitzer activity coefficients.
int getId()
Get a unique id for a cached value.
vector_fp m_Beta2MX_ij_L
Derivative of Beta2_ij[i][j] wrt T.
XML_Node * findXMLPhase(XML_Node *root, const std::string &idtarget)
Search an XML_Node tree for a named phase XML_Node.
vector_fp m_d2lnActCoeffMolaldT2_Unscaled
Derivative of the Logarithm of the activity coefficients on the molality scale wrt TT...
doublereal s_NBS_CLM_lnMolalityActCoeff() const
Calculate the Chlorine activity coefficient on the NBS scale.
doublereal MC_X_o_cutoff_
value of the solvent mole fraction that centers the cutoff polynomials for the cutoff =1 process; ...
vector_fp IMS_lnActCoeffMolal_
Logarithm of the molal activity coefficients.
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.
vector_fp m_Beta1MX_ij_LL
Derivative of Beta1_ij[i][j] wrt TT.
doublereal m_Mnaught
This is the multiplication factor that goes inside log expressions involving the molalities of specie...
vector_fp m_Mu_nnn_L
Mu coefficient temperature derivative for the self-ternary neutral coefficient.
virtual doublereal cv_mole() const
Molar heat capacity at constant volume. Units: J/kmol/K.
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.
double ADebye_J(double temperature=-1.0, double pressure=-1.0) const
Return Pitzer's definition of A_J.
virtual void getStandardVolumes(doublereal *vol) const
Get the molar volumes of each species in their standard states at the current T and P of the solution...
vector_fp m_Beta2MX_ij_P
Derivative of Beta2_ij[i][j] wrt P.
virtual void getPartialMolarCp(doublereal *cpbar) const
Return an array of partial molar heat capacities for the species in the mixture.
vector_fp m_Beta2MX_ij
Array of 2D data used in the Pitzer/HMW formulation.
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"
vector_fp m_PhiPhi_IJ
Intermediate variable called PhiPhi in Pitzer's paper.
vector_fp m_Phi_IJ_L
Derivative of m_Phi_IJ wrt T.
Header file for a common definitions used in electrolytes thermodynamics.
virtual void getCp_R(doublereal *cpr) const
Get the nondimensional Heat Capacities at constant pressure for the standard state of the species at ...
int IMS_typeCutoff_
IMS Cutoff type.
Headers for the factory class that can create known ThermoPhase objects (see Thermodynamic Properties...
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
void setMolarDensity(const doublereal conc)
Set the internally stored molar density (kmol/m^3) for the phase.
size_t m_indexCLM
Index of the phScale species.
vector_fp m_BMX_IJ_P
Derivative of BMX_IJ wrt P.
vector_fp m_Beta0MX_ij_L
Derivative of Beta0_ij[i][j] wrt T.
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.
void s_updateScaling_pHScaling() const
Apply the current phScale to a set of activity Coefficients.
virtual void updateStandardStateThermo() const
Updates the standard state thermodynamic functions at the current T and P of the solution.
Array2D m_Lambda_nj_L
Derivative of Lambda_nj[i][j] wrt T. see m_Lambda_ij.
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.
double AionicRadius(int k=0) const
Reports the ionic radius of the kth species.
vector_fp m_CphiMX_ij_P
Derivative of Cphi_ij[i][j] wrt P.
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.
doublereal s_NBS_CLM_d2lnMolalityActCoeff_dT2() const
Calculate the second temperature derivative of the Chlorine activity coefficient on the NBS scale...
virtual doublereal relative_enthalpy() const
Excess molar enthalpy of the solution from the mixing process.
vector_fp m_Psi_ijk_L
Derivative of Psi_ijk[n] wrt T.
int stateMFNumber() const
Return the State Mole Fraction Number.
void s_update_d2lnMolalityActCoeff_dT2() const
This function calculates the temperature second derivative of the natural logarithm of the molality a...
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.
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.
virtual doublereal relative_molal_enthalpy() const
Excess molar enthalpy of the solution from the mixing process on a molality basis.
vector_fp m_Beta1MX_ij_P
Derivative of Beta1_ij[i][j] wrt P.
vector_fp m_BprimeMX_IJ_LL
Derivative of BprimeMX wrt TT.
vector_fp m_PhiPhi_IJ_LL
Derivative of m_PhiPhi_IJ wrt TT.
ThermoPhase * duplMyselfAsThermoPhase() const
Duplicator from the ThermoPhase parent class.
doublereal IMS_cCut_
Parameter in the polyExp cutoff treatment having to do with rate of exp decay.
virtual void setTemperature(const doublereal temp)
Set the temperature (K)
void getMoleFractions(doublereal *const x) const
Get the species mole fraction vector.
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...
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.
void s_updateScaling_pHScaling_dP() const
Apply the current phScale to a set of derivatives of the activity Coefficients wrt pressure...
#define AssertThrowMsg(expr, procedure, message)
Assertion must be true or an error is thrown.
vector_fp m_tmpV
vector of size m_kk, used as a temporary holding area.
virtual doublereal standardConcentration(size_t k=0) const
Return the standard concentration for the kth species.
virtual doublereal thermalExpansionCoeff() const
Return the volumetric thermal expansion coefficient. Units: 1/K.
Base class for a phase with thermodynamic properties.
void getUnscaledMolalityActivityCoefficients(doublereal *acMolality) const
Get the array of unscaled non-dimensional molality based activity coefficients at the current solutio...
HMWSoln()
Default Constructor.
vector_fp m_lnActCoeffMolal_Scaled
Logarithm of the activity coefficients on the molality scale.
virtual void getActivities(doublereal *ac) const
Get the array of non-dimensional activities at the current solution temperature, pressure, and solution concentration.
doublereal mean_X(const doublereal *const Q) const
Evaluate the mole-fraction-weighted mean of an array Q.
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.
PDSS * m_waterSS
Water standard state calculator.
vector_fp m_Alpha1MX_ij
Array of 2D data used in the Pitzer/HMW formulation.
bool importPhase(XML_Node &phase, ThermoPhase *th, SpeciesThermoFactory *spfactory)
Import a phase information into an empty ThermoPhase object.
virtual void setPressure(doublereal p)
Set the internally stored pressure (Pa) at constant temperature and composition.
vector_fp m_Phiprime_IJ
Intermediate variable called Phiprime in Pitzer's paper.
virtual void getPartialMolarEntropies(doublereal *sbar) const
Returns an array of partial molar entropies of the species in the solution.
vector_fp m_h2func_IJ
hfunc2, was called gprime in Pitzer's paper.
vector_fp m_Psi_ijk_P
Derivative of Psi_ijk[n] wrt P.
void counterIJ_setup() const
Set up a counter variable for keeping track of symmetric binary interactions amongst the solute speci...
vector_fp m_CMX_IJ_L
Derivative of m_CMX_IJ wrt T.
virtual void getPartialMolarVolumes(doublereal *vbar) const
Return an array of partial molar volumes for the species in the mixture.
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.
void s_updateScaling_pHScaling_dT() const
Apply the current phScale to a set of derivatives of the activity Coefficients wrt temperature...
Headers for the HMWSoln ThermoPhase object, which models concentrated electrolyte solutions (see Ther...
void s_updatePitzer_dlnMolalityActCoeff_dT() const
Calculates the temperature derivative of the natural logarithm of the molality activity coefficients...
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.
doublereal molarVolume() const
Molar volume (m^3/kmol).
The WaterProps class is used to house several approximation routines for properties of water...
#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.
CachedScalar getScalar(int id)
Get a reference to a CachedValue object representing a scalar (doublereal) with the given id...
vector_fp m_CMX_IJ_LL
Derivative of m_CMX_IJ wrt TT.
virtual void getUnitsStandardConc(double *uA, int k=0, int sizeUA=6) const
Returns the units of the standard and generalized concentrations.
Array2D m_Beta2MX_ij_coeff
Array of coefficients for Beta2, a variable in Pitzer's papers.
MolalityVPSSTP & operator=(const MolalityVPSSTP &b)
Assignment operator.
Array2D m_Lambda_nj_LL
Derivative of Lambda_nj[i][j] wrt TT.
void s_updatePitzer_lnMolalityActCoeff() const
Calculate the Pitzer portion of the activity coefficients.
double ADebye_V(double temperature=-1.0, double pressure=-1.0) const
Return Pitzer's definition of A_V.
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.
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.
virtual doublereal entropy_mole() const
Molar entropy. Units: J/kmol/K.
void s_update_dlnMolalityActCoeff_dT() const
This function calculates the temperature derivative of the natural logarithm of the molality activity...
void s_updatePitzer_dlnMolalityActCoeff_dP() const
Calculates the Pressure derivative of the natural logarithm of the molality activity coefficients...
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.
void s_updateScaling_pHScaling_dT2() const
Apply the current phScale to a set of 2nd derivatives of the activity Coefficients wrt temperature...
Base class for exceptions thrown by Cantera classes.
vector_fp m_CMX_IJ
Intermediate variable called CMX in Pitzer's paper.
virtual doublereal enthalpy_mole() const
Molar enthalpy. Units: J/kmol.
double m_TempPitzerRef
Reference Temperature for the Pitzer formulations.
vector_fp m_CphiMX_ij_L
Derivative of Cphi_ij[i][j] wrt T.
void calc_lambdas(double is) const
Calculate the lambda interactions.
const int PHSCALE_PITZER
Scale to be used for the output of single-ion activity coefficients is that used by Pitzer...
void calc_thetas(int z1, int z2, double *etheta, double *etheta_prime) const
Calculate etheta and etheta_prime.
vector_fp m_BphiMX_IJ_L
Derivative of BphiMX_IJ wrt T.
vector_fp m_g2func_IJ
This is the value of g2(x2) in Pitzer's papers.
int m_pHScalingType
Scaling to be used for output of single-ion species activity coefficients.
virtual doublereal density() const
Return the standard state density at standard state.
double m_densWaterSS
density of standard-state water
Array2D m_Lambda_nj
Lambda coefficient for the ij interaction.
virtual ~HMWSoln()
Destructor.
vector_fp m_Phi_IJ_LL
Derivative of m_Phi_IJ wrt TT.
int m_formPitzer
This is the form of the Pitzer parameterization used in this model.
doublereal IMS_gamma_k_min_
gamma_k minimum for the cutoff process at the zero solvent point
vector_fp m_Alpha2MX_ij
Array of 2D data used in the Pitzer/HMW formulation.
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.
vector_int m_electrolyteSpeciesType
Vector containing the electrolyte species type.
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.
const int cHMWSoln0
eosTypes returned for this ThermoPhase Object
virtual doublereal isothermalCompressibility() const
Returns the isothermal compressibility. Units: 1/Pa.
doublereal IMS_gamma_o_min_
gamma_o value for the cutoff process at the zero solvent point
doublereal moleFraction(size_t k) const
Return the mole fraction of a single species.
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...
#define AssertTrace(expr)
Assertion must be true or an error is thrown.
vector_fp m_BMX_IJ_LL
Derivative of BMX_IJ wrt TT.
virtual void getEntropy_R(doublereal *sr) const
Get the array of nondimensional Enthalpy functions for the standard state species at the current T an...
doublereal temperature() const
Temperature (K).
size_t nDim() const
Returns the number of spatial dimensions (1, 2, or 3)
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 exp...
std::vector< int > CROP_speciesCropped_
This is a boolean-type vector indicating whether a species's activity coefficient is in the cropped r...
void initLengths()
Initialize all of the species-dependent lengths in the object.
virtual void getActivityConcentrations(doublereal *c) const
This method returns an array of generalized activity concentrations.
const doublereal SmallNumber
smallest number to compare to zero.
doublereal s_NBS_CLM_dlnMolalityActCoeff_dT() const
Calculate the temperature derivative of the Chlorine activity coefficient on the NBS scale...
double ADebye_L(double temperature=-1.0, double pressure=-1.0) const
Return Pitzer's definition of A_L.
virtual doublereal gibbs_mole() const
Molar Gibbs function. Units: J/kmol.
bool validate(double state1New)
Check whether the currently cached value is valid based on a single state variable.
virtual void setTemperature(const doublereal temp)
Set the internally stored temperature of the phase (K).
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 void applyphScale(doublereal *acMolality) const
Apply the current phScale to a set of activity Coefficients or activities.
virtual void getEnthalpy_RT(doublereal *hrt) const
Get the nondimensional Enthalpy functions for the species at their standard states at the current T a...
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.
doublereal meanMolecularWeight() const
The mean molecular weight. Units: (kg/kmol)
const doublereal GasConstant
Universal Gas Constant. [J/kmol/K].
virtual int eosType() const
Equation of state type flag.
virtual void getChemPotentials(doublereal *mu) const
Get the species chemical potentials. Units: J/kmol.
Contains declarations for string manipulation functions within Cantera.
#define DATA_PTR(vec)
Creates a pointer to the start of the raw data for a vector.
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; ...
void calcMolalitiesCropped() const
Calculate the cropped molalities.
vector_fp m_Psi_ijk
Array of 3D data used in the Pitzer/HMW formulation.
vector_fp m_pp
Temporary array used in equilibrium calculations.
Class HMWSoln represents a dilute or concentrated liquid electrolyte phase which obeys the Pitzer for...
doublereal ADebye(doublereal T, doublereal P, int ifunc)
ADebye calculates the value of A_Debye as a function of temperature and pressure according to relatio...
vector_fp m_BMX_IJ
Intermediate variable called BMX in Pitzer's paper This is the basic cation - anion interaction...
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...
virtual void setState_TP(doublereal t, doublereal p)
Set the temperature (K) and pressure (Pa)
size_t m_kk
Number of species in the phase.
double m_IionicMolalityStoich
Stoichiometric ionic strength on the molality scale.
virtual void initThermoFile(const std::string &inputFile, const std::string &id)
vector_fp m_BprimeMX_IJ
Intermediate variable called BprimeMX in Pitzer's paper.
doublereal m_Pcurrent
Current value of the pressure - state variable.
void s_updatePitzer_CoeffWRTemp(int doDerivs=2) const
Calculates the Pitzer coefficients' dependence on the temperature.
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...
virtual void getStandardChemPotentials(doublereal *mu) const
Get the array of chemical potentials at unit activity.
vector_fp m_CphiMX_ij
Array of 2D data used in the Pitzer/HMW formulation.
virtual doublereal density() const
Returns the current value of the density.
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 printCoeffs() const
Print out all of the input Pitzer coefficients.
HMWSoln & operator=(const HMWSoln &right)
Assignment operator.
vector_fp m_Beta1MX_ij_L
Derivative of Beta1_ij[i][j] wrt T.
vector_fp m_Theta_ij_LL
Derivative of Theta_ij[i][j] wrt TT.
void s_updatePitzer_d2lnMolalityActCoeff_dT2() const
This function calculates the temperature second derivative of the natural logarithm of the molality a...
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 cp_mole() const
Molar heat capacity at constant pressure. Units: J/kmol/K.
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.
doublereal s_NBS_CLM_dlnMolalityActCoeff_dP() const
Calculate the pressure derivative of the Chlorine activity coefficient.
vector_fp m_Mu_nnn_LL
Mu coefficient 2nd temperature derivative for the self-ternary neutral coefficient.
void calcMolalities() const
Calculates the molality of all species and stores the result internally.
std::string speciesName(size_t k) const
Name of the species with index k.
vector_fp m_Aionic
a_k = Size of the ionic species in the DH formulation units = meters
vector_fp m_BphiMX_IJ_P
Derivative of BphiMX_IJ wrt P.
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.
virtual void getPartialMolarEnthalpies(doublereal *hbar) const
Returns an array of partial molar enthalpies for the species in the mixture.
virtual void setDensity(const doublereal density_)
Set the internally stored density (kg/m^3) of the phase Note the density of a phase is an independent...
vector_fp m_Beta0MX_ij_P
Derivative of Beta0_ij[i][j] wrt P.
vector_fp m_BphiMX_IJ_LL
Derivative of BphiMX_IJ wrt TT.
doublereal charge(size_t k) const
Dimensionless electrical charge of a single molecule of species k The charge is normalized by the the...