29 "error parsing transport data: " 34 m_model(LTI_MODEL_NOTSET),
39 LiquidTranInteraction::~LiquidTranInteraction()
41 for (
size_t k = 0; k <
m_Aij.size(); k++) {
44 for (
size_t k = 0; k <
m_Bij.size(); k++) {
47 for (
size_t k = 0; k <
m_Hij.size(); k++) {
50 for (
size_t k = 0; k <
m_Sij.size(); k++) {
63 for (
size_t iChild = 0; iChild < compModelNode.
nChildren(); iChild++) {
65 std::string nodeName = xmlChild.
name();
66 if (!ba::iequals(nodeName,
"interaction")) {
67 throw CanteraError(
"TransportFactory::getLiquidInteractionsTransportData",
68 "expected <interaction> element and got <" + nodeName +
">");
70 string speciesA = xmlChild.
attrib(
"speciesA");
71 string speciesB = xmlChild.
attrib(
"speciesB");
73 if (iSpecies ==
npos) {
74 throw CanteraError(
"TransportFactory::getLiquidInteractionsTransportData",
75 "Unknown species " + speciesA);
78 if (jSpecies ==
npos) {
79 throw CanteraError(
"TransportFactory::getLiquidInteractionsTransportData",
80 "Unknown species " + speciesB);
84 m_Eij(iSpecies,jSpecies) =
getFloat(xmlChild,
"Eij",
"actEnergy");
86 m_Eij(jSpecies,iSpecies) =
m_Eij(iSpecies,jSpecies);
92 while (
m_Aij.size()<poly.size()) {
94 aTemp->
resize(nsp, nsp, 0.0);
95 m_Aij.push_back(aTemp);
97 for (
int i = 0; i < (int)poly.size(); i++) {
98 (*
m_Aij[i])(iSpecies,jSpecies) = poly[i];
105 while (
m_Bij.size() < poly.size()) {
107 bTemp->
resize(nsp, nsp, 0.0);
108 m_Bij.push_back(bTemp);
110 for (
size_t i=0; i<poly.size(); i++) {
111 (*
m_Bij[i])(iSpecies,jSpecies) = poly[i];
118 while (
m_Hij.size()<poly.size()) {
120 hTemp->
resize(nsp, nsp, 0.0);
121 m_Hij.push_back(hTemp);
123 for (
size_t i=0; i<poly.size(); i++) {
124 (*
m_Hij[i])(iSpecies,jSpecies) = poly[i];
132 while (
m_Sij.size()<poly.size()) {
134 sTemp->
resize(nsp, nsp, 0.0);
135 m_Sij.push_back(sTemp);
137 for (
size_t i=0; i<poly.size(); i++) {
138 (*
m_Sij[i])(iSpecies,jSpecies) = poly[i];
144 m_Dij(iSpecies,jSpecies) =
getFloat(xmlChild,
"Dij",
"toSI");
145 m_Dij(jSpecies,iSpecies) =
m_Dij(iSpecies,jSpecies);
156 doublereal LTI_Solvent::getMixTransProp(doublereal* speciesValues, doublereal* speciesWeight)
158 size_t nsp = m_thermo->nSpecies();
159 doublereal temp = m_thermo->temperature();
161 m_thermo->getMoleFractions(&molefracs[0]);
162 doublereal value = 0.0;
166 for (
size_t k = 0; k < nsp; k++) {
170 throw CanteraError(
"LTI_Solvent::getMixTransProp",
"You should be specifying the speciesWeight");
173 for (
size_t i = 0; i < nsp; i++) {
175 value += speciesValues[i] * speciesWeight[i];
181 for (
size_t j = 0; j < nsp; j++) {
182 for (
size_t k = 0; k < m_Aij.size(); k++) {
183 value += molefracs[i]*molefracs[j]*(*m_Aij[k])(i,j)*pow(molefracs[i], (
int) k);
185 for (
size_t k = 0; k < m_Bij.size(); k++) {
186 value += molefracs[i]*molefracs[j]*(*m_Bij[k])(i,j)*temp*pow(molefracs[i], (
int) k);
193 doublereal LTI_Solvent::getMixTransProp(std::vector<LTPspecies*> LTPptrs)
195 size_t nsp = m_thermo->nSpecies();
196 doublereal temp = m_thermo->temperature();
198 m_thermo->getMoleFractions(&molefracs[0]);
199 doublereal value = 0.0;
201 for (
size_t k = 0; k < nsp; k++) {
205 for (
size_t i = 0; i < nsp; i++) {
207 value += LTPptrs[i]->getSpeciesTransProp() * LTPptrs[i]->getMixWeight();
208 for (
size_t j = 0; j < nsp; j++) {
209 for (
size_t k = 0; k < m_Aij.size(); k++) {
210 value += molefracs[i]*molefracs[j]*(*m_Aij[k])(i,j)*pow(molefracs[i], (
int) k);
212 for (
size_t k = 0; k < m_Bij.size(); k++) {
213 value += molefracs[i]*molefracs[j]*(*m_Bij[k])(i,j)*temp*pow(molefracs[i], (
int) k);
220 void LTI_Solvent::getMatrixTransProp(DenseMatrix& mat, doublereal* speciesValues)
231 doublereal value = 0;
235 for (
size_t k = 0; k < nsp; k++) {
236 molefracs[k] = molefracs[k]*speciesWeight[k];
239 throw CanteraError(
"LTI_MoleFracs::getMixTransProp",
"You should be specifying the speciesWeight");
242 for (
size_t i = 0; i < nsp; i++) {
243 value += speciesValues[i] * molefracs[i];
244 for (
size_t j = 0; j < nsp; j++) {
245 for (
size_t k = 0; k <
m_Aij.size(); k++) {
246 value += molefracs[i]*molefracs[j]*(*
m_Aij[k])(i,j)*pow(molefracs[i], (
int) k);
248 for (
size_t k = 0; k <
m_Bij.size(); k++) {
249 value += molefracs[i]*molefracs[j]*(*
m_Bij[k])(i,j)*temp*pow(molefracs[i], (
int) k);
262 doublereal value = 0;
264 for (
size_t k = 0; k < nsp; k++) {
265 molefracs[k] = molefracs[k]*LTPptrs[k]->getMixWeight();
268 for (
size_t i = 0; i < nsp; i++) {
269 value += LTPptrs[i]->getSpeciesTransProp() * molefracs[i];
270 for (
size_t j = 0; j < nsp; j++) {
271 for (
size_t k = 0; k <
m_Aij.size(); k++) {
272 value += molefracs[i]*molefracs[j]*(*
m_Aij[k])(i,j)*pow(molefracs[i], (
int) k);
274 for (
size_t k = 0; k <
m_Bij.size(); k++) {
275 value += molefracs[i]*molefracs[j]*(*
m_Bij[k])(i,j)*temp*pow(molefracs[i], (
int) k);
288 doublereal value = 0;
292 for (
size_t k = 0; k < nsp; k++) {
293 massfracs[k] = massfracs[k]*speciesWeight[k];
296 throw CanteraError(
"LTI_MassFracs::getMixTransProp",
"You should be specifying the speciesWeight");
299 for (
size_t i = 0; i < nsp; i++) {
300 value += speciesValues[i] * massfracs[i];
301 for (
size_t j = 0; j < nsp; j++) {
302 for (
size_t k = 0; k <
m_Aij.size(); k++) {
303 value += massfracs[i]*massfracs[j]*(*
m_Aij[k])(i,j)*pow(massfracs[i], (
int) k);
305 for (
size_t k = 0; k <
m_Bij.size(); k++) {
306 value += massfracs[i]*massfracs[j]*(*
m_Bij[k])(i,j)*temp*pow(massfracs[i], (
int) k);
320 doublereal value = 0;
322 for (
size_t k = 0; k < nsp; k++) {
323 massfracs[k] = massfracs[k]*LTPptrs[k]->getMixWeight();
326 for (
size_t i = 0; i < nsp; i++) {
327 value += LTPptrs[i]->getSpeciesTransProp() * massfracs[i];
328 for (
size_t j = 0; j < nsp; j++) {
329 for (
size_t k = 0; k <
m_Aij.size(); k++) {
330 value += massfracs[i]*massfracs[j]*(*
m_Aij[k])(i,j)*pow(massfracs[i], (
int) k);
332 for (
size_t k = 0; k <
m_Bij.size(); k++) {
333 value += massfracs[i]*massfracs[j]*(*
m_Bij[k])(i,j)*temp*pow(massfracs[i], (
int) k);
346 doublereal value = 0;
350 for (
size_t k = 0; k < nsp; k++) {
351 molefracs[k] = molefracs[k]*speciesWeight[k];
354 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");
357 for (
size_t i = 0; i < nsp; i++) {
358 value += log(speciesValues[i]) * molefracs[i];
359 for (
size_t j = 0; j < nsp; j++) {
360 for (
size_t k = 0; k <
m_Hij.size(); k++) {
361 value += molefracs[i]*molefracs[j]*(*
m_Hij[k])(i,j)/temp*pow(molefracs[i], (
int) k);
363 for (
size_t k = 0; k <
m_Sij.size(); k++) {
364 value -= molefracs[i]*molefracs[j]*(*
m_Sij[k])(i,j)*pow(molefracs[i], (
int) k);
377 doublereal value = 0;
380 for (
size_t k = 0; k < nsp; k++) {
381 molefracs[k] = molefracs[k]*LTPptrs[k]->getMixWeight();
384 for (
size_t i = 0; i < nsp; i++) {
385 value += log(LTPptrs[i]->getSpeciesTransProp()) * molefracs[i];
386 for (
size_t j = 0; j < nsp; j++) {
387 for (
size_t k = 0; k <
m_Hij.size(); k++) {
388 value += molefracs[i]*molefracs[j]*(*
m_Hij[k])(i,j)/temp*pow(molefracs[i], (
int) k);
390 for (
size_t k = 0; k <
m_Sij.size(); k++) {
391 value -= molefracs[i]*molefracs[j]*(*
m_Sij[k])(i,j)*pow(molefracs[i], (
int) k);
398 void LTI_Pairwise_Interaction::setParameters(LiquidTransportParams& trParam)
401 m_diagonals.resize(nsp, 0);
403 for (
size_t k = 0; k < nsp; k++) {
404 LiquidTransportData& ltd = trParam.LTData[k];
405 if (ltd.speciesDiffusivity) {
406 m_diagonals[k] = ltd.speciesDiffusivity;
413 throw LTPmodelError(
"Calling LTI_Pairwise_Interaction::getMixTransProp does not make sense.");
418 throw LTPmodelError(
"Calling LTI_Pairwise_Interaction::getMixTransProp does not make sense.");
428 mat.
resize(nsp, nsp, 0.0);
429 for (
size_t i = 0; i < nsp; i++) {
430 for (
size_t j = 0; j < i; j++) {
431 mat(i,j) = mat(j,i) = exp(
m_Eij(i,j) / temp) /
m_Dij(i,j);
435 for (
size_t i = 0; i < nsp; i++) {
436 if (mat(i,i) == 0.0 && m_diagonals[i]) {
437 mat(i,i) = 1.0 / m_diagonals[i]->getSpeciesTransProp();
447 m_ionCondSpecies.resize(nsp,0);
448 m_mobRatMix.
resize(nsp,nsp,0.0);
449 m_mobRatMixModel.resize(nsp*nsp);
450 m_mobRatSpecies.resize(nsp*nsp);
451 m_selfDiffMix.resize(nsp,0.0);
452 m_selfDiffMixModel.resize(nsp);
453 m_selfDiffSpecies.resize(nsp);
455 for (
size_t k = 0; k < nsp*nsp; k++) {
457 m_mobRatSpecies[k].resize(nsp,0);
459 for (
size_t k = 0; k < nsp; k++) {
461 m_selfDiffSpecies[k].resize(nsp,0);
464 for (
size_t k = 0; k < nsp; k++) {
465 LiquidTransportData& ltd = trParam.
LTData[k];
466 m_ionCondSpecies[k] = ltd.ionConductivity;
467 for (
size_t j = 0; j < nsp*nsp; j++) {
468 m_mobRatSpecies[j][k] = ltd.mobilityRatio[j];
470 for (
size_t j = 0; j < nsp; j++) {
471 m_selfDiffSpecies[j][k] = ltd.selfDiffusion[j];
478 throw LTPmodelError(
"Calling LTI_StefanMaxwell_PPN::getMixTransProp does not make sense.");
483 throw LTPmodelError(
"Calling LTI_StefanMaxwell_PPN::getMixTransProp does not make sense.");
491 throw CanteraError(
"LTI_StefanMaxwell_PPN::getMatrixTransProp",
"Function may only be called with a 3-ion system");
498 vector<size_t> cation;
499 vector<size_t> anion;
506 std::vector<size_t> neutMolIndex(3);
509 if (anion.size() != 1) {
510 throw CanteraError(
"LTI_StefanMaxwell_PPN::getMatrixTransProp",
"Must have one anion only for StefanMaxwell_PPN");
512 if (cation.size() != 2) {
513 throw CanteraError(
"LTI_StefanMaxwell_PPN::getMatrixTransProp",
"Must have two cations of equal charge for StefanMaxwell_PPN");
515 if (charges[cation[0]] != charges[cation[1]]) {
516 throw CanteraError(
"LTI_StefanMaxwell_PPN::getMatrixTransProp",
"Cations must be of equal charge for StefanMaxwell_PPN");
524 for (
size_t j = 0; j < nsp; j++) {
525 for (
size_t i = 0; i < nsp; i++) {
526 if (m_mobRatMixModel[k]) {
527 m_mobRatMix(i,j) = m_mobRatMixModel[k]->getMixTransProp(m_mobRatSpecies[k]);
528 if (m_mobRatMix(i,j) > 0.0) {
529 m_mobRatMix(j,i) = 1.0/m_mobRatMix(i,j);
536 for (k = 0; k < nsp; k++) {
537 m_selfDiffMix[k] = m_selfDiffMixModel[k]->getMixTransProp(m_selfDiffSpecies[k]);
540 double vP = max(viS[cation[0]],viS[cation[1]]);
541 double vM = viS[anion[0]];
542 double zP = charges[cation[0]];
543 double zM = charges[anion[0]];
544 vector_fp dlnActCoeffdlnN_diag(neut_molefracs.size(),0.0);
547 double xA = neut_molefracs[neutMolIndex[cation[0]]];
548 double xB = neut_molefracs[neutMolIndex[cation[1]]];
549 double eps = (1-m_mobRatMix(cation[1],cation[0]))/(xA+xB*m_mobRatMix(cation[1],cation[0]));
550 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]]);
552 mat.
resize(nsp, nsp, 0.0);
553 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;
554 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;
555 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;
558 doublereal LTI_StokesEinstein::getMixTransProp(doublereal* speciesValues, doublereal* speciesWeight)
560 throw LTPmodelError(
"Calling LTI_StokesEinstein::getMixTransProp does not make sense.");
563 doublereal LTI_StokesEinstein::getMixTransProp(std::vector<LTPspecies*> LTPptrs)
565 throw LTPmodelError(
"Calling LTI_StokesEinstein::getMixTransProp does not make sense.");
568 void LTI_StokesEinstein::setParameters(LiquidTransportParams& trParam)
570 size_t nsp = m_thermo->nSpecies();
571 m_viscosity.resize(nsp, 0);
572 m_hydroRadius.resize(nsp, 0);
573 for (
size_t k = 0; k < nsp; k++) {
574 LiquidTransportData& ltd = trParam.LTData[k];
575 m_viscosity[k] = ltd.viscosity;
576 m_hydroRadius[k] = ltd.hydroRadius;
580 void LTI_StokesEinstein::getMatrixTransProp(DenseMatrix& mat, doublereal* speciesValues)
582 size_t nsp = m_thermo->nSpecies();
583 doublereal temp = m_thermo->temperature();
587 for (
size_t k = 0; k < nsp; k++) {
588 viscSpec[k] = m_viscosity[k]->getSpeciesTransProp();
589 radiusSpec[k] = m_hydroRadius[k]->getSpeciesTransProp();
592 mat.resize(nsp,nsp, 0.0);
593 for (
size_t i = 0; i < nsp; i++) {
594 for (
size_t j = 0; j < nsp; j++) {
595 mat(i,j) = (6.0 *
Pi * radiusSpec[i] * viscSpec[j]) /
GasConstant / temp;
606 doublereal value = 0;
610 for (
size_t k = 0; k < nsp; k++) {
611 molefracs[k] = molefracs[k]*speciesWeight[k];
614 throw CanteraError(
"LTI_MoleFracs_ExpT::getMixTransProp",
"You should be specifying the speciesWeight");
617 for (
size_t i = 0; i < nsp; i++) {
618 value += speciesValues[i] * molefracs[i];
619 for (
size_t j = 0; j < nsp; j++) {
620 for (
size_t k = 0; k <
m_Aij.size(); k++) {
621 value += molefracs[i]*molefracs[j]*(*
m_Aij[k])(i,j)*pow(molefracs[i], (
int) k)*exp((*
m_Bij[k])(i,j)*temp);
634 doublereal value = 0;
636 for (
size_t k = 0; k < nsp; k++) {
637 molefracs[k] = molefracs[k]*LTPptrs[k]->getMixWeight();
640 for (
size_t i = 0; i < nsp; i++) {
641 value += LTPptrs[i]->getSpeciesTransProp() * molefracs[i];
642 for (
size_t j = 0; j < nsp; j++) {
643 for (
size_t k = 0; k <
m_Aij.size(); k++) {
644 value += molefracs[i]*molefracs[j]*(*
m_Aij[k])(i,j)*pow(molefracs[i], (
int) k)*exp((*
m_Bij[k])(i,j)*temp);
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...
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 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.
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.
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.
ThermoPhase * neutralMoleculePhase_
This is a pointer to the neutral Molecule Phase.
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...