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

2024-06-12 18:29:32 发布

您现在位置: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新手。谢谢你


Tags: fromimportmodisnoterrorlisimulation
1条回答
网友
1楼 · 发布于 2024-06-12 18:29:32

错误在第行

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

相关问题 更多 >