我在工作中使用OpenModelica。
如何保存OpenModelica模拟结果?
发布于 2022-02-26 13:53:16
那得看情况。如果您正在使用OMEdit,您可以在OMEdit的工作目录中找到结果。

如果希望通过OpenModelica脚本将模型保存为可执行文件,可以通过以下方式使用mos脚本:
setCommandLineOptions({"-d=execstat"});
loadFile("model.mo");getErrorString();
buildModel(model); getErrorString();要运行该可执行文件2秒,请在这里使用IDA解决程序:
"./model -override=stopTime=2.0 -s=ida", "log.log"使用这种方法,结果模拟将保存在您的工作目录中。
或者您可以编写以下mos脚本:
loadFile("HelloWorld.mo");getErrorString();
simulate(HelloWorld);getErrorString();使用以下Modelica模型:
model HelloWorld
Real x( start = 1, fixed = true );
parameter Real a = 1;
equation
der(x) = - a * x;
end HelloWorld;产出如下:
真的
""
record SimulationResult
resultFile = "/mnt/c/<Path>/HelloWorld_res.mat",
simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'HelloWorld', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''",
messages = "LOG_SUCCESS | info | The initialization finished successfully without homotopy method.
LOG_SUCCESS | info | The simulation finished successfully.
",
timeFrontend = 0.007985600000000001,
timeBackend = 0.0152096,
timeSimCode = 0.0033462,
timeTemplates = 0.09332140000000001,
timeCompile = 1.7051749,
timeSimulation = 0.0506992,
timeTotal = 1.8771728
end SimulationResult;结果将在您的工作目录中的HelloWorld_res.mat中获得。
https://stackoverflow.com/questions/71275507
复制相似问题