-
-
Notifications
You must be signed in to change notification settings - Fork 409
Description
Problem description
The implementations of getPartialMolarIntEnergies and getPartialMolarCp in the RedlichKwongMFTP class incorrectly return the standard state internal energies and heat capacities, respectively. This can be seen pretty clearly from their implementations
cantera/src/thermo/RedlichKwongMFTP.cpp
Lines 385 to 395 in 908a2cc
| void RedlichKwongMFTP::getPartialMolarIntEnergies(doublereal* ubar) const | |
| { | |
| getIntEnergy_RT(ubar); | |
| scale(ubar, ubar+m_kk, ubar, RT()); | |
| } | |
| void RedlichKwongMFTP::getPartialMolarCp(doublereal* cpbar) const | |
| { | |
| getCp_R(cpbar); | |
| scale(cpbar, cpbar+m_kk, cpbar, GasConstant); | |
| } |
which are just scaling the values returned by functions which return the non-dimensional standard state values:
cantera/include/cantera/thermo/ThermoPhase.h
Lines 620 to 639 in 908a2cc
| //! Returns the vector of nondimensional Internal Energies of the standard | |
| //! state species at the current *T* and *P* of the solution | |
| /*! | |
| * @param urt output vector of nondimensional standard state internal energies | |
| * of the species. Length: m_kk. | |
| */ | |
| virtual void getIntEnergy_RT(doublereal* urt) const { | |
| throw NotImplementedError("ThermoPhase::getIntEnergy_RT"); | |
| } | |
| //! Get the nondimensional Heat Capacities at constant pressure for the | |
| //! species standard states at the current *T* and *P* of the | |
| //! solution | |
| /*! | |
| * @param cpr Output vector of nondimensional standard state heat | |
| * capacities. Length: m_kk. | |
| */ | |
| virtual void getCp_R(doublereal* cpr) const { | |
| throw NotImplementedError("ThermoPhase::getCp_R"); | |
| } |
In reality, the calculation of the partial molar heat capacities should be significantly more involved. The correct implementation of the partial molar internal energies can be done fairly easily by using the identity h_k = u_k + P * v_k, where the complexity is in the already-implemented methods for the partial molar enthalpies and partial molar volumes.
Steps to reproduce
This can also be seen in by computing these values as (a) the total quantity directly, (b) the dot product of the partial molar quantities with the mole fractions and (c) the dot product of the standard state quantities with the mole fractions.
>>> gas = ct.Solution('nDodecane_Reitz.yaml')
>>> gas.TPY = 300, 100 * ct.one_atm, 'CO2: 1.0, CH4: 1.0'
>>> gas.int_energy_mole
-164146896.2111432
>>> sum(gas.partial_molar_int_energies * gas.X)
-162451424.60398442
>>> sum(gas.X * gas.standard_int_energies_RT * ct.gas_constant * gas.T)
-162451424.6039844
>>> gas.cp_mole
56325.864657238315
>>> sum(gas.partial_molar_cp * gas.X)
35800.6557848247
>>> sum(gas.X * gas.standard_cp_R * ct.gas_constant)
35800.655784824696Behavior
(a) and (b) should give identical values, but instead, (b) and (c) give identical values:
System information
- Cantera version: 2.5.1 /
mainbranch at bbb752a