Using an FMU in Konjugate
An FMU (Functional Mock-up Unit) is a model packaged in a standard form, so that a tool other than the one that made it can run it. The standard is called FMI. In Konjugate an FMU becomes a node: a box with the model's inputs on one side and its outputs on the other, which you connect to the rest of your model.
This page covers everything from adding an FMU to running it, keeping it with your project and replacing it. For what is and is not supported, start at "FMI and FMUs in Konjugate".
FMUs run in the desktop app for macOS, Windows and Linux. Konjugate Web does not run them.
What you need
- An
.fmufile for Co-Simulation, in FMI 2.0 or FMI 3.0. - A binary inside it for your computer, or its C source code and a C compiler. See "FMUs from source and troubleshooting".
The examples below use PidController.fmu, a room temperature controller made in OpenModelica. It ships with our examples, in the pidController folder.
Only add FMUs from people you trust. An FMU contains compiled code, and running it is like running a downloaded program.
Add the FMU to your model
Open Add (the + button) and choose FMU…, then pick the file.

You can also drop an .fmu file onto the canvas, and the node lands where you drop it. FMUs you have added before are listed under FMU…, ready to add again. These are the only ways in: Extensions installs add-ons and plugins, not FMUs.

The new node is built from the FMU's own description:
- Each output becomes a state of the node, with its name, unit and start value. The FMU sets it.
- Each input and parameter is listed, starting at the FMU's own value. The node runs without any wiring.
Read the node's card

Under the FMU's name, the card says which binary runs on your computer, which parameters are set only when a run starts, which values are converted and which variables are not connected. About this FMU shows the FMI version, the tool that generated it, its description, the platforms it carries, the run it suggests and whether it can save its state.
That last line matters. An FMU that cannot save its state cannot be used with checkpoints, forks or rewinding.
Connect inputs and parameters
Every input and parameter row offers the same choices:
| Choice | What happens |
|---|---|
| The FMU's own start value | The FMU keeps the value it was made with. |
| A value of its own | Konjugate sets your number once, when the run starts. |
| A shared parameter | The value follows a parameter shared across the model. |
| A state | The input reads a state of this node or of any other node. |
A unit that differs from the input's own is pointed out on the row. Konjugate does not convert it.

On the canvas the inputs are listed in the order their sources appear on screen, so the arrows do not cross. The node card keeps the FMU's own order.
You can also connect on the canvas:
- Drag from an input terminal to a node, a state of a node or another FMU's output.
- Drag from an output terminal to a node's Update state, or to a component's input port. This creates a one-way relationship that sets the value.
An output cannot add to a Rate state, or set an Update that something else already sets. Konjugate says why when you try.
One step late, by design
Every node reads the others as they were at the start of each step. An FMU is no exception, so a connection between two nodes is one step late. This is why a loop of FMUs can always run without being solved iteratively. If the delay matters in your model, use a smaller step.
Choose the step
An FMU takes one step of its own for each substep of its node: the global step divided by the node's substeps.
Some FMUs work with a fixed internal step and are exact only when yours is a whole number of those. Some refuse any other step and others approximate. The Run dialog warns you when your step does not fit an FMU that declares its step, and offers one that does.

When an FMU suggests a stop time and step, the dialog offers them under Run until simulation time with a Use button.
Run and read the results
Press Run and Start. The FMU's outputs are ordinary states, so everything in exploring results applies to them.

How Konjugate runs an FMU:
- It is initialised at the start of the run with its inputs as they are then. Its outputs at that moment are the first sample.
- Inputs are set before every step. A tunable parameter is set again only when its value changes.
- A fixed parameter is set once. If what it reads changes during the run, the run stops and names the parameter.
- Whole-number inputs take the nearest whole number and a Boolean input is true for anything other than 0.
- Text, binary and clock variables and arrays are not connected. The FMU keeps its own values for them.
- The FMU handles its own events inside each step. If it asks to end the simulation, its outputs keep their last values and the rest of your model carries on.
When a run stops
When an FMU refuses something, Konjugate shows why: which node, what was refused, what the FMU itself said and the value involved.

Common causes and fixes are listed in "FMUs from source and troubleshooting".
Keep the FMU with your project
By default a project keeps a copy of each FMU inside its own file, so it opens and runs on another computer. When you open such a project, any FMU your computer lacks is added to your library and the status line says so.
An FMU over 16 MB is linked instead: the project refers to the copy in your library, and anyone else running it needs the same FMU. The card switches between the two with Keep it in the project and Link to the library instead.
The project keeps the file exactly as it came, including only the binaries it already had.
Use a newer version
Replace FMU… on the card puts another FMU in the node's place, such as a newer export. The node keeps its name, its states and what each input reads, for the names the two FMUs share.
If you add a file that has the same internal identifier as one in your library but different contents, Konjugate keeps both, numbers the new one as a later version and says so. It never runs an old binary in place of your new file.
Switch off or remove
An FMU is switched off the same way as any node, with Disable node. A switched-off node is not run, so a project still works on a computer that lacks that FMU.
Settings › Providers lists the FMUs in your library, with the open model that uses each one.

Deleting a node does not free its FMU straight away. While Undo or Redo can still bring the node back, the list says so and offers no Remove button. Close that project first. Removing an FMU never strips it out of a project file that already keeps it.
Limits
- Co-Simulation only. Model Exchange and Scheduled Execution FMUs are not supported, nor is FMI 1.0.
- A model with an FMU node in it cannot yet be exported as code or as an FMU.
- An FMU that allows only one instance can be used by one node at a time.
- An FMU that needs its original tool running beside it cannot run in Konjugate.
Try it yourself
The tutorial Bring in a controller from another tool, inside the app, walks through this with the controller above. See "Tutorials".
Follow Konjugate on LinkedIn for updates, or subscribe via RSS.
Comments
Post a Comment