[英]TypeError: search() missing 1 required positional argument: 'name'
[英]TypeError: FUNCTION NAME () missing 1 required positional argument: 'v_air
我有两个问题:
如果您的 str() 或 list() 对象可能最终为空:astr = '' 或 alist = [],那么您可能希望对 object 使用 alist[-1:] 而不是 alist[-1]同一性”。
some_list = [1, 2, 3]
some_list[-1] = 5 # Set the last element
some_list[-2] = 3 # Set the second to last element
some_list
a_list = ['zero', 'one', 'two', 'three']
a_list[-1]
'three'
看,你基本上已经做对了,但只是为了记录,这里是工作代码:
import numpy as np
from scipy.optimize import root
def viscosity(Tair_inlet):
mu=(1.458*(10**-6)*(Tair_inlet+ 273.15)**1.5)/((Tair_inlet+ 273.15)+110.4)
return mu
def per_circ(D_1):
p_c = np.pi*(D_1)
return p_c
def Tair_outlet(Ts_int,Tair_inlet, hint, p_c, v_air, rho_air, cp_air, L ):
k = hint/(p_c*v_air*rho_air*cp_air)
Tair_outlet = Ts_int + (Tair_inlet-Ts_int)*np.exp(-k*L)
return Tair_outlet
def simplified_friction_method(V_dot, rho_air , L, mu, delta_P, v_air, epsilon ):
m_dot = V_dot * rho_air
print('m_dot',m_dot, '[kgs^-1]')
D_0 = (4*m_dot/(np.pi*rho_air*v_air))**(1/2)
D_1 = D_0
print('D_0',D_0, '[m]')
Re = (v_air * D_0 * rho_air) / mu
print('Re', Re )
f_0= 0*D_0
f_0 = (-2*np.log((epsilon/D_0)/3.7065))**-2
print('f_0', f_0,)
delta_P_tot = delta_P*L
f_1 = f_0
f_2 = 0
e =np.ones(D_0.size)
print("e",e)
while e.any() > 0.0001:
D_1 = ((f_1 * L)/delta_P_tot )* rho_air *(v_air)**2
print('D_1', D_1, '[m]')
Re = (v_air * D_1 * rho_air) / mu
f_2=(-2*abs(np.log((epsilon/D_1)/3.7065 + 2.5226/(Re*np.sqrt(f_1)))))**-2
e = abs(f_1-f_2)
print('e', e, )
f_1 = f_2
return('D_1', D_1,'Re', Re,'f', f_2,'e', e )
class Duct:
def __init__(
self, Tair_inlet, Ts_int, hint, cp_air, rho_air, Rstar, epsilon
):
self.Tair_inlet = Tair_inlet
self.Ts_int = Ts_int
self.hint = hint
self.cp_air = cp_air
self.rho_air = rho_air
self.Rstar = Rstar
self.epsilon = epsilon
duct_ret = Duct(18, 19.5, 3, 1010, 1.2, 8324.68/29, 0.2/1000)
duct_circ = Duct(18, 19.5, 3, 1010, 1.2, 8324.68/29, 0.2/1000)
duct_ret.L = 8
duct_circ.L = np.array([[10, 8, 10, 8]])
duct_circ.V_dot = np.array([[3, 1, 2, 1]])
duct_circ.v_air = np.array([[5, 3, 5, 3]])
duct_circ.deltaP = 1
duct_circ.mu = viscosity(duct_circ.Tair_inlet)
print(duct_circ.mu)
duct_circ.D_1 = simplified_friction_method(
duct_circ.rho_air, duct_circ.V_dot, duct_circ.L, duct_circ.mu,
duct_circ.deltaP, duct_circ.v_air, duct_circ.epsilon
)
print(duct_circ.D_1)
请注意,由于我没有两个文件,因此我没有导入EN
,因此删除了EN.
在 function 调用之前。 我还将epsilon
参数添加到您的版本中缺少的Duct
class 并将其传递给simplified_friction_method
的摩擦方法 function。 有很多方法可以改进代码,但现在我认为更重要的是它可以工作并且你理解它。 您显然并不真正了解 Classes 是如何工作的,所以我建议您研究一下。
最小工作示例如上所示
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.