simscape model block performance

1 次查看(过去 30 天)
Albert Mathews
Albert Mathews 2016-11-7
评论: Hannes Daepp 2016-11-11
I have created two versions of simscape model block. The code for each is identical except for 2 lines where some additional math steps are added. The code below shows the portion of the equations section which is changed, the longer lines are the "complex" model, and the shorter lines are the "simple" model. with everything held equal in terms of solver, host model, etc, changing the simulink model so as to change the variable i, I am noticing that as i becomes larger, the simulation time between the two simscape implementations becomes very different. For example, my tests showed that, for a total 20sec simulation:
  • i = 26, runtime was approximately 3.7sec for both models
  • i = 260, runtime was approximately 2sec for both models
  • i = 520, runtime was 3sec for the simple model, and 12sec for the "complex" model.
I did try breaking up the lines into more equations, but this made matters worse.
Is there something with using sqrt or ^2 in simscape that could cause this?
Is there another simscape implementation of complex model that wouldn't result in the slow performance at high i values?
if i > 0
P == i*v*(1.5 - 0.5*sqrt(1+4*esr*v*i/ocv^2));%
P == i*ocv;%
else
P == i*v*(0.5 + 0.5*sqrt(1-4*esr*v*i/ocv^2));%
P == i*ocv + i*i*esr;%
end
  1 个评论
Hannes Daepp
Hannes Daepp 2016-11-11
It is hard to determine the exact cause of the difference in performance without more information on the system, or an example model. From this simple information, you are replacing a simple system with a more complex one and it takes longer; that behavior is not unexpected by itself. Furthermore, these equations scale with i, so one would expect any difference to be exacerbated as i increases in value.
However, it is important to understand that Simscape systems are handled differently than regular Simulink systems. In Simscape, the "==" operator is used to represent continuous mathematical equality, which is not synonymous with assignment, i.e. the equations are not solved sequentially. In other words, using multiple equations would not simplify your system; it would just replace a single equation with a system of equations.
You can find more information on how Simscape language solves equations in the documentation: https://www.mathworks.com/help/physmod/simscape/lang/defining-component-equations.html#brn4h9l-3

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Run-Time Parameters 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by