Using Simulink Previous page   Next Page

Choosing a Fixed-Step Solver

When the Type control of the Solver configuration pane is set to fixed-step, the configuration pane's Solver control allows you to choose one of the set of fixed-step solvers that Simulink provides. The set of fixed-step solvers comprises two types of solvers: discrete and continuous.

About the Fixed-Step Discrete Solver

The fixed-step discrete solver computes the time of the next time step by adding a fixed step size to the time of the current time. The accuracy and length of time of the resulting simulation depends on the size of the steps taken by the simulation: the smaller the step size, the more accurate the results but the longer the simulation takes. You can allow Simulink to choose the size of the step size (the default) or you can choose the step size yourself. If you allow Simulink to choose the step size, Simulink sets the step size to the fundamental sample time of the model if the model has discrete states or to the result of dividing the difference between the simulation start and stop time by 50 if the model has no discrete states. This choice assures that the simulation will hit every simulation time required to update the model's discrete states at the model's specified sample times

The fixed-step discrete solver has a fundamental limitation. It cannot be used to simulate models that have continuous states. That's because the fixed-step discrete solver relies on a model's blocks to compute the values of the states that they define. Blocks that define discrete states compute the values of those states at each time step taken by the solver. Blocks that define continuous states, on the other hand, rely on the solver to compute the states. Continuous solvers perform this task. You should thus select a continuous solver if your model contains continuous states.

About Fixed-Step Continuous Solvers

Simulink provides a set of fixed-step continuous solvers that, like the fixed-step discrete solver, compute the simulation's next time by adding a fixed-size time step to the current time. In addition, the continuous solvers employ numerical integration to compute the values of a model's continuous states at the current step from the values at the previous step and the values of the state derivatives. This allows the fixed-step continuous solvers to handle models that contain both continuous and discrete states.

Simulink provides two distinct types of fixed-step continuous solvers: explicit and implicit solvers. Explicit solvers (see Explicit Fixed-Step Continuous Solvers) compute the value of a state at the next time step as an explicit function of the current value of the state and the state derivative, e.g.,

where X is the state, DX is the state derivative, and h is the step size. An implicit solver (see Implicit Fixed-Step Continuous Solvers) computes the state at the next time step as an implicit function of the state and the state derivative at the next time step, e.g.,

This type of solver requires more computation per step than an explicit solver but is also more accurate for a given step size. This solver thus can be faster than explicit fixed-step solvers for certain types of stiff systems.

Explicit Fixed-Step Continuous Solvers.   Simulink provides a set of explicit fixed-step continuous solvers. The solvers differ in the specific integration technique used to compute the model's state derivatives. The following table lists the available solvers and the integration techniques they use.

Solver
Integration Technique
ode1
Euler's Method
ode2
Heun's Method
ode3
Bogacki-Shampine Formula
ode4
Fourth-Order Runge-Kutta (RK4) Formula
ode5
Dormand-Prince Formula

The integration techniques used by the fixed-step continuous solvers trade accuracy for computational effort. The table lists the solvers in order of the computational complexity of the integration methods they use from least complex (ode1) to most complex (ode5).

As with the fixed-step discrete solver, the accuracy and length of time of a simulation driven by a fixed-step continuous solver depends on the size of the steps taken by the solver: the smaller the step size, the more accurate the results but the longer the simulation takes. For any given step size, the more computationally complex the solver, the more accurate the simulation.

If you specify a fixed-step solver type for a model, Simulink sets the solver's model to ode3, i.e., it chooses a solver capable of handling both continuous and discrete states with moderate computational effort. As with the discrete solver, Simulink by default sets the step size to the fundamental sample time of the model if the model has discrete states or to the result of dividing the difference between the simulation start and stop time by 50 if the model has no discrete states. This assures that the solver will take a step at every simulation time required to update the model's discrete states at the model's specified sample rates. However, it does not guarantee that the default solver will accurately compute a model's continuous states or that the model cannot be simulated in less time with a less complex solver. Depending on the dynamics of your model, you may need to choose another solver and/or sample time to achieve acceptable accuracy or to shorten the simulation time.

Implicit Fixed-Step Continuous Solvers.   Simulink provides one solver in this category: ode14x. This solver uses a combination of Newton's method and extrapolation from the current value to compute the value of a model state at the next time step. Simulink allows you to specify the number of Newton's method iterations and the extrapolation order that the solver uses to compute the next value of a model state (see Fixed-Step Solver Options). The more iterations and the higher the extrapolation order that you select, the greater the accuracy but also the greater the computational burden per step size.

Choosing a Fixed-Step Continuous Solver

Any of the fixed-step continuous solvers in Simulink can simulate a model to any desired level of accuracy, given enough time and a small enough step size. Unfortunately, in general, it is not possible, or at least not practical, to decide a priori which solver and step size combination will yield acceptable results for a model's continuous states in the shortest time. Determining the best solver for a particular model thus generally requires experimentation.

Here is the most efficient way to choose the best fixed-step solver for your model experimentally. First, use one of the variable-step solvers to simulate your model to the level of accuracy that you desire. This will give you an idea of what the simulation results should be. Next, use ode1 to simulate your model at the default step size for your model. Compare the results of simulating your model with ode1 with the results of simulating with the variable-step solver. If the results are the same within the specified level of accuracy, you have found the best fixed-step solver for your model, namely ode1. That's because ode1 is the simplest of the Simulink fixed-step solvers and hence yields the shorted simulation time for the current step size.

If ode1 does not give accurate results, repeat the preceding steps with the other fixed-step solvers until you find the one that gives accurate results with the least computational effort. The most efficient way to do this is to use a binary search technique. First, try ode3. If it gives accurate results, try ode2. If ode2 gives accurate results, it is the best solver for your model; otherwise, ode3 is the best. If ode3 does not give accurate results, try ode5. If ode5 gives accurate results, try ode4. If ode4 gives accurate results, select it as the solver for your model; otherwise, select ode5.

If ode5 does not give accurate results, reduce the simulation step size and repeat the preceding process. Continue in this way until you find a solver that solves your model accurately with the least computational effort.


Previous page  Choosing a Solver Type Choosing a Variable-Step Solver Next page

© 1994-2005 The MathWorks, Inc.