项目作者: modelica

项目描述 :
Functional Mock-up Units for development, testing and debugging
高级语言: C
项目地址: git://github.com/modelica/Reference-FMUs.git
创建时间: 2020-01-13T14:56:46Z
项目社区:https://github.com/modelica/Reference-FMUs

开源协议:Other

下载


Reference FMUs

A set of hand-coded FMUs for development, testing and debugging of the Functional Mock-up Interface.

Use the fmusim executable to simulate an FMU:

  1. > fmusim --help
  2. Usage: fmusim [OPTION]... [FMU]
  3. Simulate a Functional Mock-up Unit and write the output to result.csv.
  4. --help display this help and exit
  5. --interface-type [me|cs] the interface type to use
  6. --tolerance [TOLERANCE] relative tolerance
  7. --start-time [VALUE] start time
  8. --stop-time [VALUE] stop time
  9. --output-interval [VALUE] set the output interval
  10. --start-value [name] [value] set a start value
  11. --output-variable [name] record a specific variable
  12. --input-file [FILE] read input from a CSV file
  13. --output-file [FILE] write output to a CSV file
  14. --log-fmi-calls log FMI calls
  15. --fmi-log-file [FILE] set the FMI log file
  16. --solver [euler|cvode] the solver to use
  17. --early-return-allowed allow early return
  18. --event-mode-used use event mode
  19. --record-intermediate-values record outputs in intermediate update
  20. --initial-fmu-state-file [FILE] file to read the serialized FMU state
  21. --final-fmu-state-file [FILE] file to save the serialized FMU state
  22. Example:
  23. fmusim BouncingBall.fmu simulate with the default settings

You can download the pre-built Reference FMUs and fmusim executables from releases.

CSV file structure

fmusim uses CSV (comma separated values) files with the following structure as input and output format.

  • The file must be UTF-8 encoded.
  • The first line contains the names of the columns.
  • Each column name must match a variable name of the respective FMU.
  • Names that contain commas (,) must be surrounded by double quotes (").
  • The first column is the independent variable.
  • The values of the first column must be monotonically increasing.
  • Every line is terminated by a newline character (\n).
  • Every column is separated by a comma (,).
  • Every line must have the same number of columns.
  • The values must be stored in the same format as the start values of the respective variables in the modelDescription.xml.
  • String and Binary variables can only be scalars or arrays with only one element.
  • String values must be surrounded by double quotes (").

Example:

  1. <ModelVariables>
  2. <Float64 name="time" causality="independent"></Float64>
  3. <Float64 name="Float64 array">
  4. <Dimension valueReference="2"></Dimension>
  5. </Float64>
  6. <Boolean name="Boolean array">
  7. <Dimension valueReference="4"></Dimension>
  8. </Boolean>
  9. <Binary name="Binary scalar"></Binary>
  10. </ModelVariables>
  1. time,"Float64 array","Boolean array","Binary scalar"
  2. 0,1e-2 -1,0 false 1 true,666f6f
  3. 0.1,0.02 -2,1 false 0 true,aa6f6f
  4. 0.5,0.03 -3,1 true 0 false,66bb6f

Repository structure

<model>

  • config.h - model specific types and definitions
  • FMI{1CS|1ME|2|3}.xml - model descriptions
  • model.c - implementation of the model

include

  • fmi{|2|3}Functions.h - FMI header files
  • model.h - generic model interface
  • cosimulation.h - generic co-simulation interface

src

  • fmi{1|2|3}Functions.c - FMI implementations
  • cosimulation.c - generic co-simulation

examples

  • *.c - various FMI 3.0 import examples
  • Examples.cmake - CMake configuration for the example projects

fmusim

  • sources of the fmusim executable

Build the FMUs

To build the FMUs you need CMake and a supported build tool e.g. Visual Studio ≥ 2013 , Xcode or make:

  • download or clone the repository

  • open the CMakeGUI

  • click Browse Source... and select the cloned or downloaded and extracted repository (that contains CMakeLists.txt)

  • click Browse Build... and select the folder where you want build the FMUs

  • click Configure and select the generator for your IDE / build tool

  • select the FMI_VERSION you want to build and optionally the FMI_TYPE (only for FMI 1.0)

  • click Generate to generate the project files

  • click Open Project or open the project in your build tool

  • build the project

The FMUs will be in the dist folder inside the selected build folder.

Building fmusim

To build the fmusim executable, run the build/build_*.py <platform> Python scripts (where <platform> is the platform to build for, e.g. x86_64-windows) and enable WITH_FMUSIM before generating the CMake project.

License and attribution

Copyright © 2024, Modelica Association Project “FMI”.
All rights reserved.
The code is released under the 2-Clause BSD License.

The Reference FMUs are a fork of the Test FMUs by Dassault Systèmes, which are a fork of the FMU SDK by QTronic, both released under the 2-Clause BSD License.