FMU Cosimulation using imported variable-step solver
11 views (last 30 days)
Show older comments
Federico Toso
on 17 Jan 2024
Commented: Federico Toso
on 26 Jan 2024
I have a model in Dymola which runs properly (in terms of speed & accuracy) if I use a local variable-step solver.
I imported it in Simulink via FMU, together with related Dymola local solver settings, since I would like to run the model in Simulink in "Cosimulation mode".
However, I have the problem that I must specify the communication stepsize between the FMU and Simulink, which is not trivial since my original solver uses a variable stepsize.
I tried with several values of communication stepsize; but even with relatively high values, the simulation is definetely much slower than in the original Dymola framework. I suspect the problem is not the value itself, but the fact that the FMU solver has a variable stepsize, while the communication stepsize must be fixed.
Of course I could change the settings of the original Dymola solver and use a fixed step, but then I would lose all the advantages of the variable- step solver.
So my general question is: Is there a way to do FMU Cosimulation in Simulink importing an external variable-step solver, without degrading the performance because of the fixed communication stepsize?
If not, is there any best-practice advice that I could follow?
0 Comments
Accepted Answer
Tao Cheng
on 23 Jan 2024
Hi Federico,
Let's assume dt represents communication stepsize.
In FMU Co-Simulation mode, Simulink (global) calls fmi2DoStep(t, dt) to advance FMU (local) solver, before exchanging data with FMU at t+dt time. According to FMI standard, local solver and states are not available to global solver. Therefore, the value of dt cannot be negotiated between Simulink (global) and FMU (local) solver to speed up simulation.
However, the value of dt can be variable during runtime, if you set communication stepsize to "0" on FMU Import block. This creates a Fixed-in-Minor-Step (FiM) sample time for FMU. When your Simulink (global) solver is variable-step, FMU under FiM sample time will be called at a variable dt, which may potentially speed up your simulation. The stepsize dt will be influcenced by variable-step solver settings and the dynamics of other continuous-time blocks in the same model.
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!