calculation_process.py 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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['evapTemp']*1000,
  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['condTemp']*1000,
  16. 'Q', 1, self.dict_input['refrigerant']) - 273.15
  17. def judge_null(self):
  18. Num = 0
  19. self.pre_to_temp()
  20. for k in self.dict_input:
  21. if self.dict_input[k] == '':
  22. Num += 1
  23. return Num
  24. def cop_calculation(self):
  25. dtm = DischargeTempModified(self.dict_input)
  26. self.dict_input = dtm.discharge_temp_modified()
  27. pc=PerformanceCalculation(self.dict_input)
  28. self.is_success, self.results_depict, self.results = pc.performance_calculation()
  29. return None
  30. def main_process(self):
  31. number_null = self.judge_null()
  32. if number_null > 0:
  33. self.results_depict = '输入参数存在空值,无计算结果'
  34. else:
  35. if self.dict_input['unitStatus'] == 0:
  36. self.results_depict = '冷机处于关机状态,无计算结果'
  37. else:
  38. self.cop_calculation()
  39. if self.is_success == 1:
  40. dict_results = DictResultsNormal(self.results, self.results_depict)
  41. else:
  42. dict_results = DictResultsAbnormal(self.dict_input, self.results_depict)
  43. return dict_results