37 IdealMolalSoln::IdealMolalSoln() :
41 IMS_X_o_cutoff_(0.20),
42 IMS_gamma_o_min_(0.00001),
43 IMS_gamma_k_min_(10.0),
115 IMS_X_o_cutoff_(0.2),
116 IMS_gamma_o_min_(0.00001),
117 IMS_gamma_k_min_(10.0),
137 IMS_X_o_cutoff_(0.2),
138 IMS_gamma_o_min_(0.00001),
139 IMS_gamma_k_min_(10.0),
279 return err(
"not implemented");
300 double* vbar = &
m_pp[0];
304 doublereal vtotal = 0.0;
305 for (
size_t i = 0; i <
m_kk; i++) {
306 vtotal += vbar[i] * x[i];
364 "Density is not an independent variable");
382 "molarDensity/denisty is not an independent variable");
417 for (
size_t k = 0; k <
m_kk; k++) {
422 for (
size_t k = 0; k <
m_kk; k++) {
443 double c0 = 1.0, mvSolvent;
452 c0 = 1.0 / mvSolvent;
494 for (
int i = 0; i < sizeUA; i++) {
498 for (
int i = 0; i < sizeUA; i++) {
503 uA[1] = -int(
nDim());
538 for (
size_t k = 0; k <
m_kk; k++) {
544 exp((xmolSolvent - 1.0)/xmolSolvent);
551 for (
size_t k = 1; k <
m_kk; k++) {
576 for (
size_t k = 0; k <
m_kk; k++) {
582 exp((xmolSolvent - 1.0)/xmolSolvent) / xmolSolvent;
586 for (
size_t k = 0; k <
m_kk; k++) {
587 acMolality[k] = exp(acMolality[k]);
645 for (
size_t k = 1; k <
m_kk; k++) {
647 mu[k] += RT * log(xx);
656 (RT * (xmolSolvent - 1.0) / xx);
665 for (
size_t k = 1; k <
m_kk; k++) {
684 doublereal RT =
_RT();
685 for (
size_t k = 0; k <
m_kk; k++) {
724 for (
size_t k = 0; k <
m_kk; k++) {
727 sbar[k] -= R * log(mm);
743 for (
size_t k = 0; k <
m_kk; k++) {
794 for (
size_t k = 0; k <
m_kk; k++) {
846 if (inputFile.size() == 0) {
847 throw CanteraError(
"IdealMolalSoln::constructPhaseFile",
848 "input file is null");
851 std::ifstream fin(path.c_str());
853 throw CanteraError(
"IdealMolalSoln::constructPhaseFile",
855 +path+
" for reading.");
866 throw CanteraError(
"IdealMolalSoln::constructPhaseFile",
867 "ERROR: Can not find phase named " +
868 id +
" in file named " + inputFile);
870 fxml_phase->
copy(&phaseNode_XML);
903 std::string idp = phaseNode.
id();
906 "phasenode and Id are incompatible");
913 if (!phaseNode.
hasChild(
"thermo")) {
915 "no thermo XML node");
925 throw CanteraError(
"IdealMolalSoln::constructPhaseXML",
"importPhase failed ");
957 std::string idp = phaseNode.
id();
960 "phasenode and Id are incompatible");
967 if (!phaseNode.
hasChild(
"thermo")) {
969 "no thermo XML node");
976 if (thermoNode.
hasChild(
"standardConc")) {
979 std::string formString = scNode.
attrib(
"model");
980 if (formString !=
"") {
981 if (formString ==
"unity") {
983 }
else if (formString ==
"molar_volume") {
985 }
else if (formString ==
"solvent_volume") {
989 "Unknown standardConc model: " + formString);
998 std::string solventName =
"";
999 if (thermoNode.
hasChild(
"solvent")) {
1001 std::vector<std::string> nameSolventa;
1003 int nsp =
static_cast<int>(nameSolventa.size());
1006 "badly formed solvent XML node");
1008 solventName = nameSolventa[0];
1011 if (thermoNode.
hasChild(
"activityCoefficients")) {
1012 XML_Node& acNode = thermoNode.
child(
"activityCoefficients");
1013 std::string modelString = acNode.
attrib(
"model");
1015 if (modelString !=
"IdealMolalSoln") {
1017 "unknown ActivityCoefficient model: " + modelString);
1019 if (acNode.
hasChild(
"idealMolalSolnCutoff")) {
1021 modelString = ccNode.
attrib(
"model");
1022 if (modelString !=
"") {
1023 if (modelString ==
"polyExp") {
1025 }
else if (modelString ==
"poly") {
1029 "Unknown idealMolalSolnCutoff form: " + modelString);
1032 if (ccNode.
hasChild(
"gamma_o_limit")) {
1035 if (ccNode.
hasChild(
"gamma_k_limit")) {
1038 if (ccNode.
hasChild(
"X_o_cutoff")) {
1041 if (ccNode.
hasChild(
"c_0_param")) {
1044 if (ccNode.
hasChild(
"slope_f_limit")) {
1047 if (ccNode.
hasChild(
"slope_g_limit")) {
1059 for (
size_t k = 0; k <
m_kk; k++) {
1061 if (solventName == sname) {
1067 std::cout <<
"IdealMolalSoln::initThermo: Solvent Name not found"
1070 "Solvent name not found");
1074 "Solvent " + solventName +
1075 " should be first species");
1088 for (
size_t k = 0; k <
m_kk; k++) {
1162 "Unfinished func called: " + msg);
1192 for (
size_t k = 1; k <
m_kk; k++) {
1199 for (
size_t k = 1; k <
m_kk; k++) {
1206 for (
size_t k = 1; k <
m_kk; k++) {
1217 double xminus2 = xminus * xminus;
1218 double xminus3 = xminus2 * xminus;
1222 double h2 = 3.5 * xminus2 / IMS_X_o_cutoff_ - 2.0 * xminus3 / x_o_cut2;
1223 double h2_prime = 7.0 * xminus / IMS_X_o_cutoff_ - 6.0 * xminus2 / x_o_cut2;
1225 double h1 = (1.0 - 3.0 * xminus2 / x_o_cut2 + 2.0 * xminus3/ x_o_cut3);
1226 double h1_prime = (- 6.0 * xminus / x_o_cut2 + 6.0 * xminus2/ x_o_cut3);
1232 double h1_f = h1 * alpha;
1233 double h1_f_prime = h1_prime * alpha;
1235 double f = h2 + h1_f;
1236 double f_prime = h2_prime + h1_f_prime;
1238 double g = h2 + h1_g;
1239 double g_prime = h2_prime + h1_g_prime;
1241 tmp = (xmolSolvent/ g * g_prime + (1.0-xmolSolvent) / f * f_prime);
1242 double lngammak = -1.0 - log(f) + tmp * xmolSolvent;
1243 double lngammao =-log(g) - tmp * (1.0-xmolSolvent);
1245 tmp = log(xmolSolvent) + lngammak;
1246 for (
size_t k = 1; k <
m_kk; k++) {
1256 for (
size_t k = 1; k <
m_kk; k++) {
1264 double eterm = std::exp(-xoverc);
1268 double f_prime = 1.0 + eterm*fptmp;
1273 double g_prime = 1.0 + eterm*gptmp;
1276 tmp = (xmolSolvent / g * g_prime + (1.0 - xmolSolvent) / f * f_prime);
1277 double lngammak = -1.0 - log(f) + tmp * xmolSolvent;
1278 double lngammao =-log(g) - tmp * (1.0-xmolSolvent);
1280 tmp = log(xx) + lngammak;
1281 for (
size_t k = 1; k <
m_kk; k++) {
1315 bool converged =
false;
1318 for (its = 0; its < 100 && !converged; its++) {
1333 throw CanteraError(
" IdealMolalSoln::calcCutoffParams_()",
1334 " failed to converge on the f polynomial");
1340 for (its = 0; its < 100 && !converged; its++) {
1356 throw CanteraError(
" IdealMolalSoln::calcCutoffParams_()",
1357 " failed to converge on the g polynomial");