28 "error parsing transport data: "
41 "error parsing transport data: "
51 m_model(LTI_MODEL_NOTSET),
58 size_t kmax =
m_Aij.size();
59 for (
size_t k = 0; k < kmax; k++) {
65 for (
size_t k = 0; k < kmax; k++) {
71 for (
size_t k = 0; k < kmax; k++) {
77 for (
size_t k = 0; k < kmax; k++) {
108 std::string speciesA;
109 std::string speciesB;
112 for (
size_t iChild = 0; iChild < num; iChild++) {
115 if (nodeName !=
"interaction") {
116 throw CanteraError(
"TransportFactory::getLiquidInteractionsTransportData",
117 "expected <interaction> element and got <" + nodeName +
">");
119 speciesA = xmlChild.
attrib(
"speciesA");
120 speciesB = xmlChild.
attrib(
"speciesB");
122 if (iSpecies ==
npos) {
123 throw CanteraError(
"TransportFactory::getLiquidInteractionsTransportData",
124 "Unknown species " + speciesA);
127 if (jSpecies ==
npos) {
128 throw CanteraError(
"TransportFactory::getLiquidInteractionsTransportData",
129 "Unknown species " + speciesB);
137 m_Eij(iSpecies,jSpecies) =
getFloat(xmlChild,
"Eij",
"actEnergy");
139 m_Eij(jSpecies,iSpecies) =
m_Eij(iSpecies,jSpecies) ;
147 while (
m_Aij.size()<poly.size()) {
149 aTemp->
resize(nsp, nsp, 0.0);
150 m_Aij.push_back(aTemp);
152 for (
int i = 0; i < (int)poly.size(); i++) {
153 (*
m_Aij[i])(iSpecies,jSpecies) = poly[i];
162 while (
m_Bij.size() < poly.size()) {
164 bTemp->
resize(nsp, nsp, 0.0);
165 m_Bij.push_back(bTemp);
167 for (
size_t i=0; i<poly.size(); i++) {
168 (*
m_Bij[i])(iSpecies,jSpecies) = poly[i];
178 while (
m_Hij.size()<poly.size()) {
180 hTemp->
resize(nsp, nsp, 0.0);
181 m_Hij.push_back(hTemp);
183 for (
size_t i=0; i<poly.size(); i++) {
184 (*
m_Hij[i])(iSpecies,jSpecies) = poly[i];
195 while (
m_Sij.size()<poly.size()) {
197 sTemp->
resize(nsp, nsp, 0.0);
198 m_Sij.push_back(sTemp);
200 for (
size_t i=0; i<poly.size(); i++) {
201 (*
m_Sij[i])(iSpecies,jSpecies) = poly[i];
214 m_Dij(iSpecies,jSpecies) =
getFloat(xmlChild,
"Dij",
"toSI");
215 m_Dij(jSpecies,iSpecies) =
m_Dij(iSpecies,jSpecies) ;
229 if (&right !=
this) {
253 doublereal LTI_Solvent::getMixTransProp(doublereal* speciesValues, doublereal* speciesWeight)
256 size_t nsp = m_thermo->nSpecies();
257 doublereal temp = m_thermo->temperature();
259 m_thermo->getMoleFractions(&molefracs[0]);
261 doublereal value = 0.0;
265 for (
size_t k = 0; k < nsp; k++) {
270 throw CanteraError(
"LTI_Solvent::getMixTransProp",
"You should be specifying the speciesWeight");
280 for (
size_t i = 0; i < nsp; i++) {
282 value += speciesValues[i] * speciesWeight[i];
288 for (
size_t j = 0; j < nsp; j++) {
289 for (
size_t k = 0; k < m_Aij.size(); k++) {
290 value += molefracs[i]*molefracs[j]*(*m_Aij[k])(i,j)*pow(molefracs[i], (
int) k);
292 for (
size_t k = 0; k < m_Bij.size(); k++) {
293 value += molefracs[i]*molefracs[j]*(*m_Bij[k])(i,j)*temp*pow(molefracs[i], (
int) k);
301 doublereal LTI_Solvent::getMixTransProp(std::vector<LTPspecies*> LTPptrs)
304 size_t nsp = m_thermo->nSpecies();
305 doublereal temp = m_thermo->temperature();
307 m_thermo->getMoleFractions(&molefracs[0]);
309 doublereal value = 0.0;
311 for (
size_t k = 0; k < nsp; k++) {
316 for (
size_t i = 0; i < nsp; i++) {
318 value += LTPptrs[i]->getSpeciesTransProp() * LTPptrs[i]->getMixWeight();
319 for (
size_t j = 0; j < nsp; j++) {
320 for (
size_t k = 0; k < m_Aij.size(); k++) {
321 value += molefracs[i]*molefracs[j]*(*m_Aij[k])(i,j)*pow(molefracs[i], (
int) k);
323 for (
size_t k = 0; k < m_Bij.size(); k++) {
324 value += molefracs[i]*molefracs[j]*(*m_Bij[k])(i,j)*temp*pow(molefracs[i], (
int) k);
332 void LTI_Solvent::getMatrixTransProp(DenseMatrix& mat, doublereal* speciesValues)
347 doublereal value = 0;
351 for (
size_t k = 0; k < nsp; k++) {
352 molefracs[k] = molefracs[k]*speciesWeight[k];
355 throw CanteraError(
"LTI_MoleFracs::getMixTransProp",
"You should be specifying the speciesWeight");
358 for (
size_t i = 0; i < nsp; i++) {
359 value += speciesValues[i] * molefracs[i];
360 for (
size_t j = 0; j < nsp; j++) {
361 for (
size_t k = 0; k <
m_Aij.size(); k++) {
362 value += molefracs[i]*molefracs[j]*(*
m_Aij[k])(i,j)*pow(molefracs[i], (
int) k);
364 for (
size_t k = 0; k <
m_Bij.size(); k++) {
365 value += molefracs[i]*molefracs[j]*(*
m_Bij[k])(i,j)*temp*pow(molefracs[i], (
int) k);
382 doublereal value = 0;
384 for (
size_t k = 0; k < nsp; k++) {
385 molefracs[k] = molefracs[k]*LTPptrs[k]->getMixWeight();
388 for (
size_t i = 0; i < nsp; i++) {
389 value += LTPptrs[i]->getSpeciesTransProp() * molefracs[i];
390 for (
size_t j = 0; j < nsp; j++) {
391 for (
size_t k = 0; k <
m_Aij.size(); k++) {
392 value += molefracs[i]*molefracs[j]*(*
m_Aij[k])(i,j)*pow(molefracs[i], (
int) k);
394 for (
size_t k = 0; k <
m_Bij.size(); k++) {
395 value += molefracs[i]*molefracs[j]*(*
m_Bij[k])(i,j)*temp*pow(molefracs[i], (
int) k);
411 doublereal value = 0;
415 for (
size_t k = 0; k < nsp; k++) {
416 massfracs[k] = massfracs[k]*speciesWeight[k];
419 throw CanteraError(
"LTI_MassFracs::getMixTransProp",
"You should be specifying the speciesWeight");
422 for (
size_t i = 0; i < nsp; i++) {
423 value += speciesValues[i] * massfracs[i];
424 for (
size_t j = 0; j < nsp; j++) {
425 for (
size_t k = 0; k <
m_Aij.size(); k++) {
426 value += massfracs[i]*massfracs[j]*(*
m_Aij[k])(i,j)*pow(massfracs[i], (
int) k);
428 for (
size_t k = 0; k <
m_Bij.size(); k++) {
429 value += massfracs[i]*massfracs[j]*(*
m_Bij[k])(i,j)*temp*pow(massfracs[i], (
int) k);
446 doublereal value = 0;
448 for (
size_t k = 0; k < nsp; k++) {
449 massfracs[k] = massfracs[k]*LTPptrs[k]->getMixWeight();
452 for (
size_t i = 0; i < nsp; i++) {
453 value += LTPptrs[i]->getSpeciesTransProp() * massfracs[i];
454 for (
size_t j = 0; j < nsp; j++) {
455 for (
size_t k = 0; k <
m_Aij.size(); k++) {
456 value += massfracs[i]*massfracs[j]*(*
m_Aij[k])(i,j)*pow(massfracs[i], (
int) k);
458 for (
size_t k = 0; k <
m_Bij.size(); k++) {
459 value += massfracs[i]*massfracs[j]*(*
m_Bij[k])(i,j)*temp*pow(massfracs[i], (
int) k);
480 doublereal value = 0;
484 for (
size_t k = 0; k < nsp; k++) {
485 molefracs[k] = molefracs[k]*speciesWeight[k];
488 throw CanteraError(
"LTI_Log_MoleFracs::getMixTransProp",
"You probably should have a speciesWeight when you call getMixTransProp to convert ion mole fractions to molecular mole fractions");
491 for (
size_t i = 0; i < nsp; i++) {
492 value += log(speciesValues[i]) * molefracs[i];
493 for (
size_t j = 0; j < nsp; j++) {
494 for (
size_t k = 0; k <
m_Hij.size(); k++) {
495 value += molefracs[i]*molefracs[j]*(*
m_Hij[k])(i,j)/temp*pow(molefracs[i], (
int) k);
498 for (
size_t k = 0; k <
m_Sij.size(); k++) {
499 value -= molefracs[i]*molefracs[j]*(*
m_Sij[k])(i,j)*pow(molefracs[i], (
int) k);
519 doublereal value = 0;
523 for (
size_t k = 0; k < nsp; k++) {
524 molefracs[k] = molefracs[k]*LTPptrs[k]->getMixWeight();
527 for (
size_t i = 0; i < nsp; i++) {
528 value += log(LTPptrs[i]->getSpeciesTransProp()) * molefracs[i];
529 for (
size_t j = 0; j < nsp; j++) {
530 for (
size_t k = 0; k <
m_Hij.size(); k++) {
531 value += molefracs[i]*molefracs[j]*(*
m_Hij[k])(i,j)/temp*pow(molefracs[i], (
int) k);
535 for (
size_t k = 0; k <
m_Sij.size(); k++) {
536 value -= molefracs[i]*molefracs[j]*(*
m_Sij[k])(i,j)*pow(molefracs[i], (
int) k);
554 void LTI_Pairwise_Interaction::setParameters(LiquidTransportParams& trParam)
557 m_diagonals.resize(nsp, 0);
559 for (
size_t k = 0; k < nsp; k++) {
574 doublereal value = 0;
576 throw LTPmodelError(
"Calling LTI_Pairwise_Interaction::getMixTransProp does not make sense.");
589 doublereal value = 0;
591 throw LTPmodelError(
"Calling LTI_Pairwise_Interaction::getMixTransProp does not make sense.");
604 mat.
resize(nsp, nsp, 0.0);
605 for (
size_t i = 0; i < nsp; i++)
606 for (
size_t j = 0; j < i; j++) {
607 mat(i,j) = mat(j,i) = exp(
m_Eij(i,j) / temp) /
m_Dij(i,j);
610 for (
size_t i = 0; i < nsp; i++)
611 if (mat(i,i) == 0.0 && m_diagonals[i]) {
612 mat(i,i) = 1.0 / m_diagonals[i]->getSpeciesTransProp() ;
620 size_t nsp2 = nsp*nsp;
626 m_ionCondSpecies.resize(nsp,0);
627 m_mobRatMix.
resize(nsp,nsp,0.0);
628 m_mobRatMixModel.resize(nsp2);
629 m_mobRatSpecies.resize(nsp2);
630 m_selfDiffMix.resize(nsp,0.0);
631 m_selfDiffMixModel.resize(nsp);
632 m_selfDiffSpecies.resize(nsp);
634 for (
size_t k = 0; k < nsp2; k++) {
637 m_mobRatSpecies[k].resize(nsp,0);
639 for (
size_t k = 0; k < nsp; k++) {
642 m_selfDiffSpecies[k].resize(nsp,0);
645 for (
size_t k = 0; k < nsp; k++) {
649 for (
size_t j = 0; j < nsp2; j++) {
653 for (
size_t j = 0; j < nsp; j++) {
667 doublereal value = 0;
669 throw LTPmodelError(
"Calling LTI_StefanMaxwell_PPN::getMixTransProp does not make sense.");
682 doublereal value = 0;
684 throw LTPmodelError(
"Calling LTI_StefanMaxwell_PPN::getMixTransProp does not make sense.");
696 throw CanteraError(
"LTI_StefanMaxwell_PPN::getMatrixTransProp",
"Function may only be called with a 3-ion system");
703 vector<size_t> cation;
704 vector<size_t> anion;
709 std::vector<double> viS(6);
710 std::vector<double> charges(3);
711 std::vector<size_t> neutMolIndex(3);
714 if (anion.size() != 1) {
715 throw CanteraError(
"LTI_StefanMaxwell_PPN::getMatrixTransProp",
"Must have one anion only for StefanMaxwell_PPN");
717 if (cation.size() != 2) {
718 throw CanteraError(
"LTI_StefanMaxwell_PPN::getMatrixTransProp",
"Must have two cations of equal charge for StefanMaxwell_PPN");
720 if (charges[cation[0]] != charges[cation[1]]) {
721 throw CanteraError(
"LTI_StefanMaxwell_PPN::getMatrixTransProp",
"Cations must be of equal charge for StefanMaxwell_PPN");
730 for (
size_t j = 0; j < nsp; j++) {
731 for (
size_t i = 0; i < nsp; i++) {
732 if (m_mobRatMixModel[k]) {
733 m_mobRatMix(i,j) = m_mobRatMixModel[k]->getMixTransProp(m_mobRatSpecies[k]);
734 if (m_mobRatMix(i,j) > 0.0) {
735 m_mobRatMix(j,i) = 1.0/m_mobRatMix(i,j);
743 for (k = 0; k < nsp; k++) {
744 m_selfDiffMix[k] = m_selfDiffMixModel[k]->getMixTransProp(m_selfDiffSpecies[k]);
748 int vP =
max(viS[cation[0]],viS[cation[1]]);
749 int vM = viS[anion[0]];
750 int zP = charges[cation[0]];
751 int zM = charges[anion[0]];
752 doublereal xA, xB,
eps;
753 doublereal inv_vP_vM_MutualDiff;
755 dlnActCoeffdlnN_diag.resize(neut_molefracs.size(),0.0);
758 xA = neut_molefracs[neutMolIndex[cation[0]]];
759 xB = neut_molefracs[neutMolIndex[cation[1]]];
760 eps = (1-m_mobRatMix(cation[1],cation[0]))/(xA+xB*m_mobRatMix(cation[1],cation[0]));
761 inv_vP_vM_MutualDiff = (xA*(1-xB+dlnActCoeffdlnN_diag[neutMolIndex[cation[1]]])/m_selfDiffMix[cation[1]]+xB*(1-xA+dlnActCoeffdlnN_diag[neutMolIndex[cation[0]]])/m_selfDiffMix[cation[0]]);
763 mat.
resize(nsp, nsp, 0.0);
764 mat(cation[0],cation[1]) = mat(cation[1],cation[0]) = (1+vM/vP)*(1+eps*xB)*(1-eps*xA)*inv_vP_vM_MutualDiff-zP*zP*Faraday*Faraday/
GasConstant/temp/m_ionCondMix/vol;
765 mat(cation[0],anion[0]) = mat(anion[0],cation[0]) = (1+vP/vM)*(-eps*xB*(1-eps*xA)*inv_vP_vM_MutualDiff)-zP*zM*Faraday*Faraday/
GasConstant/temp/m_ionCondMix/vol;
766 mat(cation[1],anion[0]) = mat(anion[0],cation[1]) = (1+vP/vM)*(eps*xA*(1+eps*xB)*inv_vP_vM_MutualDiff)-zP*zM*Faraday*Faraday/
GasConstant/temp/m_ionCondMix/vol;
771 doublereal LTI_StokesEinstein::getMixTransProp(doublereal* speciesValues, doublereal* speciesWeight)
774 size_t nsp = m_thermo->nSpecies();
776 m_thermo->getMoleFractions(&molefracs[0]);
778 doublereal value = 0;
780 throw LTPmodelError(
"Calling LTI_StokesEinstein::getMixTransProp does not make sense.");
786 doublereal LTI_StokesEinstein::getMixTransProp(std::vector<LTPspecies*> LTPptrs)
789 size_t nsp = m_thermo->nSpecies();
791 m_thermo->getMoleFractions(&molefracs[0]);
793 doublereal value = 0;
795 throw LTPmodelError(
"Calling LTI_StokesEinstein::getMixTransProp does not make sense.");
802 void LTI_StokesEinstein::setParameters(LiquidTransportParams& trParam)
804 size_t nsp = m_thermo->nSpecies();
805 m_viscosity.resize(nsp, 0);
806 m_hydroRadius.resize(nsp, 0);
807 for (
size_t k = 0; k < nsp; k++) {
814 void LTI_StokesEinstein::getMatrixTransProp(DenseMatrix& mat, doublereal* speciesValues)
816 size_t nsp = m_thermo->nSpecies();
817 doublereal temp = m_thermo->temperature();
822 for (
size_t k = 0; k < nsp; k++) {
823 viscSpec[k] = m_viscosity[k]->getSpeciesTransProp() ;
824 radiusSpec[k] = m_hydroRadius[k]->getSpeciesTransProp() ;
827 mat.resize(nsp,nsp, 0.0);
828 for (
size_t i = 0; i < nsp; i++)
829 for (
size_t j = 0; j < nsp; j++) {
830 mat(i,j) = (6.0 *
Pi * radiusSpec[i] * viscSpec[j]) /
GasConstant / temp;
842 doublereal value = 0;
846 for (
size_t k = 0; k < nsp; k++) {
847 molefracs[k] = molefracs[k]*speciesWeight[k];
850 throw CanteraError(
"LTI_MoleFracs_ExpT::getMixTransProp",
"You should be specifying the speciesWeight");
853 for (
size_t i = 0; i < nsp; i++) {
854 value += speciesValues[i] * molefracs[i];
855 for (
size_t j = 0; j < nsp; j++) {
856 for (
size_t k = 0; k <
m_Aij.size(); k++) {
857 value += molefracs[i]*molefracs[j]*(*
m_Aij[k])(i,j)*pow(molefracs[i], (
int) k)*exp((*
m_Bij[k])(i,j)*temp);
874 doublereal value = 0;
876 for (
size_t k = 0; k < nsp; k++) {
877 molefracs[k] = molefracs[k]*LTPptrs[k]->getMixWeight();
880 for (
size_t i = 0; i < nsp; i++) {
881 value += LTPptrs[i]->getSpeciesTransProp() * molefracs[i];
882 for (
size_t j = 0; j < nsp; j++) {
883 for (
size_t k = 0; k <
m_Aij.size(); k++) {
884 value += molefracs[i]*molefracs[j]*(*
m_Aij[k])(i,j)*pow(molefracs[i], (
int) k)*exp((*
m_Bij[k])(i,j)*temp);