Using FMUs on the Canvas
Once an FMU component is uploaded and parsed successfully, you can drag it onto the canvas like any MTK component. This article covers the port rules of FMU nodes, parameter settings, how to connect them to MTK components, and how to run an FMU + MTK hybrid simulation.
Dragging an FMU from the Component Tree
Open the model editor and expand User Components → category in the component tree on the left to find the target FMU component (FMU components from the Official source are under the Official Components node). After you drop it on the canvas, the system creates a node marked with the FMU badge and automatically creates ports from the FMU's input / output variables.

FMU Nodes and Ports
FMU nodes use a dedicated SVG icon, usually with these markers:
- An FMU text badge
- A one-line badge with the FMI version and mode (e.g.
FMI2 · CS,FMI3 · ME)
Ports follow the causal signal convention:
| Port type | Position | Meaning | Connection rule |
|---|---|---|---|
| Input | Left side of the node | The FMU's input variables |
Receives external signals only |
| Output | Right side of the node | The FMU's output variables |
Sends signals out only |

Important: The Input / Output of an FMU are causal signal ports, not the acausal physical ports of MTK. When connecting to MTK components, use equation assignment
~, notconnect().connect()applies only to acausal physical-domain ports such as electrical pins and mechanical flanges.
Parameter Settings
Select an FMU node on the canvas and the properties panel on the right lists the FMU's parameter and calculatedParameter variables:
- Name, type (currently always real
Float64), default value, unit, description - Changes are saved to the node data immediately

Parameter changes are reflected in the Code View in sync. The FMU component instance and its user parameters are generated by the platform, in the form:
# FMU load preamble (asset lifecycle is managed by the platform)
fmu_4 = loadFMU(@comodel_asset_path("fmu", 4; sha256 = "…"); type = :CS)
# FMU component instance (CS mode always carries a communication step size and a re-initialization algorithm)
@named spring = ModelingToolkit.FMIComponent(
Val(2);
fmu = fmu_4,
type = :CS,
communication_step_size = 0.001,
reinitializealg = BrownFullBasicInit(),
)
# FMU user parameters are not passed as constructor kwargs (FMIComponent rejects them);
# they are injected at simulation start via runtime data variables:
__COMODEL_FMU_INITS = Pair{String,Float64}[
"spring.mass__m" => 2.0, # modified parameter
"spring.spring__c" => 15.0,
]
Connection Rules and Signal Conversion
Basic Rules
- An Input port can only connect to another component's Output port.
- An Output port can only connect to another component's Input port.
- Two Input ports or two Output ports cannot be connected directly.
- Only
Real-typed ports participate in graphical connections;Boolean,Integer, andStringtypes do not.
Connecting to Acausal Physical Ports
To bring an FMU signal into a physical domain such as electrical or mechanical, route it through Blocks signal components (e.g. Constant, Gain, RealExpression) instead of connecting directly.
Port Mapping Example
Suppose a spring-mass FMU has one input extForce and two outputs mass.s and mass.v; when mixed with MTK components, the code looks roughly like this:
using ModelingToolkit
using ModelingToolkit: t_nounits as t, D_nounits as D
using ModelingToolkitStandardLibrary
using FMI: loadFMU
using OrdinaryDiffEqCore: BrownFullBasicInit
# Load the FMU (the asset path is emitted by the platform as @comodel_asset_path)
fmu_4 = loadFMU(@comodel_asset_path("fmu", 4; sha256 = "…"); type = :CS)
# Instantiate the FMU component
@named bouncingball1d_cs1 = ModelingToolkit.FMIComponent(
Val(2);
fmu = fmu_4,
type = :CS,
communication_step_size = 0.001,
reinitializealg = BrownFullBasicInit(),
)
# Build the top-level system
@named FMU_Test_01 = System(
Equation[],
t;
systems = [bouncingball1d_cs1],
name = :FMU_Test_01,
)
sys = mtkcompile(FMU_Test_01)
In practice, CoModel generates this code automatically from the canvas connections; you never write it by hand.
Running a Hybrid Simulation
After the FMU + MTK hybrid model is saved, switch to the Simulation panel:
- Configure the Duration, solver, step size, and other settings.
- Click Run Simulation.
- The backend loads the FMU, builds the MTK system, compiles, solves, and extracts the FMU variable series.
- When the simulation ends—successfully or not—the system calls
unloadFMU(fmu)to release memory and clean up temporary files.
In the results, FMU output variables and state variables appear in the result curves together with the MTK variables and can be selected directly.

Variable Naming and Result Extraction
FMU variable names are transformed once in each of two stages, and different places use different forms of the name:
1. Parse time: . → __. Hierarchical names separated by . in the FMU are converted to __ (double underscore, per MTK naming rules) when the component definition is generated. This is the form used by canvas ports, the parameters panel, and generated code:
| FMU variable name | Name in the component definition |
|---|---|
mass.s |
mass__s |
spring.c |
spring__c |
damper.d |
damper__d |
2. Compile time: instance scope joined by ₊. After mtkcompile flattens the system, the top-level system name no longer appears in variable names; the results panel shows variables as instanceName₊variableName(t) (₊ is the MTK nesting separator), for example:
bouncingball1d_cs1₊mass__s(t)
When accessing through the system object step by step in generated code or the REPL, use . instead:
sys.bouncingball1d_cs1.mass__s
Notes
- FMU file management (upload, metadata editing, deletion) is restricted to the uploader. FMU components with the User source are invisible to other users; FMU components whose source an administrator has set to Official are visible to all users (read-only use, under the Official Components tree).
- Make sure no model references an FMU before deleting it, otherwise deletion is blocked; you can check reference details in advance with the Usage button on the FMU management page.
- If FMU simulation fails with "cannot load .so" or "instance already exists", check that the FMU contains Linux x86_64 binaries, or try re-uploading it.
Next Steps
- To upload FMUs, read FMU Upload & Component Library.
- For how the FMI version and the CS/ME mode are chosen, read FMI Modes & Compatibility.