【问题标题】:CVodeError while simulating with pyFMI使用 pyFMI 进行模拟时出现 CVodeError
【发布时间】:2019-08-06 07:00:29
【问题描述】:

我尝试在 Anaconda (Python 3.6.8) 上设置 pyFMI

安装了 pyFMI 站点上列出的所有必需的软件包。加载 fmu 时没有问题,但是当我尝试模拟 fmu 时出现错误:

Could not find cannot import name 'radau5'
Could not find cannot import name 'dopri5'
Could not find cannot import name 'rodas'
Could not find cannot import name 'odassl'
Could not find ODEPACK functions.
Could not find RADAR5
Could not find GLIMDA.
Traceback (most recent call last):
File "assimulo\solvers\../lib/sundials_callbacks_ida_cvode.pxi", line 240, in   assimulo.solvers.sundials.cv_jac
File "C:\Users\d60378\AppData\Local\Continuum\anaconda3\lib\site-packages\pyfmi\simulation\assimulo_interface.py", line 733, in j
A = self._model._get_A(add_diag=True, output_matrix=self._A)
File "src\pyfmi\fmi.pyx", line 6041, in pyfmi.fmi.FMUModelBase2._get_A
File "src\pyfmi\fmi.pyx", line 7592, in pyfmi.fmi.FMUModelME2._get_directional_proxy
File "src\pyfmi\fmi.pyx", line 5989, in pyfmi.fmi.FMUModelBase2._get_directional_proxy
TypeError: Expected tuple, got dict_keys
Traceback (most recent call last):

 File "<ipython-input-1-6c340902ef15>", line 28, in <module>
 res = model.simulate(options=opts,start_time=tstart, final_time=tstart+172200)

  File "src\pyfmi\fmi.pyx", line 7522, in pyfmi.fmi.FMUModelME2.simulate

 File "src\pyfmi\fmi.pyx", line 304, in pyfmi.fmi.ModelBase._exec_simulate_algorithm

  File "src\pyfmi\fmi.pyx", line 300, in pyfmi.fmi.ModelBase._exec_simulate_algorithm

  File "C:\Users\d60378\AppData\Local\Continuum\anaconda3\lib\site-packages\pyfmi\fmi_algorithm_drivers.py", line 520, in solve
self.simulator.simulate(self.final_time, self.ncp)

  File "assimulo\ode.pyx", line 168, in assimulo.ode.ODE.simulate

  File "assimulo\ode.pyx", line 288, in assimulo.ode.ODE.simulate

  File "assimulo\explicit_ode.pyx", line 101, in assimulo.explicit_ode.Explicit_ODE._simulate

  File "assimulo\explicit_ode.pyx", line 187, in assimulo.explicit_ode.Explicit_ODE._simulate

  File "assimulo\solvers\sundials.pyx", line 1894, in assimulo.solvers.sundials.CVode.integrate

  File "assimulo\solvers\sundials.pyx", line 1926, in assimulo.solvers.sundials.CVode.integrate

 CVodeError: {-1: 'The solver took max internal steps but could not reach tout.', -2: 'The solver could not satisfy the accuracy demanded by the user for some internal step.', -3: 'Error test failures occurred too many times during one internal time step or minimum step size was reached.', -4: 'Convergence test failures occurred too many times during one internal time step or minimum step size was reached.', -5: 'The linear solvers initialization function failed.', -6: 'The linear solvers setup function failed in an unrecoverable manner.', -7: 'The linear solvers solve function failed in an unrecoverable manner.', -8: 'The user-provided rhs function failed in an unrecoverable manner.', -9: 'The right-hand side function failed at the first call.', -10: 'The right-hand side function had repeated recoverable errors.', -11: 'The right-hand side function had a recoverable error, but no recovery is possible.', -12: 'The rootfinding function failed in an unrecoverable manner.', -20: 'A memory allocation failed.', -21: 'The cvode_mem argument was NULL.', -22: 'One of the function inputs is illegal.', -23: 'The CVode memory block was not allocated by a call to CVodeMalloc.', -24: 'The derivative order k is larger than the order used.', -25: 'The time t is outside the last step taken.', -26: 'The output derivative vector is NULL.', -27: 'The output and initial times are too close to each other.', -41: 'The sensitivity right-hand side function failed unrecoverable.'}

如果有任何提示可以查找可能的问题,我们将不胜感激。

【问题讨论】:

    标签: python-3.x modelica dymola fmi assimulo


    【解决方案1】:

    Kelamahim,你是如何安装 PyFMI 包的?我用过了 conda install -c chria pyfmi 它有效。 仅有的 Could not find RADAR5 Could not find GLIMDA 显示在执行中,但我的模型有效。希望这会有所帮助。

    【讨论】:

    • 我使用了相同的方法 conda install -c chria pyfmi。与 assimulo 相同。您能否检查一下您在 conda list 中使用的是哪个版本。对于 FMI 库,您安装了哪个版本以及如何安装?谢谢
    • 在哪里可以找到 setup.py 文件:python setup.py install --fmil-home=/path/to/FMI_Library/
    【解决方案2】:

    我一直在使用 Anaconda2 (Conda 4.6.8/python 2.7.15)。安装过程如下:

    • FMIL 是使用 CMake 从 source code 构建的
    • pyfmi 是通过conda install -c chria pyfmi 安装的
    • assimulo 是通过conda install -c conda-forge assimulo 安装的
    • wxPython 2.8.12.1 (classic) 是通过sourceforge 上的 Windows 安装程序安装的
    • 其他依赖可以从pip安装

    我在python中加载pyfmi后也看到了如下警告信息,但是我的模拟好像没有受到影响:

    Could not find cannot import name radau5
    Could not find cannot import name dopri5
    Could not find cannot import name rodas
    Could not find cannot import name odassl
    Could not find ODEPACK functions.
    Could not find RADAR5
    Could not find GLIMDA.
    

    HTH

    【讨论】:

    • 您能指定 FMIL 部分吗?那么这里究竟应该做什么呢?我下载了 FMI 文件(都试过了)并将环境变量中的 FMIL_HOME 设置为下载的文件
    • 在我的情况下,我有 64 位 Windows 机器,因此预构建 FMIL 二进制文件不可用。我通过 CMake 生成 Visual Studio 项目,运行 BUILD 和 INSTALL 以获取头文件/DLL,并将 FMIL_HOME 指向它的位置。我使用的是 VS2017,所以在成功编译项目之前进行了一些源代码/配置更改。
    • 能否详细解释一下。我正在努力解决
    【解决方案3】:

    pyFMi 也可以从 conda-forge 频道获得:
    https://anaconda.org/conda-forge/pyfmi
    我永久添加了该频道,因为它具有可重复的构建和大量的软件包,因此通常可以解决依赖关系。 以下对我有用,在 Python 3.6 的 Anaconda3 中:

    conda config --append channels conda-forge
    conda install pyfmi
    conda list
    

    【讨论】:

    • 通过这个安装它应该可以在不使用 CMake 的情况下工作?
    • 我没有使用 Cmake 或从源代码构建任何东西(但我过去确实安装了 JModelica,包括 python、FMIL、pyFMI 等,但安装到 Anaconda 看不到的不同路径)。
    • 也许卸载 assimulo 和 pyfmi,重新安装,如果您可以模拟 MSL 中的简单示例,作为第一次测试尝试。另一种完全不同的方法:安装 JModelica,它还包含一个完整的 Python 发行版。
    • 尝试多次重新安装软件包并从多个来源安装它们,但没有成功。目前正在安装 JModelica。
    • conda install pyfmi 安装win32版本 yfmi.check_packages() 执行pyfmi包检查 ======================== ===== PyFMI 版本 ........ 2.5 平台 ............ win32 Python 版本。 ............. 3.7.1
    【解决方案4】:

    解决方案是降级到 Anaconda 3 Python 3.6.2 并使用 conda 安装 pyfmi 版本 2.4.0

    【讨论】:

    • 很高兴听到它现在对您有用。 Python 3.6.8 和 3.6.2 应该兼容。你确定它不适用于 3.6.8 吗?并且,请在您的自我回答中添加您使用的安装方式。
    • 对于 3.6.8 不确定,但确定在 3.7 上不起作用,并且在这两种情况下,pyfmi 2.5 版本都不起作用。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-02-19
    相关资源
    最近更新 更多