Closed Michael-ljn closed 8 months ago
Hi, thanks for reporting this. How are you validating what the correct enthalpy is? Enthalpy requires a reference state, so you should really only compare differences in enthalpy between states, not absolute values.
Yes, sorry for not putting the delta in the screenshot, I wanted to highlight that w.cp*w.T
and w.h
are not equal, which leads to some issues for me. I use in my code both cp
, h
and even H
separately for a given quantity, using ct.Quantity()
. As you plug in some large values for the mass in ct.Quantity()
, there is a noticeable disbalance. I avoided the issue by using w.cp*w.T
only, but then I am not sure if I can use the w.cp*w.T
value when setting HP values.
In the screenshot below, I set a new state at 60°C
I think this result makes sense. The root of the misunderstanding, I think, is that ct.Water()
actually represents a pure fluid that can assume liquid, two-phase, or gas states, with a correspondingly complicated equation of state. Therefore, I think the problem is how you're computing Delta h for the cp * T case. The definition of change of enthalpy (assuming c_p is a function of temperature only and c_p is continuous) is
Delta h = \int T_ref T_2 c_p(T) dT - \int T_ref T_1 c_p(T) dT
However, when calculating c_p_2 T_2 - c_p_1 T_1, you're not accounting for the variation of c_p with temperature, which the underlying equation of state in ct.Water()
is accounting for. In addition, c_p in general is also a function of pressure, which I'm pretty sure is also accounted for by the equation of state implemented in ct.Water()
(although the variation is likely small for these liquid states). Finally, if you were to cross a phase change, the ct.Water()
class also accounts for phase changes, in which c_p is infinite and we have to add the enthalpy of vaporization (in the case of liquid->vapor change).
Also, just to note a typo in your first image, c_p is the specific heat at constant pressure, not constant volume, c_p = \left\ \frac{\partial h}{ \partial T} \right)_P
I see, I was under the impression that the cp captured all variations between the states and that specific enthalpy was directly derived from the computed value of the cp. This is why I assumed cp*T could be used interchangeably with the specific enthalpy. I will stick to delta h in that case.
Thanks a lot for your help on this!
(About the typo yes indeed, I copied the wrong line from the documentation and manually corrected for Cp but forgot to past the correct line from the doc 😅)
Just to be extra clear:
I was under the impression that the cp captured all variations between the states
Cantera captures the cp variation between states for all the thermo models that Cantera supports, except the constant cp model which is constant by definition. That means you need to integrate from T1 to T2 to have the correct Delta h. And that's only for the case where cp is a function of temperature only (which is ideal gases and incompressible fluids). As I said, for the ct.Water()
class, it implements a more complicated equation of state which accounts for both temperature and pressure variation in cp. The reference work is noted here:
https://github.com/Cantera/cantera/blob/60ea75af4a3f34f163da07502953913a1a313cf8/interfaces/cython/cantera/liquidvapor.py#L17
Just chiming in to add two aspects that haven't been explicitly mentioned (I think; apologies if I simply missed it).
Δh = \int Cp dT
only equals CpΔT
if Cp
is constant. If Cp
varies between the two states, then Δh = Cp_avg(T2 - T1)
is frequently a pretty accurate approach, but I would not expect Cp_2*T2 - Cp_1*T1
to be all that accurate.h_i = CpT_i
into an energy balance is usually functionally/mathematically equivalent to the actual relationship above (Δh = CpΔT
), so long at constant Cp
is reasonable. I.e. it is a "correct" practice, even though it is incorrect from a theory perspective. It is therefore pretty common in undergrad thermo, for example, that students leave with the impression that h_i = CpT_i
.Thank you both for your detailed explanation and time on this!
Problem description
The enthalpies are inconsistent after updating to Cantera 3.0.0.
After importing Cantera as ct , I use the following commands:
w=ct.Water()
w.basis="mass"
w.TP=273.15+25,ct.one_atm
w.h
to obtain the specific enthalpy returns something very weird and that does not equalw.cp*w.T
. After some checks,w.cp*w.T
returns the correct result andw.h
not.System information
Attachments
since the issue is very basic, here is a screenshot: