Main Content

Model Preparation Objectives

The main goal of model preparation is to ensure that your model is real-time capable. Your model is real-time capable if it is both:

  • Accurate enough to generate simulation results that match your expectations, as based on theoretical models and empirical data

  • Fast enough to run on your real-time target machine without overruns

During model preparation, you obtain reference results and determine step size to assess the likelihood that your model is real-time capable. If it is unlikely that your model is real-time capable, you adjust the model scope or fidelity to make real-time simulation with your model feasible.

Obtain Reference Results

Moving your model from desktop simulation to real-time simulation is an iterative process that can require extensive model reconfiguration. During model preparation, you obtain reference results from a variable-step simulation of your original model. These results provide a baseline against which you can judge the accuracy of your modified models.

Determine Step Size

In terms of speed, the only way to know if your model is real-time capable is to test for overruns while simulating on real-time hardware. You can, however, analyze solver execution speed using desktop simulation to determine if your model is probably fast enough for real-time simulation. You do so by analyzing the steps of a variable-step solver to find the maximum step size to use for sufficiently accurate real-time simulation results. If the required step size appears small enough to cause an overrun on your real-time hardware, you increase the step size by improving simulation speed.

Adjust Model Fidelity or Scope

You can adjust the fidelity or scope of your model to increase speed or accuracy. Adjustments include:

  • Deleting or adding blocks or modifying block parameters to eliminate or reduce the effects of elements that introduce numerical stiffness or cause discontinuities. Simulations take small steps to calculate accurate solutions for these types of elements.

  • Modifying elements or parameters to increase simulation efficiency. For example, simplify graphics that require excessive processing power or including lookup tables instead of utilizing processing power to calculate known values.

  • Partitioning independent networks of the model to enable parallel processing.

You can also adjust solver settings to help to make your model real-time capable. For real-time simulation on target hardware, you use a fixed-step, fixed-cost solver that bounds the computation cost, that is, the time the solver takes to execute each time step. You configure the solver parameters before deploying it to a real-time target machine. The fixed-step solver settings that you adjust to improve the real-time viability of your model include step size, solver type, and number of iterations.

Due to the number of options, it is challenging to find the right combination of model size, model fidelity, and solver parameters to achieve real-time simulation. The relationship between speed and accuracy also makes it hard to find both system and solver configurations that help to make your model real-time capable. If you increase speed, you are likely to decrease accuracy. Conversely, increasing accuracy tends to decrease speed. It is especially difficult to achieve acceptable speed and accuracy if you try to adjust model fidelity and scope while you are changing fixed-step solver settings. A better approach to find the optimal configuration is to change only one or two related settings, analyze how those changes affect simulation speed and accuracy, and then make other adjustments.

The real-time model preparation and the real-time simulation workflows separate the configuration changes into two different step-wise processes. For the real-time model preparation workflow, you adjust only the size or fidelity of your model and use variable-step simulation to analyze the effects of your changes. For the real-time simulation workflow, you adjust only the solver parameters and you use fixed-step, fixed-cost simulation to analyze how the changes affect the speed and accuracy of your model.

Related Examples

More About