I'm using GEKKO and CoolProp for thermal systems simulation. When trying to use CoolProp's functions inside the model equations (as shown below for an isentropic expansion) I'm getting an error message regarding the variable type: "must be real number, not GKVariable". Could someone please help me with this issue?
from gekko import GEKKO
import CoolProp.CoolProp as CP
#
p1 = 2e5
T1 = 300.0 + 273.15
p2 = 1e5
eta = 0.80
fluid = 'H2O'
#
h1 = CP.PropsSI('H','T',T1,'P',p1,fluid)
s1 = CP.PropsSI('S','T',T1,'P',p1,fluid)
#
m = GEKKO()
h2 = m.Var()
h2s = m.Var()
T2 = m.Var()
#
m.Equation(eta * (h1 - h2) - (h1 - h2s) == 0)
m.Equation(h2s - CP.PropsSI('H','S',s1,'P',p2,fluid) == 0)
m.Equation(h2 - CP.PropsSI('H','T',T2,'P',p2,fluid) == 0)
#
m.options.IMODE = 1 #Steady state
m.options.SOLVER = 3 # solver (IPOPT)
m.solve(disp=False)
#
print(T2.value[0])
Thanks in advance.