使用 pyFMI 模拟时出现 CVodeError

CVodeError while simulating with pyFMI

我尝试在 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.'}

如果能提供在何处寻找可能问题的任何提示,我们将不胜感激。

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

我一直在使用 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(经典版)是通过 Windows 安装程序安装的 sourceforge
  • 可以从 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

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

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

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