TTSE range
There seems to be a bug with the TTSE range detection.
In [1]: import CoolProp.CoolProp as CP
In [2]: fluid = "n-Pentane"
In [3]: CP.enable_TTSE_LUT(fluid)
Out[3]: True
In [4]: CP.PropsSI('H','T',477.8,'D',31.77945717536664,fluid)
Out[4]: 320683.871345781
In [5]: CP.PropsSI('H','T',477.8,'P',1.4700000000000000e+06,fluid)
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-5-f8a5455cae59> in <module>()
----> 1 CP.PropsSI('H','T',477.8,'P',1.4700000000000000e+06,fluid)
/usr/local/lib/python2.7/dist-packages/CoolProp-4.1.2-py2.7-linux-i686.egg/CoolProp/CoolProp.so in CoolProp.CoolProp.PropsSI (build/temp.linux-i686-2.7/pyrex/CoolProp/CoolProp.cpp:12223)()
/usr/local/lib/python2.7/dist-packages/CoolProp-4.1.2-py2.7-linux-i686.egg/CoolProp/CoolProp.so in CoolProp.CoolProp.PropsSI (build/temp.linux-i686-2.7/pyrex/CoolProp/CoolProp.cpp:11622)()
/usr/local/lib/python2.7/dist-packages/CoolProp-4.1.2-py2.7-linux-i686.egg/CoolProp/CoolProp.so in CoolProp.CoolProp.__PropsSI_err2 (build/temp.linux-i686-2.7/pyrex/CoolProp/CoolProp.cpp:11150)()
ValueError: CoolProp error: Input to TTSE [T = 477.8, rho = 31.77945717536664] is out of range :: inputs were:"H","T",4.7780000000000001e+02,"P",1.4700000000000000e+06,"n-Pentane"
Note that the direct T,D call works. It is only T,P that gives an error. I will try to fix it myself.
OK, the problem is that line 2440 (if (i<0 || i>(int)NT-1 || j<0 || j>(int)Nrho-1)) and line 2116 (return (0 <= i && i <= (int)NT && 0 <= (int)j && j <= (int)Nrho);) differ in TTSE.cpp. I am going to fix it as soon as I figured out what is the correct way...
Well, the problem is solved, but we should unify the range checking and use the exposed functions internally instead of manually doing the range comparison...
This does not seem to be all done. Some funny errors keep popping up. It is a little tough to debug because there are some interesting things going on when tables are built and during saturation calls...
Looks like there are some more issues with the bicubic interpolation:
import CoolProp.CoolProp as CP
def runLine(in1=[]):
out = []
for i in range(len(in1)):
out.append(CP.PropsSI(in1[i][0],in1[i][1],in1[i][2],in1[i][3],in1[i][4],in1[i][5]))
print out
fluid = "n-Pentane"
CP.enable_TTSE_LUT(fluid)
CP.PropsSI('H','T',477.8,'D',31.77945717536664,fluid)
CP.disable_TTSE_LUT(fluid)
val = ['H','T','P']
H = [320683.8718103034, -66337.56629141961, -384680.8070781441]
T = [477.8 , 418.67414597586514, 300]
P = [14.7e+05 , 14.7e+05 , 1.47e+05]
num = [H,T,P]
for i in range(len(H)):
out = []
out.append(CP.PropsSI(val[0],val[1],num[1][i],val[2],num[2][i],fluid))
out.append(CP.PropsSI(val[1],val[2],num[2][i],val[0],num[0][i],fluid))
print out
print
print "And now with TTSE"
CP.enable_TTSE_LUT(fluid)
CP.set_TTSE_mode(fluid, "TTSE")
CP.set_debug_level(0)
for i in range(len(H)):
out = []
out.append(CP.PropsSI(val[0],val[1],num[1][i],val[2],num[2][i],fluid))
out.append(CP.PropsSI(val[1],val[2],num[2][i],val[0],num[0][i],fluid))
print out
print
print "And now with BICUBIC"
CP.enable_TTSE_LUT(fluid)
CP.set_TTSE_mode(fluid, "BICUBIC")
CP.set_debug_level(0)
for i in range(len(H)):
out = []
out.append(CP.PropsSI(val[0],val[1],num[1][i],val[2],num[2][i],fluid))
out.append(CP.PropsSI(val[1],val[2],num[2][i],val[0],num[0][i],fluid))
print out
with the old TTSE.cpp without my recent changes this results in:
0.07 to build both two phase tables
[320683.8718103034, 477.8000000000005]
[-66337.56629141963, 418.67414597586514]
[-384674.95095193223, 299.9974796336408]
And now with TTSE
[320564.30656044604, 477.7999999999999]
[-66337.95399412834, 418.67414601110397]
[-384674.9508332794, 299.9974795821881]
And now with BICUBIC
Traceback (most recent call last):
File "../../dev/Tickets/205.py", line 73, in <module>
out.append(CP.PropsSI(val[0],val[1],num[1][i],val[2],num[2][i],fluid))
File "CoolProp.pyx", line 360, in CoolProp.CoolProp.PropsSI (build/temp.linux-i686-2.7/pyrex/CoolProp/CoolProp.cpp:12223)
File "CoolProp.pyx", line 458, in CoolProp.CoolProp.PropsSI (build/temp.linux-i686-2.7/pyrex/CoolProp/CoolProp.cpp:11622)
File "CoolProp.pyx", line 356, in CoolProp.CoolProp.__PropsSI_err2 (build/temp.linux-i686-2.7/pyrex/CoolProp/CoolProp.cpp:11150)
ValueError: CoolProp error: Input to TTSE [T = 477.8, logrho = inf] is out of range :: inputs were:"H","T",4.7780000000000001e+02,"P",1.4700000000000000e+06,"n-Pentane"
and with the latest changes, we obtain:
0.07 to build both two phase tables
[320683.8718103034, 477.8000000000005]
[-66337.56629141963, 418.67414597586514]
[-384674.95095193223, 299.9974796336408]
And now with TTSE
[320564.30656044604, 477.7999999999999]
[-66337.95399412834, 418.67414601110397]
[-384674.9508332794, 299.9974795821881]
And now with BICUBIC
[-27333459712211.734, 477.7999999999999]
Traceback (most recent call last):
File "../../dev/Tickets/205.py", line 73, in <module>
out.append(CP.PropsSI(val[0],val[1],num[1][i],val[2],num[2][i],fluid))
File "CoolProp.pyx", line 360, in CoolProp.CoolProp.PropsSI (build/temp.linux-i686-2.7/pyrex/CoolProp/CoolProp.cpp:12223)
File "CoolProp.pyx", line 458, in CoolProp.CoolProp.PropsSI (build/temp.linux-i686-2.7/pyrex/CoolProp/CoolProp.cpp:11622)
File "CoolProp.pyx", line 356, in CoolProp.CoolProp.__PropsSI_err2 (build/temp.linux-i686-2.7/pyrex/CoolProp/CoolProp.cpp:11150)
ValueError: CoolProp error: Input to TTSE [p = 1470000, h = -1970531.270181991] is out of range :: inputs were:"H","T",4.1867414597586514e+02,"P",1.4700000000000000e+06,"n-Pentane"