26 static const double xxSmall = 1.0E-150;
31 MargulesVPSSTP::MargulesVPSSTP() :
33 numBinaryInteractions_(0),
50 numBinaryInteractions_(0),
59 numBinaryInteractions_(0),
146 numBinaryInteractions_(0),
190 "Unable to find LiCl(L)");
198 "Unable to find KCl(L)");
239 if ((
int) inputFile.size() == 0) {
241 "input file is null");
244 std::ifstream fin(path.c_str());
246 throw CanteraError(
"MargulesVPSSTP:constructPhaseFile",
"could not open "
247 +path+
" for reading.");
259 "ERROR: Can not find phase named " +
260 id +
" in file named " + inputFile);
262 fxml_phase->
copy(&phaseNode_XML);
297 if ((
int)
id.
size() > 0) {
298 string idp = phaseNode.
id();
301 "phasenode and Id are incompatible");
308 if (!phaseNode.
hasChild(
"thermo")) {
310 "no thermo XML node");
317 stemp = thermoNode.
attrib(
"model");
319 if (formString !=
"margules") {
321 "model name isn't Margules: " + formString);
332 throw CanteraError(
"MargulesVPSSTP::constructPhaseXML",
"importPhase failed ");
364 for (
size_t k = 0; k <
m_kk; k++) {
379 for (
size_t k = 0; k <
m_kk; k++) {
400 for (
size_t k = 0; k <
m_kk; k++) {
413 for (
size_t i = 0; i < kk; i++) {
426 for (
size_t i = 0; i < kk; i++) {
439 for (
size_t i = 0; i < kk; i++) {
476 for (
size_t k = 0; k <
m_kk; k++) {
486 for (
size_t k = 0; k <
m_kk; k++) {
519 for (
size_t k = 0; k <
m_kk; k++) {
525 for (
size_t k = 0; k <
m_kk; k++) {
559 for (
size_t k = 0; k <
m_kk; k++) {
566 for (
size_t k = 0; k <
m_kk; k++) {
588 size_t iA, iB, delAK, delBK;
589 double XA, XB, g0 , g1;
597 for (
size_t iK = 0; iK <
m_kk; iK++) {
617 vbar[iK] += XA*XB*(g0+g1*XB)+((delAK-XA)*XB+XA*(delBK-XB))*(g0+g1*XB)+XA*XB*(delBK-XB)*g1;
624 throw CanteraError(
"MargulesVPSSTP",
"Base class method "
675 string subname =
"MargulesVPSSTP::initThermoXML";
684 string mStringa = thermoNode.
attrib(
"model");
686 if (mString !=
"margules") {
688 "Unknown thermo model: " + mStringa);
701 if (thermoNode.
hasChild(
"activityCoefficients")) {
704 string mStringa = acNode.
attrib(
"model");
706 if (mString !=
"margules") {
708 "Unknown activity coefficient model: " + mStringa);
710 for (
size_t i = 0; i < acNodePtr->
nChildren(); i++) {
712 stemp = xmlACChild.
name();
719 if (nodeName ==
"binaryneutralspeciesparameters") {
744 size_t iA, iB, iK, delAK, delBK;
745 double XA, XB, g0 , g1;
749 for (iK = 0; iK <
m_kk; iK++) {
764 lnActCoeff_Scaled_[iK] += (delAK * XB + XA * delBK - XA * XB) * (g0 + g1 * XB) + XA * XB * (delBK - XB) * g1;
778 size_t iA, iB, iK, delAK, delBK;
779 doublereal XA, XB, g0, g1;
784 for (iK = 0; iK <
m_kk; iK++) {
799 double temp = (delAK * XB + XA * delBK - XA * XB) * (g0 + g1 * XB) + XA * XB * (delBK - XB) * g1;
809 for (
size_t k = 0; k <
m_kk; k++) {
817 for (
size_t k = 0; k <
m_kk; k++) {
835 doublereal* dlnActCoeffds)
const
839 size_t iA, iB, iK, delAK, delBK;
840 double XA, XB, g0 , g1, dXA, dXB;
847 for (iK = 0; iK <
m_kk; iK++) {
848 dlnActCoeffds[iK] = 0.0;
873 dlnActCoeffds[iK] += ((delBK-XB)*dXA + (delAK-XA)*dXB)*(g0+2*g1*XB) + (delBK-XB)*2*g1*XA*dXB
889 size_t iA, iB, iK, delAK, delBK;
890 double XA, XB, XK, g0 , g1;
896 for (iK = 0; iK <
m_kk; iK++) {
953 doublereal delAK, delBK;
954 double XA, XB, g0, g1,XM;
958 doublereal delAM, delBM;
965 for (
size_t iK = 0; iK <
m_kk; iK++) {
966 for (
size_t iM = 0; iM <
m_kk; iM++) {
994 dlnActCoeffdlnN_(iK,iM) += g0*((delAM-XA)*(delBK-XB)+(delAK-XA)*(delBM-XB));
995 dlnActCoeffdlnN_(iK,iM) += 2*g1*((delAM-XA)*(delBK-XB)*XB+(delAK-XA)*(delBM-XB)*XB+(delBM-XB)*(delBK-XB)*XA);
1043 for (
size_t k = 0; k <
m_kk; k++) {
1051 for (
size_t k = 0; k <
m_kk; k++) {
1060 for (
size_t k = 0; k <
m_kk; k++) {
1061 for (
size_t m = 0; m <
m_kk; m++) {
1062 dlnActCoeffdlnN[ld * k + m] = data[m_kk * k + m];
1098 string xname = xmLBinarySpecies.
name();
1099 if (xname !=
"binaryNeutralSpeciesParameters") {
1100 throw CanteraError(
"MargulesVPSSTP::readXMLBinarySpecies",
1101 "Incorrect name for processing this routine: " + xname);
1105 size_t nParamsFound;
1107 string iName = xmLBinarySpecies.
attrib(
"speciesA");
1109 throw CanteraError(
"MargulesVPSSTP::readXMLBinarySpecies",
"no speciesA attrib");
1111 string jName = xmLBinarySpecies.
attrib(
"speciesB");
1113 throw CanteraError(
"MargulesVPSSTP::readXMLBinarySpecies",
"no speciesB attrib");
1120 if (iSpecies ==
npos) {
1124 if (charge[iSpecies] != 0) {
1125 throw CanteraError(
"MargulesVPSSTP::readXMLBinarySpecies",
"speciesA charge problem");
1128 if (jSpecies ==
npos) {
1132 if (charge[jSpecies] != 0) {
1133 throw CanteraError(
"MargulesVPSSTP::readXMLBinarySpecies",
"speciesB charge problem");
1141 for (
size_t iChild = 0; iChild < xmLBinarySpecies.
nChildren(); iChild++) {
1143 stemp = xmlChild.
name();
1148 if (nodeName ==
"excessenthalpy") {
1153 nParamsFound = vParams.size();
1155 if (nParamsFound != 2) {
1156 throw CanteraError(
"MargulesVPSSTP::readXMLBinarySpecies::excessEnthalpy for " + ispName
1158 "wrong number of params found. Need 2");
1164 if (nodeName ==
"excessentropy") {
1169 nParamsFound = vParams.size();
1171 if (nParamsFound != 2) {
1172 throw CanteraError(
"MargulesVPSSTP::readXMLBinarySpecies::excessEntropy for " + ispName
1174 "wrong number of params found. Need 2");
1180 if (nodeName ==
"excessvolume_enthalpy") {
1185 nParamsFound = vParams.size();
1187 if (nParamsFound != 2) {
1188 throw CanteraError(
"MargulesVPSSTP::readXMLBinarySpecies::excessVolume_Enthalpy for " + ispName
1190 "wrong number of params found. Need 2");
1196 if (nodeName ==
"excessvolume_entropy") {
1201 nParamsFound = vParams.size();
1203 if (nParamsFound != 2) {
1204 throw CanteraError(
"MargulesVPSSTP::readXMLBinarySpecies::excessVolume_Entropy for " + ispName
1206 "wrong number of params found. Need 2");