【发布时间】:2022-10-18 09:59:07
【问题描述】:
我正在探索 Gekko 化学库和流程图实施。我定义了化合物丙烯、丙烷、丁烷和戊烷以及两种具有不同化合物分数和摩尔流速的物流。我想混合这些流并计算组合流的总摩尔流速和摩尔分数。
我得到的结果是:
Mole fraction in blended stream is: [[0.25], [0.25], [0.25], [0.25]]。它似乎是出口流的初始化值。
我仔细阅读了这个 StackOverflow 链接 [这里] 1 没有成功。
示例代码在这里:
from gekko import GEKKO, chemical
import numpy as np
m = GEKKO() #instantiate GEKKO object
f = chemical.Flowsheet(m,stream_level=0) #instantiate flowsheet object
c = chemical.Properties(m)
c.compound('propylene') #define compound 1
c.compound('propane') #define compound 2
c.compound('butane') #define compound 3
c.compound('pentane') #define compound 4
s1=f.stream(fixed=True) #define stream 1
s1.x=np.array([0.5,0.3,0.1,0.1]) #specify mole fraction of compound 1-4 for stream1
s1.ndot=10 #specify molar flow rate of stream 1
s2=f.stream(fixed=True)
s2.x=np.array([0.3,0.3,0.2,0.2]) #specify mole fraction of compound 1-4 for stream2
s2.ndot=20 #specify molar flow rate of stream 2
outlet=f.stream(fixed=False) #define outlet stream that should be solved
mx = f.mixer(ni=2) #mixer object with two inlet
#mx.inlet[0]=s1
#mx.inlet[1]=s2
f.connect(mx.inlet[0],s1) #assign stream 1 to mixer inlet 1
f.connect(mx.inlet[1],s2) #assign stream 2 to mixer inlet 2
mx.outlet=outlet #connect mixer outlet to outlet stream obj
m.options.SOLVER=1
m.solve()
print('Mole fractions in blended stream is:', mx.outlet.x)
【问题讨论】: