Stability of explicit Euler solvers

This post looks at the stability of an explicit Euler solver and explicit Euler Runge Kutta solvers from the point of view of using this solver for Hardware in the Loop experiments.

Why use an inline explicit Euler solver for Hardware in the Loop?

Explicit Euler solvers have a low variability in the amount of time required to evaluate a time step compared with implicit and variable step solvers. Also when an explicit Euler solver is inlined (see Dymola User Manual 1B Section 2.7.6) and the appropriate Dymola flags set, this typically results in a fast/efficient solver. These characteristics make the inlined explicit Euler solver a good choice as a solver for HiL. This inline solver can be selected from the Simulation>Setup on the Realtime tab as in Figure 1.

Figure 1.  Inline solver options, these include explicit Euler and explicit Runge Kutta solvers
Figure 1. Inline solver options; these include explicit Euler and explicit Runge Kutta solvers

Unfortunately this solver suffers from two main disadvantages in that it can be inaccurate and can be unstable. By running some back to back tests with a variable step solver, it is possible to get some measure of the accuracy of the solver. The rest of this post examines the stability of explicit Euler solvers.

Inlined explicit Runge Kutta solvers have similar properties to that of the explicit Euler solver except that they are slower, more accurate and more stable. The explicit Runge Kutta solver has an order associated with it. Put simply the higher the order the slower, the more accurate and the more stable the solver is.

Detecting if the explicit Euler and explicit Runge Kutta solver has become unstable

When states are too fast or too oscillatory, the results of the explicit Euler and explicit Runge Kutta solvers become unstable; this can be seen as either the derivatives oscillating wildly, the derivatives becoming inaccurate or the results becoming very large as in Figure 2.

Figure 2.  The simulation of the model is highly oscillatory with large magnitude as the states are too fast for the explicit Euler solver
Figure 2. The simulation of the model is highly oscillatory with large magnitude as the states are too fast for the explicit Euler solver

If the time step of the explicit Euler solver was reduced sufficiently, the model in Figure 2 would simulate accurately. The DiL.Functions.checkDerivatives function in the DiL library can be used to check if these unstable behaviours are occurring in your model.

How to determine if an ODE model will be stable with the selected explicit Euler solver or explicit Runge Kutta

For linear Ordinary Differential Equations, the equation in Figure 3 describes the region in which the poles of the system must lie for the simulation to be stable.

Figure 3.  Equation for the stability region of an explicit Runge Kutta solver.
Figure 3. Equation for the stability region of an explicit Runge Kutta solver. Source moodle.autolab.uni-pannon.hu

For the equation in Figure 3, h is the time step and lambda a complex pole of the model to be simulated and p is the order of the explicit Euler Runge Kutta. If p is 1 then this corresponds to the explicit Euler solver. The stable region is a range of lambda for which the above equation is true.

These stability regions can be plotted as in Figure 4 in the z plane where
z = h*lambda

Figure 5.  Stability regions of explicit Runge Kutta solvers with order 1 to 4
Figure 5. Stability regions of explicit Runge Kutta solvers with order 1 to 4. Source moodle.autolab.uni-pannon.hu

In Figure 5 the poles of a ODE model must fall within the regions above for the model to be stable.

How to check that a model should be stable with a given explicit Euler solver or explicit Runge Kutta

If a model is linearised at a number of operating states and the poles of this model fall within the appropriate stability region you can be fairly confident that the model is stable.

To do this the Tools>Linear Analysis>Full Linear Analysis tool can be used to plot the poles and then the stability regions can be plotted on this graph as in Figure 6.

Figure 6.  Poles of a vehicle model with two explicit Euler stable regions.
Figure 6. Poles of a vehicle model with two explicit Euler stable regions. The blue region has time step h=2[ms] and green has h=1.2[ms]

In Figure 6, the poles of a VeSyMA vehicle model are plotted and the stability region for an explicit Euler solver is also plotted. Note that when a time step of 2 [ms] is used with the explicit Euler solver, then some poles fall outside of this region meaning that this simulation will be unstable. If the time step could be decreased to 1.2[ms] (i.e. the green region) then all the poles fall within this region and this should result in a stable simulation.

Alternatively, by looking at the linear analysis record produced when running Tools>Linear Analysis>Full Linear Analysis it is possible to determine the states associated with the poles that fall outside of the region and the model can be modified to reduce the speed of these states.

Conclusion

By knowing the stability regions of the explicit Euler and explicit Runge Kutta solvers, one can determine if a simulation is likely to be stable or not. Also this knowledge can be used to determine what solver settings should be used or what in the model should be modified to reduce fast states.

Please request the models and instructions used to plot the stability regions on the pole plots here.

Written by: Garron Fish – Chief Engineer

Please get in touch if you have any questions or have got a topic in mind that you would like us to write about. You can submit your questions / topics via: Tech Blog Questions / Topic Suggestion

CONTACT US

Got a question? Just fill in this form and send it to us and we'll get back to you shortly.

Sending

© Copyright 2010-2023 Claytex Services Ltd All Rights Reserved

Log in with your credentials

Forgot your details?