【问题标题】:What equations are in Python Gekko flowsheet objects?Python Gekko 流程图对象中有哪些方程式?
【发布时间】:2019-11-23 14:01:19
【问题描述】:

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 个变量的更多详细信息?我对性能控制(熔体指数和密度)感兴趣,并通过调整催化剂、氢气和共聚单体(丙烯、异丁烯等)来最大限度地提高生产率。

【问题讨论】:

    标签: python gekko process-control


    【解决方案1】:

    当您将 m.options.DIAGLEVEL 设置为 4 或更高时,Gekko 会输出一个 LaTeX 文件 rto_4_latex.tex(或 {mode}_4_latex.tex} 用于 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() 打开运行目录时生成的许多文件中查看更多信息。

    \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}
    

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

    【讨论】:

    • 让 Gekko 输出 Microsoft Word 文档有多难?我猜这并不容易。它看起来像是一种将模型文档构建为 PDF 的强大方法。与我互动的很多人只想使用 Excel、Word 和电子邮件。
    • 用 LaTeX 编写方程要容易得多,尽管我在最近的 Word 版本中看到了更多的 LaTeX 方程支持。我会看看是否有东西可用于自动导出。其他人也可以向我指出一些资源。
    猜你喜欢
    • 2022-10-18
    • 2010-09-07
    • 1970-01-01
    • 2012-12-26
    • 2021-02-04
    • 1970-01-01
    • 2012-06-10
    • 1970-01-01
    • 2016-11-21
    相关资源
    最近更新 更多