Main Content

Fixed-Cost Simulation for Real-Time Viability

The step size and number of iterations that you specify affect the computational cost of your real-time simulation. As you decrease the step size or increase the number of iterations, the results become more accurate, but the simulation costs more so it can take longer to simulate. Simulation overrun occurs if the step size is too small or if there are too many iterations for the solver to calculate a solution in a single real-time computational frame.

Limit the computational cost by specifying the solver step size and, for implicit solvers, the number of iterations for the Simulink® global solver and for each Simscape™ local solver in your model.

For best results when specifying the step size of a fixed-step solver for real-time simulation:

  • Specify a sample time that results in time steps that are no greater than the maximum step size.

  • Specify the sample time for each local solver independently and as an integer multiple of the sample time that you specify for the global solver.

  • Choose a step size that is larger than the minimum step size for required speed and smaller than the maximum step size for required accuracy.

To configure the number of iterations for real-time simulation with a fixed-step solver:

  • For local solvers, specify the number of nonlinear iterations for each independently configured Solver Configuration block.

  • For global solvers ode14x and ode1be, specify the number of Newton’s iterations.

To optimize the number of iterations your model uses for fixed-cost, use the simscape.getLocalSolverFixedCostInfo function.

Troubleshooting Real-Time Simulation Issues

Avoid Computer Overloads and Unacceptable Simulation Results

A model is not real-time capable if, during simulation on real-time target hardware, it overloads the CPU or produces results that do not match your theoretical calculations or experimental data. To make your model real-time capable, use the workflows in Model Preparation Process and Fixed-Cost Simulation Process. For examples that show how to:

If you cannot find a combination of solver settings and model fidelity that makes your model real-time capable, consider one of these options:

  • Execute your real-time application on a faster target machine.

  • Configure the networks in your model so that they are independent of each other, and then partition them for parallel simulation on individual target computers. For information, see Multicore Programming with Simulink

See Also

Related Examples

More About