python - Coolprop 无法计算数值
问题描述
今天我试图将流体属性计算应用于某个值矩阵。首先,这是我尝试使用的代码:
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是这个问题的主要主题,对不起。提前谢谢你的帮助
解决方案
可能这会有所帮助:尝试不从零值初始化p_HD = np.arange(0.1, 1000, 20)
--- 这在您的代码中可以正常工作。您也可以使用 TRY/EXCEPT 在循环中捕获此类无法计算的样本
推荐阅读
- button - javaFX 场景生成器按钮不起作用,有什么解决方案吗?
- angular - Angular ngrx 设计 - 将新项目添加到列表中,而不是从后端重新加载列表
- java - Spring TransactionalTemplate 不回滚异常
- c# - 为什么我在尝试获取预制资产路径时得到空字符串?
- java - Java Pattern.matches() 返回错误结果
- javascript - 重新渲染组件以再次获取默认道具
- spring - Spring Boot Vault HashiCorp - VaultTemplate.read() 返回 null
- php - 如何获得计数结果?
- firebase - 从 2019 年 12 月 17 日起未导出到 BigQuery 的 MESSAGE_DELIVERED FCM 事件
- javascript - 如何在 TypeScript 中导入 Vanilla JS ES6 模块?