如何使用来自某个库(Modelica除外)的组件并从other运行模型?例如,
model myModel
Modelica.Electrical.Analog.Sources.ConstantVoltage cv(V=9) .... // Standard component
SomeLibrary.Components.SomeComponent myComponent .... // Some specific component
...
end myModel
如果我想通过使用loadFile("mymodel.mo")命令从OM运行这个模型,我通常会收到一条消息,上面写着无法构建模型,因为它找不到"SomeLibrary“。
我想编写命令,将模型加载到脚本(.mos)中,并从.bat文件中使用omc调用脚本。
谢谢!
发布于 2022-11-10 07:26:22
要么向模型添加一个uses-注释(应该在任何工具中工作):
model myModel
Modelica.Electrical.Analog.Sources.ConstantVoltage cv(V=9) .... // Standard component
SomeLibrary.Components.SomeComponent myComponent .... // Some specific component
...
annotation(uses(SomeLibrary(version="1.0.0")));
end myModel;
或者在你的电影剧本里:
loadFile("myModel.mo");getErrorString();
loadModel(SomeLibrary);getErrorString();
loadModel(SomeLibrary, {"1.0.0"});getErrorString(); // Or with a specific version
或者使用OpenModelica 1.19.0或更高版本(如果它在MODELICAPATH上,它应该自动加载库)。
如果没有安装库,可以使用OMEdit安装包,或者使用OMShell/mos-script:
updatePackageIndex();
installPackage(SomeLibrary);
installPackage(SomeLibrary, "1.0.0"); // Or with a specific version
https://stackoverflow.com/questions/74384034
复制相似问题