23 static const double xxSmall = 1.0E-150;
30 PhaseCombo_Interaction::PhaseCombo_Interaction() :
32 numBinaryInteractions_(0),
50 numBinaryInteractions_(0),
64 numBinaryInteractions_(0),
157 numBinaryInteractions_(0),
200 throw CanteraError(
"PhaseCombo_Interaction test1 constructor",
201 "Unable to find LiTFe1S2(S)");
208 throw CanteraError(
"PhaseCombo_Interaction test1 constructor",
209 "Unable to find Li2Fe1S2(S)");
231 return cPhaseCombo_Interaction;
253 if ((
int) inputFile.size() == 0) {
254 throw CanteraError(
"PhaseCombo_Interaction:constructPhaseFile",
255 "input file is null");
258 std::ifstream fin(path.c_str());
260 throw CanteraError(
"PhaseCombo_Interaction:constructPhaseFile",
261 "Could not open " +path+
" for reading.");
272 throw CanteraError(
"PhaseCombo_Interaction:constructPhaseFile",
273 "ERROR: Can not find phase named " +
id +
" in file named " + inputFile);
275 fxml_phase->
copy(&phaseNode_XML);
312 if ((
int)
id.
size() > 0) {
313 string idp = phaseNode.
id();
315 throw CanteraError(
"PhaseCombo_Interaction::constructPhaseXML",
316 "phasenode and Id are incompatible");
323 if (!phaseNode.
hasChild(
"thermo")) {
324 throw CanteraError(
"PhaseCombo_Interaction::constructPhaseXML",
325 "no thermo XML node");
332 stemp = thermoNode.
attrib(
"model");
334 if (formString !=
"phasecombo_interaction") {
335 throw CanteraError(
"PhaseCombo_Interaction::constructPhaseXML",
336 "model name isn't PhaseCombo_Interaction: " + formString);
346 throw CanteraError(
"PhaseCombo_Interaction::constructPhaseXML",
"importPhase failed ");
373 for (
size_t k = 0; k <
m_kk; k++) {
388 for (
size_t k = 0; k <
m_kk; k++) {
412 for (
size_t k = 0; k <
m_kk; k++) {
425 for (
size_t i = 0; i < kk; i++) {
438 for (
size_t i = 0; i < kk; i++) {
451 for (
size_t i = 0; i < kk; i++) {
488 for (
size_t k = 0; k <
m_kk; k++) {
498 for (
size_t k = 0; k <
m_kk; k++) {
530 for (
size_t k = 0; k <
m_kk; k++) {
536 for (
size_t k = 0; k <
m_kk; k++) {
570 for (
size_t k = 0; k <
m_kk; k++) {
577 for (
size_t k = 0; k <
m_kk; k++) {
598 double XA, XB, g0, g1;
606 for (
size_t iK = 0; iK <
m_kk; iK++) {
626 vbar[iK] += XA*XB*(g0+g1*XB)+((delAK-XA)*XB+XA*(delBK-XB))*(g0+g1*XB)+XA*XB*(delBK-XB)*g1;
633 throw CanteraError(
"PhaseCombo_Interaction",
"Base class method "
684 string subname =
"PhaseCombo_Interaction::initThermoXML";
693 string mStringa = thermoNode.
attrib(
"model");
695 if (mString !=
"phasecombo_interaction") {
696 throw CanteraError(subname.c_str(),
"Unknown thermo model: " + mStringa);
709 if (thermoNode.
hasChild(
"activityCoefficients")) {
712 string mStringa = acNode.
attrib(
"model");
714 if (mString !=
"margules") {
716 "Unknown activity coefficient model: " + mStringa);
719 for (
size_t i = 0; i < n; i++) {
721 stemp = xmlACChild.
name();
728 if (nodeName ==
"binaryneutralspeciesparameters") {
755 doublereal XA, XB, g0 , g1;
761 for (
size_t iK = 0; iK <
m_kk; iK++) {
788 lnActCoeff_Scaled_[iK] += (delAK * XB + XA * delBK - XA * XB) * (g0 + g1 * XB) + XA * XB * (delBK - XB) * g1;
805 doublereal XA, XB, g0, g1;
810 for (
size_t iK = 0; iK <
m_kk; iK++) {
825 double temp = (delAK * XB + XA * delBK - XA * XB) * (g0 + g1 * XB) + XA * XB * (delBK - XB) * g1;
839 for (
size_t k = 0; k <
m_kk; k++) {
851 for (
size_t k = 0; k <
m_kk; k++) {
871 doublereal* dlnActCoeffds)
const
874 doublereal XA, XB, g0 , g1, dXA, dXB;
882 for (
size_t iK = 0; iK <
m_kk; iK++) {
891 dlnActCoeffds[iK] += - 1.0 / xx;
916 dlnActCoeffds[iK] += ((delBK-XB)*dXA + (delAK-XA)*dXB)*(g0+2*g1*XB) + (delBK-XB)*2*g1*XA*dXB
937 doublereal XA, XB, XK, g0 , g1;
944 for (
size_t iK = 0; iK <
m_kk; iK++) {
995 doublereal delAK, delBK;
996 double XA, XB, g0, g1, XM;
1001 doublereal delAM, delBM;
1008 for (
size_t iK = 0; iK <
m_kk; iK++) {
1014 for (
size_t iM = 0; iM <
m_kk; iM++) {
1036 }
else if (iB==iK) {
1041 }
else if (iB==iM) {
1051 dlnActCoeffdlnN_(iK,iM) += g0*((delAM-XA)*(delBK-XB)+(delAK-XA)*(delBM-XB));
1052 dlnActCoeffdlnN_(iK,iM) += 2*g1*((delAM-XA)*(delBK-XB)*XB+(delAK-XA)*(delBM-XB)*XB+(delBM-XB)*(delBK-XB)*XA);
1062 doublereal XA, XB, g0 , g1;
1092 for (
size_t k = 0; k <
m_kk; k++) {
1104 for (
size_t k = 0; k <
m_kk; k++) {
1117 for (
size_t k = 0; k <
m_kk; k++) {
1118 for (
size_t m = 0; m <
m_kk; m++) {
1119 dlnActCoeffdlnN[ld * k + m] = data[m_kk * k + m];
1158 string xname = xmLBinarySpecies.
name();
1159 if (xname !=
"binaryNeutralSpeciesParameters") {
1160 throw CanteraError(
"PhaseCombo_Interaction::readXMLBinarySpecies",
1161 "Incorrect name for processing this routine: " + xname);
1165 size_t nParamsFound;
1167 string iName = xmLBinarySpecies.
attrib(
"speciesA");
1169 throw CanteraError(
"PhaseCombo_Interaction::readXMLBinarySpecies",
"no speciesA attrib");
1171 string jName = xmLBinarySpecies.
attrib(
"speciesB");
1173 throw CanteraError(
"PhaseCombo_Interaction::readXMLBinarySpecies",
"no speciesB attrib");
1180 if (iSpecies ==
npos) {
1184 if (charge[iSpecies] != 0) {
1185 throw CanteraError(
"PhaseCombo_Interaction::readXMLBinarySpecies",
"speciesA charge problem");
1188 if (jSpecies ==
npos) {
1192 if (charge[jSpecies] != 0) {
1193 throw CanteraError(
"PhaseCombo_Interaction::readXMLBinarySpecies",
"speciesB charge problem");
1201 size_t num = xmLBinarySpecies.
nChildren();
1202 for (
size_t iChild = 0; iChild < num; iChild++) {
1204 stemp = xmlChild.
name();
1209 if (nodeName ==
"excessenthalpy") {
1214 nParamsFound = vParams.size();
1216 if (nParamsFound != 2) {
1217 throw CanteraError(
"PhaseCombo_Interaction::readXMLBinarySpecies::excessEnthalpy for " + ispName
1219 "wrong number of params found");
1225 if (nodeName ==
"excessentropy") {
1230 nParamsFound = vParams.size();
1232 if (nParamsFound != 2) {
1233 throw CanteraError(
"PhaseCombo_Interaction::readXMLBinarySpecies::excessEntropy for " + ispName
1235 "wrong number of params found");
1241 if (nodeName ==
"excessvolume_enthalpy") {
1246 nParamsFound = vParams.size();
1248 if (nParamsFound != 2) {
1249 throw CanteraError(
"PhaseCombo_Interaction::readXMLBinarySpecies::excessVolume_Enthalpy for " + ispName
1251 "wrong number of params found");
1257 if (nodeName ==
"excessvolume_entropy") {
1262 nParamsFound = vParams.size();
1264 if (nParamsFound != 2) {
1265 throw CanteraError(
"PhaseCombo_Interaction::readXMLBinarySpecies::excessVolume_Entropy for " + ispName
1267 "wrong number of params found");