How to speed up simulation time for models using Simscape block
26 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I've developed a battery charging model using Simscape Electrical (Specialized Power systesms) blocks such as battery, resistor, mosfet, PWM, PI controller, Power Gui blocks.
Ive set, Solver - Fixed-step size auto, Power-Gui - 5e-6. But simulation time takes longer of stop time 3600 secs to run completely.
Can anyone help me in reducing / speed up simulation time for electrical models.
0 commentaires
Réponses (1)
Swaraj
le 2 Jan 2024
Hi Mahendran,
Following are workflows that decrease the Simulation run-time for a Simscape model:
Change Solvers
General improvement of a Simscape model performance includes reviewing the use of a stiff solver. Currently, you have selected a “VariableStepAuto” solver which by default uses the “daessc” solver. For physical models, it is recommended that you use implicit solvers such as the “daessc”, “ode23t”, “ode15s”. Since you already use “daessc”, you could try using the other 2 solvers for roughly 10 seconds and see if you find any difference in run times. Please note that the difference might not be significant, but it might help to know which solver is optimal for your workflow by running it for a short duration.
You can find more information on which solvers to choose in the following links:
Alternatively, you can also try the fixed step solvers since they require relatively less memory and less time for adaptive time stepping.
Declare variables beforehand
Pre-allocate variables before running the simulation to reduce the time taken by Simulink to allocate memory and can result in faster simulation.
Simulink Accelerator and Rapid Mode
This mode generates a standalone executable to simulate the real-time systems more quickly. Please refer to the following documentation for more information:
Solver Profiler
The best way to identify what is slowing down your model is to run the solver profiler. The solver profiler allows you to identify which blocks and components are contributing to the highest solver resets and zero crossings. You can use the same to identify which blocks are slowing down your model. Please refer to the following example to understand how to run the solver profiler:
In this case, the presence of 'abs' blocks resulted in multiple zero crossings, which was one of the leading causes of the slowdown. Investigate which blocks are causing the zero crossings and identify if you can disable zero crossing on these blocks by using an alternative block.
Please note that you need to ensure that the configuration parameters are set to "use local settings" for zero crossing control
Finally, identify if there are specific mechanics or equations that can cause a lot of "chatter" or oscillations within the model - these typically show up in the first few seconds on the results of the solver profiler.
Simplify model :
In Simscape, there are several pairs of physical quantities (variables) such that one quantity flows through a component while the other quantity is measured across the component causing slow run times. If you can reduce the number of branches or simplify this model in some way, then you can improve the model run time.
You can create large and complex designs through componentization and reusing your components throughout your model. You can use subsystem references, libraries, and model references to reduce the model to be more computationally efficient.
Log signals instead of using the “Scope” and “Display” blocks in your model to increase run-time efficiency. You can view the signals in the Simulink Data Inspector App.
0 commentaires
Voir également
Catégories
En savoir plus sur Choose and Parameterize Blocks dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!