Main Content

Accelerate, Refine, and Test Hybrid Dynamic System on Host Computer by Using RSim System Target File

After you create a model, you can use the rapid simulation (RSim) target to characterize model behavior. The executable program that results from the build process is for non-real-time execution on your development computer. The executable program is highly optimized for simulating models of hybrid dynamic systems, including models that use variable-step solvers and zero-crossing detection. The speed of the generated code makes the RSim system target file ideal for building programs for batch or Monte Carlo simulations.

Note

The rapid simulation (RSim) system target file (rsim.tlc) will be removed in a future release.

  • To speed up simulations, use the Simulink® Rapid Accelerator simulation mode. Rapid Accelerator simulation mode provides the same functionality as the RSim system target file, but is easier to use. See Design Your Model for Effective Acceleration.

  • To deploy standalone simulations outside of the MATLAB® and Simulink environment, use the Simulink Compiler™. The Simulink Compiler provides a turnkey solution for building and sharing simulations as standalone executables that package a compiled Simulink model with MATLAB code that sets up, runs, and analyzes model simulations. See Comparing Simulink Coder and Simulink Compiler (Simulink Compiler).

About Rapid Simulation

Use the RSim system target file to generate an executable program that runs fast, standalone simulations. You can repeat simulations with varying data sets, interactively or programmatically with scripts, without rebuilding the model. This can accelerate the characterization and tuning of model behavior and code generation testing.

Using command-line options:

  • Define parameter values and input signals in one or more MAT-files that you can load and reload at the start of simulations without rebuilding your model.

  • Redirect logging data to one or more MAT-files that you can then analyze and compare.

  • Control simulation time.

  • Specify external mode options.

Note

To run an RSim executable program, configure your computer to run MATLAB and have the MATLAB and Simulink installation folders accessible. To deploy a standalone executable program that runs on your development computer (that is, without MATLAB and Simulink installed), consider using the system target file ert_shrlib for generating a shared library that runs on your development computer.

Rapid Simulation Advantage

The advantage that you gain from rapid simulation varies. Larger simulations achieve speed improvements of up to 10 times faster than standard Simulink simulations. Some models might not show noticeable improvement in simulation speed. To determine the speed difference for your model, time your standard Simulink simulation and compare the results with a rapid simulation. In addition, test the model simulation in Rapid Accelerator simulation mode.

General Rapid Simulation Workflow

Like other stages of Model-Based Design, characterization and tuning of model behavior is an iterative process, as shown in this workflow diagram. Tasks in the workflow are:

Rapid simulation workflow

Identify Rapid Simulation Requirements

The first step to setting up a rapid simulation is to identify your simulation requirements.

Question...For More Information, See...
How long do you want simulations to run? Configure and Build Model for Rapid Simulation
Are there solver requirements? Do you expect to use the same solver for which the model is configured for your rapid simulations?Configure and Build Model for Rapid Simulation
Do your rapid simulations need to accommodate flexible custom code interfacing? Or, do your simulations need to retain storage class settings?Configure and Build Model for Rapid Simulation
Will you be running simulations with multiple data sets?Set Up Rapid Simulation Input Data
Will the input data consist of global parameters, signals, or both?Set Up Rapid Simulation Input Data
What type of source blocks provide input data to the model — From File, Inport, From Workspace? Set Up Rapid Simulation Input Data
Will the model's parameter vector (model_P) be used as input data?Create a MAT-File That Includes a Model Parameter Structure
What is the data type of the input parameters and signals?Set Up Rapid Simulation Input Data
Will the source data consist of one variable or multiple variables?Set Up Rapid Simulation Input Data
Does the input data include tunable parameters?Create a MAT-File That Includes a Model Parameter Structure
Do you need to gain access to tunable parameter information — model checksum and parameter data types, identifiers, and complexity?Create a MAT-File That Includes a Model Parameter Structure
Will you have a need to vary the simulation stop time for simulation runs?Configure and Build Model for Rapid Simulation and Override a Model Simulation Stop Time
Do you want to set a time limit for the simulation? Consider setting a time limit if your model experiences frequent zero crossings and has a small minor step size.Set a Clock Time Limit for a Rapid Simulation
Do you need to preserve the output of each simulation run? Specify a New Output File Name for a Simulation and Specify New Output File Names for To File Blocks
Do you expect to run the simulations interactively or in batch mode?Create Scripts for Batch and Monte Carlo Simulations

Configure Inports to Provide Simulation Source Data

You can use Inport blocks as a source of input data for rapid simulations. To do so, configure the blocks so that they can import data from external MAT-files. By default, the Inport block inherits parameter settings from downstream blocks. In most cases, to import data from an external MAT-file, you must explicitly set these block parameters to match the source data in the MAT-file.

  • Main > Interpolate data

  • Signal Attributes > Port dimensions

  • Signal Attributes > Data type

  • Signal Attributes > Signal type

If you do not have control over the model content, you might need to modify the data in the MAT-file to conform to what the model expects for input. Input data characteristics and specifications of the Inport block that receives the data must match.

For details on adjusting these parameters and on creating a MAT-file for use with an Inport block, see Create a MAT-File for an Inport Block. For descriptions of the preceding block parameters, see Inport.

Related Topics