耦合 ODE 系统 - 换热器问题
System of coupled ODE - heat exchanger problem
我正在解决热交换器问题,必须找到最终温度。这是一个颂歌系统,我写了下面的代码:它要求我定义 T 和 t,但它们是 x 的函数,我应该找到
import numpy as np
import matplotlib.pyplot as plt
from scipy.integrate import odeint
#propriedades trietileno glicol na entrada
T1 = 363 #K temperatura de entrada
Wt = 3.6 #kg/s vazão
#propriedades água na entrada
t1 = 298 #K
Ww = 1.0
Ww = [0.1, 0.5, 1] #kg/s vazões
Di = 0.07792 #m diâmetro interno
L = 3.048 #m comprimento do tubo
U = 283.72 #W/m²K
pi= 3.1415
cpt = 1901.09#, 2.7683*T + 896.2] #J/kg*K calor específico
cpw = 4018.04#, -0.00003*(t^3) + 0.0403*(t^2) - 16.277*t + 6083.7] #J/kg*K calor específico
cp = [cpt, cpw]
def funct(y, x):
y = T, t
dTdx = (U * Di * pi / (Wt * cpt)) * (T - t)
dtdx = (U * Di * pi / (Ww * cpw)) * (T - t)
x = np.linspace(0, L, 100)
return dTdx, dtdx
# Vetor espaço
# Initial condition
y0 = T1, t1
sol = odeint(funct, y0 , x)
# plot
plt.plot(x, sol[:, 0], label='Trietilenoglicol')
plt.plot(x, sol[:, 1], label='Água')
plt.legend()
plt.xlabel('posição')
但它给了我以下错误信息:
NameError Traceback (most recent call last)
<ipython-input-47-2f2a81626e49> in <module>
35 # Initial condition
36 y0 = T1, t1
---> 37 sol = odeint(funct, y0 , x)
38
39 # plot
c:\users\idril\appdata\local\programs\python\python36\lib\site-packages\scipy\integrate\odepack.py in odeint(func, y0, t, args, Dfun, col_deriv, full_output, ml, mu, rtol, atol, tcrit, h0, hmax, hmin, ixpr, mxstep, mxhnil, mxordn, mxords, printmessg, tfirst)
242 full_output, rtol, atol, tcrit, h0, hmax, hmin,
243 ixpr, mxstep, mxhnil, mxordn, mxords,
--> 244 int(bool(tfirst)))
245 if output[-1] < 0:
246 warning_msg = _msgs[output[-1]] + " Run with full_output = 1 to get quantitative information."
<ipython-input-47-2f2a81626e49> in funct(y, x)
23
24 def funct(y, x):
---> 25 y = T, t
26 dTdx = (U * Di * pi / (Wt * cpt)) * (T - t)
27 dtdx = (U * Di * pi / (Ww * cpw)) * (T - t)
NameError: name 'T' is not defined
我已经阅读了很多回答的问题,但仍然找不到错误。
您想将 y
中的列表解包为单个变量,这必须按照与打包 y0
,
时相反的方向编写
T,t = y
您想在与 y0
相同的点定义时间数组 x
你定义了两次Ww
,第二次作为元组。没有算术元组运算。如果第二个定义没有特殊用途,请将其删除。
我正在解决热交换器问题,必须找到最终温度。这是一个颂歌系统,我写了下面的代码:它要求我定义 T 和 t,但它们是 x 的函数,我应该找到
import numpy as np
import matplotlib.pyplot as plt
from scipy.integrate import odeint
#propriedades trietileno glicol na entrada
T1 = 363 #K temperatura de entrada
Wt = 3.6 #kg/s vazão
#propriedades água na entrada
t1 = 298 #K
Ww = 1.0
Ww = [0.1, 0.5, 1] #kg/s vazões
Di = 0.07792 #m diâmetro interno
L = 3.048 #m comprimento do tubo
U = 283.72 #W/m²K
pi= 3.1415
cpt = 1901.09#, 2.7683*T + 896.2] #J/kg*K calor específico
cpw = 4018.04#, -0.00003*(t^3) + 0.0403*(t^2) - 16.277*t + 6083.7] #J/kg*K calor específico
cp = [cpt, cpw]
def funct(y, x):
y = T, t
dTdx = (U * Di * pi / (Wt * cpt)) * (T - t)
dtdx = (U * Di * pi / (Ww * cpw)) * (T - t)
x = np.linspace(0, L, 100)
return dTdx, dtdx
# Vetor espaço
# Initial condition
y0 = T1, t1
sol = odeint(funct, y0 , x)
# plot
plt.plot(x, sol[:, 0], label='Trietilenoglicol')
plt.plot(x, sol[:, 1], label='Água')
plt.legend()
plt.xlabel('posição')
但它给了我以下错误信息:
NameError Traceback (most recent call last)
<ipython-input-47-2f2a81626e49> in <module>
35 # Initial condition
36 y0 = T1, t1
---> 37 sol = odeint(funct, y0 , x)
38
39 # plot
c:\users\idril\appdata\local\programs\python\python36\lib\site-packages\scipy\integrate\odepack.py in odeint(func, y0, t, args, Dfun, col_deriv, full_output, ml, mu, rtol, atol, tcrit, h0, hmax, hmin, ixpr, mxstep, mxhnil, mxordn, mxords, printmessg, tfirst)
242 full_output, rtol, atol, tcrit, h0, hmax, hmin,
243 ixpr, mxstep, mxhnil, mxordn, mxords,
--> 244 int(bool(tfirst)))
245 if output[-1] < 0:
246 warning_msg = _msgs[output[-1]] + " Run with full_output = 1 to get quantitative information."
<ipython-input-47-2f2a81626e49> in funct(y, x)
23
24 def funct(y, x):
---> 25 y = T, t
26 dTdx = (U * Di * pi / (Wt * cpt)) * (T - t)
27 dtdx = (U * Di * pi / (Ww * cpw)) * (T - t)
NameError: name 'T' is not defined
我已经阅读了很多回答的问题,但仍然找不到错误。
您想将 y
中的列表解包为单个变量,这必须按照与打包 y0
,
T,t = y
您想在与 y0
相同的点定义时间数组x
你定义了两次Ww
,第二次作为元组。没有算术元组运算。如果第二个定义没有特殊用途,请将其删除。