为什么这些结果是非类型的?

2024-05-15 02:47:28 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在用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. 我怎样才能解决这个问题来获得差异呢?你知道吗

以下是代码,直到它中断为止:

(注意:直到最后一行的每个结果都是可打印的,但打印出来时没有结果。为什么?)你知道吗

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

Tags: inthermotimer2gasct浓度pb

热门问题