Error in DaeBuilder.create() from a FMU model exported from Dymola

93 views Asked by At

I'm trying to follow the exemple provided in Casadi documentation called modelica_fmu_import.py. However, instead of following it to the letter, I'm using an FMU exported by Dymola instead (Co-simulation using Dymola solvers).

The commands

dae = DaeBuilder('pump', 'pump_fmu_unzipped')
dae.disp(True)

apparently work successfully, as I get the following result:

Unpacked "folder.path"
nx = 5, nz = 0, nq = 0, ny = 1, np = 0, nc = 0, nd = 0, nw = 0, nu = 1
Variables
  x = [pumps.medium.p, pumps.medium.T, reservoir.level, reservoir.medium.T, PT1.y]
  y = [tank_pressure]
  u = [pump_rpm]
Differential equations
  \dot{pumps.medium.p} == der(pumps.medium.p)
  \dot{pumps.medium.T} == der(pumps.medium.T)
  \dot{reservoir.level} == der(reservoir.level)
  \dot{reservoir.medium.T} == der(reservoir.medium.T)
  \dot{PT1.y} == der(PT1.y)
Output variables
  tank_pressure

The description of differential equations don't seem very informative though, but I assume that this is how it is supposed to work?

A problem arises when I try to run

f = dae.create('f', ['x', 'u'], ['ode'])

And the following error is reported:

RuntimeError: Error in DaeBuilder::create for 'process'  at .../casadi/core/dae_builder.cpp:737:
Error in Fmu::init for 'f' [Fmu2] at .../casadi/core/fmu.cpp:63:
.../casadi/core/casadi_os.cpp:166: Assertion "handle!=nullptr" failed:
DllLibrary::init_handle: Cannot load shared library 'folder.path/binaries/win64/.dll': 
   (
    Searched directories: 1. casadipath from GlobalOptions
                          2. CASADIPATH env var
                          3. PATH env var (Windows)
                          4. LD_LIBRARY_PATH env var (Linux)
                          5. DYLD_LIBRARY_PATH env var (osx)
    A library may be 'not found' even if the file exists:
          * library is not compatible (different compiler/bitness)
          * the dependencies are not found
   )
  Tried '...\anaconda3\Lib\site-packages\casadi' :
    Error code (WIN32): 126
  Tried '' :
    Error code (WIN32): 126
  Tried '.' :
    Error code (WIN32): 126

I'm wondering what is going on? Is there something wrong with the exported FMU or do I have to add my work folder (where the unpacked FMU is) to CASADIPATH or something?

1

There are 1 answers

1
Christian Bertsch On

Please check if you FMU contains win32 or win64 binaries. You can create both from Dymola (can be configured in the FMI export tab of Dymola). You can inspect your FMU by unzipping it and checking the binaries folder for subfolders "win32" "win64". Casadi seem to expect a windows binary with a bit-ness that is not present in your FMU.