-
Notifications
You must be signed in to change notification settings - Fork 299
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Computational performance #411
Comments
Could you do the same with REFPROP? I'm curious to see how the speeds compare. |
Very interesting results - makes me think that the solver for the melting line is the problem. When you are below the critical temp, D,T is very slow! This might actually be pretty easy to fix. @jowr , do you still have the code used to generate this figure? The performance in the subcooled liquid region is VERY bad. |
I added the script to https://github.com/CoolProp/CoolProp/tree/master/dev/TTSE |
Ok, I now understand this issue. There is a clear problem for D,T inputs that I don't entirely understand how to fix. I was checking that if the density was more than 1.05 times the ancillary equation for saturated liquid density, it was liquid. As it turns out, because the liquid phase is very, very incompressible, 5% turns into a large pressure (the red line in the figure). Thus, all the slow points are places where it tries to do a saturation call. import matplotlib.pyplot as plt, CoolProp, numpy as np
import time
import matplotlib.colors as colors
backend = 'HEOS'
fld = 'CO2'
Tt, Tmax = CoolProp.CoolProp.PropsSI('Ttriple', fld), CoolProp.CoolProp.PropsSI('Tmax', fld)
pt, pmax = CoolProp.CoolProp.PropsSI('ptriple', fld), CoolProp.CoolProp.PropsSI('pmax', fld)
Ts = np.linspace(Tt, CoolProp.CoolProp.PropsSI('Tcrit', fld))
ps = CoolProp.CoolProp.PropsSI('P','T',Ts,'Q',1,backend+'::'+fld)
plt.plot(Ts, ps, 'k')
rhos = CoolProp.CoolProp.PropsSI('D','T',Ts,'Q',0,backend+'::'+fld)
p2 = CoolProp.CoolProp.PropsSI('P','T',Ts,'D',1.05*rhos,backend+'::'+fld)
plt.plot(Ts, p2, 'r')
NT, Np = 50, 50
HEOS = CoolProp.AbstractState(backend, fld)
data = []
for T in np.linspace(Tt, Tmax, NT):
for p in np.logspace(np.log10(pt*1.05), np.log10(pmax), Np):
rho = CoolProp.CoolProp.PropsSI('D','T',T,'P',p,backend+'::'+fld)
t1 = time.clock()
N = 1000
for i in range(N):
HEOS.update(CoolProp.DmassT_INPUTS, rho, T)
HEOS.p()
t2 = time.clock()
data.append((T, p, (t2-t1)/N))
T, p, times = zip(*data)
cNorm = colors.LogNorm(vmin=1e-6, vmax=200e-6)
plt.scatter(T, p, c = times, cmap = plt.get_cmap('jet'), s = 20, lw = 0, norm = cNorm)
cb = plt.colorbar()
cb.set_label('time per call (s)')
plt.yscale('log')
plt.xlabel('T (K)')
plt.ylabel('p (Pa)')
plt.tight_layout()
plt.savefig(fld+'.png')
plt.show() |
And now with P,H as inputs: import matplotlib.pyplot as plt, CoolProp, numpy as np
import time
import matplotlib.colors as colors
backend = 'HEOS'
fld = 'CO2'
Tt, Tmax = CoolProp.CoolProp.PropsSI('Ttriple', fld), CoolProp.CoolProp.PropsSI('Tmax', fld)
pt, pmax = CoolProp.CoolProp.PropsSI('ptriple', fld), CoolProp.CoolProp.PropsSI('pmax', fld)
Ts = np.linspace(Tt, CoolProp.CoolProp.PropsSI('Tcrit', fld))
ps = CoolProp.CoolProp.PropsSI('P','T',Ts,'Q',1,backend+'::'+fld)
plt.plot(Ts, ps, 'k')
rhos = CoolProp.CoolProp.PropsSI('D','T',Ts,'Q',0,backend+'::'+fld)
p2 = CoolProp.CoolProp.PropsSI('P','T',Ts,'D',1.05*rhos,backend+'::'+fld)
plt.plot(Ts, p2, 'r')
NT, Np = 50, 50
HEOS = CoolProp.AbstractState(backend, fld)
data = []
for T in np.linspace(Tt, Tmax, NT):
for p in np.logspace(np.log10(pt*1.0), np.log10(pmax), Np):
try:
h = CoolProp.CoolProp.PropsSI('H','T',T,'P',p,backend+'::'+fld)
t1 = time.clock()
N = 100
for i in range(N):
HEOS.update(CoolProp.HmassP_INPUTS, h, p)
HEOS.p()
t2 = time.clock()
data.append((T, p, (t2-t1)/N*1e6))
except:
pass
T, p, times = zip(*data)
cNorm = colors.Normalize(vmin=np.min(times), vmax=np.max(times))
plt.scatter(T, p, c = times, cmap = plt.get_cmap('jet'), s = 20, lw = 0, norm = cNorm)
cb = plt.colorbar()
cb.set_label('time per call ($\mu$s)')
plt.yscale('log')
plt.xlabel('T (K)')
plt.ylabel('p (Pa)')
plt.tight_layout()
plt.savefig(fld+'.png')
plt.show() |
That looks good already, let us keep this issue around. Could be nice to get closer to REFPROP performance, which should be possible.. |
Yeah that's why I was hoping you could run your script again so we can see since I can't run your script. |
I thought, I fixed the script, but now there are some issues with CO2. You could try to run and see where it takes you. |
I have tried, but I'm missing quite a lot of stuff, like jopy :) On Sat, Apr 25, 2015 at 4:57 PM, Jorrit Wronski notifications@github.com
|
Have you tried the latest version? 20 minutes old ... |
Ah not since then, you mean T-S? I'm aware of that issue at least : #619 On Sat, Apr 25, 2015 at 5:04 PM, Jorrit Wronski notifications@github.com
|
Hmm seems broken. I get a lot of errors like these:
On Sat, Apr 25, 2015 at 5:05 PM, Ian Bell ian.h.bell@gmail.com wrote:
|
Yes, I get the same error. I am afraid that it comes from inside CoolProp because the error also occurred after I disabled the melting line in the plots. :( |
Argh. I think we are getting pretty close to REFPROP speed, but its On Sat, Apr 25, 2015 at 5:11 PM, Jorrit Wronski notifications@github.com
|
Yes, that is why the script does not run a "best of X" configuration for the different points. I see what I can do about the script next month. It would be really nice to have a reliable method for mapping the performance, especially with inputs that require iteration like h,p. |
Yeah, and that way we could triage and see what is most important to fix. On Sat, Apr 25, 2015 at 5:17 PM, Jorrit Wronski notifications@github.com
|
Very nice! The f(rho,T) calls improved significantly for CO2 (the script works now). |
After revising the data for #624, I am tempted to say that the CO2 and water errors are caused by some change in CoolProp's intestines. |
The HEOS backend for air still produces many exceptions, I left it out. For water, something is wrong with Tmin in the REFPROP wrapper. REFPROP keeps choking, I also imitted that. For the other fluids, here are the latest results based on 50 000 data points with the very latest CoolProp: CO2n-pentaneR134a |
No, not if we take Modelica to 5.1.1. |
More data:
yields
|
See also updates to PY in 8e5930d |
I currently try to map the performance of the EOS solvers as f(D,T) and f(H,P) and it produces very interesting graphs. One thing that strikes me is that all fluids I have looked at exhibit a poor performance for subcooled liquid with T<Tcrit. Is that related to the guess values? There is also pressure band from pcrit<p<5*pcrit where performance is limited. The inflection points of the critical isotherm affect the behaviour as well. @ibell, have you ever looked into that? These plots could help us to improve performance even more in the future.
The text was updated successfully, but these errors were encountered: