Skip to content

Commit 1b28545

Browse files
committed
Update to use partial derivative identities
Also fix equations in comments
1 parent a9b5945 commit 1b28545

File tree

4 files changed

+11
-56
lines changed

4 files changed

+11
-56
lines changed

include/cantera/thermo/PengRobinson.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ class PengRobinson : public MixtureFugacityTP
208208
//! Returns the isothermal compressibility (\f$\beta_T\f$). Units: 1/Pa.
209209
/*!
210210
* \f[
211-
* \beta_T = \frac{1}{v} \left(\frac{\partial v}{\partial p}\right)_T
211+
* \beta_T = -\frac{1}{v} \left(\frac{\partial v}{\partial p}\right)_T
212212
* \f]
213213
*/
214214
virtual double isothermalCompressibility() const;

include/cantera/thermo/RedlichKwongMFTP.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,15 +176,15 @@ class RedlichKwongMFTP : public MixtureFugacityTP
176176
//! Returns the isothermal compressibility (\f$\beta_T\f$). Units: 1/Pa.
177177
/*!
178178
* \f[
179-
* \beta_T = \frac{1}{v} \left(\frac{\partial v}{\partial p}\right)_T
179+
* \beta_T = -\frac{1}{v} \left(\frac{\partial v}{\partial p}\right)_T
180180
* \f]
181181
*/
182182
virtual double isothermalCompressibility() const;
183183

184184
//! Return the volumetric thermal expansion coefficient (\f$\alpha_V\f$). Units: 1/K.
185185
/*!
186186
* \f[
187-
* alpha_V = \frac{1}{v} \left(\frac{\partial v}{\partial T}\right)_p
187+
* \alpha_V = \frac{1}{v} \left(\frac{\partial v}{\partial T}\right)_p
188188
* \f]
189189
*/
190190
virtual double thermalExpansionCoeff() const;

src/thermo/PengRobinson.cpp

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -632,37 +632,14 @@ double PengRobinson::dpdVCalc(double T, double molarVol, double& presCalc) const
632632

633633
double PengRobinson::isothermalCompressibility() const
634634
{
635-
double P = pressure();
636-
double RT_ = RT();
637-
double Z = z();
638-
639-
double A = m_aAlpha_mix * P / (RT_ * RT_);
640-
double B = m_b * P / RT_;
641-
642-
double dAdP = A / P;
643-
double dBdP = B / P;
644-
double dZdP = ((B - Z) * dAdP + (A - 2 * B - 3 * B * B + 2 * Z + 6 * B * Z - Z * Z) * dBdP) /
645-
(3 * Z * Z + 2 * Z * (B - 1) + A - 2 * B - 3 * B * B);
646-
647-
return 1 / P - dZdP / Z;
635+
calculatePressureDerivatives();
636+
return -1 / (molarVolume() * m_dpdV);
648637
}
649638

650639
double PengRobinson::thermalExpansionCoeff() const
651640
{
652-
double P = pressure();
653-
double T = temperature();
654-
double RT_ = RT();
655-
double Z = z();
656-
657-
double A = m_aAlpha_mix * P / (RT_ * RT_);
658-
double B = m_b * P / RT_;
659-
660-
double dAdT = P / (RT_ * RT_) * (daAlpha_dT() - 2 * m_aAlpha_mix / T);
661-
double dBdT = -B / T;
662-
double dZdT = ((B - Z) * dAdT + (A - 2 * B - 3 * B * B + 2 * Z + 6 * B * Z - Z * Z) * dBdT) /
663-
(3 * Z * Z + 2 * Z * (B - 1) + A - 2 * B - 3 * B * B);
664-
665-
return 1 / T + dZdT / Z;
641+
calculatePressureDerivatives();
642+
return -m_dpdT / (molarVolume() * m_dpdV);
666643
}
667644

668645
void PengRobinson::calculatePressureDerivatives() const

src/thermo/RedlichKwongMFTP.cpp

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -709,36 +709,14 @@ doublereal RedlichKwongMFTP::dpdVCalc(doublereal TKelvin, doublereal molarVol, d
709709

710710
double RedlichKwongMFTP::isothermalCompressibility() const
711711
{
712-
double P = pressure();
713-
double T = temperature();
714-
double RT_ = RT();
715-
double Z = z();
716-
717-
double A = m_a_current * P / (RT_ * RT_ * pow(T, 0.5));
718-
double B = m_b_current * P / RT_;
719-
720-
double dAdP = A / P;
721-
double dBdP = B / P;
722-
double dZdP = ((B - Z) * dAdP + (A + Z + 2 * B * Z) * dBdP) / (3 * Z * Z - 2 * Z + A - B - B * B);
723-
724-
return 1 / P - dZdP / Z;
712+
pressureDerivatives();
713+
return -1 / (molarVolume() * dpdV_);
725714
}
726715

727716
double RedlichKwongMFTP::thermalExpansionCoeff() const
728717
{
729-
double P = pressure();
730-
double T = temperature();
731-
double RT_ = RT();
732-
double Z = z();
733-
734-
double A = m_a_current * P / (RT_ * RT_ * pow(T, 0.5));
735-
double B = m_b_current * P / RT_;
736-
737-
double dAdT = -2.5 * A / T + A / m_a_current * da_dt();
738-
double dBdT = -B / T;
739-
double dZdT = ((B - Z) * dAdT + (A + Z + 2 * B * Z) * dBdT) / (3 * Z * Z - 2 * Z + A - B - B * B);
740-
741-
return 1 / T + dZdT / Z;
718+
pressureDerivatives();
719+
return -dpdT_ / (molarVolume() * dpdV_);
742720
}
743721

744722
void RedlichKwongMFTP::pressureDerivatives() const

0 commit comments

Comments
 (0)