Skip to content

modelica/fmi-import-export-tutorial-2025

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FMI-tutorial-logo

FMI Implementation tutorial

This is the repository for the tutorial "Exporting and importing an FMU using C code" presented at the Modelica and FMI Conference 2025.

Target Audience

Developers who want to import or export models as FMUs or couple their tool to other tools using FMI.

Before we start

  • install uv
  • install Visual Studio or your favorite IDE that's supported by CMake
  • clone this repository recursively git clone --recursive https://github.com/modelica/fmi-import-export-tutorial-2025.git

Anatomy of an FMU

Model Description

  • meta information
  • interface types
  • variables, causality, variability
  • model structure

Directory Structure

  • documentation
  • resources
  • binaries
  • source code

Sources

  • FMU structure
  • schema
  • headers
  • resources: FMI Spec, FMI Implementers Guide

Implement an FMU

  • generate scaffolding with FMPy
  • compile & run with FMPy
  • set up a CMake project
  • run FMU with fmusim
    • log FMI calls
    • provide input
    • save output
  • debug
    • attach a debugger to FMPy
    • debug with fmusim

Import an FMU

The hard way

  • read model description
  • load shared library
  • load symbols
  • call functions

Challenges:

  • extract the FMU
  • read & validate model description
  • validate structured variable names
  • check return codes
  • log messages
  • log API calls

Use Reference FMUs Framework

  • clone repo
  • create a CMake project
  • get inspiration from Reference FMUs examples and fmusim

Tips & Tricks

  • debug import and export with Visual Studio

About

Learn to how to import and export FMUs from scratch

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published