Degenerate mass distribution after reducing step size and using state-space model

4 views (last 30 days)
Erika Limon
Erika Limon on 25 Jun 2021
Commented: Erika Limon on 28 Jun 2021
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?

Accepted Answer

Yifeng Tang
Yifeng Tang on 25 Jun 2021
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: 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:
  1. Simulink solver: variable auto; Simscape local solver: off. This will be the RIGHT answer.
  2. Simulink solver: variable auto; Simscape local solver: backward Euler, no limit on iterations; make sure you get RIGHT answer.
  3. 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).
  4. 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).
  5. 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.
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 Comment
Erika Limon
Erika Limon on 28 Jun 2021
Going step by step including changing the local simscape solver was a huge help!
I was able to run my simulation at 100 Hz with ode14x and using backward Euler in the Simscape local solver, extremely slow but it gets the job done.
Thank you so much! :)

Sign in to comment.

More Answers (1)

Steve Miller
Steve Miller on 25 Jun 2021
Hi Erika,
A few things you can try:
  1. 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)
  2. 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.
  3. Try using solver ode1be - that one is usually stable at larger step sizes.
  4. You can also try ode14x - that one is usually stable at larger step sizes, but does a lot more computation per time step.
  5. Try simulating just the Simscape piece variable step and see if it highlights any issues in the model.
  1 Comment
Erika Limon
Erika Limon on 28 Jun 2021
Very helpful advice!
Isolating my state space model helped me realize I could run at 100 Hz with ode14x.
Thank you :)

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!