17 PhaseCombo_Interaction::PhaseCombo_Interaction() :
18 numBinaryInteractions_(0),
22 warn_deprecated(
"Class PhaseCombo_Interaction",
"To be removed after Cantera 2.4");
26 const std::string& id_) :
27 numBinaryInteractions_(0),
31 warn_deprecated(
"Class PhaseCombo_Interaction",
"To be removed after Cantera 2.4");
36 const std::string& id_) :
37 numBinaryInteractions_(0),
41 warn_deprecated(
"Class PhaseCombo_Interaction",
"To be removed after Cantera 2.4");
53 for (
size_t k = 0; k <
m_kk; k++) {
68 for (
size_t k = 0; k <
m_kk; k++) {
79 for (
size_t i = 0; i <
m_kk; i++) {
90 for (
size_t i = 0; i <
m_kk; i++) {
101 for (
size_t i = 0; i <
m_kk; i++) {
118 for (
size_t k = 0; k <
m_kk; k++) {
126 for (
size_t k = 0; k <
m_kk; k++) {
142 for (
size_t k = 0; k <
m_kk; k++) {
147 for (
size_t k = 0; k <
m_kk; k++) {
163 for (
size_t k = 0; k <
m_kk; k++) {
169 for (
size_t k = 0; k <
m_kk; k++) {
181 for (
size_t iK = 0; iK <
m_kk; iK++) {
198 vbar[iK] += XA*XB*(g0+g1*XB)+((delAK-XA)*XB+XA*(delBK-XB))*(g0+g1*XB)+XA*XB*(delBK-XB)*g1;
216 if ((
int)
id.
size() > 0 && phaseNode.
id() !=
id) {
217 throw CanteraError(
"PhaseCombo_Interaction::initThermoXML",
218 "phasenode and Id are incompatible");
223 if (!phaseNode.
hasChild(
"thermo")) {
224 throw CanteraError(
"PhaseCombo_Interaction::initThermoXML",
225 "no thermo XML node");
229 throw CanteraError(
"PhaseCombo_Interaction::initThermoXML",
230 "model name isn't PhaseCombo_Interaction: " + thermoNode[
"model"]);
235 if (thermoNode.
hasChild(
"activityCoefficients")) {
238 throw CanteraError(
"PhaseCombo_Interaction::initThermoXML",
239 "Unknown activity coefficient model: " + acNode[
"model"]);
241 for (
size_t i = 0; i < acNode.
nChildren(); i++) {
262 for (
size_t iK = 0; iK <
m_kk; iK++) {
284 lnActCoeff_Scaled_[iK] += (delAK * XB + XA * delBK - XA * XB) * (g0 + g1 * XB) + XA * XB * (delBK - XB) * g1;
294 for (
size_t iK = 0; iK <
m_kk; iK++) {
309 double temp = (delAK * XB + XA * delBK - XA * XB) * (g0 + g1 * XB) + XA * XB * (delBK - XB) * g1;
319 for (
size_t k = 0; k <
m_kk; k++) {
327 for (
size_t k = 0; k <
m_kk; k++) {
333 doublereal* dlnActCoeffds)
const 338 for (
size_t iK = 0; iK <
m_kk; iK++) {
344 dlnActCoeffds[iK] += - 1.0 / xx;
361 double dXA = dXds[iA];
362 double dXB = dXds[iB];
365 dlnActCoeffds[iK] += ((delBK-XB)*dXA + (delAK-XA)*dXB)*(g0+2*g1*XB) + (delBK-XB)*2*g1*XA*dXB
376 for (
size_t iK = 0; iK <
m_kk; iK++) {
414 for (
size_t iK = 0; iK <
m_kk; iK++) {
417 for (
size_t iM = 0; iM <
m_kk; iM++) {
450 dlnActCoeffdlnN_(iK,iM) += g0*((delAM-XA)*(delBK-XB)+(delAK-XA)*(delBM-XB));
451 dlnActCoeffdlnN_(iK,iM) += 2*g1*((delAM-XA)*(delBK-XB)*XB+(delAK-XA)*(delBM-XB)*XB+(delBM-XB)*(delBK-XB)*XA);
475 throw CanteraError(
"PhaseCombo_Interaction::s_update_dlnActCoeff_dlnX_diag",
"unimplemented");
481 for (
size_t k = 0; k <
m_kk; k++) {
489 for (
size_t k = 0; k <
m_kk; k++) {
498 for (
size_t k = 0; k <
m_kk; k++) {
499 for (
size_t m = 0; m <
m_kk; m++) {
500 dlnActCoeffdlnN[ld * k + m] = data[
m_kk * k + m];
526 string xname = xmLBinarySpecies.
name();
527 if (xname !=
"binaryNeutralSpeciesParameters") {
528 throw CanteraError(
"PhaseCombo_Interaction::readXMLBinarySpecies",
529 "Incorrect name for processing this routine: " + xname);
532 string iName = xmLBinarySpecies.
attrib(
"speciesA");
534 throw CanteraError(
"PhaseCombo_Interaction::readXMLBinarySpecies",
"no speciesA attrib");
536 string jName = xmLBinarySpecies.
attrib(
"speciesB");
538 throw CanteraError(
"PhaseCombo_Interaction::readXMLBinarySpecies",
"no speciesB attrib");
544 if (iSpecies ==
npos) {
548 if (
charge(iSpecies) != 0) {
549 throw CanteraError(
"PhaseCombo_Interaction::readXMLBinarySpecies",
"speciesA charge problem");
552 if (jSpecies ==
npos) {
556 if (
charge(jSpecies) != 0) {
557 throw CanteraError(
"PhaseCombo_Interaction::readXMLBinarySpecies",
"speciesB charge problem");
565 for (
size_t iChild = 0; iChild < xmLBinarySpecies.
nChildren(); iChild++) {
570 if (nodeName ==
"excessenthalpy") {
572 getFloatArray(xmlChild, vParams,
true,
"toSI",
"excessEnthalpy");
573 if (vParams.size() != 2) {
574 throw CanteraError(
"PhaseCombo_Interaction::readXMLBinarySpecies::excessEnthalpy for " + ispName
576 "wrong number of params found");
582 if (nodeName ==
"excessentropy") {
584 getFloatArray(xmlChild, vParams,
true,
"toSI",
"excessEntropy");
585 if (vParams.size() != 2) {
586 throw CanteraError(
"PhaseCombo_Interaction::readXMLBinarySpecies::excessEntropy for " + ispName
588 "wrong number of params found");
594 if (nodeName ==
"excessvolume_enthalpy") {
596 getFloatArray(xmlChild, vParams,
true,
"toSI",
"excessVolume_Enthalpy");
597 if (vParams.size() != 2) {
598 throw CanteraError(
"PhaseCombo_Interaction::readXMLBinarySpecies::excessVolume_Enthalpy for " + ispName
600 "wrong number of params found");
606 if (nodeName ==
"excessvolume_entropy") {
608 getFloatArray(xmlChild, vParams,
true,
"toSI",
"excessVolume_Entropy");
609 if (vParams.size() != 2) {
610 throw CanteraError(
"PhaseCombo_Interaction::readXMLBinarySpecies::excessVolume_Entropy for " + ispName
612 "wrong number of params found");
void s_update_dlnActCoeff_dlnX_diag() const
Update the derivative of the log of the activity coefficients wrt log(mole fraction) ...
vector_fp m_VSE_b_ij
Entropy 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. ...
virtual double size(size_t k) const
virtual void getPartialMolarEnthalpies(doublereal *hbar) const
Returns an array of partial molar enthalpies for the species in the mixture.
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.
vector_fp dlnActCoeffdlnX_diag_
Storage for the current derivative values of the gradients with respect to logarithm of the mole frac...
vector_fp m_VHE_c_ij
Enthalpy term for the ternary mole fraction interaction of the excess Gibbs free energy expression...
doublereal temperature() const
Temperature (K).
void resize(size_t n, size_t m, doublereal v=0.0)
Resize the array, and fill the new entries with 'v'.
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.
virtual void getdlnActCoeffdlnN(const size_t ld, doublereal *const dlnActCoeffdlnN)
Get the array of derivatives of the log activity coefficients with respect to the log of the species ...
Header for intermediate ThermoPhase object for phases which employ the Margules Gibbs free energy for...
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.
Headers for the factory class that can create known ThermoPhase objects (see Thermodynamic Properties...
virtual void getdlnActCoeffdlnX_diag(doublereal *dlnActCoeffdlnX_diag) const
Get the array of ln mole fraction derivatives of the log activity coefficients - diagonal component o...
PhaseCombo_Interaction()
Constructor.
Class XML_Node is a tree-based representation of the contents of an XML file.
vector_fp m_HE_d_ij
Enthalpy term for the quaternary mole fraction interaction of the excess Gibbs free energy expression...
virtual void initThermoXML(XML_Node &phaseNode, const std::string &id)
Import and initialize a ThermoPhase object using an XML tree.
virtual void getCp_R(doublereal *cpr) const
Get the nondimensional Heat Capacities at constant pressure for the species standard states at the cu...
void warn_deprecated(const std::string &method, const std::string &extra)
Print a warning indicating that method is deprecated.
void resizeNumInteractions(const size_t num)
Resize internal arrays within the object that depend upon the number of binary Margules interaction t...
virtual void getdlnActCoeffds(const doublereal dTds, const doublereal *const dXds, doublereal *dlnActCoeffds) const
Get the change in activity coefficients wrt changes in state (temp, mole fraction, etc) along a line in parameter space or along a line in physical space.
virtual doublereal cp_mole() const
Molar heat capacity at constant pressure. 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...
doublereal RT() const
Return the Gas Constant multiplied by the current temperature.
std::vector< size_t > m_pSpecies_A_ij
vector of species indices representing species A in the interaction
virtual void getdlnActCoeffdlnN_diag(doublereal *dlnActCoeffdlnN_diag) const
Get the array of log species mole number derivatives of the log activity coefficients.
virtual void getPartialMolarCp(doublereal *cpbar) const
Returns an array of partial molar entropies for the species in the mixture.
void readXMLBinarySpecies(XML_Node &xmlBinarySpecies)
Process an XML node called "binaryNeutralSpeciesParameters".
virtual doublereal entropy_mole() const
Molar entropy. Units: J/kmol/K.
virtual doublereal enthalpy_mole() const
Molar enthalpy. Units: J/kmol.
virtual void initThermo()
virtual void initThermo()
virtual void getdlnActCoeffdT(doublereal *dlnActCoeffdT) const
Get the array of temperature derivatives of the log activity coefficients.
vector_fp dlnActCoeffdlnN_diag_
Storage for the current derivative values of the gradients with respect to logarithm of the mole frac...
vector_fp d2lnActCoeffdT2_Scaled_
Storage for the current derivative values of the gradients with respect to temperature of the log of ...
vector_fp m_VSE_d_ij
Entropy term for the quaternary mole fraction interaction of the excess Gibbs free energy expression...
vector_fp m_VHE_d_ij
Enthalpy term for the quaternary mole fraction interaction of the excess Gibbs free energy expression...
virtual void getPartialMolarEntropies(doublereal *sbar) const
Returns an array of partial molar entropies for the species in the mixture.
std::string speciesName(size_t k) const
Name of the species with index k.
bool caseInsensitiveEquals(const std::string &input, const std::string &test)
Case insensitive equality predicate.
vector_fp m_HE_b_ij
Enthalpy 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 for the species at their standard states at the...
Base class for exceptions thrown by Cantera classes.
virtual void getPartialMolarVolumes(doublereal *vbar) const
Return an array of partial molar volumes for the species in the mixture.
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 importPhase(XML_Node &phase, ThermoPhase *th)
Import a phase information into an empty ThermoPhase object.
vector_fp lnActCoeff_Scaled_
Storage for the current values of the activity coefficients of the species.
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.
std::string id() const
Return the string id for the phase.
virtual void initThermoXML(XML_Node &phaseNode, const std::string &id)
Import and initialize a ThermoPhase object using an XML tree.
const doublereal SmallNumber
smallest number to compare to zero.
void s_update_dlnActCoeff_dlnN_diag() const
Update the derivative of the log of the activity coefficients wrt log(moles) - diagonal only...
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.
std::string id() const
Return the id attribute, if present.
void s_update_dlnActCoeff_dT() const
Update the derivative of the log of the activity coefficients wrt T.
const doublereal GasConstant
Universal Gas Constant. [J/kmol/K].
Contains declarations for string manipulation functions within Cantera.
virtual doublereal cv_mole() const
Molar heat capacity at constant volume. Units: J/kmol/K.
vector_fp moleFractions_
Storage for the current values of the mole fractions of the species.
vector_fp m_SE_d_ij
Entropy term for the quaternary mole fraction interaction of the excess Gibbs free energy expression...
virtual void getChemPotentials(doublereal *mu) const
Get the species chemical potentials. Units: J/kmol.
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...
virtual void getEntropy_R(doublereal *sr) const
Get the array of nondimensional Entropy functions for the standard state species at the current T and...
void zero()
Set all of the entries to zero.
virtual void initThermoFile(const std::string &inputFile, const std::string &id)
std::string toLowerCopy(const std::string &input)
Convert to lower case.
Namespace for the Cantera kernel.
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...
void s_update_lnActCoeff() const
Update the activity coefficients.
size_t nChildren(bool discardComments=false) const
Return the number of children.
void s_update_dlnActCoeff_dlnN() const
Update the derivative of the log of the activity coefficients wrt log(moles_m)
virtual void getEnthalpy_RT(doublereal *hrt) const
Get the nondimensional Enthalpy functions for the species at their standard states at the current T a...
doublereal charge(size_t k) const
Dimensionless electrical charge of a single molecule of species k The charge is normalized by the the...
virtual void getStandardVolumes(doublereal *vol) const
Get the molar volumes of the species standard states at the current T and P of the solution...
vector_fp dlnActCoeffdT_Scaled_
Storage for the current derivative values of the gradients with respect to temperature of the log of ...