【发布时间】:2021-05-26 15:15:36
【问题描述】:
在 Dymola 中,我可以执行以下操作:
when time > 100 then
assert(false,"Simulation taking too long");
end when;
根据时间变量本身停止模拟。
但是,我想做的是根据经过的 CPU 时间停止模拟。 Dymola 有一种输出 CPU 时间的方法,它在结果中显示为 CPUtime,但我不知道如何访问该变量。换句话说,这是我想做的,但 CPUtime 变量不在范围内:
when CPUtime > 100 then
assert(false,"Simulation taking too long");
end when;
任何建议,无论是如何访问 CPUtime,或其他解决方法来终止基于 cpu 时间的模拟?
【问题讨论】:
-
Dymola 2022 可以根据最大挂钟时间(不是 CPU 时间)停止模拟,也许这对您有用? 3ds.com/products-services/catia/products/dymola/latest-release
-
另外,您可以使用系统调用来获取挂钟时间并编写自己的 tic-toc 函数。然后使用 terminate() 运算符终止模拟。
-
是的,Dymola 2022 的新功能在这里看起来很完美,感谢您指出这一点。我也尝试了 tic/toc 类型的解决方案,但我只能让它以交互方式工作(比如在脚本环境中),而不是作为模拟中的模型。可能需要再试一次