calculation_process.py 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. from normalization.constant import *
  2. from CoolProp.CoolProp import PropsSI
  3. from calculation.system_performance import DischargeTempModified, PerformanceCalculation
  4. class CalculationProcess(object):
  5. def __init__(self, dict_input):
  6. self.dict_input = dict_input
  7. self.is_success = 0
  8. self.results = {}
  9. self.results_depict = ''
  10. def pre_to_temp(self):
  11. if self.dict_input["evapPre"] and not self.dict_input["evapTemp"]:
  12. self.dict_input["evapTemp"] = PropsSI('T', 'P', self.dict_input['evapPre']*1000 + 101325,
  13. 'Q', 1, self.dict_input['refrigerant']) - 273.15
  14. if self.dict_input["condPre"] and not self.dict_input["condTemp"]:
  15. self.dict_input["condTemp"] = PropsSI('T', 'P', self.dict_input['condPre']*1000 + 101325,
  16. 'Q', 1, self.dict_input['refrigerant']) - 273.15
  17. if self.dict_input["evapTemp"] and not self.dict_input["sucTemp"]:
  18. self.dict_input["sucTemp"] = self.dict_input["evapTemp"]
  19. def judge_null(self):
  20. Num = 0
  21. self.pre_to_temp()
  22. for k in self.dict_input:
  23. if self.dict_input[k] == '' or not self.dict_input[k]:
  24. Num += 1
  25. return Num
  26. def cop_calculation(self):
  27. dtm = DischargeTempModified(self.dict_input)
  28. self.dict_input = dtm.discharge_temp_modified()
  29. pc = PerformanceCalculation(self.dict_input)
  30. self.is_success, self.results_depict, self.results = pc.performance_calculation()
  31. return None
  32. def main_process(self):
  33. number_null = self.judge_null()
  34. if number_null > 0:
  35. self.results_depict = '输入参数存在空值,无计算结果'
  36. else:
  37. if self.dict_input['unitStatus'] == 0:
  38. self.results_depict = '冷机处于关机状态,无计算结果'
  39. else:
  40. self.cop_calculation()
  41. if self.is_success == 1:
  42. dict_results = DictResultsNormal(self.results, self.results_depict)
  43. else:
  44. dict_results = DictResultsAbnormal(self.dict_input, self.results_depict)
  45. return dict_results