架构调整
This commit is contained in:
1 parent
ff3eaab3d9
commit
1d09599e8c
6 files changed
+948
-971
No files matched your search
@@ -0,0 +1,65 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""REFPROP-backed CO2 property helpers."""
|
||||
|
||||
import ctREFPROP.ctREFPROP as ct
|
||||
|
||||
|
||||
class CO2PropertyCalculator():
|
||||
"""二氧化碳物性计算"""
|
||||
def __init__(self, refprop_path = None):
|
||||
"""初始化库"""
|
||||
self.rp = ct.REFPROPFunctionLibrary(refprop_path)
|
||||
# 设置流体文件
|
||||
self.rp.SETUPdll(1, 'CO2.FLD', 'HMX.BNC', 'DEF')
|
||||
# 设置单位
|
||||
self.rp.SETUPdll(2, 'SI', 'SI', 'DEF')
|
||||
self.z = [1.0]
|
||||
self.mw = self.rp.WMOLdll(self.z)
|
||||
def calculate_properties(self, T=None, P=None, h=None, s=None):
|
||||
"""计算二氧化碳物性"""
|
||||
if T is not None and P is not None:
|
||||
# 已知Tp
|
||||
result = self.rp.TPFLSHdll(T, P, self.z)
|
||||
properties = {
|
||||
'T': T,
|
||||
'P': P,
|
||||
'h': result.h,
|
||||
's': result.s,
|
||||
}
|
||||
elif P is not None and h is not None:
|
||||
# 已知Ph
|
||||
result = self.rp.PHFLSHdll(P, h, self.z)
|
||||
properties = {
|
||||
'T': result.T,
|
||||
'P': P,
|
||||
'h': h,
|
||||
's': result.s,
|
||||
}
|
||||
elif T is not None and h is not None:
|
||||
# 已知Th
|
||||
result = self.rp.THFLSHdll(T, h, self.z)
|
||||
properties = {
|
||||
'T': T,
|
||||
'P': result.P,
|
||||
'h': h,
|
||||
's': result.s,
|
||||
}
|
||||
elif P is not None and s is not None:
|
||||
# 已知Ps
|
||||
result = self.rp.PSFLSHdll(P, s, self.z)
|
||||
properties = {
|
||||
'T': result.T,
|
||||
'P': P,
|
||||
'h': result.h,
|
||||
's': s,
|
||||
}
|
||||
else:
|
||||
raise ValueError("提供的参数不足")
|
||||
if result.ierr > 0:
|
||||
raise ValueError(f"REFPROP计算错误:{result.ierr}")
|
||||
|
||||
# 补充提取的物性,这里由于后续还要使用,不进行参数变换
|
||||
properties['D'] = result.D
|
||||
properties['cp'] = result.Cp
|
||||
properties['cv'] = result.Cv,
|
||||
return properties
|
||||
Reference in new issue
Block a user