Coolprop not able to calculate values

Viewed 162

today I was trying to apply a fluid-property-calculation to a certain matrix of values. First of all, here is the code I was trying to use:

import CoolProp
from CoolProp.CoolProp import PropsSI
import numpy as np
import matplotlib as mlp 

###Values I know
#Limits of the sytem
p_ND = np.array([5, 7, 9, 10, 13, 20, 23, 32, 52])
p_HD = np.arange(0, 1000, 20)
#print(len(p_HD))
V_HD_max = 96
#assumptions for calculation
T_ND = 293.15
V_in = 240

#switching the array of p_ND to an array of possible entropys at inlet
s_ND_Air = np.array([PropsSI('S', 'T', T_ND, 'P', pi, 'Air') for pi in p_ND])
D_ND_Air = np.array([PropsSI('D', 'T', T_ND, 'P', pi, 'Air') for pi in p_ND])
#Array taht cotains possible mass-flows
m_dot = np.array([V_in * Di for Di in D_ND_Air])
#print(m_dot)
#print(s_ND_Air)

#creating matrices containing entropys and p_HD that can be caluclated with another
s_ND_Air_M, p_HD_M = np.meshgrid(s_ND_Air, p_HD)
#print(s_ND_Air_M)
#print(p_HD_M)

#array with every possible density at outlet
#Matrix contains densitys at this point, will be used to get to volume-flows at outlet
V_out = np.zeros(s_ND_Air_M.shape)
for i, p_i in enumerate(p_HD_M):
    for i, s_i in enumerate(s_ND_Air_M):
        V_out[i] = PropsSI('D', 'P', p_i, 'S', s_i, 'Air')

Now the error-message I received:

Traceback (most recent call last):
  File directory(placeholder)
  File "CoolProp\CoolProp.pyx", line 450, in CoolProp.CoolProp.PropsSI
ValueError: No outputs were able to be calculated

I really have no clue why PropsSI can not calculate the values I want to know. The value-combinations in and of itself schould not be a problem thermodynamically speaking. What I want to achieve is that the Matrix V_out contains the density of every possible value-combination of p_HD and s_ND. Also I did not find the right tag to imply that coolprop is the main subject of this question, I am sorry. Thank you for your help in advance

2 Answers

may be this would help: try to init not from zero values p_HD = np.arange(0.1, 1000, 20) --- this would work OK in your code. Also you can use TRY/EXCEPT to catch such uncalculable samples in the loop

Change the order of assignment: s_ND_Air_M, p_HD_M = np.meshgrid (s_ND_Air, p_HD) to p_HD_M, s_ND_Air_M, = np.meshgrid (s_ND_Air, p_HD)

Related