我有一个Modelica文件,在仿真期间通过外部库* .a文件引用c代码。在JModelica中引用外部文件
例如:
model CallAdd
input Real FirstInput(start=0);
input Real SecondInput(start=0);
output Real FMUOutput(start=0);
function CAdd
input Real x(start=0);
input Real y(start=0);
output Real z(start=0);
external "C" annotation(Library = "CAdd", LibraryDirectory = "modelica://CallAdd");
end CAdd;
equation
FMUOutput = CAdd(FirstInput,SecondInput);
annotation(uses(Modelica(version = "3.2.1")));
end CallAdd;
当打开在OpenModelica的Modelica的模型所需的文件似乎被自动加载,因为它模拟,并给出相应的结果。
但是,当我尝试使用JModelica-SDK-1.12编译Modelica文件时,收到无法找到库* .a文件的错误。
所以我的问题是:在JModelica中使用compile_fmu时引用其他文件的正确方法是什么?
没有成功,我已经试过:
# Import the compiler function
from pymodelica import compile_fmu
model_name = "CallAdd"
mo_file = "CallAdd.mo"
# Compile the model and save the return argument, for use later if wanted
my_fmu = compile_fmu(model_name, mo_file, target="cs",compiler_options = {'extra_lib_dirs':'C:/ToFolderContainingLib/'})
奇怪的是,当我使用JModelica-1.17(非SDK)文件编译罚款,但结果并没有什么意义。我建议尝试SDK版本,看看它是否修复了我之前发布的文章here中的错误。
嗨克里斯蒂安安德森,似乎已经解决了这个问题。非常感谢你! –