Python 错误:未生成应用程序文件?

问题描述

我想借助 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 新手。谢谢你

解决方法

错误在一行,

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

据报道,

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

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