jjgomera / iapws

python libray for IAPWS standard calculation of water and steam properties
GNU General Public License v3.0
170 stars 64 forks source link

Problem when calculate density #70

Closed yiping-git closed 11 months ago

yiping-git commented 11 months ago

Hi,

This work helped me a lot, thank you!

But I met a problem when calculating the density of water under saturated vapor pressure:

for t in range(100,260,10):
    t = t + 273.16 # to kelvin
    sat_vp = iapws.iapws97._PSat_T(t)
    water = iapws.iapws97.IAPWS97(T=t, P=sat_vp)
    rho = water.rho
    print(t, sat_vp, rho)

the output is:

# t       sat_vp                    rho
373.16 0.101454175185790 0.5983356525765507
383.16 0.143424132639235 0.8271232345047005
393.16 0.198728323471400 1.12228436641077
403.16 0.270340446243486 1.4972364265432332
413.16 0.361603245192254 926.1231396954009
423.16 0.476229003905304 2.548398203083523
433.16 0.618296419089154 3.260039863128644
443.16 0.792244622230799 897.4444319746991
453.16 1.002865188165989 886.9946352680865
463.16 1.255293024303198 876.0729346948829
473.16 1.554997088684903 7.861846538110679
483.16 1.907771956567075 9.589419096863011
493.16 2.319731363530238 840.2129933441278
503.16 2.79730502274571  827.1090491793891
513.16 3.347240277790728 813.3507541339516
523.16 3.976610557728294 798.8750608132859

the density values looks strange, as a reference, here are values calculated with the CHNOSZ R package:

T(°C)   P(bar)       rho   
100   1.013220 0.9583926 
110   1.432410 0.9509951 
120   1.984829 0.9431552 
130   2.700203 0.9348829 
140   3.611948 0.9261835 
150   4.757169 0.9170577 
160   6.176634 0.9075019 
170   7.914706 0.8975079 
180  10.019272 0.8870627 
190  12.541651 0.8761489 
200  15.536499 0.8647434 
210  19.061733 0.8528175 
220  23.178463 0.8403358 
230  27.950971 0.8272548 
240  33.446729 0.8135218 
250  39.736493 0.7990719 
jjgomera commented 11 months ago

Hi, the principal difference is the units of density returned values, iapws return kg/m3, the other library are g/cm3. Furthermore, for saturated stated don't use the P-T as pair input parameters, use the T-x pair input parameters.

liq_sat = IAPWS97(T=t, x=0) vap_sat = IAPWS97(T=t, x=1)

I can't check right now because I don't have a PC but probably that's is the reason of tiny decimal deviation between both libraries

yiping-git commented 11 months ago

You are right, the problem is the input of the saturated state

water = iapws.iapws97.IAPWS97(T=t, P=sat_vp) 

is problematic

liq_sat =  iapws.iapws97.IAPWS97(T=t, x=0)

works

the result:

#T(K)        P(MPa)                 kg/m^3
373.16 0.1014541751857905  958.3470966887131
383.16 0.14342413263923512 950.9420658011924
393.16 0.19872832347140001 943.0976170897111
403.16 0.27034044624348613 934.8231741477138
413.16 0.36160324519225406 926.1231396954009
423.16 0.476229003905304   916.9972445842704
433.16 0.6182964190891547  907.4407368057052
443.16 0.7922446222307992  897.4444319746991
453.16 1.0028651881659896  886.9946352680865
463.16 1.2552930243031988  876.0729346948829
473.16 1.554997088684903   864.6558537877045
483.16 1.9077719565670752  852.7143345086881
493.16 2.319731363530238   840.2129933441278
503.16 2.79730502274571    827.1090491793891
513.16 3.347240277790728   813.3507541339516
523.16 3.976610557728294   798.8750608132859

Thank you!