Recommendations for Choosing a Solver (Control Design and Simulation Module)
- Updated2023-03-14
- 4 minute(s) read
Because many dynamic system models consist of differential equations, you must solve these differential equations to observe the behavior of the simulated system. Most simulations you create in the LabVIEW Control Design and Simulation Module use ordinary differential equation (ODE) solvers. However, you also can choose to implement differential algebraic equations (DAE) solvers that enable you solve equations that contain an unknown function.
Before you simulate a dynamic system model, you must specify and configure the solver for that simulation. ODE and DAE solvers use methods to approximate the solution to a differential equation. The solvers implement these methods in a variety of ways, each with various strengths and weaknesses. Defining characteristics of a solver include the following qualities:
- Accuracy or order
- Stability
- Computational speed
- Use of a fixed-time step size versus a variable-time step size
- Use of a single step versus multiple steps
- Suitability for stiff problems
Recommendations for Choosing an Appropriate Solver
Use the recommendations in the following sections to choose an appropriate solver for a simulation.
Models with Unknown Characteristics
If you do not know the expected behavior of a model, choose one of the following variable step-size, variable order solvers:
Deterministic Execution on a Real-Time Target
Choose a fixed step-size ODE solver for use with a simulation that must run deterministically in real time. Fixed step-size solvers run deterministically on RT targets, whereas variable step-size ODE solvers might not because the computational overhead of taking a time step varies over the course of an application.
The Control & Simulation Loop provides the following fixed step-size ODE solvers:
Models with Discontinuities
If a model encounters many discontinuities—in the form of logic that causes a discontinuity in the ODE states or their derivatives—choose a lower order solver, such as a solver of first, second, or third order. The following features introduce this type of discontinuity and might make a lower order solver appropriate.
![]() |
Note This recommendation does not apply to discontinuities introduced by sample data systems in the model. |
- Detect Zero Crossing function
- Friction function
- Integrator function, when you use the reset or limit features
- Lookup Table 1D, Lookup Table 2D, or Lookup Table 3D functions whose interpolation method you set as Nearest, Below, or Above
- Quantizer function
- Relay function
- Switch function
- Logic involving integers
- Other logic that causes a discontinuity in the ODE states or their derivatives
If the model does not encounter any discontinuities, choose a higher order solver, such as a solver of fourth order or greater.
Solutions That Require Resets
A single-step ODE solver might be most efficient for applications that reset the solver often. Initializing a solver requires a certain amount of computation. This computation takes place each time the calculation resets a VI or encounters a discontinuity. Thus, a multi-step ODE solver that requires initialization at each step might be less efficient than a single-step solver.
The Control & Simulation Loop provides the following single-step ODE solvers:
- Runge-Kutta 1 (Euler)
- Runge-Kutta 2
- Runge-Kutta 3
- Runge-Kutta 4
- Runge-Kutta 23
- Runge-Kutta 45
- Rosenbrock
Stiff Problems
If a model varies in stiffness over time, choose an implicit solver. Consider a system that has a broad spectrum of time constants and whose solution contains a component that is high in frequency but quickly dies out relative to the amplitude of the lower frequency waveform. An appropriate solver integrates the system when the high frequency solution is present, and then changes its strategy for the lower frequency solution.
The following implicit solvers start the solution at a low order and gradually move to a higher order when the solution is not stiff or does not experience discontinuities:
When a model varies in stiffness, the solver might need to make certain steps with a very small step size. When you configure the solver, if you set the Minimum Step Size (s) parameter too large, the step might become unstable or, for implicit solvers, the step might lose convergence. If you experience these conditions, try reducing the Minimum Step Size (s). This same logic applies to the Initial Step Size (s) parameter.
Variable step-size solvers make as large a step as seems stable for the ODE. If the collected output does not contain the details you want, you can limit the step size with the Maximum Step Size (s) parameter.
Differential Algebraic Equations
When you use the Algebraic Variable, Implicit State, or Implicit Variable functions to solve differential algebraic equations, use one of the following solvers for implicit systems: