我正在使用Python进行Cantera仿真,并研究一些产品和燃料的浓度。我已经成功地模拟了不同燃料的浓度。但是,只要我尝试从彼此中减去2个浓度值以得到平方误差,我就会收到以下错误:
Traceback (most recent call last): File "<stdin>", line 1, in <module> File "Comparison.py", line 145, in <module> SEPOSF2 = (ConcPOSF-ConcPOSF2)^2 TypeError: unsupported operand type(s) for -: 'NoneType' and 'NoneType'
我的问题:
ConcPOSF
和ConcPOSF2
类型为NoneType
? 以下是代码中断的代码:
(注意:到最后一行的每个结果都是可绘图的,但打印为无。为什么?)
import cantera as ct
T = 1200
#Pb is P in bar
Pb = 1
P = Pb*101325
tn = 100
reactors = 'POSF10264:1'
gas = ct.Solution('mech10264C2.cti')
gas.TPY = T, P, reactors
r = ct.IdealGasReactor(gas)
net = ct.ReactorNet([r])
gas2 = ct.Solution('5k410k.cti')
gas2.TPY = T,P,reactors
r2 = ct.IdealGasReactor(gas2)
net2 = ct.ReactorNet([r2])
tim = []
Temp = []
Pres = []
p = []
t = []
x0 = []
x1 = []
x2 = []
x3 = []
x4 = []
x5 = []
x6 = []
x7 = []
y0 = []
Temp2 = []
Pres2 = []
p2 = []
t2 = []
x02 = []
x12 = []
x22 = []
x32 = []
x42 = []
x52 = []
x62 = []
x72 = []
y02 = []
timen = []
for n in range(tn):
time = (n+1)*(0.001)
net.advance(time)
net2.advance(time)
timen = tim.append(time * 1000)
Temp = t.append(r.T)
Pres = p.append(r.thermo.P)
ConcPOSF = x0.append(r.thermo['POSF10264'].X[0])
ConcC2H4 = y0.append(r.thermo['C2H4'].X[0])
ConcC3H6 = x1.append(r.thermo['C3H6'].X[0])
ConcC4H81 = x2.append(r.thermo['C4H81'].X[0])
ConciC4H8 = x3.append(r.thermo['iC4H8'].X[0])
ConcC6H6 = x4.append(r.thermo['C6H6'].X[0])
ConcC6H5CH3 = x5.append(r.thermo['C6H5CH3'].X[0])
ConcH = x6.append(r.thermo['H'].X[0])
ConcCH3 = x7.append(r.thermo['CH3'].X[0])
Temp2 = t2.append(r2.T)
Pres2 = p2.append(r2.thermo.P)
ConcPOSF2 = x02.append(r2.thermo['POSF10264'].X[0])
ConcC2H42 = y02.append(r2.thermo['C2H4'].X[0])
ConcC3H62 = x12.append(r2.thermo['C3H6'].X[0])
ConcC4H812 = x22.append(r2.thermo['C4H81'].X[0])
ConciC4H82 = x32.append(r2.thermo['iC4H8'].X[0])
ConcC6H62 = x42.append(r2.thermo['C6H6'].X[0])
ConcC6H5CH32 = x52.append(r2.thermo['C6H5CH3'].X[0])
ConcH2 = x62.append(r2.thermo['H'].X[0])
ConcCH32 = x72.append(r2.thermo['CH3'].X[0])
SEPOSF2 = (ConcPOSF-ConcPOSF2)^2 #### BOOM
答案 0 :(得分:1)
方法append()不返回任何内容。它在列表中添加了一个元素,因此返回None。