Main Content

Use Multi-Instance FMU for Simultaneous Simulations

This example demonstrates how to generate and simulate an Functional Mock Up Unit (FMU) compatible with multi-instantiation in Simulink®. You can export Simulink models with fixed-step solvers to standalone FMUs, which can be reused in multiple instances in Simulink. This enables the FMU to be used within For Each Subsystems in Simulink for simultaneous simulations.

In the first section of this example, a multi-instantiable FMU is generated from a Simulink model. In the second section, this FMU is imported back to Simulink and used within a For Each subsystem for simultaneous simulations with different input signals.

Generate Multi-Instance FMU

Open the suspensionModel_halfCar model. This is a simplified mathematical model of a vehicle's front and rear suspension system which can be used to study it's ride characteristics. The two inputs to this model are the pitch moment induced due to the vehicle's acceleration and the change in the road height that it travels on. For more information about this model, see Automotive Suspension.

suspension_model = 'suspensionModel_halfCar';
suspensionModel_data;
open_system(suspension_model);

Use the function with supportMultiInstance argument set to on to export this model as an FMU compatible with multi-instantiation.

exportToFMU(suspension_model,'FMUType','CS','FMIVersion','3.0','SupportMultiInstance','on');

You can also use the FMU Export dialog box to generate the FMU. In to the Simulation tab on the Simulink toolstrip, click drop-down button for Save. Select Standalone FMU.... to open the FMU Export dialog box. Open the Advanced tab within the dialog box and select the Support multiple instantiation per process check box. Click Create to generate the FMU.

In the generated FMU, the canBeInstantiatedOnlyOncePerProcess flag in the modelDescription.xml file is set to false.

Import and Simulate FMU in a For Each Subsystem

Open the suspension_simulation model that imports the FMU into Simulink and implements it within a For Each Subsystem. The suspension model is simultaneously given three different road profiles as input. You can use For Each subsystem to perform simultaneous simulations for various FMU inputs or parameters. For more information about For Each Subsystem, see Repeat an Algorithm Using a For-Each Subsystem

suspension_model_sim = 'suspension_simulation.slx';
open_system(suspension_model_sim);

Simulate the model and observe the system response for the three different road profiles.

sim(suspension_model_sim);
open_system('suspension_simulation/Scope');

See Also

exportToFMU

Topics