Dymola provides unique support for real-time simulation to support hardware-in-the-loop (HiL) and driver-in-the-loop (DiL) applications through the use of symbolic manipulation to make simulation more efficient. For example, it is possible to run full MultiBody vehicle dynamics models in real-time as part of a driving simulator with the physics model running at 1kHz.
A wide variety of HiL platforms are supported through FMI, Simulink or by the source code export option. A number of HiL platforms, including those from dSPACE and Concurrent support the FMI standard which means Dymola models can be compiled and directly imported into these tools. For many other systems, Simulink is used to provide support for the HiL platform. In these cases, the Dymola model is compiled as an s-function to run in Simulink and then Simulink Coder is used to download the model to the target system.
In addition Dymola has a number of additional features that are targeted at improving real-time performance. These include mode handling, event detection and mixed-mode and inline integration.
Dymola supports HIL simulation using dSpace, xPC and McLaren Electronics vTag platforms. Other platforms can be supported using the C-code export feature.
Mixed-mode and inline integration
Mathematical models often contain both fast and slow dynamics which can lead to stiff systems. Use of explicit methods to solve these types of systems demand step sizes that are much lower than the given real-time step size. Implicit methods allow larger step-sizes at the cost of solving a non-linear set of equations at each time step. Dymola uses a new approach called mixed-mode integration that takes a middle course. The system is split up into fast and slow states. Only the fast states are discretised implicitly.
To further increase the simulation speed, Dymola supports inline integration. The discretisation formulas are inserted (in-line) into the problem and Dymola’s symbolic engine is applied to the resulting equations. Speed-up factors from about 4-16 have been recorded for applications including a diesel engine and an industrial robot.
Mode Handling
The mathematical model of an automatic gearbox, for example, is a mixed system of boolean equations and differential-algebraic equations with hundreds of unknown variables. There are no general-purpose solvers for such a problem and although DAE solvers could be used to solve the continuous part they are too slow. The traditional approach has been to manually manipulate the model equations for each mode of operation. Dymola is able to do this automatically and generates different sets of code for each of the different operating conditions (or modes).
Multi-threading and Parallelisation of models
Dymola includes support for multi-threading models to fully take advantage of multi-core systems. There are various different options for enabling this within Dymola including a fully automated approach that determines how to split the model into multiple threads based on the model equations. There are also approaches that allow the user to control how and where the model is partitioned into separate threads.
Dymola utilitses OpenMP to implement multi-threading in the generated c-code. Therefore, if the compiler for your HiL system supports this you should be able to use the same capability for real-time simulation.