【问题标题】:Python Error: Application file not generated?Python 错误:未生成应用程序文件?
【发布时间】:2021-05-05 08:28:16
【问题描述】:

我想借助 OMPython 在 Python 中模拟 OpenModelica 模型。以下是我的代码:

import matplotlib.pyplot as plt  
import OMPython
from OMPython import OMCSessionZMQ
from OMPython import ModelicaSystem
omc = OMCSessionZMQ()
mod = ModelicaSystem("Li_ionBattery.mo", "Li_ionBattery.TestBench.VaryingCurrent")
Li_simulation = mod.getSimulationOptions()
mod.setSimulationOptions(["stopTime=2000", "stepSize=50"])
variables_vary = mod.getQuantities()
Parameters_vary = mod.getParameters() 
continous_vary = mod.getContinuous() 
mod.setParameters(["nMC_Data.Q_nom=11", "nMC_Data.Rs=0.0003"])
mod.simulate()

我收到以下错误:

Notification: Li_ionBattery requested package Modelica of version 3.2.2. Modelica 3.2.3 is used instead which states that it is fully compatible without conversion script needed.

Error: Class Li_ionBattery.TestBench.VaryingCurrent not found in scope <top>.
Error: Class Li_ionBattery.TestBench.VaryingCurrent not found in scope <TOP>.

stopTime !is not a simulation-option variable
Traceback (most recent call last):

 

raise Exception("Error: application file not generated yet")

Exception: Error: application file not generated yet

【问题讨论】:

    标签: python modeling battery openmodelica simulate


    【解决方案1】:

    错误在行,

    mod = ModelicaSystem("Li_ionBattery.mo", "Li_ionBattery.TestBench.VaryingCurrent")

    据报道,

    Error: Class Li_ionBattery.TestBench.VaryingCurrent not found in scope &lt;top&gt;.

    确保Li_ionBattery.TestBench.VaryingCurrent 类存在于Li_ionBattery.mo 中。

    【讨论】:

    • 我检查并更正了它,但现在出现新错误:AttributeError: 'xml.etree.ElementTree.Element' object has no attribute 'getchildren' from File "/home/nupur/.local/lib/python3.9/site-packages/OMPython/__init__.py", line 974, in xmlparse ch = sv.getchildren()
    • 您使用的是哪个版本的 OMPython?
    • 我正在使用 OMPython 3.3.0
    • 在 OMPython master 中修复了 xml 树错误,但 pip install 不可用,我建议您从 master 克隆 OMPython 并使用安装文件“python setup.py install”手动构建它"
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-06-25
    • 1970-01-01
    • 2011-06-11
    • 1970-01-01
    • 1970-01-01
    • 2012-05-13
    • 1970-01-01
    相关资源
    最近更新 更多