- Simulink solver: variable auto; Simscape local solver: off. This will be the RIGHT answer.
- Simulink solver: variable auto; Simscape local solver: backward Euler, no limit on iterations; make sure you get RIGHT answer.
- Simulink solver: variable auto; Simscape local solver: backward Euler, put limit on iterations and gradually reduce the number to say 5 (or whatever small number that your model can take and produce RIGHT answer).
- Simulink solver: low order fixed step solver (ode2, e.g.); everything else the same. Play with time steps. Check results and stability. Change time step in the local solver together with the SL solver (unless you have a good reason not to).
- Increase the order of Simulink solver. You'll need to strike some balance here. Given a desired level of accuracy, high order solvers can usually tolerate a larger time step than low order solvers, BUT they can be less stable at the same step size (aka blow up more easily). The "best" choice depends on the type of problem and the resulting equations you have.
Degenerate mass distribution after reducing step size and using state-space model
3 次查看(过去 30 天)
显示 更早的评论
Hello,
I am currently using a state-space model within my Simscape model.
I am using ode4 with a fixed time step of .01 and an absolute tolerance of 1e-12.
My Simscape model works perfectly with no state-space inputs so I am confident there is nothing wrong with my Simscape model, but as soon as I command small inputs, I see my state-space model outputs exponentially grow so it results in a non-finte solution some 30-40 seconds later. My inputs are quite small, so I am puzzled at my state-space outputs growing to 10e300....
I have tried reducing my time step to .001, but when this happens I get the degenerate mass distribution error in the Simscape model.
I am constrained to only using a fixed-step solver and can not switch to a variable step solver.
Does anybody have any ideas on what I might try to get this working?
Thanks!
0 个评论
采纳的回答
Yifeng Tang
2021-6-25
ODE4 is an explicit solver, so it tends to be less stable when the time step is "large". You trying to reduce the time step is definitely heading in the right direction.
At the same time, ode4 may not be the ideal solver for a Simscape network. One common practice to run Simscape in fixed step is to turn on the local solver using fixed time step. You can use a same value as you have for the main model. You can set up the local solver in the Solver Configuration block in your Simscape network. Backward Euler usually works fine. More details here: https://www.mathworks.com/help/physmod/simscape/ug/setting-up-solvers-for-physical-models.html#bsjpduw Backward Euler is an implicit solver, so it will perform iteration during each time step. Depending on your need/requirement, you may want to limit the number of iterations in the block settings as well.
I would suggest you try things in this order:
Hope you can get to step 5 with no problem. If you still have problem and can share the model, I can take a look and let you know what I find.
更多回答(1 个)
Steve Miller
2021-6-25
Hi Erika,
A few things you can try:
- Typically the degenerate mass distribution error with a fixed step solver indicates a numerical issue (step size is too large, solver choice is inappropriate for the system)
- Try analying/simulating your state space model alone and see what frequencies it has. You may find the step size is just too large for what that represents.
- Try using solver ode1be - that one is usually stable at larger step sizes.
- You can also try ode14x - that one is usually stable at larger step sizes, but does a lot more computation per time step.
- Try simulating just the Simscape piece variable step and see if it highlights any issues in the model.
--Steve
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Simulation Setup 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!