Coupling AutoFOCUS3 with other Tools using Co-Simulation

The following sections provide introduction and discuss co-simulation functionality in detail. The inverted pendulum example illustrates the concepts introduced in this section with a co-simulation comprising three tools.

Introduction

AF3 alone cannot satisfy all the needs of system development. Other tools are often needed, e.g., for modeling continuous behavior (for the environment or for analog parts of a system), for interoperability with legacy tools, or simply for using non-AF3 features in combination with AF3 (e.g., visualization).

In such cases, AF3 has co-simulation capabilities which allows to use AF3 simulation with other tools in a synchronous manner. AF3 offers co-simulation functionality in the following two ways:

Co-simulation using FMI (Functional Mockup Interface)

AutoFOCUS3 supports currently supports FMU 2.0 export on the following platforms that meet the listed prerequisites:

Note:

Exporting component architecture as an FMU

FMI export can be done at the level of both component architecture and component. To export anyone of them to the FMU, right-click on it in the model navigator and select "Export to FMU2.0":

AF3 works with logical time, however co-simulation is generally achieved with tools modeling reality and therefore working with real time. Therefore, the FMI standard requires that AF3 notion of time is translated to real time. For that, a function with the name 'SAMPLING_TIME()' can be defined in the data dictionary and used inside the AF3 component's behavior. If the SAMPLING_TIME() is not defined, the user will be asked to provide the required frequency (equivalent to sampling time) for the component:

You will then be asked where to store the generated FMU. Once this is done, a message confirming that generation was successful appears and you can find the generated FMU in the directory that you selected. You can then make use of the numerous co-simulation tools along with AF3 itself, supporting FMI to co-simulate the generated AF3 model's FMU.

Importing FMUs and their co-simulation

The FMU's from other tools can be imported in AF3 for the co-simulation together with the AF3's own behavior components.

Creating an FMU Specification

To use the co-simulation feature, you have to create the FMU Specification inside the component. Only the entire component architecture can be simulated having FMUs or other AF3 behaviors inside its subcomponents.

To create an FMU specification for a component, open the context menu of the component and select "FMU Specification".

The FMU Specification can also be dragged and dropped from the Model Elements window.

The FMU Specification consists of only one section available by double clicking the FMU Specification icon or its component. It has a field with:

Different AF3 component and the FMUs are connected with each other through the input and output ports. The outputs that has to be displayed as a result of the co-simulation are assigned to the Component Architecture's root component.

Running a Co-simulation

To start the co-simulation, right-click on the Component Architecture element in the Model Navigator and select "Run Co-simulator". Remember that this option will only be available, if there is at least two atomic component and one of them has an FMU Specification behavior.

If there would be no error in the model, then Co-simulation Configuration window will open containing two sections:

Then press OK to proceed or cancel to stop the co-simulator.

OK will execute the co-simulation of the components and at last the window with graph having the results will pop up.