added enthalpy_mole(), entropy_mole().... capabilities to MargulesVPSSTP

This commit is contained in:
Christopher Lueth 2010-05-26 23:15:29 +00:00
parent 2820296ac5
commit 42e2dd0c0b
6 changed files with 143 additions and 5 deletions

View file

@ -66,6 +66,7 @@ namespace Cantera {
moleFractions_ = b.moleFractions_;
lnActCoeff_Scaled_ = b.lnActCoeff_Scaled_;
dlnActCoeffdT_Scaled_ = b.dlnActCoeffdT_Scaled_;
d2lnActCoeffdT2_Scaled_ = b.d2lnActCoeffdT2_Scaled_;
dlnActCoeffdlnX_Scaled_ = b.dlnActCoeffdlnX_Scaled_;
dlnActCoeffdlnN_Scaled_ = b.dlnActCoeffdlnN_Scaled_;
m_pp = b.m_pp;
@ -324,6 +325,7 @@ namespace Cantera {
moleFractions_.resize(m_kk);
lnActCoeff_Scaled_.resize(m_kk);
dlnActCoeffdT_Scaled_.resize(m_kk);
d2lnActCoeffdT2_Scaled_.resize(m_kk);
dlnActCoeffdlnX_Scaled_.resize(m_kk);
dlnActCoeffdlnN_Scaled_.resize(m_kk);
m_pp.resize(m_kk);

View file

@ -578,6 +578,11 @@ namespace Cantera {
//! 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 temperature of the
//! log of theactivity coefficients of the species
mutable std::vector<doublereal> d2lnActCoeffdT2_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

View file

@ -408,6 +408,43 @@ namespace Cantera {
}
}
/// Molar enthalpy. Units: J/kmol.
doublereal MargulesVPSSTP::enthalpy_mole() const {
int kk = nSpecies();
double hbar[kk], h = 0;
getPartialMolarEnthalpies(hbar);
for (int i = 0; i < kk; i++){
h += moleFractions_[i]*hbar[i];
}
return h;
}
/// Molar entropy. Units: J/kmol.
doublereal MargulesVPSSTP::entropy_mole() const {
int kk = nSpecies();
double sbar[kk], s = 0;
getPartialMolarEntropies(sbar);
for (int i = 0; i < kk; i++){
s += moleFractions_[i]*sbar[i];
}
return s;
}
/// Molar heat capacity at constant pressure. Units: J/kmol/K.
doublereal MargulesVPSSTP::cp_mole() const {
int kk = nSpecies();
double cpbar[kk], cp = 0;
getPartialMolarCp(cpbar);
for (int i = 0; i < kk; i++){
cp += moleFractions_[i]*cpbar[i];
}
return cp;
}
/// Molar heat capacity at constant volume. Units: J/kmol/K.
doublereal MargulesVPSSTP::cv_mole() const {
return cp_mole() - GasConstant;
}
// Returns an array of partial molar enthalpies for the species
// in the mixture.
@ -448,6 +485,44 @@ namespace Cantera {
}
}
// Returns an array of partial molar heat capacities for the species
// in the mixture.
/*
* Units (J/kmol)
*
* For this phase, the partial molar enthalpies are equal to the
* standard state enthalpies modified by the derivative of the
* activity coefficent wrt temperature
*
* \f[
* ??????????? \bar s_k(T,P) = s^o_k(T,P) - R T^2 \frac{d \ln(\gamma_k)}{dT}
* \f]
*
*/
void MargulesVPSSTP::getPartialMolarCp(doublereal* cpbar) const {
/*
* Get the nondimensional standard state entropies
*/
getCp_R(cpbar);
double T = temperature();
/*
* Update the activity coefficients, This also update the
* internally storred molalities.
*/
s_update_lnActCoeff();
s_update_dlnActCoeff_dT();
for (int k = 0; k < m_kk; k++) {
cpbar[k] -= 2 * T * dlnActCoeffdT_Scaled_[k] + T * T * d2lnActCoeffdT2_Scaled_[k];
}
/*
* dimensionalize it.
*/
for (int k = 0; k < m_kk; k++) {
cpbar[k] *= GasConstant;
}
}
// Returns an array of partial molar entropies for the species
// in the mixture.
/*
@ -733,6 +808,7 @@ namespace Cantera {
double RTT = GasConstant*T*T;
fvo_zero_dbl_1(dlnActCoeffdT_Scaled_, m_kk);
fvo_zero_dbl_1(d2lnActCoeffdT2_Scaled_, m_kk);
for ( iK = 0; iK < m_kk; iK++ ){
@ -755,7 +831,9 @@ namespace Cantera {
g0 = -m_HE_b_ij[i] / RTT;
g1 = -m_HE_c_ij[i] / RTT;
dlnActCoeffdT_Scaled_[iK] += (delAK*XB+XA*delBK-XA*XB)*(g0+g1*XB)+XA*XB*(delBK-XB)*g1;
double temp = (delAK*XB+XA*delBK-XA*XB)*(g0+g1*XB)+XA*XB*(delBK-XB)*g1;
dlnActCoeffdT_Scaled_[iK] += temp;
d2lnActCoeffdT2_Scaled_[iK] -= 2*temp/T;
}
}
}
@ -793,6 +871,13 @@ namespace Cantera {
}
}
void MargulesVPSSTP::getd2lnActCoeffdT2(doublereal *d2lnActCoeffdT2) const {
s_update_dlnActCoeff_dT();
for (int k = 0; k < m_kk; k++) {
d2lnActCoeffdT2[k] = d2lnActCoeffdT2_Scaled_[k];
}
}
// calculate the change of the log of the activity coefficients wrt change in state: dT, dX
/*
* This function will be called to calculate gradient of the

View file

@ -525,7 +525,18 @@ namespace Cantera {
*/
virtual void getChemPotentials(doublereal* mu) const;
/// Molar enthalpy. Units: J/kmol.
virtual doublereal enthalpy_mole() const;
/// Molar entropy. Units: J/kmol.
virtual doublereal entropy_mole() const;
/// Molar heat capacity at constant pressure. Units: J/kmol/K.
virtual doublereal cp_mole() const;
/// Molar heat capacity at constant volume. Units: J/kmol/K.
virtual doublereal cv_mole() const;
//! Returns an array of partial molar enthalpies for the species
//! in the mixture.
/*!
@ -564,6 +575,28 @@ namespace Cantera {
*/
virtual void getPartialMolarEntropies(doublereal* sbar) const;
//! Returns an array of partial molar entropies for the species
//! in the mixture.
/*!
* Units (J/kmol)
*
* For this phase, the partial molar enthalpies are equal to the
* standard state enthalpies modified by the derivative of the
* activity coefficent wrt temperature
*
* \f[
* ???????????????
* \bar s_k(T,P) = s^o_k(T,P) - R T^2 \frac{d \ln(\gamma_k)}{dT}
* - R \ln( \gamma_k X_k)
* - R T \frac{d \ln(\gamma_k) }{dT}
* ???????????????
* \f]
*
* @param cpbar Vector of returned partial molar heat capacities
* (length m_kk, units = J/kmol/K)
*/
virtual void getPartialMolarCp(doublereal* cpbar) const;
//! Return an array of partial molar volumes for the
//! species in the mixture. Units: m^3/kmol.
@ -604,6 +637,19 @@ namespace Cantera {
*/
virtual void getdlnActCoeff(const doublereal dT, const doublereal * const dX, doublereal *dlnActCoeffdT) const;
//! Get the array of temperature second derivatives of the log activity coefficients
/*!
* This function is a virtual class, but it first appears in GibbsExcessVPSSTP
* class and derived classes from GibbsExcessVPSSTP.
*
* units = 1/Kelvin
*
* @param d2lnActCoeffdT2 Output vector of temperature 2nd derivatives of the
* log Activity Coefficients. length = m_kk
*
*/
virtual void getd2lnActCoeffdT2(doublereal *d2lnActCoeffdT2) const;
//! Get the array of temperature derivatives of the log activity coefficients
/*!
* This function is a virtual class, but it first appears in GibbsExcessVPSSTP

View file

@ -829,7 +829,7 @@ namespace Cantera {
f0->name() + " and " + f1->name());
}
}
else if (nc >= 2) {
else if (nc > 2) {
const XML_Node* f0 = tp[0];
if (f0->name() == "NASA9") {
installNasa9ThermoFromXML(speciesNode["name"], spthermo, k, tp);

View file

@ -859,7 +859,7 @@ namespace Cantera {
/// Molar internal energy. Units: J/kmol.
virtual doublereal intEnergy_mole() const {
return err("intEnergy_mole");
return enthalpy_mole() - pressure()* molarVolume();
}
/// Molar entropy. Units: J/kmol/K.
@ -869,7 +869,7 @@ namespace Cantera {
/// Molar Gibbs function. Units: J/kmol.
virtual doublereal gibbs_mole() const {
return err("gibbs_mole");
return enthalpy_mole() - temperature()*entropy_mole();
}
/// Molar heat capacity at constant pressure. Units: J/kmol/K.