5

I try to set up the pyFMI on Anaconda (Python 3.6.8)

Installed all the required packages listed on the pyFMI site. The fmu is loaded without the issue but while I try to simulate the fmu I get an error:

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.'}

Would appreciate any hints where to look for the possible issue.

kelamahim
  • 577
  • 1
  • 4
  • 21

4 Answers4

3

Kelamahim, how have you installed the PyFMI package? I have used conda install -c chria pyfmi and it works. Only Could not find RADAR5 Could not find GLIMDA are shown in the execution, but my models works. Hope this helps.

ignacio
  • 41
  • 3
  • I used the same approach conda install-c chria pyfmi. Same for assimulo. Could you please check which verison are you using with conda list. For the FMI Library which verison did you install and how? Thanks – kelamahim Mar 18 '19 at 07:46
  • Where can I find the setup.py file :python setup.py install --fmil-home=/path/to/FMI_Library/ – kelamahim Mar 28 '19 at 15:58
2

The solution is downgrading to Anaconda 3 Python 3.6.2 and installing with conda the pyfmi version 2.4.0

kelamahim
  • 577
  • 1
  • 4
  • 21
  • Good to hear it now works for you. Python 3.6.8 and 3.6.2 should be compatible. Are you sure it does not work for 3.6.8? And, please add to your self-answer which of the ways for installing you used. – matth Apr 04 '19 at 10:47
  • 1
    Not sure for 3.6.8 but sure that is not working on 3.7 and in both cases the pyfmi 2.5 version is not working. – kelamahim Apr 04 '19 at 12:16
1

I have been using Anaconda2 (Conda 4.6.8/python 2.7.15). Here's the installation process:

  • FMIL is built from source code using CMake
  • pyfmi is installed via conda install -c chria pyfmi
  • assimulo is installed via conda install -c conda-forge assimulo
  • wxPython 2.8.12.1 (classic) is installed via the Windows installer available on sourceforge
  • Other dependencies can be installed from pip

I also saw the following warning messages after loading pyfmi in python, but my simulation doesn't seem to be affected:

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

dchneric
  • 121
  • 5
  • Could you specify the FMIL part? So what exactly should be done here? I downloaded the FMI files (tried both) and set the FMIL_HOME in the environmental variables to the dowloaded files – kelamahim Mar 19 '19 at 15:33
  • In my case I have 64-bit windows machine so prebuild FMIL binaries are not available. I generate visual studio project via CMake, run BUILD and INSTALL to get the headers/DLLs, and point FMIL_HOME to its location. I used VS2017 so a few source code/confiuration changes are made before sucessfully compile the project. – dchneric Mar 19 '19 at 15:51
  • Can you explain in detail. I'm trying to figure it out – kelamahim Mar 28 '19 at 13:26
1

pyFMi is also available from the conda-forge channel:
https://anaconda.org/conda-forge/pyfmi
I permanentely added that channel, because it has reproducible builds and a huge number of packages, so usually dependencies can be resolved. The following worked for me, in Anaconda3 with Python 3.6:

conda config --append channels conda-forge
conda install pyfmi
conda list
matth
  • 2,568
  • 2
  • 21
  • 41
  • With this installation it should work without using the CMake? – kelamahim Mar 20 '19 at 10:29
  • I did not use Cmake or build anything from source (but I did install JModelica in the past, including python, FMIL, pyFMI, etc, but to a different path that was not visible to Anaconda). – matth Mar 20 '19 at 10:35
  • Maybe uninstall assimulo and pyfmi, re-install, and as first test try if you can simulate simple examples frm the MSL. Another completely different approach: Install JModelica, it includes a full Python distribution also. – matth Mar 28 '19 at 13:32
  • Tried to reinstall the packages several time and install them from multiple sources no luck. Currently installing JModelica. – kelamahim Mar 28 '19 at 13:41
  • The conda install pyfmi installes win32 version the yfmi.check_packages() Performing pyfmi package check ============================== PyFMI version ................ 2.5 Platform ..................... win32 Python version ............... 3.7.1 – kelamahim Mar 28 '19 at 13:42
  • Are you using win32? – kelamahim Mar 28 '19 at 14:39
  • I use Windows 10 with 64bit, my Anaconda is also 64bit. Jmodelica installs Python 32 and 64 bit I believe. – matth Mar 28 '19 at 19:26
  • The Jmodelica works. But I need to have it in Anaconda Python version 3.6. Any idea how to transfer? – kelamahim Mar 29 '19 at 10:24
  • Sorry, it cannot be transferred right away. But could you try if that maybe installed some missing dependencies? Just rerun the above commands, check if installation reports any errors, then try to simulate some small model from the MSL (you can translate to fmu using JModelica, then simulate that fmu using Anaconda pyfmi). For me it just works, and the error you posted is not really helpful. – matth Mar 30 '19 at 20:50