## Solver decreases step-size at certain anomalies

Hey hello there!

So i have the following Issue. I am simulating the attitude (orientation) of a satellite via simulink. My initial conditions are usually a spinning satellite that gets slowed down. And when i reach small turn rates (derivative of the magnetic field is very low) my simulation breaks down and my step size decreases so drastically that it takes almost 30min to simulate 1s. And that cant be right somehow.

My tolerance settings are:

Absolute Tolerance: 10*e-8

Relative Tolerance: 10*e-6

Maybe they are low, but they work for most of the time with reasonable step sizes. (as one can see in the graph below)

This is how the step-size graph looks like for an edge case where i get the solver exceptiosn with error control but only for "short" time frames that still take minutes to compute.

At those time intervals the derivative of the magnetic field approaches 0 (1st graph below) and starts to do weird stuff. But when i tell the derivative that it should be 0 when close to 0 the simulation slows down even faster and my magnetic field derivative just starts to flicker (2nd graph).

Are there any general things one has to consider? Does stuff like this happen often in simulations?

Any Ideas how to fix this?

Some more additional Information:

Simulation Overview:

So what the simulation basically does is. It tries to bring the angular velocity of the satellite close to zero. This is done by "measuring" the magnetic field of earth and then trying to align the satellite with earths magnetic field (as it can be roughly assumed constant). This is done via this logic:

Here the graph of my angular Velocity around the x-Axis and the Angular Acceleration Graph when those anomalies occur:

(The Angular acceleration graph is zoomed in on the y-axis as otherwise one would only see the spikes and the angular velocity graph is zoomed in a lot in both axis)

One can clearly see that the Angular Velocity first runs smoothly and then for some reason flattens out until increasing not so smoothly.

If you need more information i will gladly provide them.

Thanks for your Help :)Hey hello there!

So i have the following Issue. I am simulating the attitude (orientation) of a satellite via simulink. My initial conditions are usually a spinning satellite that gets slowed down. And when i reach small turn rates (derivative of the magnetic field is very low) my simulation breaks down and my step size decreases so drastically that it takes almost 30min to simulate 1s. And that cant be right somehow.

My tolerance settings are:

Absolute Tolerance: 10*e-8

Relative Tolerance: 10*e-6

Maybe they are low, but they work for most of the time with reasonable step sizes. (as one can see in the graph below)

This is how the step-size graph looks like for an edge case where i get the solver exceptiosn with error control but only for "short" time frames that still take minutes to compute.

At those time intervals the derivative of the magnetic field approaches 0 (1st graph below) and starts to do weird stuff. But when i tell the derivative that it should be 0 when close to 0 the simulation slows down even faster and my magnetic field derivative just starts to flicker (2nd graph).

Are there any general things one has to consider? Does stuff like this happen often in simulations?

Any Ideas how to fix this?

Some more additional Information:

Simulation Overview:

So what the simulation basically does is. It tries to bring the angular velocity of the satellite close to zero. This is done by "measuring" the magnetic field of earth and then trying to align the satellite with earths magnetic field (as it can be roughly assumed constant). This is done via this logic:

Here the graph of my angular Velocity around the x-Axis and the Angular Acceleration Graph when those anomalies occur:

(The Angular acceleration graph is zoomed in on the y-axis as otherwise one would only see the spikes and the angular velocity graph is zoomed in a lot in both axis)

One can clearly see that the Angular Velocity first runs smoothly and then for some reason flattens out until increasing not so smoothly.

If you need more information i will gladly provide them.

Thanks for your Help 🙂 Hey hello there!

So i have the following Issue. I am simulating the attitude (orientation) of a satellite via simulink. My initial conditions are usually a spinning satellite that gets slowed down. And when i reach small turn rates (derivative of the magnetic field is very low) my simulation breaks down and my step size decreases so drastically that it takes almost 30min to simulate 1s. And that cant be right somehow.

My tolerance settings are:

Absolute Tolerance: 10*e-8

Relative Tolerance: 10*e-6

Maybe they are low, but they work for most of the time with reasonable step sizes. (as one can see in the graph below)

This is how the step-size graph looks like for an edge case where i get the solver exceptiosn with error control but only for "short" time frames that still take minutes to compute.

At those time intervals the derivative of the magnetic field approaches 0 (1st graph below) and starts to do weird stuff. But when i tell the derivative that it should be 0 when close to 0 the simulation slows down even faster and my magnetic field derivative just starts to flicker (2nd graph).

Are there any general things one has to consider? Does stuff like this happen often in simulations?

Any Ideas how to fix this?

Some more additional Information:

Simulation Overview:

So what the simulation basically does is. It tries to bring the angular velocity of the satellite close to zero. This is done by "measuring" the magnetic field of earth and then trying to align the satellite with earths magnetic field (as it can be roughly assumed constant). This is done via this logic:

Here the graph of my angular Velocity around the x-Axis and the Angular Acceleration Graph when those anomalies occur:

(The Angular acceleration graph is zoomed in on the y-axis as otherwise one would only see the spikes and the angular velocity graph is zoomed in a lot in both axis)

One can clearly see that the Angular Velocity first runs smoothly and then for some reason flattens out until increasing not so smoothly.

If you need more information i will gladly provide them.

Thanks for your Help 🙂 simulink, solver, step-size MATLAB Answers — New Questions