我有以下代码:
from scipy.constants import R as Rgi
from numpy import *
import numpy as np
import matplotlib.pyplot as plt
Tccomp = array([190.56,305.32,369.83,425.12,469.7,507.6,282.34,365.57,511.76,553.58,562.16,591.8,512.64,513.92,536.78,400.1,408.00,508.2,591.95,469.15,132.45,154.58,126.2,405.65,430.75,304.26,647.13,535.5]) #k
Pccomp = array([45.90,48.50,42.10,37.70,33.60,30.40,50.30,46.30,45.00,41.00,48.00,41.30,81.40,61.20,51.20,52.70,65.90,47.10,57.40,72.60,37.90,50.20,33.98,113.00,78.60,73.90,219.40,41.50]) # bar
Vccomp = array([0.099,0.146,0.2,0.255,0.315,0.373,0.132,0.188,0.257,0.308,0.261,0.314,0.117,0.168,0.22,0.171,0.115,0.21,0.179,0.142,0.092,0.074,0.089,0.072,0.123,0.095,0.056,0.267]) # m^3/kmol
Zccomp = array([0.286,0.279,0.273,0.272,0.271,0.269,0.283,0.286,0.272,0.274,0.273,0.262,0.224,0.24,0.252,0.271,0.223,0.234,0.208,0.264,0.318,0.287,0.288,0.241,0.269,0.277,0.228,0.249])
Wcomp = array([0.011,0.098,0.149,0.197,0.251,0.304,0.086,0.137,0.196,0.212,0.209,0.262,0.566,0.643,0.617,0.192,0.282,0.307,0.463,0.201,0.0,0.02,0.037,0.253,0.244,0.244,0.343,0.323])
Nombre = array(['Metano','Etano','Propano','Butano','Pentano','Hexano','Etileno','Propileno','Ciclopentano','Ciclohexano','Benceno','Tolueno','Metanol','Etanol','1-Propanol','Dimetileter','Formaldehido','Acetona','Acido Actico','Oxido de etileno','Aire','Oxigeno','Nitrogeno','Amoniaco','Dioxido de azufre','Dioxido de carbono','Agua','Metiletilcetona'])
Rbar = Rgi*10 # bar*cm^3/K*mol
Rgas = Rgi # Kj / Kmol * K
print 'Cálculo de la fugacidad de una mezcla de gases reales utilizando Peng Robinson'
print '-----------------------------------------------------------------------------------'
print ' Metano |(0)| '
print ' Etano |(1)| '
print ' Propano |(2)| '
print ' Butano |(3)| '
print ' Pentano |(4)| '
print ' Hexano |(5)| '
print ' Etileno |(6)| '
print ' Propileno |(7)| '
print ' Ciclopentano |(8)| '
print ' Ciclohexano |(9)| '
print ' Benceno |(10)|'
print ' Tolueno |(11)|'
print ' Metanol |(12)|'
print ' Etanol |(13)|'
print ' 1-propanol |(14)|'
print ' Dimetileter |(15)|'
print ' Formaldehido |(16)|'
print ' Acetona |(17)|'
print ' Ácido acético |(18)|'
print ' Óxido de etileno |(19)|'
print ' Aire |(20)|'
print ' Oxígeno |(21)|'
print ' Nitrógeno |(22)|'
print ' Amoniaco |(23)|'
print ' Dióxido de azufre |(24)|'
print ' Agua |(25)|'
print ' Metiletilcetona |(26)|'
print '-------------------------------------------------------------------------------------'
print ' '
print ' '
ncomp = int(input('numero de componentes del sistema : '))
def PRMix(T,P):
comp = zeros(ncomp)
y = zeros(ncomp)
Wcomp = zeros(ncomp)
Tccomp = zeros(ncomp)
Pccomp = zeros(ncomp)
a = zeros(ncomp)
b = zeros(ncomp)
sumbi = zeros(ncomp)
s = (ncomp,ncomp)
aij = zeros(s)
sumaij = zeros(s)
for i in arange(0,ncomp,1):
comp[i] = int(input('Escoja el componente : '))
y[i] = float(input(' Fraccion : '))
print ' '
for i in arange (0,ncomp,1):
Wcomp[i] = Wcomp[int(comp[i])]
Tccomp[i] = Tccomp[int(comp[i])]
Pccomp[i] = Pccomp[int(comp[i])]
kappa = 0.37464 + 1.54226*Wcomp - 0.26992*Wcomp**2
alpha = (1 + kappa*(1 - sqrt(T/Tccomp)))**2
a = 0.45724*(((Rgi**2) * (Tccomp**2))/(Pccomp))*alpha
b = 0.0788*((Rgi*Tccomp)/Pccomp)
for i in arange(0,ncomp,1):
sumbi[i] = y[i]*b[i]
for j in arange(0,ncomp,1):
aij[i,j] = sqrt(a[i]*a[j])
sumaij[i,j] = y[i]*y[j] * aij[i,j]
amix = sum(sumaij)
bmix = sum(sumbi)
Aij = (aij * P) / ((Rgi*T)**2)
Bi = (b * P) / (Rgi * T)
Amix = (amix * P)/((Rgi*T)**2)
Bmix = (bmix * P)/(Rgi * T)
pol = [1,(Bmix - 1), (Amix - 2 * Bmix - 3 * Bmix**2),(Bmix**2 + Bmix**3 -Amix * Bmix)]
Z = roots(pol)
Z = real(Z)
Zvmix = max(Z)
Zlmix = min(Z)
LnPhiV = (Bi/Bmix)*(Zvmix-1) - log(Zvmix-Bmix)-(Amix/(2*Sqrt(2)*Bmix)) * ((2 *(dot(Aij,y)/Amix) -(Bi/Bmix)) * log((Zvmix + (1 + sqrt(2)) * Bmix) / (Zvmix + (1 - sqrt(2)) * Bmix)))
LnPhiL = (Bi/Bmix)*(Zlmix-1) - log(Zlmix-Bmix)-(Amix/(2*Sqrt(2)*Bmix)) * ((2 *(dot(Aij,y)/Amix) -(Bi/Bmix)) * log((Zlmix + (1 + sqrt(2)) * Bmix) / (Zlmix + (1 - sqrt(2)) * Bmix)))
PhiV = exp(LnPhiV)
PhiL = exp(LnPhiL)
然而,当我运行它时,我收到此错误:
Traceback (most recent call last):
line 82, in PRMix
Wcomp[i] = Wcomp[int(comp[i])]
IndexError: index 5 is out of bounds for axis 0 with size 2
>>> IndexError: index 5 is out of bounds for axis 0 with size 2
我无法弄清楚出了什么问题。我尝试阅读有关错误但未找到任何适用于我的代码的内容。