很久以前,我使用JModelica/pymodelica将modelica模型编译成fmu,使用一个简单的python脚本。现在我了解到JModelica已经不再是一个开源项目了。(运行FMU的库似乎已经扩展到新的开源项目中,但我没有找到编译器。)
有没有一种新的、开源的、同样简单的替代方案
我从《何时》回来的脚本如下,我希望能找到一些东西,让我将其更新到Python3,并继续我多年前离开的地方
#! /local/opt/modelica/bin/jm_python.sh
# Import the compiler function
from pymodelica import compile_fmu
import optparse
parser = optparse.OptionParser()
(options,args) = parser.parse_args()
# Specify Modelica model and model file (.mo or .mop)
mo_file = args[0]
model_name = mo_file.split(".")[0]
print mo_file, model_name
# Compile the model and save the return argument, which is the file name of the FMU
my_fmu = compile_fmu(model_name, mo_file, target='cs')
剩下的唯一开源替代方案是OpenModelica。当然,JModelica仍然存在于一些github分叉中,但我不确定它是否仍然得到更新和支持
您可以尝试使用OpenModelica和OMPython。 https://www.openmodelica.org/doc/OpenModelicaUsersGuide/latest/ompython.html
另见: https://www.openmodelica.org/forum/default-topic/3121-compile-cosimulation-fmu-via-ompython-api-call
我猜要生成FMU,它应该是这样的:
相关问题 更多 >
编程相关推荐