Skip to content

Redlich-Kwong implementations of getPartialMolarIntEnergies and getPartialMolarCp are incorrect #998

@speth

Description

@speth

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

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:

//! 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.655784824696

Behavior

(a) and (b) should give identical values, but instead, (b) and (c) give identical values:

System information

  • Cantera version: 2.5.1 / main branch at bbb752a

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions