29 "error parsing transport data: " 34 m_model(LTI_MODEL_NOTSET),
37 warn_deprecated(
"Class LiquidTranInteraction",
"To be removed after Cantera 2.4");
40 LiquidTranInteraction::~LiquidTranInteraction()
42 for (
size_t k = 0; k <
m_Aij.size(); k++) {
45 for (
size_t k = 0; k <
m_Bij.size(); k++) {
48 for (
size_t k = 0; k <
m_Hij.size(); k++) {
51 for (
size_t k = 0; k <
m_Sij.size(); k++) {
64 for (
size_t iChild = 0; iChild < compModelNode.
nChildren(); iChild++) {
66 std::string nodeName = xmlChild.
name();
68 throw CanteraError(
"TransportFactory::getLiquidInteractionsTransportData",
69 "expected <interaction> element and got <" + nodeName +
">");
71 string speciesA = xmlChild.
attrib(
"speciesA");
72 string speciesB = xmlChild.
attrib(
"speciesB");
74 if (iSpecies ==
npos) {
75 throw CanteraError(
"TransportFactory::getLiquidInteractionsTransportData",
76 "Unknown species " + speciesA);
79 if (jSpecies ==
npos) {
80 throw CanteraError(
"TransportFactory::getLiquidInteractionsTransportData",
81 "Unknown species " + speciesB);
85 m_Eij(iSpecies,jSpecies) =
getFloat(xmlChild,
"Eij",
"actEnergy");
87 m_Eij(jSpecies,iSpecies) =
m_Eij(iSpecies,jSpecies);
93 while (
m_Aij.size()<poly.size()) {
95 aTemp->
resize(nsp, nsp, 0.0);
96 m_Aij.push_back(aTemp);
98 for (
int i = 0; i < (int)poly.size(); i++) {
99 (*
m_Aij[i])(iSpecies,jSpecies) = poly[i];
106 while (
m_Bij.size() < poly.size()) {
108 bTemp->
resize(nsp, nsp, 0.0);
109 m_Bij.push_back(bTemp);
111 for (
size_t i=0; i<poly.size(); i++) {
112 (*
m_Bij[i])(iSpecies,jSpecies) = poly[i];
119 while (
m_Hij.size()<poly.size()) {
121 hTemp->
resize(nsp, nsp, 0.0);
122 m_Hij.push_back(hTemp);
124 for (
size_t i=0; i<poly.size(); i++) {
125 (*
m_Hij[i])(iSpecies,jSpecies) = poly[i];
133 while (
m_Sij.size()<poly.size()) {
135 sTemp->
resize(nsp, nsp, 0.0);
136 m_Sij.push_back(sTemp);
138 for (
size_t i=0; i<poly.size(); i++) {
139 (*
m_Sij[i])(iSpecies,jSpecies) = poly[i];
145 m_Dij(iSpecies,jSpecies) =
getFloat(xmlChild,
"Dij",
"toSI");
146 m_Dij(jSpecies,iSpecies) =
m_Dij(iSpecies,jSpecies);
157 doublereal LTI_Solvent::getMixTransProp(doublereal* speciesValues, doublereal* speciesWeight)
159 size_t nsp = m_thermo->nSpecies();
160 doublereal temp = m_thermo->temperature();
162 m_thermo->getMoleFractions(&molefracs[0]);
163 doublereal value = 0.0;
167 for (
size_t k = 0; k < nsp; k++) {
171 throw CanteraError(
"LTI_Solvent::getMixTransProp",
"You should be specifying the speciesWeight");
174 for (
size_t i = 0; i < nsp; i++) {
176 value += speciesValues[i] * speciesWeight[i];
182 for (
size_t j = 0; j < nsp; j++) {
183 for (
size_t k = 0; k < m_Aij.size(); k++) {
184 value += molefracs[i]*molefracs[j]*(*m_Aij[k])(i,j)*pow(molefracs[i], (
int) k);
186 for (
size_t k = 0; k < m_Bij.size(); k++) {
187 value += molefracs[i]*molefracs[j]*(*m_Bij[k])(i,j)*temp*pow(molefracs[i], (
int) k);
194 doublereal LTI_Solvent::getMixTransProp(std::vector<LTPspecies*> LTPptrs)
196 size_t nsp = m_thermo->nSpecies();
197 doublereal temp = m_thermo->temperature();
199 m_thermo->getMoleFractions(&molefracs[0]);
200 doublereal value = 0.0;
202 for (
size_t k = 0; k < nsp; k++) {
206 for (
size_t i = 0; i < nsp; i++) {
208 value += LTPptrs[i]->getSpeciesTransProp() * LTPptrs[i]->getMixWeight();
209 for (
size_t j = 0; j < nsp; j++) {
210 for (
size_t k = 0; k < m_Aij.size(); k++) {
211 value += molefracs[i]*molefracs[j]*(*m_Aij[k])(i,j)*pow(molefracs[i], (
int) k);
213 for (
size_t k = 0; k < m_Bij.size(); k++) {
214 value += molefracs[i]*molefracs[j]*(*m_Bij[k])(i,j)*temp*pow(molefracs[i], (
int) k);
221 void LTI_Solvent::getMatrixTransProp(DenseMatrix& mat, doublereal* speciesValues)
232 doublereal value = 0;
236 for (
size_t k = 0; k < nsp; k++) {
237 molefracs[k] = molefracs[k]*speciesWeight[k];
240 throw CanteraError(
"LTI_MoleFracs::getMixTransProp",
"You should be specifying the speciesWeight");
243 for (
size_t i = 0; i < nsp; i++) {
244 value += speciesValues[i] * molefracs[i];
245 for (
size_t j = 0; j < nsp; j++) {
246 for (
size_t k = 0; k <
m_Aij.size(); k++) {
247 value += molefracs[i]*molefracs[j]*(*
m_Aij[k])(i,j)*pow(molefracs[i], (
int) k);
249 for (
size_t k = 0; k <
m_Bij.size(); k++) {
250 value += molefracs[i]*molefracs[j]*(*
m_Bij[k])(i,j)*temp*pow(molefracs[i], (
int) k);
263 doublereal value = 0;
265 for (
size_t k = 0; k < nsp; k++) {
266 molefracs[k] = molefracs[k]*LTPptrs[k]->getMixWeight();
269 for (
size_t i = 0; i < nsp; i++) {
270 value += LTPptrs[i]->getSpeciesTransProp() * molefracs[i];
271 for (
size_t j = 0; j < nsp; j++) {
272 for (
size_t k = 0; k <
m_Aij.size(); k++) {
273 value += molefracs[i]*molefracs[j]*(*
m_Aij[k])(i,j)*pow(molefracs[i], (
int) k);
275 for (
size_t k = 0; k <
m_Bij.size(); k++) {
276 value += molefracs[i]*molefracs[j]*(*
m_Bij[k])(i,j)*temp*pow(molefracs[i], (
int) k);
289 doublereal value = 0;
293 for (
size_t k = 0; k < nsp; k++) {
294 massfracs[k] = massfracs[k]*speciesWeight[k];
297 throw CanteraError(
"LTI_MassFracs::getMixTransProp",
"You should be specifying the speciesWeight");
300 for (
size_t i = 0; i < nsp; i++) {
301 value += speciesValues[i] * massfracs[i];
302 for (
size_t j = 0; j < nsp; j++) {
303 for (
size_t k = 0; k <
m_Aij.size(); k++) {
304 value += massfracs[i]*massfracs[j]*(*
m_Aij[k])(i,j)*pow(massfracs[i], (
int) k);
306 for (
size_t k = 0; k <
m_Bij.size(); k++) {
307 value += massfracs[i]*massfracs[j]*(*
m_Bij[k])(i,j)*temp*pow(massfracs[i], (
int) k);
321 doublereal value = 0;
323 for (
size_t k = 0; k < nsp; k++) {
324 massfracs[k] = massfracs[k]*LTPptrs[k]->getMixWeight();
327 for (
size_t i = 0; i < nsp; i++) {
328 value += LTPptrs[i]->getSpeciesTransProp() * massfracs[i];
329 for (
size_t j = 0; j < nsp; j++) {
330 for (
size_t k = 0; k <
m_Aij.size(); k++) {
331 value += massfracs[i]*massfracs[j]*(*
m_Aij[k])(i,j)*pow(massfracs[i], (
int) k);
333 for (
size_t k = 0; k <
m_Bij.size(); k++) {
334 value += massfracs[i]*massfracs[j]*(*
m_Bij[k])(i,j)*temp*pow(massfracs[i], (
int) k);
347 doublereal value = 0;
351 for (
size_t k = 0; k < nsp; k++) {
352 molefracs[k] = molefracs[k]*speciesWeight[k];
355 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");
358 for (
size_t i = 0; i < nsp; i++) {
359 value += log(speciesValues[i]) * molefracs[i];
360 for (
size_t j = 0; j < nsp; j++) {
361 for (
size_t k = 0; k <
m_Hij.size(); k++) {
362 value += molefracs[i]*molefracs[j]*(*
m_Hij[k])(i,j)/temp*pow(molefracs[i], (
int) k);
364 for (
size_t k = 0; k <
m_Sij.size(); k++) {
365 value -= molefracs[i]*molefracs[j]*(*
m_Sij[k])(i,j)*pow(molefracs[i], (
int) k);
378 doublereal value = 0;
381 for (
size_t k = 0; k < nsp; k++) {
382 molefracs[k] = molefracs[k]*LTPptrs[k]->getMixWeight();
385 for (
size_t i = 0; i < nsp; i++) {
386 value += log(LTPptrs[i]->getSpeciesTransProp()) * molefracs[i];
387 for (
size_t j = 0; j < nsp; j++) {
388 for (
size_t k = 0; k <
m_Hij.size(); k++) {
389 value += molefracs[i]*molefracs[j]*(*
m_Hij[k])(i,j)/temp*pow(molefracs[i], (
int) k);
391 for (
size_t k = 0; k <
m_Sij.size(); k++) {
392 value -= molefracs[i]*molefracs[j]*(*
m_Sij[k])(i,j)*pow(molefracs[i], (
int) k);
399 void LTI_Pairwise_Interaction::setParameters(LiquidTransportParams& trParam)
402 m_diagonals.resize(nsp, 0);
404 for (
size_t k = 0; k < nsp; k++) {
405 LiquidTransportData& ltd = trParam.LTData[k];
406 if (ltd.speciesDiffusivity) {
407 m_diagonals[k] = ltd.speciesDiffusivity;
414 throw LTPmodelError(
"Calling LTI_Pairwise_Interaction::getMixTransProp does not make sense.");
419 throw LTPmodelError(
"Calling LTI_Pairwise_Interaction::getMixTransProp does not make sense.");
429 mat.
resize(nsp, nsp, 0.0);
430 for (
size_t i = 0; i < nsp; i++) {
431 for (
size_t j = 0; j < i; j++) {
432 mat(i,j) = mat(j,i) = exp(
m_Eij(i,j) / temp) /
m_Dij(i,j);
436 for (
size_t i = 0; i < nsp; i++) {
437 if (mat(i,i) == 0.0 && m_diagonals[i]) {
438 mat(i,i) = 1.0 / m_diagonals[i]->getSpeciesTransProp();
448 m_ionCondSpecies.resize(nsp,0);
449 m_mobRatMix.
resize(nsp,nsp,0.0);
450 m_mobRatMixModel.resize(nsp*nsp);
451 m_mobRatSpecies.resize(nsp*nsp);
452 m_selfDiffMix.resize(nsp,0.0);
453 m_selfDiffMixModel.resize(nsp);
454 m_selfDiffSpecies.resize(nsp);
456 for (
size_t k = 0; k < nsp*nsp; k++) {
458 m_mobRatSpecies[k].resize(nsp,0);
460 for (
size_t k = 0; k < nsp; k++) {
462 m_selfDiffSpecies[k].resize(nsp,0);
465 for (
size_t k = 0; k < nsp; k++) {
466 LiquidTransportData& ltd = trParam.
LTData[k];
467 m_ionCondSpecies[k] = ltd.ionConductivity;
468 for (
size_t j = 0; j < nsp*nsp; j++) {
469 m_mobRatSpecies[j][k] = ltd.mobilityRatio[j];
471 for (
size_t j = 0; j < nsp; j++) {
472 m_selfDiffSpecies[j][k] = ltd.selfDiffusion[j];
479 throw LTPmodelError(
"Calling LTI_StefanMaxwell_PPN::getMixTransProp does not make sense.");
484 throw LTPmodelError(
"Calling LTI_StefanMaxwell_PPN::getMixTransProp does not make sense.");
492 throw CanteraError(
"LTI_StefanMaxwell_PPN::getMatrixTransProp",
"Function may only be called with a 3-ion system");
499 vector<size_t> cation;
500 vector<size_t> anion;
507 std::vector<size_t> neutMolIndex(3);
510 if (anion.size() != 1) {
511 throw CanteraError(
"LTI_StefanMaxwell_PPN::getMatrixTransProp",
"Must have one anion only for StefanMaxwell_PPN");
513 if (cation.size() != 2) {
514 throw CanteraError(
"LTI_StefanMaxwell_PPN::getMatrixTransProp",
"Must have two cations of equal charge for StefanMaxwell_PPN");
516 if (charges[cation[0]] != charges[cation[1]]) {
517 throw CanteraError(
"LTI_StefanMaxwell_PPN::getMatrixTransProp",
"Cations must be of equal charge for StefanMaxwell_PPN");
525 for (
size_t j = 0; j < nsp; j++) {
526 for (
size_t i = 0; i < nsp; i++) {
527 if (m_mobRatMixModel[k]) {
528 m_mobRatMix(i,j) = m_mobRatMixModel[k]->getMixTransProp(m_mobRatSpecies[k]);
529 if (m_mobRatMix(i,j) > 0.0) {
530 m_mobRatMix(j,i) = 1.0/m_mobRatMix(i,j);
537 for (k = 0; k < nsp; k++) {
538 m_selfDiffMix[k] = m_selfDiffMixModel[k]->getMixTransProp(m_selfDiffSpecies[k]);
541 double vP = max(viS[cation[0]],viS[cation[1]]);
542 double vM = viS[anion[0]];
543 double zP = charges[cation[0]];
544 double zM = charges[anion[0]];
545 vector_fp dlnActCoeffdlnN_diag(neut_molefracs.size(),0.0);
548 double xA = neut_molefracs[neutMolIndex[cation[0]]];
549 double xB = neut_molefracs[neutMolIndex[cation[1]]];
550 double eps = (1-m_mobRatMix(cation[1],cation[0]))/(xA+xB*m_mobRatMix(cation[1],cation[0]));
551 double 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]]);
553 mat.
resize(nsp, nsp, 0.0);
554 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;
555 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;
556 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;
559 doublereal LTI_StokesEinstein::getMixTransProp(doublereal* speciesValues, doublereal* speciesWeight)
561 throw LTPmodelError(
"Calling LTI_StokesEinstein::getMixTransProp does not make sense.");
564 doublereal LTI_StokesEinstein::getMixTransProp(std::vector<LTPspecies*> LTPptrs)
566 throw LTPmodelError(
"Calling LTI_StokesEinstein::getMixTransProp does not make sense.");
569 void LTI_StokesEinstein::setParameters(LiquidTransportParams& trParam)
571 size_t nsp = m_thermo->nSpecies();
572 m_viscosity.resize(nsp, 0);
573 m_hydroRadius.resize(nsp, 0);
574 for (
size_t k = 0; k < nsp; k++) {
575 LiquidTransportData& ltd = trParam.LTData[k];
576 m_viscosity[k] = ltd.viscosity;
577 m_hydroRadius[k] = ltd.hydroRadius;
581 void LTI_StokesEinstein::getMatrixTransProp(DenseMatrix& mat, doublereal* speciesValues)
583 size_t nsp = m_thermo->nSpecies();
584 doublereal temp = m_thermo->temperature();
588 for (
size_t k = 0; k < nsp; k++) {
589 viscSpec[k] = m_viscosity[k]->getSpeciesTransProp();
590 radiusSpec[k] = m_hydroRadius[k]->getSpeciesTransProp();
593 mat.resize(nsp,nsp, 0.0);
594 for (
size_t i = 0; i < nsp; i++) {
595 for (
size_t j = 0; j < nsp; j++) {
596 mat(i,j) = (6.0 *
Pi * radiusSpec[i] * viscSpec[j]) /
GasConstant / temp;
607 doublereal value = 0;
611 for (
size_t k = 0; k < nsp; k++) {
612 molefracs[k] = molefracs[k]*speciesWeight[k];
615 throw CanteraError(
"LTI_MoleFracs_ExpT::getMixTransProp",
"You should be specifying the speciesWeight");
618 for (
size_t i = 0; i < nsp; i++) {
619 value += speciesValues[i] * molefracs[i];
620 for (
size_t j = 0; j < nsp; j++) {
621 for (
size_t k = 0; k <
m_Aij.size(); k++) {
622 value += molefracs[i]*molefracs[j]*(*
m_Aij[k])(i,j)*pow(molefracs[i], (
int) k)*exp((*
m_Bij[k])(i,j)*temp);
635 doublereal value = 0;
637 for (
size_t k = 0; k < nsp; k++) {
638 molefracs[k] = molefracs[k]*LTPptrs[k]->getMixWeight();
641 for (
size_t i = 0; i < nsp; i++) {
642 value += LTPptrs[i]->getSpeciesTransProp() * molefracs[i];
643 for (
size_t j = 0; j < nsp; j++) {
644 for (
size_t k = 0; k <
m_Aij.size(); k++) {
645 value += molefracs[i]*molefracs[j]*(*
m_Aij[k])(i,j)*pow(molefracs[i], (
int) k)*exp((*
m_Bij[k])(i,j)*temp);
doublereal molarVolume() const
Molar volume (m^3/kmol).
thermo_t * m_thermo
pointer to thermo object to get current temperature
doublereal getMixTransProp(doublereal *valueSpecies, doublereal *weightSpecies=0)
Return the mixture transport property value.
TransportPropertyType
Enumeration of the types of transport properties that can be handled by the variables in the various ...
LiquidTranMixingModel m_model
Model for species interaction effects. Takes enum LiquidTranMixingModel.
CTML ("Cantera Markup Language") is the variant of XML that Cantera uses to store data...
std::string name() const
Returns the name of the XML node.
std::vector< LiquidTranInteraction * > mobilityRatio
Vector of pointer to the LiquidTranInteraction object which handles the calculation of the mobility r...
void getMassFractions(doublereal *const y) const
Get the species mass fractions.
(see Thermodynamic Properties and class MargulesVPSSTP).
std::vector< DenseMatrix * > m_Hij
Matrix of interaction coefficients for polynomial in molefraction*weight of speciesA (in energy units...
doublereal temperature() const
Temperature (K).
size_t getFloatArray(const XML_Node &node, vector_fp &v, const bool convert, const std::string &unitsString, const std::string &nodeName)
This function reads the current node or a child node of the current node with the default name...
size_t speciesIndex(const std::string &name) const
Returns the index of a species named 'name' within the Phase object.
Header for intermediate ThermoPhase object for phases which consist of ions whose thermodynamics is c...
const size_t npos
index returned by functions to indicate "no position"
doublereal getMixTransProp(doublereal *valueSpecies, doublereal *weightSpecies=0)
Return the mixture transport property value.
std::vector< DenseMatrix * > m_Bij
Matrix of interaction coefficients for polynomial in molefraction*weight of speciesA (linear temperat...
std::vector< DenseMatrix * > m_Aij
Matrix of interaction coefficients for polynomial in molefraction*weight of speciesA (no temperature ...
Class XML_Node is a tree-based representation of the contents of an XML file.
void warn_deprecated(const std::string &method, const std::string &extra)
Print a warning indicating that method is deprecated.
size_t nSpecies() const
Returns the number of species in the phase.
virtual void getdlnActCoeffdlnN_diag(doublereal *dlnActCoeffdlnN_diag) const
Get the array of log species mole number derivatives of the log activity coefficients.
virtual doublereal getMixTransProp(doublereal *speciesValues, doublereal *weightSpecies=0)
Return the mixture transport property value.
void getMatrixTransProp(DenseMatrix &mat, doublereal *speciesValues=0)
Return the matrix of binary interaction parameters.
void getMatrixTransProp(DenseMatrix &mat, doublereal *speciesValues=0)
Return the matrix of binary interaction parameters.
std::vector< LiquidTransportData > LTData
Species transport parameters.
void getAnionList(std::vector< size_t > &anion) const
Get the list of anions in this object.
Base class for a phase with thermodynamic properties.
Class LiquidTransportParams holds transport model parameters relevant to transport in mixtures...
std::vector< LiquidTranInteraction * > selfDiffusion
Vector of pointer to the LiquidTranInteraction object which handles the calculation of each species' ...
Header file defining class LiquidTransportParams.
LiquidTranInteraction * ionConductivity
Object that specifies the ionic Conductivity of the mixture.
void resize(size_t n, size_t m, doublereal v=0.0)
Resize the matrix.
DenseMatrix m_Dij
Matrix of interactions.
bool caseInsensitiveEquals(const std::string &input, const std::string &test)
Case insensitive equality predicate.
Base class for exceptions thrown by Cantera classes.
Exception thrown if an error is encountered while reading the transport database. ...
std::vector< DenseMatrix * > m_Sij
Matrix of interaction coefficients for polynomial in molefraction*weight of speciesA (in entropy unit...
void getNeutralMolecMoleFractions(vector_fp &neutralMoleculeMoleFractions) const
Return the current value of the neutral mole fraction vector.
void getMoleFractions(doublereal *const x) const
Get the species mole fraction vector.
bool hasChild(const std::string &ch) const
Tests whether the current node has a child node with a particular name.
XML_Node & child(const size_t n) const
Return a changeable reference to the n'th child of the current node.
#define AssertTrace(expr)
Assertion must be true or an error is thrown.
std::string attrib(const std::string &attr) const
Function returns the value of an attribute.
std::vector< double > vector_fp
Turn on the use of stl vectors for the basic array type within cantera Vector of doubles.
doublereal getMixTransProp(doublereal *valueSpecies, doublereal *weightSpecies=0)
Return the mixture transport property value.
const doublereal GasConstant
Universal Gas Constant. [J/kmol/K].
doublereal getMixTransProp(doublereal *valueSpecies, doublereal *weightSpecies=0)
Return the mixture transport property value.
Contains declarations for string manipulation functions within Cantera.
doublereal getFloat(const XML_Node &parent, const std::string &name, const std::string &type)
Get a floating-point value from a child element.
MargulesVPSSTP is a derived class of GibbsExcessVPSSTP that employs the Margules approximation for th...
doublereal getMixTransProp(doublereal *valueSpecies, doublereal *weightSpecies=0)
Return the mixture transport property value.
void getCationList(std::vector< size_t > &cation) const
Get the list of cations in this object.
virtual void init(const XML_Node &compModelNode=XML_Node(), thermo_t *thermo=0)
initialize LiquidTranInteraction objects with thermo and XML node
void getDissociationCoeffs(vector_fp &fm_neutralMolec_ions, vector_fp &charges, std::vector< size_t > &neutMolIndex) const
Get the Salt Dissociation Coefficients.
Namespace for the Cantera kernel.
doublereal getMixTransProp(doublereal *valueSpecies, doublereal *weightSpecies=0)
Return the mixture transport property value.
DenseMatrix m_Eij
Matrix of interactions (in energy units, 1/RT temperature dependence)
Base class to handle transport property evaluation in a mixture.
size_t nChildren(bool discardComments=false) const
Return the number of children.
A class for full (non-sparse) matrices with Fortran-compatible data storage, which adds matrix operat...