25 MixedSolventElectrolyte::MixedSolventElectrolyte() :
27 numBinaryInteractions_(0),
34 const std::string& id_) :
36 numBinaryInteractions_(0),
44 const std::string& id_) :
46 numBinaryInteractions_(0),
97 numBinaryInteractions_(0),
138 throw CanteraError(
"MixedSolventElectrolyte test1 constructor",
139 "Unable to find LiCl(L)");
146 throw CanteraError(
"MixedSolventElectrolyte test1 constructor",
147 "Unable to find KCl(L)");
175 for (
size_t k = 0; k <
m_kk; k++) {
188 for (
size_t k = 0; k <
m_kk; k++) {
211 for (
size_t k = 0; k <
m_kk; k++) {
223 for (
size_t i = 0; i < kk; i++) {
235 for (
size_t i = 0; i < kk; i++) {
247 for (
size_t i = 0; i < kk; i++) {
269 for (
size_t k = 0; k <
m_kk; k++) {
279 for (
size_t k = 0; k <
m_kk; k++) {
298 for (
size_t k = 0; k <
m_kk; k++) {
304 for (
size_t k = 0; k <
m_kk; k++) {
324 for (
size_t k = 0; k <
m_kk; k++) {
331 for (
size_t k = 0; k <
m_kk; k++) {
336 void MixedSolventElectrolyte::getPartialMolarVolumes(doublereal* vbar)
const
339 double XA, XB, g0 , g1;
347 for (
size_t iK = 0; iK <
m_kk; iK++) {
366 vbar[iK] += XA*XB*(g0+g1*XB)+((delAK-XA)*XB+XA*(delBK-XB))*(g0+g1*XB)+XA*XB*(delBK-XB)*g1;
373 throw CanteraError(
"MixedSolventElectrolyte",
"Base class method "
392 string subname =
"MixedSolventElectrolyte::initThermoXML";
395 if ((
int) id_.size() > 0) {
396 string idp = phaseNode.
id();
398 throw CanteraError(subname,
"phasenode and Id are incompatible");
406 if (!phaseNode.
hasChild(
"thermo")) {
410 string mStringa = thermoNode.
attrib(
"model");
412 if (mString !=
"mixedsolventelectrolyte") {
413 throw CanteraError(subname,
"Unknown thermo model: " + mStringa);
421 if (thermoNode.
hasChild(
"activityCoefficients")) {
424 mStringa = acNode.
attrib(
"model");
426 if (mString !=
"margules") {
428 "Unknown activity coefficient model: " + mStringa);
431 for (
size_t i = 0; i < n; i++) {
433 stemp = xmlACChild.
name();
440 if (nodeName ==
"binaryneutralspeciesparameters") {
458 double XA, XB, g0, g1;
462 for (
size_t iK = 0; iK <
m_kk; iK++) {
477 lnActCoeff_Scaled_[iK] += (delAK * XB + XA * delBK - XA * XB) * (g0 + g1 * XB) + XA * XB * (delBK - XB) * g1;
485 doublereal XA, XB, g0, g1;
490 for (
size_t iK = 0; iK <
m_kk; iK++) {
505 double temp = (delAK * XB + XA * delBK - XA * XB) * (g0 + g1 * XB) + XA * XB * (delBK - XB) * g1;
515 for (
size_t k = 0; k <
m_kk; k++) {
523 for (
size_t k = 0; k <
m_kk; k++) {
529 doublereal* dlnActCoeffds)
const
532 double XA, XB, g0, g1, dXA, dXB;
539 for (
size_t iK = 0; iK <
m_kk; iK++) {
540 dlnActCoeffds[iK] = 0.0;
564 dlnActCoeffds[iK] += ((delBK-XB)*dXA + (delAK-XA)*dXB)*(g0+2*g1*XB) + (delBK-XB)*2*g1*XA*dXB
573 double XA, XB, XK, g0, g1;
579 for (
size_t iK = 0; iK <
m_kk; iK++) {
627 doublereal delAK, delBK;
628 double XA, XB, g0, g1,XM;
632 doublereal delAM, delBM;
638 for (
size_t iK = 0; iK <
m_kk; iK++) {
639 for (
size_t iM = 0; iM <
m_kk; iM++) {
667 dlnActCoeffdlnN_(iK,iM) += g0*((delAM-XA)*(delBK-XB)+(delAK-XA)*(delBM-XB));
668 dlnActCoeffdlnN_(iK,iM) += 2*g1*((delAM-XA)*(delBK-XB)*XB+(delAK-XA)*(delBM-XB)*XB+(delBM-XB)*(delBK-XB)*XA);
693 doublereal XA, XB, g0 , g1;
719 for (
size_t k = 0; k <
m_kk; k++) {
727 for (
size_t k = 0; k <
m_kk; k++) {
736 for (
size_t k = 0; k <
m_kk; k++) {
737 for (
size_t m = 0; m <
m_kk; m++) {
738 dlnActCoeffdlnN[ld * k + m] = data[m_kk * k + m];
766 string xname = xmLBinarySpecies.
name();
767 if (xname !=
"binaryNeutralSpeciesParameters") {
768 throw CanteraError(
"MixedSolventElectrolyte::readXMLBinarySpecies",
769 "Incorrect name for processing this routine: " + xname);
774 string iName = xmLBinarySpecies.
attrib(
"speciesA");
776 throw CanteraError(
"MixedSolventElectrolyte::readXMLBinarySpecies",
"no speciesA attrib");
778 string jName = xmLBinarySpecies.
attrib(
"speciesB");
780 throw CanteraError(
"MixedSolventElectrolyte::readXMLBinarySpecies",
"no speciesB attrib");
787 if (iSpecies ==
npos) {
791 if (
charge(iSpecies) != 0) {
792 throw CanteraError(
"MixedSolventElectrolyte::readXMLBinarySpecies",
"speciesA charge problem");
795 if (jSpecies ==
npos) {
799 if (
charge(jSpecies) != 0) {
800 throw CanteraError(
"MixedSolventElectrolyte::readXMLBinarySpecies",
"speciesB charge problem");
808 size_t num = xmLBinarySpecies.
nChildren();
809 for (
size_t iChild = 0; iChild < num; iChild++) {
811 stemp = xmlChild.
name();
816 if (nodeName ==
"excessenthalpy") {
821 nParamsFound = vParams.size();
823 if (nParamsFound != 2) {
824 throw CanteraError(
"MixedSolventElectrolyte::readXMLBinarySpecies::excessEnthalpy for " + ispName
826 "wrong number of params found");
832 if (nodeName ==
"excessentropy") {
837 nParamsFound = vParams.size();
839 if (nParamsFound != 2) {
840 throw CanteraError(
"MixedSolventElectrolyte::readXMLBinarySpecies::excessEntropy for " + ispName
842 "wrong number of params found");
848 if (nodeName ==
"excessvolume_enthalpy") {
853 nParamsFound = vParams.size();
855 if (nParamsFound != 2) {
856 throw CanteraError(
"MixedSolventElectrolyte::readXMLBinarySpecies::excessVolume_Enthalpy for " + ispName
858 "wrong number of params found");
864 if (nodeName ==
"excessvolume_entropy") {
869 nParamsFound = vParams.size();
871 if (nParamsFound != 2) {
872 throw CanteraError(
"MixedSolventElectrolyte::readXMLBinarySpecies::excessVolume_Entropy for " + ispName
874 "wrong number of params found");
virtual void getdlnActCoeffdlnN_diag(doublereal *dlnActCoeffdlnN_diag) const
Get the array of derivatives of the log activity coefficients wrt mole numbers - diagonal only...
void s_update_dlnActCoeff_dlnN_diag() const
Update the derivative of the log of the activity coefficients wrt log(moles) - diagonal only...
std::string int2str(const int n, const std::string &fmt)
Convert an int to a string using a format converter.
doublereal electricPotential() const
Returns the electric potential of this phase (V).
virtual void getPartialMolarEntropies(doublereal *sbar) const
Returns an array of partial molar entropies for the species in the mixture.
virtual void getPartialMolarEnthalpies(doublereal *hbar) const
Returns an array of partial molar enthalpies for the species in the mixture.
XML_Node * findXMLPhase(XML_Node *root, const std::string &idtarget)
Search an XML_Node tree for a named phase XML_Node.
std::string attrib(const std::string &attr) const
Function returns the value of an attribute.
void s_update_dlnActCoeff_dlnN() const
Update the derivative of the log of the activity coefficients wrt log(moles_m)
void resize(size_t n, size_t m, doublereal v=0.0)
Resize the array, and fill the new entries with 'v'.
virtual void getd2lnActCoeffdT2(doublereal *d2lnActCoeffdT2) const
Get the array of temperature second derivatives of the log activity coefficients. ...
void s_update_dlnActCoeff_dlnX_diag() const
Update the derivative of the log of the activity coefficients wrt log(mole fraction) ...
void s_update_lnActCoeff() const
Update the activity coefficients.
virtual ThermoPhase * duplMyselfAsThermoPhase() const
Duplication routine for objects which inherit from ThermoPhase.
virtual void getStandardVolumes(doublereal *vol) const
Get the molar volumes of each species in their standard states at the current T and P of the solution...
const size_t npos
index returned by functions to indicate "no position"
virtual void getCp_R(doublereal *cpr) const
Get the nondimensional Heat Capacities at constant pressure for the standard state of the species at ...
vector_fp m_HE_d_ij
Enthalpy term for the quaternary mole fraction interaction of the excess gibbs free energy expression...
Headers for the factory class that can create known ThermoPhase objects (see Thermodynamic Properties...
Class XML_Node is a tree-based representation of the contents of an XML file.
vector_fp m_SE_b_ij
Entropy term for the binary mole fraction interaction of the excess gibbs free energy expression...
std::string lowercase(const std::string &s)
Cast a copy of a string to lower case.
std::vector< doublereal > d2lnActCoeffdT2_Scaled_
Storage for the current derivative values of the gradients with respect to temperature of the log of ...
std::vector< doublereal > dlnActCoeffdlnN_diag_
Storage for the current derivative values of the gradients with respect to logarithm of the mole frac...
MolarityIonicVPSSTP & operator=(const MolarityIonicVPSSTP &b)
Assignment operator.
virtual doublereal entropy_mole() const
Molar entropy. Units: J/kmol.
XML_Node & child(const size_t n) const
Return a changeable reference to the n'th child of the current node.
virtual void getChemPotentials(doublereal *mu) const
Get the species chemical potentials. Units: J/kmol.
Base class for a phase with thermodynamic properties.
void readXMLBinarySpecies(XML_Node &xmlBinarySpecies)
Process an XML node called "binaryNeutralSpeciesParameters".
size_t speciesIndex(const std::string &name) const
Returns the index of a species named 'name' within the Phase object.
bool importPhase(XML_Node &phase, ThermoPhase *th, SpeciesThermoFactory *spfactory)
Import a phase information into an empty thermophase object.
virtual void getdlnActCoeffds(const doublereal dTds, const doublereal *const dXds, doublereal *dlnActCoeffds) const
Get the change in activity coefficients w.r.t.
void initThermoXML(XML_Node &phaseNode, const std::string &id)
Import and initialize a ThermoPhase object.
virtual void getPartialMolarCp(doublereal *cpbar) const
Returns an array of partial molar entropies for the species in the mixture.
void initLengths()
Initialize lengths of local variables after all species have been identified.
int formTempModel_
form of the temperature dependence of the Margules interaction expression
virtual void getdlnActCoeffdlnX_diag(doublereal *dlnActCoeffdlnX_diag) const
Get the array of log concentration-like derivatives of the log activity coefficients - diagonal compo...
void s_update_dlnActCoeff_dT() const
Update the derivative of the log of the activity coefficients wrt T.
vector_fp m_HE_b_ij
Enthalpy term for the binary mole fraction interaction of the excess gibbs free energy expression...
void initThermoXML(XML_Node &phaseNode, const std::string &id)
Import and initialize a ThermoPhase object.
virtual void initThermo()
MixedSolventElectrolyte is a derived class of GibbsExcessVPSSTP that employs the DH and local Margule...
virtual void getdlnActCoeffdlnN(const size_t ld, doublereal *const dlnActCoeffdlnN)
Get the array of derivatives of the log activity coefficients with respect to the ln species mole num...
vector_fp m_VHE_d_ij
Enthalpy term for the quaternary mole fraction interaction of the excess gibbs free energy expression...
std::string name() const
Returns the name of the XML node.
void resizeNumInteractions(const size_t num)
Resize internal arrays within the object that depend upon the number of binary Margules interaction t...
virtual doublereal cv_mole() const
Molar heat capacity at constant volume. Units: J/kmol/K.
virtual void getActivityCoefficients(doublereal *ac) const
Get the array of non-dimensional molar-based activity coefficients at the current solution temperatur...
Base class for exceptions thrown by Cantera classes.
vector_fp m_VHE_b_ij
Enthalpy term for the binary mole fraction interaction of the excess gibbs free energy expression...
int formMargules_
form of the Margules interaction expression
vector_fp m_VHE_c_ij
Enthalpy term for the ternary mole fraction interaction of the excess gibbs free energy expression...
bool hasChild(const std::string &ch) const
Tests whether the current node has a child node with a particular name.
doublereal err(const std::string &msg) const
Error function.
virtual void initThermo()
virtual void getdlnActCoeffdT(doublereal *dlnActCoeffdT) const
Get the array of temperature derivatives of the log activity coefficients.
void getElectrochemPotentials(doublereal *mu) const
Get the species electrochemical potentials.
vector_fp m_VSE_c_ij
Entropy term for the ternary mole fraction interaction of the excess gibbs free energy expression...
vector_fp m_VSE_d_ij
Entropy term for the quaternary mole fraction interaction of the excess gibbs free energy expression...
std::vector< size_t > m_pSpecies_B_ij
vector of species indices representing species B in the interaction
vector_fp m_SE_c_ij
Entropy term for the ternary mole fraction interaction of the excess gibbs free energy expression...
vector_fp m_HE_c_ij
Enthalpy term for the ternary mole fraction interaction of the excess gibbs free energy expression...
size_t numBinaryInteractions_
number of binary interaction expressions
size_t nSpecies() const
Returns the number of species in the phase.
virtual doublereal enthalpy_mole() const
Molar enthalpy. Units: J/kmol.
std::vector< size_t > m_pSpecies_A_ij
vector of species indices representing species A in the interaction
std::vector< doublereal > dlnActCoeffdlnX_diag_
Storage for the current derivative values of the gradients with respect to logarithm of the mole frac...
virtual void getEntropy_R(doublereal *sr) const
Get the array of nondimensional Enthalpy functions for the standard state species at the current T an...
doublereal temperature() const
Temperature (K).
std::string id() const
Return the id attribute, if present.
const doublereal SmallNumber
smallest number to compare to zero.
std::vector< doublereal > lnActCoeff_Scaled_
Storage for the current values of the activity coefficients of the species.
std::vector< double > vector_fp
Turn on the use of stl vectors for the basic array type within cantera Vector of doubles.
std::vector< doublereal > moleFractions_
Storage for the current values of the mole fractions of the species.
virtual void getEnthalpy_RT(doublereal *hrt) const
Get the nondimensional Enthalpy functions for the species at their standard states at the current T a...
virtual int eosType() const
Equation of state type flag.
const doublereal GasConstant
Universal Gas Constant. [J/kmol/K].
Contains declarations for string manipulation functions within Cantera.
size_t m_kk
Number of species in the phase.
Array2D dlnActCoeffdlnN_
Storage for the current derivative values of the gradients with respect to logarithm of the species m...
virtual doublereal cp_mole() const
Molar heat capacity at constant pressure. Units: J/kmol/K.
vector_fp m_SE_d_ij
Entropy term for the quaternary mole fraction interaction of the excess gibbs free energy expression...
void zero()
Set all of the entries to zero.
virtual void initThermoFile(const std::string &inputFile, const std::string &id)
MixedSolventElectrolyte & operator=(const MixedSolventElectrolyte &b)
Assignment operator.
vector_fp m_VSE_b_ij
Entropy term for the binary mole fraction interaction of the excess gibbs free energy expression...
virtual void getStandardChemPotentials(doublereal *mu) const
Get the array of chemical potentials at unit activity.
MixedSolventElectrolyte()
Constructor.
Header for intermediate ThermoPhase object for phases which employ gibbs excess free energy based for...
std::string speciesName(size_t k) const
Name of the species with index k.
size_t getFloatArray(const Cantera::XML_Node &node, std::vector< doublereal > &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 nChildren(bool discardComments=false) const
Return the number of children.
std::vector< doublereal > dlnActCoeffdT_Scaled_
Storage for the current derivative values of the gradients with respect to temperature of the log of ...
doublereal charge(size_t k) const
Dimensionless electrical charge of a single molecule of species k The charge is normalized by the the...