19 PhaseCombo_Interaction::PhaseCombo_Interaction() :
20 numBinaryInteractions_(0),
27 const std::string& id_) :
28 numBinaryInteractions_(0),
36 const std::string& id_) :
37 numBinaryInteractions_(0),
86 numBinaryInteractions_(0),
90 warn_deprecated(
"PhaseCombo_Interaction::PhaseCombo_Interaction(int testProb)",
91 "To be removed after Cantera 2.2");
130 throw CanteraError(
"PhaseCombo_Interaction test1 constructor",
131 "Unable to find LiTFe1S2(S)");
138 throw CanteraError(
"PhaseCombo_Interaction test1 constructor",
139 "Unable to find Li2Fe1S2(S)");
142 throw CanteraError(
"PhaseCombo_Interaction test1 constructor",
"unimplemented");
151 return cPhaseCombo_Interaction;
168 for (
size_t k = 0; k <
m_kk; k++) {
181 for (
size_t k = 0; k <
m_kk; k++) {
201 for (
size_t k = 0; k <
m_kk; k++) {
212 for (
size_t i = 0; i <
m_kk; i++) {
223 for (
size_t i = 0; i <
m_kk; i++) {
234 for (
size_t i = 0; i <
m_kk; i++) {
255 for (
size_t k = 0; k <
m_kk; k++) {
264 for (
size_t k = 0; k <
m_kk; k++) {
283 for (
size_t k = 0; k <
m_kk; k++) {
289 for (
size_t k = 0; k <
m_kk; k++) {
308 for (
size_t k = 0; k <
m_kk; k++) {
315 for (
size_t k = 0; k <
m_kk; k++) {
329 for (
size_t iK = 0; iK <
m_kk; iK++) {
349 vbar[iK] += XA*XB*(g0+g1*XB)+((delAK-XA)*XB+XA*(delBK-XB))*(g0+g1*XB)+XA*XB*(delBK-XB)*g1;
367 if ((
int)
id.
size() > 0 && phaseNode.
id() !=
id) {
368 throw CanteraError(
"PhaseCombo_Interaction::initThermoXML",
369 "phasenode and Id are incompatible");
376 if (!phaseNode.
hasChild(
"thermo")) {
377 throw CanteraError(
"PhaseCombo_Interaction::initThermoXML",
378 "no thermo XML node");
382 if (formString !=
"phasecombo_interaction") {
383 throw CanteraError(
"PhaseCombo_Interaction::initThermoXML",
384 "model name isn't PhaseCombo_Interaction: " + formString);
391 if (thermoNode.
hasChild(
"activityCoefficients")) {
393 string mString = acNode.
attrib(
"model");
395 throw CanteraError(
"PhaseCombo_Interaction::initThermoXML",
396 "Unknown activity coefficient model: " + mString);
398 for (
size_t i = 0; i < acNode.
nChildren(); i++) {
405 if (
lowercase(xmlACChild.
name()) ==
"binaryneutralspeciesparameters") {
425 for (
size_t iK = 0; iK <
m_kk; iK++) {
452 lnActCoeff_Scaled_[iK] += (delAK * XB + XA * delBK - XA * XB) * (g0 + g1 * XB) + XA * XB * (delBK - XB) * g1;
462 for (
size_t iK = 0; iK <
m_kk; iK++) {
477 double temp = (delAK * XB + XA * delBK - XA * XB) * (g0 + g1 * XB) + XA * XB * (delBK - XB) * g1;
487 for (
size_t k = 0; k <
m_kk; k++) {
495 for (
size_t k = 0; k <
m_kk; k++) {
501 doublereal* dlnActCoeffds)
const
506 for (
size_t iK = 0; iK <
m_kk; iK++) {
515 dlnActCoeffds[iK] += - 1.0 / xx;
534 double dXA = dXds[iA];
535 double dXB = dXds[iB];
540 dlnActCoeffds[iK] += ((delBK-XB)*dXA + (delAK-XA)*dXB)*(g0+2*g1*XB) + (delBK-XB)*2*g1*XA*dXB
551 for (
size_t iK = 0; iK <
m_kk; iK++) {
599 for (
size_t iK = 0; iK <
m_kk; iK++) {
605 for (
size_t iM = 0; iM <
m_kk; iM++) {
642 dlnActCoeffdlnN_(iK,iM) += g0*((delAM-XA)*(delBK-XB)+(delAK-XA)*(delBM-XB));
643 dlnActCoeffdlnN_(iK,iM) += 2*g1*((delAM-XA)*(delBK-XB)*XB+(delAK-XA)*(delBM-XB)*XB+(delBM-XB)*(delBK-XB)*XA);
668 throw CanteraError(
"PhaseCombo_Interaction::s_update_dlnActCoeff_dlnX_diag",
"unimplemented");
674 for (
size_t k = 0; k <
m_kk; k++) {
682 for (
size_t k = 0; k <
m_kk; k++) {
691 for (
size_t k = 0; k <
m_kk; k++) {
692 for (
size_t m = 0; m <
m_kk; m++) {
693 dlnActCoeffdlnN[ld * k + m] = data[m_kk * k + m];
720 string xname = xmLBinarySpecies.
name();
721 if (xname !=
"binaryNeutralSpeciesParameters") {
722 throw CanteraError(
"PhaseCombo_Interaction::readXMLBinarySpecies",
723 "Incorrect name for processing this routine: " + xname);
726 string iName = xmLBinarySpecies.
attrib(
"speciesA");
728 throw CanteraError(
"PhaseCombo_Interaction::readXMLBinarySpecies",
"no speciesA attrib");
730 string jName = xmLBinarySpecies.
attrib(
"speciesB");
732 throw CanteraError(
"PhaseCombo_Interaction::readXMLBinarySpecies",
"no speciesB attrib");
739 if (iSpecies ==
npos) {
743 if (
charge(iSpecies) != 0) {
744 throw CanteraError(
"PhaseCombo_Interaction::readXMLBinarySpecies",
"speciesA charge problem");
747 if (jSpecies ==
npos) {
751 if (
charge(jSpecies) != 0) {
752 throw CanteraError(
"PhaseCombo_Interaction::readXMLBinarySpecies",
"speciesB charge problem");
760 for (
size_t iChild = 0; iChild < xmLBinarySpecies.
nChildren(); iChild++) {
766 if (nodeName ==
"excessenthalpy") {
770 getFloatArray(xmlChild, vParams,
true,
"toSI",
"excessEnthalpy");
771 if (vParams.size() != 2) {
772 throw CanteraError(
"PhaseCombo_Interaction::readXMLBinarySpecies::excessEnthalpy for " + ispName
774 "wrong number of params found");
780 if (nodeName ==
"excessentropy") {
784 getFloatArray(xmlChild, vParams,
true,
"toSI",
"excessEntropy");
785 if (vParams.size() != 2) {
786 throw CanteraError(
"PhaseCombo_Interaction::readXMLBinarySpecies::excessEntropy for " + ispName
788 "wrong number of params found");
794 if (nodeName ==
"excessvolume_enthalpy") {
798 getFloatArray(xmlChild, vParams,
true,
"toSI",
"excessVolume_Enthalpy");
799 if (vParams.size() != 2) {
800 throw CanteraError(
"PhaseCombo_Interaction::readXMLBinarySpecies::excessVolume_Enthalpy for " + ispName
802 "wrong number of params found");
808 if (nodeName ==
"excessvolume_entropy") {
812 getFloatArray(xmlChild, vParams,
true,
"toSI",
"excessVolume_Entropy");
813 if (vParams.size() != 2) {
814 throw CanteraError(
"PhaseCombo_Interaction::readXMLBinarySpecies::excessVolume_Entropy for " + ispName
816 "wrong number of params found");
vector_fp m_VSE_b_ij
Entropy term for the binary mole fraction interaction of the excess Gibbs free energy expression...
PhaseCombo_Interaction & operator=(const PhaseCombo_Interaction &b)
Assignment operator.
doublereal electricPotential() const
Returns the electric potential of this phase (V).
CTML ("Cantera Markup Language") is the variant of XML that Cantera uses to store data...
virtual void getPartialMolarCp(doublereal *cpbar) const
Returns an array of partial molar entropies for the species in the mixture.
int formTempModel_
form of the temperature dependence of the Margules interaction expression
XML_Node * findXMLPhase(XML_Node *root, const std::string &idtarget)
Search an XML_Node tree for a named phase XML_Node.
virtual void getdlnActCoeffdT(doublereal *dlnActCoeffdT) const
Get the array of temperature derivatives of the log activity coefficients.
std::string attrib(const std::string &attr) const
Function returns the value of an attribute.
vector_fp m_VHE_c_ij
Enthalpy term for the ternary mole fraction interaction of the excess Gibbs free energy expression...
GibbsExcessVPSSTP & operator=(const GibbsExcessVPSSTP &b)
Assignment operator.
void resize(size_t n, size_t m, doublereal v=0.0)
Resize the array, and fill the new entries with 'v'.
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...
Header for intermediate ThermoPhase object for phases which employ the Margules Gibbs free energy for...
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"
void initLengths()
Initialize lengths of local variables after all species have been identified.
void s_update_dlnActCoeff_dT() const
Update the derivative of the log of the activity coefficients wrt T.
virtual void getCp_R(doublereal *cpr) const
Get the nondimensional Heat Capacities at constant pressure for the standard state of the species at ...
Headers for the factory class that can create known ThermoPhase objects (see Thermodynamic Properties...
virtual doublereal cv_mole() const
Molar heat capacity at constant volume. Units: J/kmol/K.
virtual void getdlnActCoeffds(const doublereal dTds, const doublereal *const dXds, doublereal *dlnActCoeffds) const
Get the change in activity coefficients w.r.t.
PhaseCombo_Interaction()
Constructor.
virtual void getActivityCoefficients(doublereal *ac) const
Get the array of non-dimensional molar-based activity coefficients at the current solution temperatur...
Class XML_Node is a tree-based representation of the contents of an XML file.
doublereal size(size_t k) const
This routine returns the size of species k.
vector_fp m_HE_d_ij
Enthalpy term for the quaternary 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.
void warn_deprecated(const std::string &method, const std::string &extra)
Print a warning indicating that method is deprecated.
virtual void getPartialMolarVolumes(doublereal *vbar) const
Return an array of partial molar volumes for the species in the mixture.
int formMargules_
form 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...
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 ...
void resizeNumInteractions(const size_t num)
Resize internal arrays within the object that depend upon the number of binary Margules interaction t...
std::vector< doublereal > dlnActCoeffdlnN_diag_
Storage for the current derivative values of the gradients with respect to logarithm of the mole frac...
void s_update_dlnActCoeff_dlnN() const
Update the derivative of the log of the activity coefficients wrt log(moles_m)
XML_Node & child(const size_t n) const
Return a changeable reference to the n'th child of the current node.
std::vector< size_t > m_pSpecies_A_ij
vector of species indices representing species A in the interaction
Base class for a phase with thermodynamic properties.
virtual ThermoPhase * duplMyselfAsThermoPhase() const
Duplication routine for objects which inherit from ThermoPhase.
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 initThermo()
virtual void getChemPotentials(doublereal *mu) const
Get the species chemical potentials. Units: J/kmol.
vector_fp m_VSE_d_ij
Entropy term for the quaternary mole fraction interaction of the excess Gibbs free energy expression...
void getElectrochemPotentials(doublereal *mu) const
Get the species electrochemical potentials.
vector_fp m_VHE_d_ij
Enthalpy term for the quaternary mole fraction interaction of the excess Gibbs free energy expression...
void s_update_dlnActCoeff_dlnX_diag() const
Update the derivative of the log of the activity coefficients wrt log(mole fraction) ...
std::string name() const
Returns the name of the XML node.
virtual doublereal cp_mole() const
Molar heat capacity at constant pressure. Units: J/kmol/K.
virtual void getPartialMolarEnthalpies(doublereal *hbar) const
Returns an array of partial molar enthalpies for the species in the mixture.
std::string id() const
Return the string id for the phase.
vector_fp m_HE_b_ij
Enthalpy term for the binary mole fraction interaction of the excess Gibbs free energy expression...
Base class for exceptions thrown by Cantera classes.
std::vector< size_t > m_pSpecies_B_ij
vector of species indices representing species B in the interaction
vector_fp m_VSE_c_ij
Entropy term for the ternary mole fraction interaction of the excess Gibbs free energy expression...
size_t numBinaryInteractions_
number of binary interaction expressions
vector_fp m_SE_c_ij
Entropy term for the ternary mole fraction interaction of the excess Gibbs free energy expression...
void s_update_lnActCoeff() const
Update the activity coefficients.
bool hasChild(const std::string &ch) const
Tests whether the current node has a child node with a particular name.
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.
virtual void getdlnActCoeffdlnN_diag(doublereal *dlnActCoeffdlnN_diag) const
Get the array of derivatives of the log activity coefficients wrt mole numbers - diagonal only...
size_t getFloatArray(const 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...
std::vector< doublereal > moleFractions_
Storage for the current values of the mole fractions of the species.
PhaseCombo_Interaction is a derived class of GibbsExcessVPSSTP that employs the Margules approximatio...
virtual void getEnthalpy_RT(doublereal *hrt) const
Get the nondimensional Enthalpy functions for the species at their standard states at the current T a...
const doublereal GasConstant
Universal Gas Constant. [J/kmol/K].
virtual void initThermoXML(XML_Node &phaseNode, const std::string &id)
Initialize a ThermoPhase object, potentially reading activity coefficient information from an XML dat...
Contains declarations for string manipulation functions within Cantera.
virtual void initThermo()
vector_fp m_SE_d_ij
Entropy term for the quaternary mole fraction interaction of the excess Gibbs free energy expression...
virtual doublereal entropy_mole() const
Molar entropy. Units: J/kmol.
virtual int eosType() const
Equation of state type flag.
vector_fp m_SE_b_ij
Entropy term for the binary mole fraction interaction of the excess Gibbs free energy expression...
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...
void zero()
Set all of the entries to zero.
virtual void initThermoFile(const std::string &inputFile, const std::string &id)
virtual void getStandardChemPotentials(doublereal *mu) const
Get the array of chemical potentials at unit activity.
vector_fp m_HE_c_ij
Enthalpy term for the ternary mole fraction interaction of the excess Gibbs free energy expression...
vector_fp m_VHE_b_ij
Enthalpy term for the binary mole fraction interaction of the excess Gibbs free energy expression...
virtual void getd2lnActCoeffdT2(doublereal *d2lnActCoeffdT2) const
Get the array of temperature second derivatives of the log activity coefficients. ...
void s_update_dlnActCoeff_dlnN_diag() const
Update the derivative of the log of the activity coefficients wrt log(moles) - diagonal only...
std::string speciesName(size_t k) const
Name of the species with index k.
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 ...
virtual void getPartialMolarEntropies(doublereal *sbar) const
Returns an array of partial molar entropies for the species in the mixture.
doublereal charge(size_t k) const
Dimensionless electrical charge of a single molecule of species k The charge is normalized by the the...
virtual doublereal enthalpy_mole() const
Molar enthalpy. Units: J/kmol.