while error > 1e-4 && iter < max_iter#误差和迭代次数满足条件
iter += 1
for i = 1:NH
TH[i] = TH_initial[i]#每次迭代开始时,高温流体温度为初始温度
end
for j = 1:NC
TC[j] = TC_mem[j] + (TC_initial[j] - TC[j]) / 2.0
TC_mem[j] = TC[j]
end
for i = 1:NH*NC*JJJ#遍历所有的热交换单元
if ES[i] == 0
continue#无换热器时,则跳过计算
end
temp_ex = i % (NH * NC)
if temp_ex == 0
temp_ex = NH * NC
end
tmpH = div(temp_ex - 1, NC) + 1
tmpC = temp_ex % NC
if tmpC == 0
tmpC = NC
end
T_new = EXTEM(TH[tmpH], TC[tmpC], WH[tmpH], WC[tmpC], K, EA[i])
TH[tmpH] = T_new[1]
TC[tmpC] = T_new[2]
end
error = 0.0
for j = 1:NC
error += abs(TC[j] - TC_target[j])
end
end
return [TH, TC_mem]
end