为什么这些结果是 NoneType?

Why are these results NoneType?

我正在 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'

我的问题:

  1. 为什么 ConcPOSFConcPOSF2NoneType 类型?
  2. 我怎样才能解决这个问题来获得差异?

这里是代码中断点:

(注意:直到最后一行的每个结果都是可绘制的,但打印输出为 None。为什么?)

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

方法 append() 没有 return 任何东西。它将一个元素添加到列表中,因此 returns None.