27 static const double xxSmall = 1.0E-150;
33 RedlichKisterVPSSTP::RedlichKisterVPSSTP() :
35 numBinaryInteractions_(0),
41 formRedlichKister_(0),
58 numBinaryInteractions_(0),
64 formRedlichKister_(0),
73 numBinaryInteractions_(0),
79 formRedlichKister_(0),
95 numBinaryInteractions_(0),
101 formRedlichKister_(0),
126 throw CanteraError(
"RedlichKisterVPSSTP test1 constructor",
127 "Unable to find LiLi");
134 throw CanteraError(
"RedlichKisterVPSSTP test1 constructor",
135 "Unable to find VLi");
150 numBinaryInteractions_(0),
156 formRedlichKister_(0),
244 if ((
int) inputFile.size() == 0) {
245 throw CanteraError(
"RedlichKisterVPSSTP:constructPhaseFile",
246 "input file is null");
249 std::ifstream fin(path.c_str());
251 throw CanteraError(
"RedlichKisterVPSSTP:constructPhaseFile",
"could not open "
252 +path+
" for reading.");
263 throw CanteraError(
"RedlichKisterVPSSTP:constructPhaseFile",
264 "ERROR: Can not find phase named " +
265 id +
" in file named " + inputFile);
267 fxml_phase->
copy(&phaseNode_XML);
302 if ((
int)
id.
size() > 0) {
303 string idp = phaseNode.
id();
305 throw CanteraError(
"RedlichKisterVPSSTP::constructPhaseXML",
306 "phasenode and Id are incompatible");
313 if (!phaseNode.
hasChild(
"thermo")) {
314 throw CanteraError(
"RedlichKisterVPSSTP::constructPhaseXML",
315 "no thermo XML node");
322 stemp = thermoNode.
attrib(
"model");
324 if (formString !=
"redlich-kister") {
325 throw CanteraError(
"RedlichKisterVPSSTP::constructPhaseXML",
326 "model name isn't Redlich-Kister: " + formString);
337 throw CanteraError(
"RedlichKisterVPSSTP::constructPhaseXML",
"importPhase failed ");
361 for (
size_t k = 0; k <
m_kk; k++) {
374 for (
size_t k = 0; k <
m_kk; k++) {
397 for (
size_t k = 0; k <
m_kk; k++) {
410 for (
size_t i = 0; i < kk; i++) {
423 for (
size_t i = 0; i < kk; i++) {
436 for (
size_t i = 0; i < kk; i++) {
473 for (
size_t k = 0; k <
m_kk; k++) {
483 for (
size_t k = 0; k <
m_kk; k++) {
516 for (
size_t k = 0; k <
m_kk; k++) {
522 for (
size_t k = 0; k <
m_kk; k++) {
556 for (
size_t k = 0; k <
m_kk; k++) {
563 for (
size_t k = 0; k <
m_kk; k++) {
588 for (
size_t iK = 0; iK <
m_kk; iK++) {
596 throw CanteraError(
"RedlichKisterVPSSTP",
"Base class method "
641 std::string subname =
"RedlichKisterVPSSTP::initThermoXML";
650 std::string mStringa = thermoNode.
attrib(
"model");
651 std::string mString =
lowercase(mStringa);
652 if (mString !=
"redlich-kister") {
654 "Unknown thermo model: " + mStringa +
" - This object only knows \"Redlich-Kister\" ");
666 if (thermoNode.
hasChild(
"activityCoefficients")) {
669 std::string mStringa = acNode.
attrib(
"model");
670 std::string mString =
lowercase(mStringa);
671 if (mString !=
"redlich-kister") {
673 "Unknown activity coefficient model: " + mStringa);
676 for (
size_t i = 0; i < n; i++) {
678 stemp = xmlACChild.
name();
685 if (nodeName ==
"binaryneutralspeciesparameters") {
721 doublereal deltaX = XA - XB;
725 doublereal poly = 1.0;
726 doublereal polyMm1 = 1.0;
727 doublereal sum = 0.0;
728 doublereal sumMm1 = 0.0;
729 doublereal sum2 = 0.0;
730 for (
size_t m = 0; m < N; m++) {
731 doublereal A_ge = (he_vec[m] - T * se_vec[m]) / RT;
733 sum2 += A_ge * (m + 1) * poly;
736 sumMm1 += (A_ge * polyMm1 * m);
740 doublereal oneMXA = 1.0 - XA;
741 doublereal oneMXB = 1.0 - XB;
742 for (
size_t k = 0; k <
m_kk; k++) {
745 }
else if (iB == k) {
752 #ifdef DEBUG_MODE_NOT
756 double fac = 2.0 * XA - 1.0;
757 for (
int m = 0; m < N; m++) {
758 doublereal A_ge = (he_vec[m] - T * se_vec[m]) / RT;
759 lnA += A_ge * oneMXA * oneMXA * polyk * (1.0 + 2.0 * XA * m / fac);
760 lnB += A_ge * XA * XA * polyk * (1.0 - 2.0 * oneMXA * m / fac);
793 doublereal deltaX = XA - XB;
795 doublereal poly = 1.0;
796 doublereal sum = 0.0;
799 doublereal sumMm1 = 0.0;
800 doublereal polyMm1 = 1.0;
801 doublereal sum2 = 0.0;
802 for (
size_t m = 0; m < N; m++) {
803 doublereal A_ge = - se_vec[m];
805 sum2 += A_ge * (m + 1) * poly;
808 sumMm1 += (A_ge * polyMm1 * m);
812 doublereal oneMXA = 1.0 - XA;
813 doublereal oneMXB = 1.0 - XB;
814 for (
size_t k = 0; k <
m_kk; k++) {
817 }
else if (iB == k) {
829 for (
size_t k = 0; k <
m_kk; k++) {
837 for (
size_t k = 0; k <
m_kk; k++) {
854 doublereal deltaX = XA - XB;
856 doublereal poly = 1.0;
857 doublereal sum = 0.0;
860 doublereal sumMm1 = 0.0;
861 doublereal polyMm1 = 1.0;
862 doublereal polyMm2 = 1.0;
863 doublereal sum2 = 0.0;
864 doublereal sum2Mm1 = 0.0;
865 doublereal sumMm2 = 0.0;
866 for (
size_t m = 0; m < N; m++) {
867 doublereal A_ge = he_vec[m] - T * se_vec[m];
869 sum2 += A_ge * (m + 1) * poly;
872 sumMm1 += (A_ge * polyMm1 * m);
873 sum2Mm1 += (A_ge * polyMm1 * m * (1.0 + m));
877 sumMm2 += (A_ge * polyMm2 * m * (m - 1.0));
882 for (
size_t k = 0; k <
m_kk; k++) {
886 + XB * sumMm1 * (1.0 - 2.0 * XA + XB)
887 + XA * XB * sumMm2 * (1.0 - XA + XB));
890 + XA * sumMm1 * (1.0 + 2.0 * XB - XA)
891 - XA * XB * sumMm2 * (1.0 - XA + XB));
893 }
else if (iB == k) {
896 + XB * sumMm1 * (1.0 - 2.0 * XA + XB)
897 + XA * XB * sumMm2 * (1.0 - XA + XB));
900 + XA * sumMm1 * (XB - XA - (1.0 - XB))
901 - XA * XB * sumMm2 * (-XA - (1.0 - XB)));
925 doublereal* dlnActCoeffds)
const
929 for (
size_t k = 0; k <
m_kk; k++) {
931 for (
size_t l = 0; l <
m_kk; l++) {
941 for (
size_t l = 0; l <
m_kk; l++) {
943 for (
size_t k = 0; k <
m_kk; k++) {
952 for (
size_t k = 0; k <
m_kk; k++) {
961 for (
size_t k = 0; k <
m_kk; k++) {
962 for (
size_t m = 0; m <
m_kk; m++) {
963 dlnActCoeffdlnN[ld * k + m] = data[m_kk * k + m];
987 std::string xname = xmLBinarySpecies.
name();
988 if (xname !=
"binaryNeutralSpeciesParameters") {
989 throw CanteraError(
"RedlichKisterVPSSTP::readXMLBinarySpecies",
990 "Incorrect name for processing this routine: " + xname);
996 std::string iName = xmLBinarySpecies.
attrib(
"speciesA");
998 throw CanteraError(
"RedlichKisterVPSSTP::readXMLBinarySpecies",
"no speciesA attrib");
1000 std::string jName = xmLBinarySpecies.
attrib(
"speciesB");
1002 throw CanteraError(
"RedlichKisterVPSSTP::readXMLBinarySpecies",
"no speciesB attrib");
1010 if (iSpecies ==
npos) {
1014 if (charge[iSpecies] != 0) {
1015 throw CanteraError(
"RedlichKisterVPSSTP::readXMLBinarySpecies",
"speciesA charge problem");
1018 if (jSpecies ==
npos) {
1022 if (charge[jSpecies] != 0) {
1023 throw CanteraError(
"RedlichKisterVPSSTP::readXMLBinarySpecies",
"speciesB charge problem");
1035 size_t num = xmLBinarySpecies.
nChildren();
1036 for (
size_t iChild = 0; iChild < num; iChild++) {
1038 stemp = xmlChild.
name();
1043 if (nodeName ==
"excessenthalpy") {
1048 size_t nParamsFound = hParams.size();
1049 if (nParamsFound > Npoly) {
1050 Npoly = nParamsFound;
1055 if (nodeName ==
"excessentropy") {
1060 size_t nParamsFound = sParams.size();
1061 if (nParamsFound > Npoly) {
1062 Npoly = nParamsFound;
1066 hParams.resize(Npoly, 0.0);
1067 sParams.resize(Npoly, 0.0);
1075 void RedlichKisterVPSSTP::Vint(
double& VintOut,
double& voltsOut)
1090 if (XA <= 1.0E-14) {
1093 if (XA >= (1.0 - 1.0E-14)) {
1100 double fac = 2.0 * XA - 1.0;
1101 if (fabs(fac) < 1.0E-13) {
1104 double polykp1 = fac;
1105 double poly1mk = fac;
1107 for (m = 0; m < N; m++) {
1108 doublereal A_ge = he_vec[m] - T * se_vec[m];
1109 Volts += A_ge * (polykp1 - (2.0 * XA * m * (1.0-XA)) / poly1mk);
1116 double termp = RT * log((1.0 - XA)/XA) / Faraday;
1119 voltsOut = Volts + termp;