来自另一个问题:
我注意到在 Modelica 中,模拟时间有不同的标志,但实际上,与我按下模拟按钮到模拟结束所经过的时间(大约用手机时钟测量)相比,我得到的时间非常小。
报告的时间是正确的。大部分时间不是初始化或模拟,而是编译。如果您使用 OMEdit 中的重新模拟选项(右键单击变量绘图视图中的结果文件),您会注意到模拟速度非常快。
$ cat e.mos
loadString("model M
Real r(fixed=true, start=2.0);
equation
der(r) = time;
end M;");getErrorString();
simulate(M);getErrorString();
$ omc e.mos
true
""
record SimulationResult
resultFile = "/mnt/data/@Mech/martin/tmp/M_res.mat",
simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'M', 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.004114061,
timeBackend = 0.00237546,
timeSimCode = 0.0008126780000000001,
timeTemplates = 0.062749837,
timeCompile = 0.633754155,
timeSimulation = 0.006627571000000001,
timeTotal = 0.7106012479999999
end SimulationResult;
""
据我所知,OMEdit 不会报告这些其他数字(翻译和编译模型的时间)。在 Windows 上,这些时间相当长,因为链接需要更长的时间。