CoolProp icon indicating copy to clipboard operation
CoolProp copied to clipboard

Fix set_Tp_limits TypeError

Open HaSchneider opened this issue 3 months ago • 4 comments

Description of the Change

This should solve the issue #2289 by setting the limits in the set_Tp_limits method as tuple and not as list.

Verification Process

Tested with:

from CoolProp.Plots import PropertyPlot
plot = PropertyPlot('Water', 'hs', tp_limits = 'ORC')
my_limits=[10, 800, 0.1, 40]
plot.set_Tp_limits(my_limits)
plot.calc_isolines()
plot.show()

Screenshot: grafik

Applicable Issues

Closes #2289

HaSchneider avatar Sep 11 '25 08:09 HaSchneider

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Sep 11 '25 08:09 CLAassistant

Can you please confirm that you can also set the limits by specifying the limit set ('achp' for instance)

ibell avatar Sep 13 '25 01:09 ibell

Almost every limit set works most of the time:

grafik

Sometimes it randomly gives me userwarnings but a result anyway:

[c:\Apps\anaconda3\envs\test_coolprop\lib\site-packages\CoolProp\Plots\Common.py:655](file:///C:/Apps/anaconda3/envs/test_coolprop/lib/site-packages/CoolProp/Plots/Common.py:655): UserWarning: An error occurred for inputs 39.240696, 1455.965854 with index (0,): Even by increasing rhoc, not able to bound input; input 0.706932 is not in range 27.7706,394.92
  warnings.warn(
[c:\Apps\anaconda3\envs\test_coolprop\lib\site-packages\CoolProp\Plots\Common.py:655](file:///C:/Apps/anaconda3/envs/test_coolprop/lib/site-packages/CoolProp/Plots/Common.py:655): UserWarning: An error occurred for inputs 89.950814, 1455.965854 with index (1,): Even by increasing rhoc, not able to bound input; input 1.62049 is not in range 27.7706,394.92
  warnings.warn(
[c:\Apps\anaconda3\envs\test_coolprop\lib\site-packages\CoolProp\Plots\Common.py:655](file:///C:/Apps/anaconda3/envs/test_coolprop/lib/site-packages/CoolProp/Plots/Common.py:655): UserWarning: An error occurred for inputs 140.660932, 1455.965854 with index (2,): Even by increasing rhoc, not able to bound input; input 2.53404 is not in range 27.7706,394.92
  warnings.warn(
[c:\Apps\anaconda3\envs\test_coolprop\lib\site-packages\CoolProp\Plots\Common.py:655](file:///C:/Apps/anaconda3/envs/test_coolprop/lib/site-packages/CoolProp/Plots/Common.py:655): UserWarning: An error occurred for inputs 191.371050, 1455.965854 with index (3,): Even by increasing rhoc, not able to bound input; input 3.4476 is not in range 27.7706,394.92
  warnings.warn(
[c:\Apps\anaconda3\envs\test_coolprop\lib\site-packages\CoolProp\Plots\Common.py:608](file:///C:/Apps/anaconda3/envs/test_coolprop/lib/site-packages/CoolProp/Plots/Common.py:608): UserWarning: Please use "calc_sat_range" to calculate saturation and isoquality lines. Input ranges are discarded.
  warnings.warn(
[c:\Apps\anaconda3\envs\test_coolprop\lib\site-packages\CoolProp\Plots\Plots.py:217](file:///C:/Apps/anaconda3/envs/test_coolprop/lib/site-packages/CoolProp/Plots/Plots.py:217): UserWarning: Detected an incomplete phase envelope, fixing it numerically.

And the "achp" limit set does not work at all, but even without my changes:

---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
Cell In[6], [line 2](vscode-notebook-cell:?execution_count=6&line=2)
      1 plot = PropertyPlot('Water', 'hs', tp_limits = 'achp')
----> [2](vscode-notebook-cell:?execution_count=6&line=2) plot.calc_isolines()
      3 plot.show()

File c:\Apps\anaconda3\envs\test_coolprop\lib\site-packages\CoolProp\Plots\Plots.py:127, in PropertyPlot.calc_isolines(self, iso_type, iso_range, num, rounding, points)
    125     for i_type in IsoLine.XY_SWITCH:
    126         if IsoLine.XY_SWITCH[i_type].get(self.y_index * 10 + self.x_index, None) is not None:
--> [127](file:///C:/Apps/anaconda3/envs/test_coolprop/lib/site-packages/CoolProp/Plots/Plots.py:127)             self.calc_isolines(i_type, None, num, rounding, points)
    128     return
    130 if iso_range is None:

File c:\Apps\anaconda3\envs\test_coolprop\lib\site-packages\CoolProp\Plots\Plots.py:160, in PropertyPlot.calc_isolines(self, iso_type, iso_range, num, rounding, points)
    158 lines = self.isolines.get(iso_type, [])
    159 for i in range(num):
--> [160](file:///C:/Apps/anaconda3/envs/test_coolprop/lib/site-packages/CoolProp/Plots/Plots.py:160)     lines.append(IsoLine(iso_type, self._x_index, self._y_index, value=dim.to_SI(iso_range[i]), state=self._state))
    161     lines[-1].calc_range(ixrange, iyrange)
    162     lines[-1].sanitize_data()

IndexError: index 1 is out of bounds for axis 0 with size 1

HaSchneider avatar Sep 25 '25 15:09 HaSchneider

Did you test all the others, including setting the limits via tuple? That is required before this PR can be merged

ibell avatar Oct 02 '25 22:10 ibell