本文介绍了有没有办法使用 python 库 FMPy 或 pyFMI 列出 FMU(或 FMU 中的子模型)的参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个模型的 FMU,用例是更改 FMU 的参数值以查看对结果的影响.如果我无法访问 Modelica 模型,有没有办法使用 FMPy 或 pyFMI 列出 FMU 的顶级参数?

I have a FMU of a model and the use case is to change parameter values of the FMU to see the impact on the results. Is there a way to list top level parameters of the FMU using either FMPy or pyFMI if I dont' have access to the Modelica model?

我一直遵循的一个过程是使用 FMPy.gui 打开 FMU 并查看参数列表,然后在脚本中使用它们,但我想知道是否有更简单的方法来做到这一点我可以在 Jupyter notebook 中列出然后根据需要更改参数吗?

One of the process I have been following is to open the FMU using FMPy.gui and go through the list of parameters and then use them in the script but I would like to know if there an easier way of doing it so that I can list then in the Jupyter notebook and change the parameters as needed?

推荐答案

使用 fmpy 你可以循环遍历模型描述中的 modelVariables 如下:

With fmpy you can loop over the modelVariables in the model description as follows:

from fmpy import read_model_description
from fmpy.util import download_test_file

fmu_filename = 'CoupledClutches.fmu'

download_test_file('2.0', 'CoSimulation', 'MapleSim', '2016.2', 'CoupledClutches', fmu_filename)

model_description = read_model_description(fmu_filename)

parameters = [v for v in model_description.modelVariables if v.causality == 'parameter']

这篇关于有没有办法使用 python 库 FMPy 或 pyFMI 列出 FMU(或 FMU 中的子模型)的参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-27 16:05