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

Backward Equation p(h,s) for Region 1 #25

Closed wbprgrmr closed 7 years ago

wbprgrmr commented 7 years ago

For IAPWS97, using the Table 3 from Supp-PHS12-2014.pdf the first entry returns an "Incoming out of bound" error.

import iapws prop = iapws.IAPWS97(h=0.001, s=0) Traceback (most recent call last): File "", line 1, in File "c:\Python27\lib\site-packages\iapws\iapws97.py", line 2756, in init self.call(**kwargs) File "c:\Python27\lib\site-packages\iapws\iapws97.py", line 2763, in call self.calculo() File "c:\Python27\lib\site-packages\iapws\iapws97.py", line 2940, in calculo raise NotImplementedError("Incoming out of bound") NotImplementedError: Incoming out of bound

When debugging, it appears to be getting the correct pressure value but gets kicked out at line 2552 of iapws97.py, "if T-0.0218 >= 273.15 and Pt <= P <= 100:", where T-0.0218 is a value less than 273.15. Is it possible that the -0.0218 should be +0.0218? T + 0.0218 would be above 273.15. The other entries in Table 3 return close to the correct values:

prop = iapws.IAPWS97(h=90, s=0) prop.P 91.930758227675483 prop = iapws.IAPWS97(h=1500, s=3.4) prop.P 58.677689985997915

jjgomera commented 7 years ago

Hi, I can't reproduce your error:

In [1]: import iapws
In [2]: prop = iapws.IAPWS97(h=0.001, s=0)
In [3]: prop.P
Out[3]: 0.00098296920149068719

I think you aren't using the last version, the line code of error don't fit the last commit. Its for some version from six months ago or so. Try with last commit in github, or the last version in pypi.

The IAPWS97 class implement the several region fundamental equations, the backward equations are used to fast region calculation, so if you want to calculate the backward equation directly use the appropriate Backward procedure:

In [1]: from iapws.iapws97 import _Backward1_P_hs
In [2]: _Backward1_P_hs(0.001, 0)
Out[2]: 0.0009800980612120335
In [3]: _Backward1_P_hs(90, 0)
Out[3]: 91.92954726666242

These values are the same than Table 3 you talk about, but IAPWS97 correct pressure for that value it's the calculated with the IAPWS97 class:

In [1]: import iapws
In [2]: prop = iapws.IAPWS97(h=0.001, s=0)
In [3]: prop.P
Out[3]: 0.00098296920149068719
In [4]: prop.h
Out[4]: 0.00099999877169937106
In [5]: prop.s
Out[5]: -9.1930500900308588e-12

The h and s calculated values are quasi the input parameters.

wbprgrmr commented 7 years ago

Thank you for your reply. I went ahead and updated and this error has gone away.