因工作中经常要核算单通道和双通道列管式换热器(主要用于烟气余热利用)的参数及换热温度,为了减少重复无用工作,本着学以致用的原则,自己动手用PyQT6写了一个列管式换热器的计算程序。
程序编写使用的Eric-IDE编辑器。程序除了常规气体换热计算外,还设计了单通道和双通道计算的切换,以及管内和管外气体的切换功能,考虑到换热计算的特点,使用程序迭代计算,收敛到可接受余量即可。
下面是双通道列管换热器计算界面:
下面是单通道列管换热器的计算界面:
气体在不同温度下的比热、粘度、密度等数据都存放在Excel文件中,通过openpyxl读取,然后根据列表数据进行线性拟合得到不同温度点的气体参数。
import openpyxl as xl
#从文件读取气体数据
wb = xl.load_workbook(filename="./data/heat_change_cp.xlsx", read_only=True, data_only=True)
sht_cp = wb['cp']
rows = sht_cp.max_row
temp_list = []
cp_list = []
vis_list = []
density_list = []
lamda_list = []
for i in range(2, rows+1):
cell_temp_value = sht_cp.cell(row=i, column=1).value
temp_list.append(cell_temp_value)
cell_vis_value = sht_cp.cell(row=i, column=2).value
vis_list.append(cell_vis_value)
cell_cp_value = sht_cp.cell(row=i, column=3).value
cp_list.append(cell_cp_value)
cell_density_value = sht_cp.cell(row=i, column=4).value
density_list.append(cell_density_value)
cell_lamda_value = sht_cp.cell(row=i, column=5).value
lamda_list.append(cell_lamda_value)
wb.close()
#自定义线性拟合函数
def linear_fitting(self, input_value, x_list, y_list):
lenx = len(x_list)
leny = len(y_list)
if lenx != leny:
lenmin = min(lenx, leny)
if lenmin <= 1:
return "error"
if lenx == lenmin:
y_list = y_list[0:lenmin]
else:
x_list = x_list[0:lenmin]
lenx =len(x_list)
else:
if lenx <= 1:
return "error"
if input_value < x_list[0] or input_value > x_list[lenx-1]:
return "error"
if input_value == x_list[-1]:
return y_list[-1]
for i in range(lenx-1):
if input_value >= x_list[i]and input_value < x_list[i+1]:
target_value = y_list[i] + (y_list[i+1]-y_list[i])/(x_list[i+1]-x_list[i])*(input_value-x_list[i])
return target_value
Excel文件中气体参数数据如下:
这样通过修改Excel文件,就可以修改气体参数。实际上该程序也可用于其它流体简单的换热计算。
程序用到了一些换热方面的专业知识和计算,直接套用前人总结的方法。
Eric7用于PyQT程序编写还是比较方便的,界面编辑和程序衔接比较好。