system_performance.py 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. # coding=gbk
  2. import pandas as pd
  3. from CoolProp.CoolProp import PropsSI
  4. import numpy as np
  5. from logs.logger import *
  6. class BasicParameterCalculation(object):
  7. def __init__(self, data_dict):
  8. self.data_dict = data_dict.copy()
  9. def parameter_first_cal(self):
  10. """
  11. 制冷剂物性参数计算,主要用于排气温度修正过程的计算
  12. 计算参数包括:吸排气压力、吸气熵、吸气焓以及等熵排气焓
  13. :return:
  14. """
  15. self.data_dict['sucPre'] = PropsSI('P', 'T', self.data_dict['evapTemp'] + 273.15, 'Q', 1, self.data_dict['refrigerant']) / 1000.0 # 将单位化成kPa
  16. self.data_dict['disPre'] = PropsSI('P', 'T', self.data_dict['condTemp'] + 273.15, 'Q', 1, self.data_dict['refrigerant']) / 1000.0 # 将单位化成kPa
  17. if self.data_dict['sucTemp'] - self.data_dict['evapTemp'] > 0:
  18. self.data_dict['sucEntropy'] = PropsSI('S', 'T', self.data_dict['sucTemp'] + 273.15, 'P', self.data_dict['sucPre'] * 1000,
  19. self.data_dict['refrigerant']) # 单位:J/kg-K
  20. self.data_dict['sucEnthalpy'] = PropsSI('H', 'T', self.data_dict['sucTemp'] + 273.15, 'P', self.data_dict['sucPre'] * 1000,
  21. self.data_dict['refrigerant']) / 1000.0 # 单位:kJ/kg
  22. else:
  23. self.data_dict['sucEntropy'] = PropsSI('S', 'T', self.data_dict['sucTemp'] + 273.15, 'Q', 1, self.data_dict['refrigerant'])
  24. self.data_dict['sucEnthalpy'] = PropsSI('H', 'T', self.data_dict['sucTemp'] + 273.15, 'Q', 1, self.data_dict['refrigerant']) / 1000.0
  25. self.data_dict['iseDisEnthalpy'] = PropsSI('H', 'P', self.data_dict['disPre'] * 1000.0, 'S',
  26. self.data_dict['sucEntropy'], self.data_dict['refrigerant']) / 1000.0
  27. return self.data_dict
  28. def parameter_second_cal(self):
  29. """
  30. 制冷剂物性参数计算:计算冷凝器出口焓值
  31. :return:
  32. """
  33. if self.data_dict['condTemp'] - self.data_dict['expanTemp'] > 0:
  34. self.data_dict['condOutEnthalpy'] = PropsSI('H', 'T', self.data_dict['expanTemp'] + 273.15, 'P', self.data_dict['disPre'] * 1000.0,
  35. self.data_dict['refrigerant']) / 1000.0
  36. else:
  37. self.data_dict['condOutEnthalpy'] = PropsSI('H', 'T', self.data_dict['expanTemp'] + 273.15, 'Q', 0,
  38. self.data_dict['refrigerant']) / 1000.0
  39. return self.data_dict
  40. class DischargeTempModified(BasicParameterCalculation):
  41. def __init__(self, data_dict):
  42. super(DischargeTempModified, self).__init__(data_dict)
  43. def eta_ise_cal(self):
  44. """
  45. 根据排气焓值、吸气焓值以及等熵过程排气焓值计算等熵效率
  46. :return:
  47. """
  48. if self.data_dict['dischargeTemp'] - self.data_dict['condTemp'] < 1:
  49. self.data_dict['dischargeTemp'] = self.data_dict['condTemp'] + 1
  50. self.data_dict['disEnthalpy'] = PropsSI('H', 'T', self.data_dict['dischargeTemp'] + 273.15, 'P', self.data_dict['disPre'] * 1000.0,
  51. self.data_dict['refrigerant']) / 1000.0
  52. self.data_dict['etaIseCal'] = (self.data_dict['iseDisEnthalpy'] - self.data_dict['sucEnthalpy']) / (
  53. self.data_dict['disEnthalpy'] - self.data_dict['sucEnthalpy'])
  54. return self.data_dict
  55. def dis_temp_cal(self, disPre, sucEnthalpy, iseDisEnthalpy, etaIseEvaluate):
  56. """
  57. 根据等熵效率修正方法计算压缩机排气温度
  58. :param disPre:
  59. :param sucEnthalpy:
  60. :param iseDisEnthalpy:
  61. :param etaIseEvaluate:
  62. :return:
  63. """
  64. disEnthalpyCal = sucEnthalpy + (iseDisEnthalpy - sucEnthalpy) / etaIseEvaluate
  65. disTempCal = PropsSI('T', 'H', disEnthalpyCal * 1000.0, 'P', disPre * 1000.0, self.data_dict['refrigerant']) - 273.15
  66. return disTempCal, disEnthalpyCal
  67. def eta_ise_recal(self, x):
  68. """
  69. 根据历史等熵效率值进行修正:
  70. 根据经验数据进行修正
  71. 修正公式:f(x,y) = p00 + p10*x + p01*y + p11*x*y + p02*y^2 x:负载率,y:冷凝温度
  72. :param x:
  73. :return:
  74. """
  75. p00 = 0.06996
  76. p10 = 0.02528
  77. p01 = -0.04132
  78. p11 = -0.0005824
  79. p02 = 0.001406
  80. eta_ise_evaluate = p00 + p10 * self.data_dict['loadRate'] + p01 * self.data_dict['condTemp'] + p11 * \
  81. self.data_dict['loadRate'] * self.data_dict['condTemp'] + p02 * self.data_dict['condTemp'] ** 2
  82. if eta_ise_evaluate > 0.8 or eta_ise_evaluate < 0.4:
  83. eta_ise_pass = pd.DataFrame(x, columns=['eta_ise'])
  84. eta_ise_pass = eta_ise_pass.drop_duplicates()
  85. eta_ise_pass = eta_ise_pass[eta_ise_pass['eta_ise'] != 0]
  86. eta_ise_pass = eta_ise_pass[eta_ise_pass['eta_ise'] > 0.4]
  87. if eta_ise_evaluate < 0.4:
  88. if len(eta_ise_pass) < 1:
  89. eta_ise_evaluate = 0.5
  90. else:
  91. eta_ise_evaluate = eta_ise_pass['eta_ise'].mean()
  92. else:
  93. if len(eta_ise_pass) < 1:
  94. eta_ise_evaluate = 0.8
  95. else:
  96. mean_ise = eta_ise_pass['eta_ise'].mean()
  97. eta_ise_evaluate = 0.8 if mean_ise <= 0.7 else mean_ise
  98. return eta_ise_evaluate
  99. def discharge_temp_modified(self):
  100. """
  101. 排气温度修正算法
  102. :return:
  103. """
  104. self.data_dict = self.parameter_first_cal()
  105. self.data_dict = self.eta_ise_cal()
  106. if self.data_dict['etaIseCal'] > 0.75:
  107. self.data_dict['etaIseCal'] = self.eta_ise_recal(self.data_dict['etaIse'])
  108. results = self.dis_temp_cal(self.data_dict['disPre'], self.data_dict['sucEnthalpy'], self.data_dict['iseDisEnthalpy'],
  109. self.data_dict['etaIseCal'])
  110. self.data_dict['dischargeTemp'] = results[0]
  111. self.data_dict['disEnthalpy'] = results[1]
  112. return self.data_dict
  113. class PerformanceCalculation(BasicParameterCalculation):
  114. def __init__(self, dict_cal):
  115. """
  116. 初始化相关参数
  117. :param dict_cal:
  118. """
  119. super(PerformanceCalculation, self).__init__(dict_cal)
  120. self.dict_cal = dict_cal
  121. self.powerRated = dict_cal['powerRated']
  122. self.way_cooling = dict_cal['coolingWay']
  123. def para_verify(self):
  124. if self.dict_cal['compRunTime']:
  125. self.dict_cal['compRunTime'] = self.dict_cal['compRunTime'] / 8760
  126. if self.dict_cal['compRunTime'] > 100:
  127. self.dict_cal['compRunTime'] = 10
  128. logger.critical('============压缩机运行时间错误,程序进行了动态修正===========')
  129. elif self.dict_cal['compRunTime'] > 20:
  130. logger.critical('============压缩机运行时间为%.0f年,请检查与实际情况是否吻合===========' % self.dict_cal['compRunTime'])
  131. self.dict_cal['compRunTime'] = 4
  132. elif self.dict_cal['compRunTime'] > 0:
  133. pass
  134. else:
  135. self.dict_cal['compRunTime'] = 7.0
  136. else:
  137. self.dict_cal['compRunTime'] = 7.0
  138. return None
  139. def eta_cal(self):
  140. self.factor_motor = 1 - 0.01 * self.dict_cal['compRunTime']
  141. self.factor_roller = 1 - 0.003 * self.dict_cal['compRunTime']
  142. self.phi_heat_loss = 0.025
  143. self.eta_motor = 0.95 * self.factor_motor ** 0.5
  144. self.eta_roller = 0.97 * self.factor_roller ** 0.5
  145. self.phi_power_fan = 0.03
  146. return None
  147. def mass_flow(self):
  148. """
  149. 计算制冷剂流量
  150. :return:
  151. """
  152. self.para_verify()
  153. self.eta_cal()
  154. if self.way_cooling == 'suctionCooling':
  155. self.dict_cal['powerTheory'] = self.dict_cal['power'] - self.phi_heat_loss * self.powerRated
  156. self.dict_cal['massCompressor'] = self.dict_cal['powerTheory'] / \
  157. (self.dict_cal['disEnthalpy'] -
  158. self.dict_cal['sucEnthalpy'])
  159. self.dict_cal['massSuction'] = self.dict_cal['massCompressor']
  160. elif self.way_cooling == 'liquidInjectionCooling':
  161. self.dict_cal['powerTheory'] = self.eta_motor * self.eta_roller * self.dict_cal['power'] - \
  162. self.phi_heat_loss * self.powerRated
  163. self.dict_cal['massCompressor'] = self.dict_cal['powerTheory'] / \
  164. (self.dict_cal['disEnthalpy'] - self.dict_cal['sucEnthalpy'])
  165. self.dict_cal['massSuction'] = self.dict_cal['massCompressor'] - \
  166. ((1 - self.eta_motor * self.eta_roller) * self.dict_cal['power']
  167. - self.phi_heat_loss * self.powerRated) / \
  168. (self.dict_cal['sucEnthalpy'] - self.dict_cal['condOutEnthalpy'])
  169. elif self.way_cooling == 'fanCooling':
  170. self.dict_cal['powerTheory'] = self.eta_motor * self.eta_roller * self.dict_cal['power'] \
  171. - (self.phi_heat_loss + self.phi_power_fan) * self.powerRated
  172. self.dict_cal['massCompressor'] = self.dict_cal['powerTheory'] / \
  173. (self.dict_cal['disEnthalpy'] - self.dict_cal['sucEnthalpy'])
  174. self.dict_cal['massSuction'] = self.dict_cal['massCompressor']
  175. else:
  176. logger.critical('==========电机冷却形式输入不正确==========')
  177. return None
  178. def system_performance(self):
  179. """
  180. 系统性能计算
  181. :return:
  182. """
  183. self.dict_cal['coolingCapacity'] = self.dict_cal['massSuction'] * \
  184. (self.dict_cal['sucEnthalpy'] -
  185. self.dict_cal['condOutEnthalpy'])
  186. self.dict_cal['COP'] = self.dict_cal['coolingCapacity'] / \
  187. self.dict_cal['power']
  188. if self.dict_cal['COP'] > 10 or self.dict_cal['COP'] < 2:
  189. self.dict_cal['COP'] = np.random.uniform(9, 10)
  190. self.dict_cal['coolingCapacity'] = self.dict_cal['power'] * self.dict_cal['COP']
  191. return None
  192. @staticmethod
  193. def judge_results(data):
  194. if data['etaIseCal'] < 0.25:
  195. is_success = 0
  196. results_depict = '输入参数存在问题,计算结果偏小'
  197. elif data['etaIseCal'] < 0.9:
  198. is_success = 1
  199. results_depict = '输入参数正常,计算结果正常'
  200. else:
  201. is_success = 0
  202. results_depict = '输入参数存在问题,计算结果偏大'
  203. if data['coolingCapacity'] > 1.2 * data['coolingCapacityRated']:
  204. is_success = 0
  205. results_depict = '冷机计算结果存在严重问题,请检查输入参数'
  206. logger.critical('===========冷机计算结果存在严重问题,请检查输入参数==========')
  207. return is_success, results_depict
  208. def chilled_water_flow_cal(self):
  209. """
  210. 冷冻水流量计算
  211. 水流量单位:m3/h
  212. :return:
  213. """
  214. self.dict_cal['chilledWaterFlow'] = self.dict_cal['coolingCapacity'] / 4.187 / (
  215. self.dict_cal['chilledWaterInput'] - self.dict_cal['chilledWaterOutput']) / 1000 * 3600
  216. chilledWaterFlowRated = self.dict_cal['coolingCapacityRated'] / 4.187 / 5.0 / 1000 * 3600
  217. chilledFlowRatio = self.dict_cal['chilledWaterFlow'] / chilledWaterFlowRated
  218. if chilledFlowRatio < 0.3 or chilledFlowRatio > 2.5:
  219. self.dict_cal['chilledWaterFlow'] = ''
  220. logger.critical('==========冷冻水流量计算异常,请检查输入参数===========')
  221. return None
  222. def cooling_water_flow_cal(self):
  223. """
  224. 冷却水流量计算
  225. 比热容按照4.187计算,暂不进行公式拟合
  226. 水流量单位:m3/h
  227. :return:
  228. """
  229. self.dict_cal['coolingWaterFlow'] = (self.dict_cal['power'] + self.dict_cal['coolingCapacity']) / 4.187 / (
  230. self.dict_cal['coolingWaterOutput'] - self.dict_cal['coolingWaterInput']) / 1000 * 3600
  231. coolingWaterFlowRated = (self.dict_cal['powerRated'] + self.dict_cal['coolingCapacityRated']) / 4.187 / 5.0 / 1000 * 3600
  232. coolingFlowRatio = self.dict_cal['coolingWaterFlow'] / coolingWaterFlowRated
  233. if coolingFlowRatio < 0.3 or coolingFlowRatio > 2.5:
  234. self.dict_cal['coolingWaterFlow'] = ''
  235. logger.critical('==========冷却水流量计算异常,请检查输入参数===========')
  236. return None
  237. def performance_calculation(self):
  238. self.dict_cal = self.parameter_second_cal()
  239. self.mass_flow()
  240. self.system_performance()
  241. is_success, results_depict = self.judge_results(self.dict_cal)
  242. if is_success == 1:
  243. self.cooling_water_flow_cal()
  244. self.chilled_water_flow_cal()
  245. self.dict_cal.update(
  246. etaMotor=round(self.eta_motor, 3),
  247. etaRoller=round(self.eta_roller, 3))
  248. return is_success, results_depict, self.dict_cal