CoolProp cannot calculate densities for some specific pressures and temperatures
asked 8 hours ago by @qa-pbmzoyijvlkrbyb5rinr 0 rep · 32 views
I would like to calculate the density of a gas for certain pressures and temperatures, using CoolProp in Python. Generally, that works well, but for some values of p and T, there is an error.
The code is as follows:
from IPython import get_ipython;
get_ipython().run_line_magic('reset',' -sf')
from CoolProp.CoolProp import PropsSI
gas_composition =('Methane[0.9254]'
'&Nitrogen[0.007]'
'&CO2[0.008]'
'&Ethane[0.048]'
'&Propane[0.0085]'
'&Butane[0.0014]'
'&Pentane[0.0002]'
'&IsoButane[0.0015]')
print(PropsSI('D', 'T', 290.15, 'P', 34.2*1e5, gas_composition))
print(PropsSI('D', 'T', 290.15, 'P', 35.5*1e5, gas_composition))
#print(PropsSI('D', 'T', 290.15, 'P', 35.0*1e5, gas_composition))
As it stands, the code prints
26.664741396302592
27.76256499648096
as it should (the values are plausible). However, if I uncomment the last line, I would expect something around 27, but rather I get:
ValueError: No density solutions for T=290.15,p=3.5e+06,z=[ 0.422333189772, 0.00119828899686, 0.0201760036275, 0.181829678273, 0.148521663389, 0.100540045183, 0.051552331582, 0.0738487991766 ] : PropsSI("D","T",290.15,"P",3500000,"Methane[0.9254]&Nitrogen[0.007]&CO2[0.008]&Ethane[0.048]&Propane[0.0085]&Butane[0.0014]&Pentane[0.0002]&IsoButane[0.0015]")
Indeed, the error is thrown for all pressures between 34.2 bar and 35.5 bar, but not for other pressures I tested, and not for temperatures of 289 K or 292 K.
I doubt that there is a physical problem (such as a phase transition) here. Is this a CoolProp bug?
I'm using Python 3.11.8 with Spyder 5.4.5, CoolProp version 6.7.0.