Closed zzlonggg closed 1 year ago
The log message is not very conclusive, it only tells that Dymola is not able to load the FMU's shared library. This can have several reasons.
To investigate what went wrong I propose to start by inspecting the generated FMU:
Controller.fmu
) and check if the shared library (Controller.dll
in subfolder binaries\win64
) is present. In case it is missing, the most likely reason is that the fmipp library was not installed properly.CFF Explorer
from the Explorer Suite to check that all FMI functions have been exported (see Export Directory
in CFF Explorer
) and that all dependencies are met (see Dependency Walker
in CFF Explorer
).For the first point, I checked its subfolders. the shared library ( in subfolder ) is present. (I used pip to install fmipp (pip install fmipp). Given the initial value, then run the create_fmu.py in the “export” folder, and finally exported the fmu file. I don't know whether this process is correct)
For the second point,I think it is valid and complete(Attached with inspection results) .However, no matter which modelica development tool and fmpy are used, the result is that the shared library cannot be imported.I don't know whether there are examples of exported fmu files.(Attached source document)
I think I found the culprit. The shared library had a dependency to another shared library (Boost filesystem library). I have uploaded a new release to PyPI that fixes this issue:
pip install fmipp==2.0.2 --prefer-binary
I re exported the fmu file. It works in dymola, which is exciting.But when I tried to parse the fmu file with fmpy, it encountered an error(unable to parse xml model description file). This confused me, so I checked the xml file of the model(Attached xml file).It seems to lack something. ModelStructure/InitialUnknowns does not contain the expected set of variables. Output variable has been defined(self.defineRealOutputs( 'Pheat' )). But it seems that it is not shown in the model structure part of the xml file. modelDescription.zip
Good to hear that the new version works with Dymola!
The last time I checked, the generated models passed the official FMU compliance checker. ModelStructure.InitialUnknowns
is an optional element in the model description.
However, fmpy
's XML model description checking is more restrictive than what the FMI 2.0 standard defines. This is especially true for the VendorAnnotations
element. Hence, even though the model description is valid with respect to the FMI 2.0 specification, fmpy
returns an error. I suggest to open a new issue for fmpy
.
Alternatively, you can also use fmipp
for importing FMUs (at least v1.0 and v2.0).
When I import the exported FMU into Dymola for use, an error occurs during the simulation The details are as follows: Log-file of program ./dymosim (generated: Mon Nov 21 10:53:15 2022)
dymosim started ... "test" simulating ... "dsin.txt" loading (dymosim input file) Error: The following error was detected at time: 0 Loading of FMU dynamic link library (Controller.dll) failed! The stack of functions is: Controller_fmu.fmi_Functions.fmiModel Controller_fmu.fmi_Functions.fmiModel("Controller_fmu", controller_fmu.fmi_loggingOn, "file:///D:/Users/J/Desktop/fmi++/py-fmipp-tutorial-master/py-fmipp-tutorial-master/exercises/export/Resources/Library/FMU/Controller/resources", 0, 1)
Error: Integrator failed to start model.
... Error message from dymosim
ERROR: The simulation of Unnamed FAILED