41 MolalityVPSSTP::MolalityVPSSTP() :
46 m_weightSolvent(18.01528),
47 m_xmolSolventMIN(0.01),
48 m_Mnaught(18.01528E-3)
66 m_indexSolvent(b.m_indexSolvent),
67 m_pHScalingType(b.m_pHScalingType),
68 m_indexCLM(b.m_indexCLM),
69 m_xmolSolventMIN(b.m_xmolSolventMIN),
70 m_Mnaught(b.m_Mnaught),
71 m_molalities(b.m_molalities)
148 "Unknown scale type: " +
int2str(pHscaleType));
178 "Molality-based methods limit solvent id to being 0");
198 if (xmolSolventMIN <= 0.0) {
199 throw CanteraError(
"MolalityVPSSTP::setSolute ",
"trouble");
200 }
else if (xmolSolventMIN > 0.9) {
201 throw CanteraError(
"MolalityVPSSTP::setSolute ",
"trouble");
236 double denomInv = 1.0/ (
m_Mnaught * xmolSolvent);
237 for (
size_t k = 0; k <
m_kk; k++) {
260 for (
size_t k = 0; k <
m_kk; k++) {
284 for (
size_t k = 1; k <
m_kk; k++) {
288 double tmp = 1.0 / Lsum;
291 for (
size_t k = 1; k <
m_kk; k++) {
297 for (
size_t k = 0; k <
m_kk; k++) {
329 compositionMap::iterator p;
330 for (
size_t k = 0; k < kk; k++) {
332 if (p != mMap.end()) {
342 size_t largePos =
npos;
344 size_t largeNeg =
npos;
347 for (
size_t k = 0; k < kk; k++) {
351 if (ch * mf[k] > cPos) {
357 if (fabs(ch) * mf[k] > cNeg) {
359 cNeg = fabs(ch) * mf[k];
368 mf[largePos] -= sum /
charge(largePos);
370 throw CanteraError(
"MolalityVPSSTP:setMolalitiesbyName",
371 "unbalanced charges");
375 mf[largeNeg] -= (-sum) / fabs(
charge(largeNeg));
377 throw CanteraError(
"MolalityVPSSTP:setMolalitiesbyName",
378 "unbalanced charges");
384 for (
size_t k = 0; k < kk; k++) {
388 for (
size_t k = 0; k < kk; k++) {
408 for (
size_t k = 0; k <
nSpecies(); k++) {
451 err(
"getActivityConcentrations");
456 err(
"standardConcentration");
462 err(
"logStandardConc");
468 err(
"getActivities");
492 for (
size_t k = 1; k <
m_kk; k++) {
493 ac[k] /= xmolSolvent;
540 for (
size_t k = 1; k <
m_kk; k++) {
545 if (sum > 1.0E-200) {
556 for (
size_t k = 0; k <
m_kk; k++) {
568 throw CanteraError(
"MolalityVPSSTP",
"Base class method "
597 for (
int i = 0; i < sizeUA; i++) {
602 uA[1] = -int(
nDim());
622 err(
"setToEquilState");
646 const doublereal*
const molalities)
713 err(
"getUnscaledMolalityActivityCoefficients");
743 size_t indexCLM =
npos;
748 for (
size_t e = 0; e < ne; e++) {
750 if (sn ==
"Cl" || sn ==
"CL") {
759 for (
size_t e = 0; e < ne; e++) {
761 if (sn ==
"E" || sn ==
"e") {
770 for (
size_t k = 1; k <
m_kk; k++) {
771 doublereal nCl =
nAtoms(k, eCl);
775 doublereal nE =
nAtoms(k, eE);
779 for (
size_t e = 0; e < ne; e++) {
780 if (e != eE && e != eCl) {
781 doublereal nA =
nAtoms(k, e);
788 if (sn !=
"Cl-" && sn !=
"CL-") {
844 sprintf(p,
" \n %s:\n",
name().c_str());
847 sprintf(p,
" \n temperature %12.6g K\n",
temperature());
849 sprintf(p,
" pressure %12.6g Pa\n",
pressure());
851 sprintf(p,
" density %12.6g kg/m^3\n",
density());
857 sprintf(p,
" potential %12.6g V\n", phi);
876 double pH = -log(actMolal[iHp]) / log(10.0);
877 sprintf(p,
" pH %12.4g \n", pH);
884 sprintf(p,
" 1 kg 1 kmol\n");
886 sprintf(p,
" ----------- ------------\n");
888 sprintf(p,
" enthalpy %12.6g %12.4g J\n",
891 sprintf(p,
" internal energy %12.6g %12.4g J\n",
894 sprintf(p,
" entropy %12.6g %12.4g J/K\n",
897 sprintf(p,
" Gibbs function %12.6g %12.4g J\n",
900 sprintf(p,
" heat capacity c_p %12.6g %12.4g J/K\n",
904 sprintf(p,
" heat capacity c_v %12.6g %12.4g J/K\n",
909 sprintf(p,
" heat capacity c_v <not implemented> \n");
918 " Molalities Chem.Pot. ChemPotSS ActCoeffMolal\n");
921 " (J/kmol) (J/kmol) \n");
923 sprintf(p,
" ------------- "
924 " ------------ ------------ ------------ ------------\n");
926 for (
size_t k = 0; k < kk; k++) {
928 sprintf(p,
"%18s %12.6g %12.6g %12.6g %12.6g %12.6g\n",
929 speciesName(k).c_str(), x[k], molal[k], mu[k], muss[k], acMolal[k]);
931 sprintf(p,
"%18s %12.6g %12.6g N/A %12.6g %12.6g \n",
932 speciesName(k).c_str(), x[k], molal[k], muss[k], acMolal[k]);
940 sprintf(p,
" -------------"
943 for (
size_t k = 0; k < kk; k++) {
944 sprintf(p,
"%18s %12.6g %12.6g\n",
962 csvFile.precision(3);
968 csvFile <<
"\n"+
name()+
"\n\n";
970 csvFile << setw(tabL) <<
"temperature (K) =" << setw(tabS) <<
temperature() << endl;
971 csvFile << setw(tabL) <<
"pressure (Pa) =" << setw(tabS) <<
pressure() << endl;
972 csvFile << setw(tabL) <<
"density (kg/m^3) =" << setw(tabS) <<
density() << endl;
973 csvFile << setw(tabL) <<
"mean mol. weight (amu) =" << setw(tabS) <<
meanMolecularWeight() << endl;
974 csvFile << setw(tabL) <<
"potential (V) =" << setw(tabS) <<
electricPotential() << endl;
977 csvFile << setw(tabL) <<
"enthalpy (J/kg) = " << setw(tabS) <<
enthalpy_mass() << setw(tabL) <<
"enthalpy (J/kmol) = " << setw(tabS) <<
enthalpy_mole() << endl;
978 csvFile << setw(tabL) <<
"internal E (J/kg) = " << setw(tabS) <<
intEnergy_mass() << setw(tabL) <<
"internal E (J/kmol) = " << setw(tabS) <<
intEnergy_mole() << endl;
979 csvFile << setw(tabL) <<
"entropy (J/kg) = " << setw(tabS) <<
entropy_mass() << setw(tabL) <<
"entropy (J/kmol) = " << setw(tabS) <<
entropy_mole() << endl;
980 csvFile << setw(tabL) <<
"Gibbs (J/kg) = " << setw(tabS) <<
gibbs_mass() << setw(tabL) <<
"Gibbs (J/kmol) = " << setw(tabS) <<
gibbs_mole() << endl;
981 csvFile << setw(tabL) <<
"heat capacity c_p (J/K/kg) = " << setw(tabS) <<
cp_mass() << setw(tabL) <<
"heat capacity c_p (J/K/kmol) = " << setw(tabS) <<
cp_mole() << endl;
982 csvFile << setw(tabL) <<
"heat capacity c_v (J/K/kg) = " << setw(tabS) <<
cv_mass() << setw(tabL) <<
"heat capacity c_v (J/K/kmol) = " << setw(tabS) <<
cv_mole() << endl;
984 csvFile.precision(8);
986 vector<std::string> pNames;
987 vector<vector_fp> data;
991 pNames.push_back(
"X");
992 data.push_back(temp);
995 pNames.push_back(
"Molal");
996 data.push_back(temp);
1002 pNames.push_back(
"Chem. Pot. (J/kmol)");
1003 data.push_back(temp);
1009 pNames.push_back(
"Chem. Pot. SS (J/kmol)");
1010 data.push_back(temp);
1016 pNames.push_back(
"Molal Act. Coeff.");
1017 data.push_back(temp);
1023 pNames.push_back(
"Molal Activity");
1024 data.push_back(temp);
1027 double pH = -log(temp[iHp]) / log(10.0);
1028 csvFile << setw(tabL) <<
"pH = " << setw(tabS) << pH << endl;
1035 pNames.push_back(
"Part. Mol Enthalpy (J/kmol)");
1036 data.push_back(temp);
1042 pNames.push_back(
"Part. Mol. Entropy (J/K/kmol)");
1043 data.push_back(temp);
1049 pNames.push_back(
"Part. Mol. Energy (J/kmol)");
1050 data.push_back(temp);
1056 pNames.push_back(
"Part. Mol. Cp (J/K/kmol");
1057 data.push_back(temp);
1063 pNames.push_back(
"Part. Mol. Cv (J/K/kmol)");
1064 data.push_back(temp);
1069 csvFile << endl << setw(tabS) <<
"Species,";
1070 for (
size_t i = 0; i < pNames.size(); i++) {
1071 csvFile << setw(tabM) << pNames[i] <<
",";
1079 for (
size_t k = 0; k <
nSpecies(); k++) {
1082 for (
size_t i = 0; i < pNames.size(); i++) {
1083 csvFile << setw(tabM) << data[i][k] <<
",";
1087 for (
size_t i = 0; i < pNames.size(); i++) {
1088 csvFile << setw(tabM) << 0 <<
",";