jjgomera/iapws

Curious difference in steam fugacity coefficients between IAPWS95 and 97

Closed this issue · 7 comments

I came across this difference when doing thermodynamic calculations of water vapor at lower temperatures. To illustrate this

water95=iapws.IAPWS95(P=2.5,T=300)
water97=iapws.IAPWS97(P=2.5,T=300)
print(water95.fi) # 0.0014380592326015483
print(water97.fi) # 0.9795678149261304

Clearly the first result is wrong. Other properties such as enthalpy and entropy are consistent between 95 and 97, and at high temperature the results are also close. I wonder if this is due to some inherent bug in the 95 formulations.

You're right, the iapws95 used a bad formulae to calculate that property, fixed with last commit.

Thanks for report!!

I am afraid this does not give correct fugacity coefficient either. The g0 value is 1458.72, and to get the correct value, g0 should be zero. I am not sure if this is fixable without introducing something like the region criteria as in IAPWS97.

ummm, really iapws97 was the wrong, it forced g0 to 0 for liquid water with no reason at all. There are too errors in ideal properties for iapws95, but for fugacity the values from iapws95 was the correct, i undo last commit and add fix in last commit, try now.

For check value i've found this paper with experimental values for the fugacity of vapor water

import iapws
from math import log

pi = (5, 10, 15, 20, 25, 30, 40, 50, 60, 70, 80, 90, 100, 120, 140, 160, 180,
      200, 240, 280, 320, 360, 400, 500, 600, 700, 800, 900, 1000)
ti = (673.15, 773.15, 873.15, 973.15, 1073.15)

for p in pi:
    lst95 = []
    lst97 = []
    for t in ti:
        try:
            water97=iapws.IAPWS97(P=p, T=t)
            lst97.append(-log(water97.fi))
        except NotImplementedError:
            pass

        water95=iapws.IAPWS95(P=p, T=t)
        lst95.append(-log(water95.fi))

    # print(lst97)
    print(lst95)

This code generate the table 2 in paper with fairly similar values at all range of P and T.

Now both library return similar values for your example too

water95=iapws.IAPWS95(P=2.5, T=300)
water97=iapws.IAPWS97(P=2.5, T=300)
print(water97.fi, water95.fi)
>>> 0.0014380718720867372 0.0014380592326015483

Waiting for any other comments you can add, thank you for your feedback, and sorry for the delay in responding

I do not find any sources saying why the g0 for liquid water is set to zero for iapws97. I checked the CORK equations for H2O by Holland and Powell (1998), and it gave the fugacity for water at different temperature and pressure, which convert to similar results for iapws95.
Screenshot 2024-04-20 at 22 04 23

I can't reproduce that values with iapws, sorry

I didn't make myself clear. I can reproduce the table as follows


import numpy as np
from iapws import IAPWS95

R = 0.008314  # kJ/mol/K
t = np.arange(200, 1100, 100)
p = np.arange(0.5, 10.5, 0.5)  # kbar
T, P = np.meshgrid(t + 273.15, p * 1e2)  # °C to K, kbar to MPa
phi = np.zeros_like(P.flatten())
for i, (Pi, Ti) in enumerate(zip(P.ravel(), T.ravel())):
    phi[i] = IAPWS95(T=Ti, P=Pi).fi # now IAPWS97 gives same value
phi = phi.reshape(P.shape)
f = phi * P * 1e6  # Pa
print(R * T * np.log(f / 1e5))

Thanks, I couldn't understand the RTlog(f) equation correctly in that paper, f in bar. So, I think bug fixed finally.