Coolprop无法计算值

2024-06-16 11:38:10 发布

您现在位置:Python中文网/ 问答频道 /正文

今天,我尝试将流体属性计算应用于某个值矩阵。首先,以下是我试图使用的代码:

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')

现在,我收到了错误消息:

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

我真的不知道为什么PropsSI不能计算我想知道的值。从热力学角度讲,价值组合本身并不是一个问题。我想要实现的是,矩阵V_out包含p_HD和s_ND的每个可能值组合的密度。我也没有找到正确的标签来暗示coolprop是这个问题的主要主题,对不起。 提前谢谢你的帮助


Tags: oftoinimportfornppiair
2条回答

这可能会有帮助:尝试不从零值初始化p_HD = np.arange(0.1, 1000, 20)-这在代码中可以正常工作。您还可以使用TRY/EXCEPT在循环中捕获此类无法计算的样本

更改分配顺序: s_n_Air_M,p_HD_M=np.meshgrid(s_n_Air,p_HD)到 p_HD_M,s_ND_Air_M,=np.meshgrid(s_ND_Air,p_HD)

相关问题 更多 >