我已编写此代码来模拟沿管式换热器内管的温度变化。我用odeint积分了耦合的微分方程,但我认为积分部分出了问题,因为能量平衡不匹配'-'
我知道这很具体,但是谢谢您的帮助,谢谢!
import numpy as np
import matplotlib.pyplot as plt
from scipy.integrate import odeint
%matplotlib inline
%config InlineBackend.figure_format = 'svg'
#anything + tr stands for trietylen glicol
#anything + w stands for water
#trietileno glicol inlet properties
T0 = 363 #K inlet temperature
Wtr = 3.6 #kg/s mass rate
#water inlet properties
t0 = 298 #K inlet temperature
Ww = [0.1, 0.5, 1] #kg/s mass rate
y0 = T0, t0 # Initial condition
Di = 0.07792 #m inner diameter
L = 3.048 #m tube length
U = 283.72 #W/m²K
pi= 3.1415
cptr0 = 1901.09 #J/kgK....
#cpti = (2.7683*T + 896.2) #J/kg*K calor específico
cpw0 = 4018.05 #J/kgK
#cpwi = (-0.00003*(t**3) + 0.0403*(t**2) - 16.277*t + 6083.7) #J/kg*K calor específico
#Calculus of the derivatives
def funct(y, x, W, cpt, cpw):
Ti = y[0]
ti = y[1]
dTdx = (Ti - ti)*(U * Di * pi / (Wtr * cpt))
dtdx = (Ti - ti)*(U * Di * pi / (W * cpw))
x = np.linspace(0, L, 100)
return dTdx, dtdx
#integration
def solve_plot(W, cpw, cpt):
x = np.linspace(0, L, 300)
sol = odeint(funct, y0 , x, args = (W, cpw, cpt))
T = sol[:, 0]
t = sol[:, 1]
rev_x = x[::-1]
#plot and printing of the properties in each position of the tube
print('T1 = {:.2e} K, T2= {:.2e} K\n'
't1 = {:.2e} K, t2= {:.2e} K\n'.format(T[99],T[0],t[0],t[99]))
plt.plot(rev_x, T, 'b-', label='Trietileno-glicol', linewidth = 2)
plt.plot(x, t,'r--', label='Água', linewidth = 2)
plt.xlabel('Posição(ft)')
plt.ylabel('Temperatura (F)')
plt.title('Perfil de temperatura dos fluidos(Ww = {})'.format(W))
plt.legend()
plt.show()
print(' T delta_ht t delta_hw')
for i in range(100):
print('{:.2e} K {:.2e} W {:.2e} K {:.2e} W'.format( T[99-i],(T[99-i] -T[99])*cpt*Wtr, t[i], (t[i]-t[0])*cpw*W))
print('---------------------------------------------------------------------------------------------------------------------')
return
solve_plot(W = Ww[0], cpw = cpw0, cpt = cptr0)
solve_plot(W = Ww[1], cpw = cpw0, cpt = cptr0)
solve_plot(W = Ww[2],cpw = cpw0, cpt = cptr0)
我希望输出列2和4相等,这是其中的一部分:
T delta_ht t delta_hw
3.63e+02 K 0.00e+00 W 2.98e+02 K 0.00e+00 W
3.63e+02 K -1.52e+01 W 2.98e+02 K 9.71e+01 W
3.63e+02 K -3.04e+01 W 2.98e+02 K 1.94e+02 W
3.63e+02 K -4.56e+01 W 2.99e+02 K 2.90e+02 W
3.63e+02 K -6.10e+01 W 2.99e+02 K 3.86e+02 W
3.63e+02 K -7.64e+01 W 2.99e+02 K 4.82e+02 W
3.63e+02 K -9.18e+01 W 2.99e+02 K 5.77e+02 W
3.63e+02 K -1.07e+02 W 3.00e+02 K 6.72e+02 W
3.63e+02 K -1.23e+02 W 3.00e+02 K 7.67e+02 W
3.63e+02 K -1.38e+02 W 3.00e+02 K 8.61e+02 W
3.63e+02 K -1.54e+02 W 3.00e+02 K 9.55e+02 W
3.63e+02 K -1.70e+02 W 3.01e+02 K 1.05e+03 W
3.63e+02 K -1.86e+02 W 3.01e+02 K 1.14e+03 W