如何使用FMPy来获取访问FMU-CS中存储的结果的方法?

huangapple go评论95阅读模式
英文:

How to get access to how results are stored using FMPy to simulate FMU-CS?

问题

在使用FMPy时,可以实现在每次函数评估都是一次模拟的情况下,将结果存储在RAM内存中,避免写入硬盘,以显著提高速度。相应的命令如下:

opts_fast = mode.simulate_options()
opts_fast['result_handling'] = 'memory'

然后,进行模拟操作:

sim_res = model.simulate(final_time=1, options=opts_fast)

请注意,这是在使用FMPy时进行此操作的示例代码。

英文:

I develop a simulation script for optimization where each function evaluation is a simulation. Usually the speed can be improved considerably by only allow the simulation to store results in the RAM memory and thus avoid writing to the hard disc. How can this be done using FMPy?

When I use PyFMI the corresponding commands are:

opts_fast = mode.simulate_options()
opts_fast['result_handling'] = 'memory'

and the simulation is done with

sim_res = model.simulate(final_time=1 , options=opts_fast)

答案1

得分: 0

与FMPy软件背后的人联系告诉我,模拟结果仅存储在RAM内存中。对于simulate_fmu()函数,有许多选项,您可以通过以下方式查看:

from fmpy import simulate_fmu
simulate_fmu?

在这里没有选项可以将结果存储在磁盘文件中。这意味着如果您需要将结果存储在磁盘上,您需要编写相应的Python代码。

FMPy和PyFMI之间关于生成的结果的一个关键区别是,对于FMPy,您需要指定要存储哪些变量,并在名为"output"的变量中指定要在模拟期间存储的变量列表。而PyFMI默认存储所有内容,但您也可以选择指定一个(较小的)要存储的变量列表。

为了提高涉及许多模拟评估的优化速度,重要的是重置() FMU,而不是重新加载它。这与使用PyFMI时的建议相同。

英文:

My contact with people behind the FMPy software tell me that simulations results are stored in RAM-memory only. There are a number of options for the function simulate_fmu() as you can see by

from fmpy import simulate_fmu
simulate_fmu?

Here is no option for storing results in a file on disk. This means that if you need to store the result on disk you need to write the appropriate Python code for that.

A key difference between FMPy and PyFMI concerning results generated is that for FMPy you need to specify what variables you want to store and specify that in the variable "output" that is a list of variables to be stored during simulation. While PyFMI stores by default everything, but you can alternatively specify a (smaller) list of variables to be stored.

To improve speed in optmization involving many evaluations using simulations it is important to reset() the FMU rather than loading it anew again. That is the same advice as for using PyFMI.

huangapple
  • 本文由 发表于 2023年3月8日 16:15:48
  • 转载请务必保留本文链接:https://go.coder-hub.com/75670667.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定