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

If Vapor quality is a small value, (h,s) of IAPWS97 raise NotImplementedError("Incoming out of bound") #24

Closed thermalogic closed 7 years ago

thermalogic commented 7 years ago
from iapws.iapws97 import IAPWS97

f_px =IAPWS97(P=0.00353658941,x=0.20)
f_hs = IAPWS97(h=f_px.h, s=f_px.s)
print(f_hs.P)

_Bound_hs(h, s) Returns region = None
raise
NotImplementedError("Incoming out of bound")

jjgomera commented 7 years ago

You are right, and with 0.2 as quality value isn't a small value near saturation line, so this is a gross bug. Nowadays I'm trying to add coverage to iapws code, and i can see the _Bound_hs method is too tricky and bug prone. I'm trying to rewrite it. Thanks and stay tuned for commit

thermalogic commented 7 years ago

Your job is the most perfect in all open source codes on IAPWS-IF97. Thanks

Please check the following code:

    if h <= hmax:
        if smin <= s <= s13:
            P = _Backward1_P_hs(h, s) # if (h,s) is wet steam region, the line may produce the bug, p is error.
            T = _Backward1_T_Ph(P, h)
            if T-0.0218 >= 273.15 and Pt <= P <= 100:
                hs = _h1_s(s)
                if h >= hs:
                    region = 1
                elif hmin <= h < hs:
                    region = 4
jjgomera commented 7 years ago

Hi, i think it's solved with last commit

In [1]: from iapws.iapws97 import IAPWS97
In [2]: f_px = IAPWS97(P=0.00353658941, x=0.2)
In [3]: f_hs = IAPWS97(h=f_px.h, s=f_px.s)
In [4]: f_hs.P
Out[4]: 0.003536589410004118
In [5]: f_hs.x
Out[5]: 0.19999999999996446

Try it

thermalogic commented 7 years ago

Your work is great! I have improved my IF97 code in C with your python code Thanks!