Python-Gekko流程图对象中有哪些等式?

2024-04-29 03:15:30 发布

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

方程和built-in Python Gekko flowsheet objects的其他细节是什么,比如反应堆模型?Gekko有我需要的化合物,用于气相流化床聚合物(聚乙烯)反应器的非线性模型预测控制(MPC)的工业应用

from gekko import GEKKO, chemical
m = GEKKO(remote=False)
c = chemical.Properties(m)
c.compound('ethylene')    # primary monomer reactant
c.compound('propylene')   # co-polymer monomer reactant
c.compound('hydrogen')    # melt-index modifier
c.compound('ethane')      # inert
c.compound('propane')     # inert
c.compound('cyclohexene') # density modifier
c.compound('isopentane')  # condensing agent
c.compound('nitrogen')    # pressure control
f = chemical.Flowsheet(m)
r = f.reactor(ni=2)
m.options.SOLVER = 1
m.solve()

这个简单的反应器模型产生以下输出:

 --------- APM Model Size ------------
 Each time step contains
   Objects      :  1
   Constants    :  0
   Variables    :  12
   Intermediates:  0
   Connections  :  12
   Equations    :  0
   Residuals    :  0

 Number of state variables:    29
 Number of total equations: -  10
 Number of slack variables: -  0
 ---------------------------------------
 Degrees of freedom       :    19

 ----------------------------------------------
 Steady State Optimization with APOPT Solver
 ----------------------------------------------

 Iter    Objective  Convergence
    0  2.55529E-16  1.38889E+00
    1  2.38753E-25  1.23358E-16
    2  2.38753E-25  1.23358E-16
 Successful solution

 ---------------------------------------------------
 Solver         :  APOPT (v1.0)
 Solution time  :  0.026300000000000004 sec
 Objective      :  0.
 Successful solution
 ---------------------------------------------------

我怎样才能找到更多关于10个方程和29个变量的细节呢?我对性能控制(熔融指数和密度)感兴趣,并通过调整催化剂、氢气和共单体(丙烯、异丁烯等)来最大限度地提高生产率


Tags: of模型numbertime细节方程modifier反应器
1条回答
网友
1楼 · 发布于 2024-04-29 03:15:30

当您将m.options.DIAGLEVEL设置为4或更高时,Gekko输出一个带有方程和变量模型细节的LaTeX文件rto_4_latex.tex(或{mode}_4_latex.tex}for other modes

from gekko import GEKKO, chemical
m = GEKKO(remote=False)
c = chemical.Properties(m)
c.compound('ethylene')    # primary monomer reactant
c.compound('propylene')   # co-polymer monomer reactant
c.compound('hydrogen')    # melt-index modifier
c.compound('ethane')      # inert
c.compound('propane')     # inert
c.compound('cyclohexene') # density modifier
c.compound('isopentane')  # condensing agent
c.compound('nitrogen')    # pressure control
f = chemical.Flowsheet(m)
r = f.reactor(ni=2)
m.options.SOLVER = 1
m.options.DIAGLEVEL = 4
m.solve()
m.open_folder()

当您用remote=False在本地求解并用m.open_folder()打开run目录时,您还可以在它生成的许多文件中看到更多信息

\documentclass[8pt]{article}
\begin{document}
\title{Model Title}
\author{John D. Hedengren}
\maketitle
\section{equations}

\subsection{Equation 1 }
\texttt{ ss.reactor1.overall\_mole\_balance }
\begin{equation}
0 = {\dot n}_{in} + {\dot r}_{gen} - {\dot n}_{out} - \frac{\partial n}{\partial t}
\end{equation}
Variables
\begin{enumerate}
\item \texttt{ 0.60000E+00 kmol/sec    ss.reactor1.inlet[1].ndot * 2}
\item \texttt{ 0.60000E+00 kmol/sec    ss.reactor1.inlet[2].ndot * 11}
\item \texttt{ 0.12000E+01 kmol/sec    ss.reactor1.outlet.ndot * 19}
\item \texttt{ 0.00000E+00 kmol/sec    ss.v1 * 29}
\end{enumerate}

如果在Windows中使用call pdflatex main编译LaTeX文档,并且有downloaded texlive,则可以获得PDF文档。否则,您可以将其放入online OverLeaf editor以转换为PDF。下面是创建的7页文档的前两个公式

PDF of Gekko Model

相关问题 更多 >