Added method
virtual void getdlnActCoeffdlnX(doublereal *dlnActCoeffdlnX) const; to ThermoPhase, GibbsExcessVPSSTP, VPStandardStateTP and MargulesVPSSTP classes (i.e. the whole thermo tree). In GibbsExcessVPSSTP and above, these methods are not yet implemented. In MargulesVPSSTP, the internal method void s_update_dlnActCoeff_dlnX() const; does the work and stores the result in the member dlnActCoeffdlnX_Scaled_.
This commit is contained in:
parent
134b7acf3c
commit
aae7d0b440
7 changed files with 146 additions and 8 deletions
|
|
@ -63,6 +63,7 @@ namespace Cantera {
|
|||
moleFractions_ = b.moleFractions_;
|
||||
lnActCoeff_Scaled_ = b.lnActCoeff_Scaled_;
|
||||
dlnActCoeffdT_Scaled_ = b.dlnActCoeffdT_Scaled_;
|
||||
dlnActCoeffdlnC_Scaled_ = b.dlnActCoeffdlnC_Scaled_;
|
||||
m_pp = b.m_pp;
|
||||
|
||||
return *this;
|
||||
|
|
@ -329,6 +330,7 @@ namespace Cantera {
|
|||
moleFractions_.resize(m_kk);
|
||||
lnActCoeff_Scaled_.resize(m_kk);
|
||||
dlnActCoeffdT_Scaled_.resize(m_kk);
|
||||
dlnActCoeffdlnC_Scaled_.resize(m_kk);
|
||||
m_pp.resize(m_kk);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -302,6 +302,28 @@ namespace Cantera {
|
|||
err("getdlnActCoeffdT");
|
||||
}
|
||||
|
||||
//! Get the array of log concentration-like derivatives of the
|
||||
//! log activity coefficients
|
||||
/*!
|
||||
* This function is a virtual method. For ideal mixtures
|
||||
* (unity activity coefficients), this can return zero.
|
||||
* Implementations should take the derivative of the
|
||||
* logarithm of the activity coefficient with respect to the
|
||||
* logarithm of the concentration-like variable (i.e. mole fraction,
|
||||
* molality, etc.) that represents the standard state.
|
||||
* This quantity is to be used in conjunction with derivatives of
|
||||
* that concentration-like variable when the derivative of the chemical
|
||||
* potential is taken.
|
||||
*
|
||||
* units = dimensionless
|
||||
*
|
||||
* @param dlnActCoeffdlnC Output vector of derivatives of the
|
||||
* log Activity Coefficients. length = m_kk
|
||||
*/
|
||||
virtual void getdlnActCoeffdlnC(doublereal *dlnActCoeffdlnC) const {
|
||||
err("getdlnActCoeffdlnC");
|
||||
}
|
||||
|
||||
//@}
|
||||
/// @name Partial Molar Properties of the Solution
|
||||
//@{
|
||||
|
|
@ -532,10 +554,16 @@ namespace Cantera {
|
|||
//! species, divided by RT
|
||||
mutable std::vector<doublereal> lnActCoeff_Scaled_;
|
||||
|
||||
//! Storage for the current derivative values of the log of the
|
||||
// activity coefficients of the species
|
||||
//! Storage for the current derivative values of the
|
||||
//! gradients with respect to temperature of the
|
||||
//! log of theactivity coefficients of the species
|
||||
mutable std::vector<doublereal> dlnActCoeffdT_Scaled_;
|
||||
|
||||
//! Storage for the current derivative values of the
|
||||
//! gradients with respect to logarithm of the mole fraction of the
|
||||
//! log of theactivity coefficients of the species
|
||||
mutable std::vector<doublereal> dlnActCoeffdlnC_Scaled_;
|
||||
|
||||
//! Temporary storage space that is fair game
|
||||
mutable std::vector<doublereal> m_pp;
|
||||
|
||||
|
|
|
|||
|
|
@ -648,6 +648,46 @@ namespace Cantera {
|
|||
}
|
||||
}
|
||||
|
||||
// Update the derivative of the log of the activity coefficients wrt ln(X)
|
||||
/*
|
||||
* This function will be called to update the internally stored gradients of the
|
||||
* logarithm of the activity coefficients. These are used in the determination
|
||||
* of the diffusion coefficients.
|
||||
*
|
||||
* he = X_A X_B(B + C(X_A - X_B))
|
||||
*/
|
||||
void MargulesVPSSTP::s_update_dlnActCoeff_dlnX() const {
|
||||
int iA, iB;
|
||||
doublereal XA, XB, g0 , g1;
|
||||
doublereal T = temperature();
|
||||
|
||||
fvo_zero_dbl_1(dlnActCoeffdlnX_Scaled_, m_kk);
|
||||
|
||||
doublereal RT = GasConstant * T;
|
||||
for (int i = 0; i < numBinaryInteractions_; i++) {
|
||||
iA = m_pSpecies_A_ij[i];
|
||||
iB = m_pSpecies_B_ij[i];
|
||||
|
||||
XA = moleFractions_[iA];
|
||||
XB = moleFractions_[iB];
|
||||
|
||||
g0 = (m_HE_b_ij[i] - T * m_SE_b_ij[i]) / RT ;
|
||||
g1 = (m_HE_c_ij[i] - T * m_SE_c_ij[i]) / RT;
|
||||
|
||||
dlnActCoeffdlnX_Scaled_[iA] += XA * ( ( - 2.0 + 2.0 * XA ) * g0
|
||||
+ ( - 4.0 + 10.0 * XA - 6.0 * XA*XA ) * g1 ) ;
|
||||
dlnActCoeffdlnX_Scaled_[iB] += XB * ( ( - 2.0 + 2.0 * XB ) * g0
|
||||
+ ( 2.0 - 8.0 * XB + 6.0 * XB*XB ) * g1 ) ;
|
||||
}
|
||||
}
|
||||
|
||||
void MargulesVPSSTP::getdlnActCoeffdlnX(doublereal *dlnActCoeffdlnX) const {
|
||||
s_update_dlnActCoeff_dlnX();
|
||||
for (int k = 0; k < m_kk; k++) {
|
||||
dlnActCoeffdlnX[k] = dlnActCoeffdlnX_Scaled_[k];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MargulesVPSSTP::resizeNumInteractions(const int num) {
|
||||
numBinaryInteractions_ = num;
|
||||
|
|
|
|||
|
|
@ -589,13 +589,27 @@ namespace Cantera {
|
|||
* @param dlnActCoeffdT Output vector of temperature derivatives of the
|
||||
* log Activity Coefficients. length = m_kk
|
||||
*
|
||||
* @param dlnActCoeffdT Vector of returned derivatives of
|
||||
* ln (actCoeff) wrt temperature.
|
||||
* (length m_kk, units = 1/K)
|
||||
*/
|
||||
virtual void getdlnActCoeffdT(doublereal *dlnActCoeffdT) const;
|
||||
|
||||
|
||||
//! Get the array of derivatives of the log activity coefficients
|
||||
//! with respect to the log mole fractions
|
||||
/*!
|
||||
* This function is a virtual class, but it first appears in
|
||||
* GibbsExcessVPSSTP class and derived classes.
|
||||
* Output vector of log(mole fraction) derivatives of the
|
||||
* log Activity Coefficients.
|
||||
*
|
||||
* units = dimensionless
|
||||
*
|
||||
* @param dlnActCoeffdlnX Output vector of log(mole fraction)
|
||||
* derivatives of the log Activity Coefficients.
|
||||
* length = m_kk
|
||||
*/
|
||||
virtual void getdlnActCoeffdlnX(doublereal *dlnActCoeffdlnX) const;
|
||||
|
||||
|
||||
//@}
|
||||
/// @name Properties of the Standard State of the Species in the Solution
|
||||
//@{
|
||||
|
|
@ -735,6 +749,15 @@ namespace Cantera {
|
|||
*/
|
||||
void s_update_dlnActCoeff_dT() const;
|
||||
|
||||
//! Update the derivative of the log of the activity coefficients
|
||||
//! wrt log(mole fraction)
|
||||
/*!
|
||||
* This function will be called to update the internally storred
|
||||
* derivative of the natural logarithm of the activity coefficients
|
||||
* wrt logarithm of the mole fractions.
|
||||
*/
|
||||
void s_update_dlnActCoeff_dlnX() const;
|
||||
|
||||
|
||||
private:
|
||||
//! Error function
|
||||
|
|
|
|||
|
|
@ -39,7 +39,8 @@ namespace Cantera {
|
|||
}
|
||||
|
||||
|
||||
PDSS_SSVol::PDSS_SSVol(VPStandardStateTP *tp, int spindex, std::string inputFile, std::string id) :
|
||||
PDSS_SSVol::PDSS_SSVol(VPStandardStateTP *tp,
|
||||
int spindex, std::string inputFile, std::string id) :
|
||||
PDSS(tp, spindex),
|
||||
volumeModel_(cSSVOLUME_CONSTANT),
|
||||
m_constMolarVolume(-1.0)
|
||||
|
|
|
|||
|
|
@ -848,6 +848,29 @@ namespace Cantera {
|
|||
}
|
||||
|
||||
|
||||
//! Get the array of log concentration-like derivatives of the
|
||||
//! log activity coefficients
|
||||
/*!
|
||||
* This function is a virtual method. For ideal mixtures
|
||||
* (unity activity coefficients), this can return zero.
|
||||
* Implementations should take the derivative of the
|
||||
* logarithm of the activity coefficient with respect to the
|
||||
* logarithm of the concentration-like variable (i.e. mole fraction,
|
||||
* molality, etc.) that represents the standard state.
|
||||
* This quantity is to be used in conjunction with derivatives of
|
||||
* that concentration-like variable when the derivative of the chemical
|
||||
* potential is taken.
|
||||
*
|
||||
* units = dimensionless
|
||||
*
|
||||
* @param dlnActCoeffdlnC Output vector of derivatives of the
|
||||
* log Activity Coefficients. length = m_kk
|
||||
*/
|
||||
virtual void getdlnActCoeffdlnC(doublereal *dlnActCoeffdlnC) const {
|
||||
err("getdlnActCoeffdlnC");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @name Mechanical Properties
|
||||
|
|
|
|||
|
|
@ -120,10 +120,31 @@ namespace Cantera {
|
|||
*/
|
||||
virtual int standardStateConvention() const;
|
||||
|
||||
//@}
|
||||
//! Get the array of log concentration-like derivatives of the
|
||||
//! log activity coefficients
|
||||
/*!
|
||||
* This function is a virtual method. For ideal mixtures
|
||||
* (unity activity coefficients), this can return zero.
|
||||
* Implementations should take the derivative of the
|
||||
* logarithm of the activity coefficient with respect to the
|
||||
* logarithm of the concentration-like variable (i.e. mole fraction,
|
||||
* molality, etc.) that represents the standard state.
|
||||
* This quantity is to be used in conjunction with derivatives of
|
||||
* that concentration-like variable when the derivative of the chemical
|
||||
* potential is taken.
|
||||
*
|
||||
* units = dimensionless
|
||||
*
|
||||
* @param dlnActCoeffdlnC Output vector of derivatives of the
|
||||
* log Activity Coefficients. length = m_kk
|
||||
*/
|
||||
virtual void getdlnActCoeffdlnC(doublereal *dlnActCoeffdlnC) const {
|
||||
err("getdlnActCoeffdlnC");
|
||||
}
|
||||
|
||||
|
||||
/// @name Partial Molar Properties of the Solution (VPStandardStateTP)
|
||||
//@}
|
||||
/// @name Partial Molar Properties of the Solution (VPStandardStateTP)
|
||||
//@{
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue