Giter VIP home page Giter VIP logo

fmikit-simulink's Introduction

FMI Kit banner

FMI Kit for Simulink

Build Status

A Simulink library to import and export Functional Mock-up Units that supports...

  • FMI 1.0, 2.0, and 3.0
  • Model Exchange and Co-Simulation
  • MATLAB R2016a - R2023a

Quick start

To get started with FMI Kit run the following commands in the MATLAB Command Window

% download and extract the distribution archive to the current folder
unzip(['https://github.com/CATIA-Systems/FMIKit-Simulink/releases/' ...
  'download/v3.1/FMIKit-Simulink-3.1.zip'], 'FMIKit-Simulink-3.1')

% add the folder to the MATLAB path
addpath(fullfile(pwd, 'FMIKit-Simulink-3.1'))

% initialize FMI Kit
FMIKit.initialize()

% open the Bouncing Ball demo
fmikit_demo_BouncingBall

% open the documentation
web('FMIKit-Simulink-3.1/html/index.html')

See the documentation to learn how to import and export FMUs.

Commercial Support

You're starting a project, need training or professional support? Our partners at Claytex are ready to help you.

License

Copyright © 2023 Dassault Systèmes. The code is released under the 2-Clause BSD license.

fmikit-simulink's People

Contributors

dependabot[bot] avatar dhenriksson avatar t-sommer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fmikit-simulink's Issues

Don't remove square brackets from port names

When a Simulink port name contains square brackets (e.g. Output[2]) the ModelDescription.xml will not contain these brackets (e.g. name="Output2").
Please keep the brackets!

Better DirectFedthrough setting for ME Import

In Simulink, direct feethrough is a property of inputs of an S-Function, while in FMI ME one can provide a matrix providing the information which input has direct feedthrough to which output.

Thus it is not possible to make use of all present direct feedthrough information from the FMI in Simulink.

Currently FMI-Kit sets all inputs of the S-Function which wraps the FMU to HasDirectFeedthough=true, and sets the inputs of the FMU in the mdlOutputs method of the S-function.

However, this leads possibly to unnecessary detected "Algebraic loops" in Simulink, which can lead to slow simulations and prossible problems in combination with discontinueties, as for algebraic loops Simulink changes the solver behaviour.

Proposal:
find out from the XML, which input of the FMU is used for any output and set HasDirectFeedthrough only for the inputs where it is necessary.

Then the inputs should be set then for the variables with directFeedthrough=true in mdlOutputs, and for the variables with directFeedthrough=false in mdlDerivatives.

Thus fewer "false" algebraic loops would be created.

S-function sources must be stored in local directory

Often we use S-Functions where the sources are stored in other directories/repositories.

In order to generate FMUs, FMI-Kit has the requirement to locally store the C-Source file of an S-Function in the local directory. This is hard to keep consistent and thus error-prone.

The following tests were made with the feature/relative-tolerance installer in ML/SL2016b.
I used the timesthree.c S-Function in minimal Simulink model (see attachment, remove zip ending)
mytest.slx.zip

Summary: both rtwsfcnfmi and grtfmi targets require the S-function source to be in the local directory, while for grt target it is enough to put the directory including the source file of the S-Function on the MATLAB path

This requirement/behaviour was documented in the PDF delivered with FMIKit 2.4.2., but I cannot find it in the current documentation.
It would be good to get rid of this requirement (at least for the grt-based target), or at least document it in the documentation that is delivered with FMI-Kit

  • grt : S-Function Source on path: works fine
  • grtfmi target: S-Function Source in local directory: works fine
  • grtfmi target: (S-Function source on path and directory listed in include directories: fails:
### Generating code into build folder: C:\home\FMIKit-Simulink-develop\tests\mytest_grt_fmi_rtw
The S-function 'mytest/S-Function' has the option SS_OPTION_WORKS_WITH_CODE_REUSE set but it does not have a 'timesthree.tlc' file. The system that it lives in will not be reused
Component:Simulink | Category:Blockwarning
### Invoking Target Language Compiler on mytest.rtw ### Using System Target File: C:\Users\cbt2si\Documents\MATLAB\Add-Ons\Apps\FMIKit - 6\code\grtfmi\grtfmi.tlc ### Loading TLC function libraries ### Initial pass through model to cache user defined code . ### Caching model source code ### Writing header file mytest.h ### Writing header file mytest_types.h ### Writing header file rtwtypes.h ### Writing header file multiword_types.h . ### Writing source file mytest.c ### Writing header file mytest_private.h ### Writing header file rtmodel.h ### Writing header file rt_nonfinite.h ### Writing source file rt_nonfinite.c ### Writing header file rt_defines.h . ### Writing header file rtGetInf.h ### Writing source file rtGetInf.c ### Writing header file rtGetNaN.h ### Writing source file rtGetNaN.c ### TLC code generation complete. ### Writing modelDescription.xml ### Creating project marker file: rtw_proj.tmw ### Running CMake generator -- Selecting Windows SDK version 10.0.10586.0 to target Windows 10.0.17763. -- The C compiler identification is MSVC 19.0.24213.1 -- The CXX compiler identification is MSVC 19.0.24213.1 -- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe -- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Detecting C compile features -- Detecting C compile features - done -- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe -- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done -- Configuring done -- Generating done -- Build files have been written to: C:/home/FMIKit-Simulink-develop/tests/mytest_grt_fmi_rtw ### Building FMU Microsoft (R) Build Engine version 14.0.25420.1 Copyright (C) Microsoft Corporation. All rights reserved. Build started 12.06.2019 14:59:23. Project "C:\home\FMIKit-Simulink-develop\tests\mytest_grt_fmi_rtw\ALL_BUILD.vcxproj" on node 1 (default targets). Project "C:\home\FMIKit-Simulink-develop\tests\mytest_grt_fmi_rtw\ALL_BUILD.vcxproj" (1) is building "C:\home\FMIKit-Simulink-develop\tests\mytest_grt_fmi_rtw\ZERO_CHECK.vcxproj" (2) on node 1 (default targets). PrepareForBuild: Creating directory "x64\Release\ZERO_CHECK\". Creating directory "x64\Release\ZERO_CHECK\ZERO_CHECK.tlog\". InitializeBuildStatus: Creating "x64\Release\ZERO_CHECK\ZERO_CHECK.tlog\unsuccessfulbuild" because "AlwaysCreate" was specified. CustomBuild: Checking Build System CMake does not need to re-run because C:/home/FMIKit-Simulink-develop/tests/mytest_grt_fmi_rtw/CMakeFiles/generate.stamp is up-to-date. FinalizeBuildStatus: Deleting file "x64\Release\ZERO_CHECK\ZERO_CHECK.tlog\unsuccessfulbuild". Touching "x64\Release\ZERO_CHECK\ZERO_CHECK.tlog\ZERO_CHECK.lastbuildstate". Done Building Project "C:\home\FMIKit-Simulink-develop\tests\mytest_grt_fmi_rtw\ZERO_CHECK.vcxproj" (default targets). Project "C:\home\FMIKit-Simulink-develop\tests\mytest_grt_fmi_rtw\ALL_BUILD.vcxproj" (1) is building "C:\home\FMIKit-Simulink-develop\tests\mytest_grt_fmi_rtw\mytest.vcxproj" (3) on node 1 (default targets). PrepareForBuild: Creating directory "mytest.dir\Release\". Creating directory "C:\home\FMIKit-Simulink-develop\tests\mytest_grt_fmi_rtw\Release\". Creating directory "mytest.dir\Release\mytest.tlog\". InitializeBuildStatus: Creating "mytest.dir\Release\mytest.tlog\unsuccessfulbuild" because "AlwaysCreate" was specified. CustomBuild: Building Custom Rule C:/Users/cbt2si/Documents/MATLAB/Add-Ons/Apps/FMIKit - 6/code/grtfmi/CMakeLists.txt CMake does not need to re-run because C:/home/FMIKit-Simulink-develop/tests/mytest_grt_fmi_rtw/CMakeFiles/generate.stamp is up-to-date. ClCompile: C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\x86_amd64\CL.exe /c /I"C:\Users\cbt2si\Documents\MATLAB\Add-Ons\Apps\FMIKit - 6\code\grtfmi" /I"C:\home\FMIKit-Simulink-develop\tests\mytest_grt_fmi_rtw" /I"C:\home\FMIKit-Simulink-develop\tests\mytest_grt_fmi_rtw\..\slprj\grtfmi\_sharedutils" /I"C:\home\FMIKit-Simulink-develop\tests\mytest_grt_fmi_rtw\..\slprj\grtfmi\sldemo_mdlref_counter_bus" /I"C:\Program Files\MATLAB\R2016b\extern\include" /I"C:\Program Files\MATLAB\R2016b\simulink\include" /I"C:\Program Files\MATLAB\R2016b\rtw\c\src" /I"C:\Program Files\MATLAB\R2016b\rtw\c\src\ext_mode\common" /nologo /W3 /WX- /Od /Ob2 /D WIN32 /D _WINDOWS /D NDEBUG /D _CRT_SECURE_NO_WARNINGS /D RT /D USE_RTMODEL /D "CMAKE_INTDIR=\"Release\"" /D mytest_EXPORTS /D _WINDLL /D _MBCS /Gm- /MT /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Fo"mytest.dir\Release\\" /Fd"mytest.dir\Release\vc140.pdb" /Gd /TC /errorReport:queue "C:\home\FMIKit-Simulink-develop\tests\mytest_grt_fmi_rtw\mytest.c" "C:\home\FMIKit-Simulink-develop\tests\mytest_grt_fmi_rtw\rtGetInf.c" "C:\home\FMIKit-Simulink-develop\tests\mytest_grt_fmi_rtw\rtGetNaN.c" "C:\home\FMIKit-Simulink-develop\tests\mytest_grt_fmi_rtw\rt_nonfinite.c" "C:\Users\cbt2si\Documents\MATLAB\Add-Ons\Apps\FMIKit - 6\code\grtfmi\fmi2Functions.c" mytest.c rtGetInf.c rtGetNaN.c rt_nonfinite.c fmi2Functions.c C:\Users\cbt2si\Documents\MATLAB\Add-Ons\Apps\FMIKit - 6\code\grtfmi\fmi2Functions.c(230): warning C4244: '=': conversion from 'const fmi2Real' to 'float', possible loss of data [C:\home\FMIKit-Simulink-develop\tests\mytest_grt_fmi_rtw\mytest.vcxproj] Generating Code... Link: C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\x86_amd64\link.exe /ERRORREPORT:QUEUE /OUT:"C:\home\FMIKit-Simulink-develop\tests\mytest_grt_fmi_rtw\Release\mytest.dll" /INCREMENTAL:NO /NOLOGO kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /PDB:"C:/home/FMIKit-Simulink-develop/tests/mytest_grt_fmi_rtw/Release/mytest.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:"C:/home/FMIKit-Simulink-develop/tests/mytest_grt_fmi_rtw/Release/mytest.lib" /MACHINE:X64 /machine:x64 /DLL mytest.dir\Release\mytest.obj mytest.dir\Release\rtGetInf.obj mytest.dir\Release\rtGetNaN.obj mytest.dir\Release\rt_nonfinite.obj mytest.dir\Release\fmi2Functions.obj Creating library C:/home/FMIKit-Simulink-develop/tests/mytest_grt_fmi_rtw/Release/mytest.lib and object C:/home/FMIKit-Simulink-develop/tests/mytest_grt_fmi_rtw/Release/mytest.exp mytest.obj : error LNK2019: unresolved external symbol timesthree referenced in function mytest [C:\home\FMIKit-Simulink-develop\tests\mytest_grt_fmi_rtw\mytest.vcxproj] C:\home\FMIKit-Simulink-develop\tests\mytest_grt_fmi_rtw\Release\mytest.dll : fatal error LNK1120: 1 unresolved externals [C:\home\FMIKit-Simulink-develop\tests\mytest_grt_fmi_rtw\mytest.vcxproj] Done Building Project "C:\home\FMIKit-Simulink-develop\tests\mytest_grt_fmi_rtw\mytest.vcxproj" (default targets) -- FAILED. Done Building Project "C:\home\FMIKit-Simulink-develop\tests\mytest_grt_fmi_rtw\ALL_BUILD.vcxproj" (default targets) -- FAILED. Build FAILED. "C:\home\FMIKit-Simulink-develop\tests\mytest_grt_fmi_rtw\ALL_BUILD.vcxproj" (default target) (1) -> "C:\home\FMIKit-Simulink-develop\tests\mytest_grt_fmi_rtw\mytest.vcxproj" (default target) (3) -> (ClCompile target) -> C:\Users\cbt2si\Documents\MATLAB\Add-Ons\Apps\FMIKit - 6\code\grtfmi\fmi2Functions.c(230): warning C4244: '=': conversion from 'const fmi2Real' to 'float', possible loss of data [C:\home\FMIKit-Simulink-develop\tests\mytest_grt_fmi_rtw\mytest.vcxproj] "C:\home\FMIKit-Simulink-develop\tests\mytest_grt_fmi_rtw\ALL_BUILD.vcxproj" (default target) (1) -> "C:\home\FMIKit-Simulink-develop\tests\mytest_grt_fmi_rtw\mytest.vcxproj" (default target) (3) -> (Link target) -> mytest.obj : error LNK2019: unresolved external symbol timesthree referenced in function mytest [C:\home\FMIKit-Simulink-develop\tests\mytest_grt_fmi_rtw\mytest.vcxproj] C:\home\FMIKit-Simulink-develop\tests\mytest_grt_fmi_rtw\Release\mytest.dll : fatal error LNK1120: 1 unresolved externals [C:\home\FMIKit-Simulink-develop\tests\mytest_grt_fmi_rtw\mytest.vcxproj] 1 Warning(s) 2 Error(s) Time Elapsed 00:00:01.90
The call to grtfmi_make_rtw_hook, during the after_make hook generated the following error: Failed to build FMU The build process will terminate as a result.
Caused by:
•	Failed to build FMU
  • twsfnctfmi target: source file of C-S-function locally present: works fine
  • rtwsfnctfmi: s-funcion source only on path: fails
### Generating code into build folder: C:\home\FMIKit-Simulink-develop\tests\mytest_sfcn_rtw_fmi
The S-function 'mytest/S-Function' has the option SS_OPTION_WORKS_WITH_CODE_REUSE set but it does not have a 'timesthree.tlc' file. The system that it lives in will not be reused
Component:Simulink | Category:Blockwarning
### Invoking Target Language Compiler on mytest.rtw ### Using System Target File: C:\Users\cbt2si\Documents\MATLAB\Add-Ons\Apps\FMIKit - 6\code\rtwsfcnfmi\tlc\rtwsfcnfmi.tlc ### Loading TLC function libraries Warning: Simulink Coder: Changing output file name to mytest_sf ### Initial pass through model to cache user defined code . ### Caching model source code ### Writing header file mytest_sf.h . ### Writing header file mytest_sf_types.h ### Writing header file rtwtypes.h ### Writing header file multiword_types.h ### Writing source file mytest_sf.c ### Writing header file mytest_sf_private.h ### Writing header file mytest_sid.h . ### Writing header file mytest_mid.h ### Writing header file rtGetNaN.h ### Writing source file rtGetNaN.c ### Writing header file rt_nonfinite.h ### Writing source file rt_nonfinite.c ### Writing header file rt_defines.h . ### Writing header file rtGetInf.h ### Writing source file rtGetInf.c ### TLC code generation complete. ### ### Creating model variable description for FMI: modelDescription.xml ### . ### Processing Template Makefile: C:\Users\cbt2si\Documents\MATLAB\Add-Ons\Apps\FMIKit - 6\code\rtwsfcnfmi\tlc\rtwsfcnfmi_vcx64.tmf ### mytest.mk which is generated from C:\Users\cbt2si\Documents\MATLAB\Add-Ons\Apps\FMIKit - 6\code\rtwsfcnfmi\tlc\rtwsfcnfmi_vcx64.tmf is up to date ### Building mytest: .\mytest.bat C:\home\FMIKit-Simulink-develop\tests\mytest_sfcn_rtw_fmi>call "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\VCVARSALL.BAT " amd64 Microsoft (R) Program Maintenance Utility Version 12.00.21005.1 Copyright (C) Microsoft Corporation. All rights reserved. ### Compiling mytest_sf.c C:\PROGRA~1\MATLAB\R2016b\bin\mex -c -win64 OPTIMFLAGS="/Od /Oy- /MD" -f "C:\Users\cbt2si\AppData\Roaming\MathWorks\MATLAB\R2016b\mex_C_win64.xml" mytest_sf.c Building with 'Microsoft Visual C++ 2013 Professional (C)'. MEX completed successfully. ### Compiling rtGetInf.c C:\PROGRA~1\MATLAB\R2016b\bin\mex -c -win64 OPTIMFLAGS="/Od /Oy- /MD" -f "C:\Users\cbt2si\AppData\Roaming\MathWorks\MATLAB\R2016b\mex_C_win64.xml" rtGetInf.c Building with 'Microsoft Visual C++ 2013 Professional (C)'. MEX completed successfully. ### Compiling rtGetNaN.c C:\PROGRA~1\MATLAB\R2016b\bin\mex -c -win64 OPTIMFLAGS="/Od /Oy- /MD" -f "C:\Users\cbt2si\AppData\Roaming\MathWorks\MATLAB\R2016b\mex_C_win64.xml" rtGetNaN.c Building with 'Microsoft Visual C++ 2013 Professional (C)'. MEX completed successfully. ### Linking ... C:\PROGRA~1\MATLAB\R2016b\sys\perl\win32\bin\perl C:\PROGRA~1\MATLAB\R2016b\rtw\c\tools\mkvc_lnk.pl mytest.lnk mytest_sf.obj rtGetInf.obj rtGetNaN.obj C:\PROGRA~1\MATLAB\R2016b\bin\mex -win64 OPTIMFLAGS="/Od /Oy- /MD" -f "C:\Users\cbt2si\AppData\Roaming\MathWorks\MATLAB\R2016b\mex_C_win64.xml" @mytest.lnk C:\PROGRA~1\MATLAB\R2016b\extern\lib\win64\microsoft\libut.lib C:\PROGRA~1\MATLAB\R2016b\extern\lib\win64\microsoft\libfixedpoint.lib -outdir .. Building with 'Microsoft Visual C++ 2013 Professional (C)'. MEX completed successfully. ### Created MEX-file mytest_sf.mexw64 ### ### Compiling FMI wrapper: C:\Users\cbt2si\Documents\MATLAB\Add-Ons\Apps\FMIKit - 6\code\rtwsfcnfmi\c\fmi2ModelFunctions.c cl /c /Zp8 /GR /W3 /EHs /DWIN64 /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=0 /nologo /MD /O2 /Oy- /DNDEBUG /DFIPXT_SHARED_MODULE /Drt_matrx_h /DRT_MALLOC "C:\Users\cbt2si\Documents\MATLAB\Add-Ons\Apps\FMIKit - 6\code\rtwsfcnfmi\c\fmi2ModelFunctions.c" fmi2ModelFunctions.c cl /c /Zp8 /GR /W3 /EHs /DWIN64 /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=0 /nologo /MD /O2 /Oy- /DNDEBUG /DFIPXT_SHARED_MODULE /Drt_matrx_h /DRT_MALLOC "C:\Users\cbt2si\Documents\MATLAB\Add-Ons\Apps\FMIKit - 6\code\rtwsfcnfmi\c\fmi2.c" fmi2.c cl /c /Zp8 /GR /W3 /EHs /DWIN64 /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=0 /nologo /MD /O2 /Oy- /DNDEBUG /DFIPXT_SHARED_MODULE /Drt_matrx_h /DRT_MALLOC "C:\Users\cbt2si\Documents\MATLAB\Add-Ons\Apps\FMIKit - 6\code\rtwsfcnfmi\c\rtPrintfNoOp_cpp.cpp" rtPrintfNoOp_cpp.cpp ### Compiling fixed-step solver: C:\PROGRA~1\MATLAB\R2016b\rtw\c\src\ode1.c cl /c /Zp8 /GR /W3 /EHs /DWIN64 /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=0 /nologo /MD /O2 /Oy- /DNDEBUG /DNRT /DRT_MALLOC /I"C:\PROGRA~1\MATLAB\R2016b\rtw\c\src\matrixmath" "C:\PROGRA~1\MATLAB\R2016b\rtw\c\src\ode1.c" ode1.c cl /c /Zp8 /GR /W3 /EHs /DWIN64 /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=0 /nologo /MD /O2 /Oy- /DNDEBUG /DNRT /DRT_MALLOC "C:\PROGRA~1\MATLAB\R2016b\rtw\c\src\rt_matrx.c" rt_matrx.c NMAKE : fatal error U1073: don't know how to make 'timesthree.dum' Stop. The make command returned an error of 2 'An_error_occurred_during_the_call_to_make' is not recognized as an internal or external command, operable program or batch file.
Error(s) encountered while building "mytest"

Enhanced readme file

It would be helpful if the readme file contained a bit more information, for example about what releases of MATLAB are supported and other pre-requisites.

Document CMake installation

On PCs without admin rights, one might not be able to install CMake.

Please document, that one can download the ZIP file instead of installer:
https://cmake.org/download
e.g. use e.g. cmake-3.14.5-win64-x64.zip

Which version is required?

Problem with FMIKit in Simulink Library browser

When in installing the alpha3 mlapp in ML/SL 2016b, I get the following error in the library browser:
image
and the FMIKit Block is not displayd.

When I click on the "Fix" I get
image
Then a modified version of the slx file is generated and stored
FMIKit_blocks.zip
Only then the FMIKit Block appears in the Simulink library browser,

mex64 compilation successfull but ...

After some adaptations to the CMakeLists.txt and build.bat bat file. i.e.:

  • adapt to available visual studio version:
    cmake -G "Visual Studio 12 2013 Win64" -DCMAKE_BUILD_TYPE=Release ..

  • change to MATLAB path to 2015b:
    set(MATLAB_DIR "C:/Program Files/MATLAB/R2015b" CACHE STRING "MATLAB install directory")

mex64 and compilation in general will succeed.
the succeding MATLAB call as:
matlab -nodisplay -nosplash -wait -r "matlab.apputil.package('FMIKit.prj'); exit()"
will return an error:

Error using matlab.apputil.package (line 50) Java exception occurred: com.mathworks.project.api.InvalidProjectException: File fmi1.c from Files included through analysis does not exist.

A second try, by running initialize_fmikit.m will return an error as well:
Warning: Invalid file or directory 'C:\FMIDS\FMIKit-Simulink\fmikit.jar'.

Therefore I wonder:

  • What are the toolchain dependencies to build the project?
  • What's wrong with our build process?
  • is there a reason for hard coded (Specific) MATLAB and Visual Studio Versions in the bat and cmake file?

Thanks in advanced!

Matlab R2016b FMU Export in ME and Co-simulation error

Hi @t-sommer

I've got the error shown in the figure below, along what the settings I'm using.

What's my mistake or its this a bug?

Thanks

Luigi

screenshot 2019-03-07 13 54 13

ver


MATLAB Version: 9.1.0.441655 (R2016b)

Operating System: Microsoft Windows 10 Enterprise Version 10.0 (Build 17763)
Java Version: Java 1.7.0_60-b19 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode

MATLAB Version 9.1 (R2016b)
Simulink Version 8.8 (R2016b)
Control System Toolbox Version 10.1 (R2016b)
Curve Fitting Toolbox Version 3.5.4 (R2016b)
DSP System Toolbox Version 9.3 (R2016b)
Database Toolbox Version 7.0 (R2016b)
Datafeed Toolbox Version 5.4 (R2016b)
Fuzzy Logic Toolbox Version 2.2.24 (R2016b)
Global Optimization Toolbox Version 3.4.1 (R2016b)
MATLAB Coder Version 3.2 (R2016b)
MATLAB Compiler Version 6.3 (R2016b)
MATLAB Compiler SDK Version 6.3 (R2016b)
MATLAB Report Generator Version 5.1 (R2016b)
Model Predictive Control Toolbox Version 5.2.1 (R2016b)
Model-Based Calibration Toolbox Version 5.2 (R2016b)
Neural Network Toolbox Version 9.1 (R2016b)
Optimization Toolbox Version 7.5 (R2016b)
Parallel Computing Toolbox Version 6.9 (R2016b)
Robust Control Toolbox Version 6.2 (R2016b)
Signal Processing Toolbox Version 7.3 (R2016b)
SimEvents Version 5.1 (R2016b)
Simscape Version 4.1 (R2016b)
Simscape Power Systems Version 6.6 (R2016b)
Simulink Coder Version 8.11 (R2016b)
Simulink Control Design Version 4.4 (R2016b)
Simulink Design Optimization Version 3.1 (R2016b)
Simulink Desktop Real-Time Version 5.3 (R2016b)
Simulink Real-Time Version 6.5 (R2016b)
Simulink Report Generator Version 5.1 (R2016b)
Stateflow Version 8.8 (R2016b)
Statistics and Machine Learning Toolbox Version 11.0 (R2016b)
Symbolic Math Toolbox Version 7.1 (R2016b)
System Identification Toolbox Version 9.5 (R2016b)
Trading Toolbox Version 3.1 (R2016b)
Wavelet Toolbox Version 4.17 (R2016b)

feature/grt-build-variables: Inports appear multiple times

In the feature/grt-build-variables all inports appear several times in the FMU.

<!-- Inputs --> <ScalarVariable name="In1" valueReference="3" causality="input"> <Real start="0"/> </ScalarVariable> <ScalarVariable name="In2[1]" valueReference="4" causality="input"> <Real start="0"/> </ScalarVariable> <ScalarVariable name="In2[2]" valueReference="5" causality="input"> <Real start="0"/> </ScalarVariable> <ScalarVariable name="In2[3]" valueReference="6" causality="input"> <Real start="0"/> </ScalarVariable> <ScalarVariable name="In1" valueReference="7" causality="input"> <Real start="0"/> </ScalarVariable> <ScalarVariable name="In2[1]" valueReference="8" causality="input"> <Real start="0"/> </ScalarVariable> <ScalarVariable name="In2[2]" valueReference="9" causality="input"> <Real start="0"/> </ScalarVariable> <ScalarVariable name="In2[3]" valueReference="10" causality="input"> <Real start="0"/> </ScalarVariable>

Make "Direct Input" the default for ME FMU import

Unexperienced users get wrong results especially in feedback loops, as delays are included if "direct inputs" is unchecked.
Additionally it would be good to document the behaviour of "Direct inputs" both for ME and CS FMUs

Wrong Version in modelDescription.xml

When creating a FMU with FMIKit 2.6.0 rtwsfcnfmi.tlc the entry in modelDescription is the following:

generationTool="Dassault Systemes FMI Kit for Simulink, ver. 2.5.0 (MATLAB 8.10 (R2016a) 10-Feb-2016)"

It should be 2.6.0.

Expose selected parameters from black box FMU

I want to expose some (but not all) parameters so they are tunable by the user of the FMU.

There is currently a way to do this. One can set the "Default parameter behaviour" under "Optimization/Signals and Parameters" to "Inlined", and then use the "Configure..." button to make selected parameters tunable (set to "ExportedGlobal"). Then, when "Generate black-box FMU" is not enabled, only the selected parameters are visible in the generated FMU.

However, there are some side-effects:

  1. The internal states of the integrators and their derivatives are now named after the block name, and not "concealed", leaking information about the internal structure of the FMU.
  2. As the non-visible parameters are now inlined, the generated code is different than when not inlining them. We have a model that crashes, when the parameters are inlined.

It would be great to be able to build a black box FMU and then have a list of parameters that are made visible, without affecting the actual generated code.

Where can I download previous releases (FMI Kit 2.4)?

FMI Kit 2.4 is the latest release of FMI Kit that ships with Dymola and is typically installed to C:/Program Files/Dymola 2019 FD01/Mfiles/FMIKit_for_Simulink.zip .

To install it without Dymola download and extract FMIKit-2.4.2-fixpack1.zip.

In the MATLAB command windows type:

addpath 'C:/path/to/FMIKit_for_Simulink'
FMIKit.initialize()

Supported MATLAB versions: R2010a - R2017b

On Windows FMI Kit 2.4 requires the Visual C++ Redistributable for Visual Studio 2015 that automatically installed with Dymola.

Set solver tolerances of imported CS FMUs

It would be beneficial to set the solver tolerances for imported CS FMUs in the mask of an FMI-Kit FMU-Block.

For Dymola exported CS-FMUs: This would be possible through the function fmi2SetupExperiment for dymoaSolver exported FMU’s since Dymola 2019 and has always been available for cvode exported fmu’s.

Make description editable

The description attribute of the fmiModelDescription in the modelDescription.xml is set to "S-function with FMI generated from Simulink model xxxx" as standard.
Making this editable (same way as the author attribute) would allow to give a meaningful description to the users of the FMU.

Export FMUs including S-Functions with variable step size

We have a use case in which we build a Simulink model that includes an S-function. This S-function specifies a variable step size with which the Simulink model is simulated. The step size is read with the function mdlGetTimeOfNextVarHit.

An FMU for ModelExchange is to be exported via the rtwsfcnfmi target. However, this export fails because no S-Functions with variable step size are supported.

'sfcndemo_vsfunc/Continuous-Time Variable Step by S-function' has a variable sample time. Variable sample times are not supported by the S-Function Target.

The export for CoSimulation fails due to the VariableStep Solver. The same is true for the grtfmi target.

In the appendix a Simulink model is attached, which shows the problem exemplarily. The model contains an S-function, which has a sine function as input and outputs it again. The sampling rate at which the S-function operates is specified at the second input. The S-function then determines the step size of the Simulink VariableStep Solver. (Note in the real application, the step size is completely defined within the S-function.)

VarSampleTime_TimeOfNextVarHit.zip

Would it be conceivable for future releases that FMUs can be exported from such models that execute a possible S-function function mdlGetTimeOfNextVarHit? In this way, internal step sizes could be read and made available to the master. This could also be an interesting implementation of the clocks from FMI 3.0.

Automate initialization of FMIKit App

With the new app mechanism (which in general works great), I have after startup of MATLAB once to klick on the app to initialize it. With the old installation method I could automatize this in the startup.m file. Is this also possible with the app?
Is the installation and initialization documented somewhere (cannot find it in the documentation folder)

Use DefaultExperiment.stepSize as sample time

If an FMU has a preferred default step size (e.g. the fixed step size of an embedded solver)

<DefaultExperiment stepSize="0.01"/>

it should be used as the default for the block's sample time instead of -1 (inherited), especially if the FMU has no inputs.

Document automatic initialization of FMI-Kit

It would be good to add something like the following text in the documentation:

To run the FMI Kit app automatically when you start MATLAB you can add the following lines to your startup.m file (as you, @t-sommer, have provided to me. Thanks!):

apps = matlab.apputil.getInstalledAppInfo();

for i = 1:numel(apps)
    app = apps(i);
    if strcmp(app.name, 'FMI Kit')
        matlab.apputil.run(app.id);
        return
    end

end

Provide possibility to rename Ports/Parameters in the modelDescription.xml

Currently the ports and parameters in the modelDescription.xml are named after the c-representation of the port/parameter name.

It would be useful to have a possibility to change the names in the modelDescription, e.g. to order them in a structure/tree for orientation, use characters not allowed in C (e.g. ':'), or fix the indexing of arrays (0-based vs. 1-based).

I see two approaches to this:

  1. Offer a way for the user to enter the mapping in the FMU generation options (as for the Visible parameters)
  2. Offer a way for the user to provide a standardized callback functions with gets called with every port/parameter and returns the name as it should show up in the modelDescription.

RTWSFCN FMU crashes on fmi2Reset()

Hi,

I'm using FMI Toolkit version 2.4. In general it works well but I get reproducible crashes when calling fmi2Reset. Sometimes the fmi2Reset function crashes directly, sometimes the following call to fmi2DoStep crashes.

I downloaded & built today's Master-Branch (23.05.19) and compiled the FMU with that version. Still the same problem.

I'm compiling a FMI2, CoSimulation FMU on win64.

I'm working on my own Co-Simulation master and I'm not ruling out the possibility that there is a bug in my code. However, I think that's rather unlikely because FMUs generated by other tools work well.

Unfortunately my use-case requires the reset to work, so I would appreciate if you could take at looks at this. If you could explain how I can generate the .dll with debug information included, I might be able to track down the problem for you.

Best Regards
Dirk

Set unzip directory path

In some cases I get that unzipping is not possible when trying to load an FMU.
One example is: If you have a Simulink model open with an FMU imported, and create a new Simulink model where you want to import the same FMU.
Would it be possible to make the unzip-directory configurable in the "load FMU" mask=

Support for get_param, set_param MATLAB Commands for FMIkit Block

Would it be possible to support get_param and set_param commands for an FMI-Kit Block in a Simulink model?

Use case: Re-use toolboxes in Matlab that use these commands e.g. for parameter sweeps for "normal" Simulink blocks.

(Current work-around: use a MATLAB workspace variable as a parameter for the FMU in the FMI-Kit mask and change this workspace variable)

Problem with simulating an FMU containing an FMU

The attached FMU (remove ending .zip) was create by importing a simple ME 2.0 FMU (Simulink model: input is integrated) generate from Simulink with FMI-Kit 2.4.2 to SimulationX 4.0 and re-exported as a CS-FMU. integrator_cs.fmu.zip
I can be run by the FMU Compliance Checker and fmpy, but not with FMI-Kit 2.4.2 within ML/SL 2.4.2; the following error is produced:

ERROR: Error: Simulation stopped!
The FMU "C:/home/fmi_test_ME_CS/integrator_cs/integrator_sf.fmu" could not be found.
CVODE Error: Initialization of model failed.
Error during initialization of FMU.
Failed to enter initialization mode
Failed to enter initialization mode. The FMU crashed (exception code: UNKOWN_EXEPTION_CODE).
Error in 'asdfuntitled/FMU' while executing C MEX S-function 'sfun_fmurun', (mdlStart), at time 0.0.
Caused by:
Unexpected Standard exception from MEX file.
What() is:Failed to enter initialization mode. The FMU crashed (exception code: UNKOWN_EXEPTION_CODE).

Add a variable step solver to RTWSFCN export

For models with changing dynamics or stiffness, it would be great to export CS FMUs from Simulink with a variable step solver inside. As this is not possible currently for Simulink solvers, it would be good to have e.g. a CVODE solver as an alternative.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.