﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
6017	FMUs don't export libopenblas.so	Andreas Heuermann	Andreas Heuermann	"I'm building a static C FMU 2.0 for ModelExchange with OpenModelica and try to simulate it with FMPy in a clean testing environment without omc available.

Our OpenModelica FMUs can't be simulated with FMPy since they are missing openblas.so 

'''How to reproduce'''
Note: You will need omc and docker in your path.
Also you have to trust my docker container or build your own ;-)

Run in your shell:
{{{
$ omc buildFMU.mos
true
""""
""/home/.../ticket6010/BouncingBall.fmu""
""""
$ docker run -it --rm -v $(pwd):/testDir anheuermann/fmpy:focal-arm64 /bin/bash
root@19cd9af7df5a:/# cd /testDir/
root@19cd9af7df5a:/testDir# ls *.fmu
BouncingBall.fmu
root@19cd9af7df5a:/testDir# python3
Python 3.8.2 (default, Apr 27 2020, 15:53:34)
[GCC 9.3.0] on linux
Type ""help"", ""copyright"", ""credits"" or ""license"" for more information.
>>> from fmpy import *
>>> fmu='BouncingBall.fmu'
>>> result = simulate_fmu(fmu)
Traceback (most recent call last):
  File ""/usr/local/lib/python3.8/dist-packages/fmpy/fmi1.py"", line 142, in __init__
    self.dll = cdll.LoadLibrary(libraryPath)
  File ""/usr/lib/python3.8/ctypes/__init__.py"", line 451, in LoadLibrary
    return self._dlltype(name)
  File ""/usr/lib/python3.8/ctypes/__init__.py"", line 373, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: libopenblas.so.0: cannot open shared object file: No such file or directory

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File ""<stdin>"", line 1, in <module>
  File ""/usr/local/lib/python3.8/dist-packages/fmpy/simulation.py"", line 557, in simulate_fmu
    fmu = instantiate_fmu(unzipdir, model_description, fmi_type, visible, debug_logging, logger, fmi_call_logger, use_remoting)
  File ""/usr/local/lib/python3.8/dist-packages/fmpy/simulation.py"", line 646, in instantiate_fmu
    fmu = FMU2Model(**fmu_args)
  File ""/usr/local/lib/python3.8/dist-packages/fmpy/fmi2.py"", line 409, in __init__
    super(FMU2Model, self).__init__(**kwargs)
  File ""/usr/local/lib/python3.8/dist-packages/fmpy/fmi2.py"", line 85, in __init__
    super(_FMU2, self).__init__(**kwargs)
  File ""/usr/local/lib/python3.8/dist-packages/fmpy/fmi1.py"", line 144, in __init__
    raise Exception(""Failed to load shared library %s. %s"" % (libraryPath, e))
Exception: Failed to load shared library /tmp/tmprujxrrsu/binaries/linux64/BouncingBall.so. libopenblas.so.0: cannot open shared object file: No such file or directory
>>>
}}}

buildFMU.mos
{{{
loadString(""
model BouncingBall
  parameter Real e=0.7 \""coefficient of restitution\"";
  parameter Real g=9.81 \""gravity acceleration\"";
  Real h(fixed=true, start=1) \""height of ball\"";
  Real v(fixed=true) \""velocity of ball\"";
  Boolean flying(fixed=true, start=true) \""true, if ball is flying\"";
  Boolean impact;
  Real v_new(fixed=true);
  Integer foo;
equation
  impact = h <= 0.0;
  foo = if impact then 1 else 2;
  der(v) = if flying then -g else 0;
  der(h) = v;
  when {h <= 0.0 and v <= 0.0,impact} then
    v_new = if edge(impact) then -e*pre(v) else 0;
    flying = v_new > 0;
    reinit(v, v_new);
  end when;
end BouncingBall;"");
getErrorString();

buildModelFMU(BouncingBall, version=""2.0"", fmuType=""me"", fileNamePrefix=""BouncingBall"", platforms={""static""});
getErrorString();
}}}"	defect	assigned	blocker	1.19.0	FMI	v1.16.0-dev		fmi-cross-check	Martin Sjölund
