Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IdealSolidSolnPhase::getPartialMolarEnthalpies - needs pressure dependence? #1080

Closed
decaluwe opened this issue Jul 30, 2021 · 4 comments · Fixed by #1087
Closed

IdealSolidSolnPhase::getPartialMolarEnthalpies - needs pressure dependence? #1080

decaluwe opened this issue Jul 30, 2021 · 4 comments · Fixed by #1087

Comments

@decaluwe
Copy link
Member

decaluwe commented Jul 30, 2021

Problem description
The getPartialMolarEnthalpies routine in IdealSolidSolnPhase would appear to be missing the required pressure dependence implemented elsewhere in the model.

All other enthalpy (and, by association, chemical potential) calculations involve some form of (P - Pref)*molarVolume (where molarVolume is of either the phase or the individual species).

IdealSolidSolnPhase::getPartialMolarEnthalpies does not:

void IdealSolidSolnPhase::getPartialMolarEnthalpies(doublereal* hbar) const
{
    const vector_fp& _h = enthalpy_RT_ref();
    scale(_h.begin(), _h.end(), hbar, RT());
}

I think this ought to be replaced with:

void IdealSolidSolnPhase::getPartialMolarEnthalpies(doublereal* hbar) const
{
    const vector_fp& _h = enthalpy_RT_ref();
    scale(_h.begin(), _h.end(), hbar, RT());
    double delta_p = (m_Pcurrent - m_Pref);
    for (size_t k = 0; k < m_kk; k++) {
        hbar[k] += delta_p * m_speciesMolarVolume[k];
    }
}

System information

  • Cantera version: 2.6.0a2

Wanted to check if I was missing something, before fixing it.

@speth
Copy link
Member

speth commented Aug 5, 2021

Seems correct to me. If you follow through the more convoluted logic for the similar IdealSolnGasVPSS class, the (P - Pref)*molarVolume term does get added to the standard state enthalpy, which then gets carried through to the partial molar enthalpies.

@decaluwe
Copy link
Member Author

Sorry if this is dense, but: "seems correct to me" meaning "the current implementation seems correct," or "your critique seems correct?" 🙄

Since IdealSolidSolnPhase does not add the pressure term to the standard state values, I'll assume you mean the latter 😉. Just to make sure, I did a little check:

import cantera as ct
import numpy as np

gas = ct.Solution('IdealSolidSolnPhaseExample.yaml',"solidSolutionExample")

# At standard pressure: h_mole = sum(X_k*h_k)
h_mole = gas.enthalpy_mole
h_k = gas.partial_molar_enthalpies

h_check = np.dot(h_k,gas.X)
print(h_mole, h_check)
5895465.481744414 5895465.481744414

# At non-standard pressure, h_mole shows the correct pressure dependence, but the partial molar enthalpies do not:
gas.TP = None, 3*ct.one_atm
h_mole = gas.enthalpy_mole
h_k = gas.partial_molar_enthalpies
h_check = np.dot(h_k,gas.X)
print(h_mole, h_check)
6199440.481744414 5895465.481744414

When I originally created this issue, I thought we were considering folding IdealSolnGasVPSS into this class. But since the opposite is true, I will hold off on doing anything about this, for now.

@speth
Copy link
Member

speth commented Aug 18, 2021

Yes, I meant your interpretation seems correct and IdealSolidSolnPhase does not.

@decaluwe
Copy link
Member Author

lol, thanks for the confirmation :)

decaluwe added a commit to decaluwe/cantera that referenced this issue Aug 19, 2021
decaluwe added a commit to decaluwe/cantera that referenced this issue Aug 19, 2021
decaluwe added a commit to decaluwe/cantera that referenced this issue Aug 19, 2021
chinahg pushed a commit to chinahg/cantera that referenced this issue Oct 23, 2021
Combustion-Zhen pushed a commit to Combustion-Zhen/cantera that referenced this issue Nov 16, 2021
Combustion-Zhen pushed a commit to Combustion-Zhen/cantera that referenced this issue Nov 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants