Rerunning a Simulation without Further Compiling
Use the Rerun Simulation feature in MapleSim to rerun your simulation without having to recompile the entire model. This capability significantly reduces the time required to update and test changes to parameters and initial conditions (ICs), making your workflow more efficient.
Initial Simulation
First, use the Parameter Block on your workspace to define the parameters that you would like to be able to adjust when you rerun your model. Ensure that that Make Parameters Available for Rerun is selected. For more information, see tasks,building,parameterSets,usingParameterBlocks
Next, click Play ( ) to build and simulate the model.
When you first run your model, MapleSim performs two main tasks:
Constructing the Simulation Model, which involves compiling the code and generating the necessary equations.
Integrating the Simulation Model and Event Handling.
After these processes are complete, MapleSim automatically creates a rerun module, which you can reuse after the model has finished its simulation run.
Rerun Simulation Process
After the initial simulation, you can then use the rerun module. This module allows you to rerun the simulation using the previously built model, avoiding the need for a full recompilation.
To use the Rerun Simulation feature:
Click Show Rerun Panel ( ) in the main toolbar to open the Rerun Simulation panel.
In the Rerun Simulation panel, you can modify parameters and initial conditions that have been defined and exposed to the rerun module.
Note: Only parameters within Parameter Blocks with Make Parameters Available for Rerun set to true can be adjusted here.
After making changes, click Rerun ( ) in the panel to re-initialize (if necessary) and rerun the simulation with the new parameter values. The simulation uses the previously built model, allowing for quick feedback and iterative tuning.
Notes:
If you alter parameters or ICs at the main level of the model (outside the rerun module), you must rerun the entire simulation to generate a new rerun module that includes these changes.
You can save your simulation settings within the Rerun Simulation panel, make further adjustments, and rerun the simulation multiple times to iteratively refine your model.
An Example
The example below illustrates the use of the Rerun Simulation feature as applied to a simple model. The example is intended to provide a look at the process of creating a model with the ability to quickly update certain parameters, initial conditions, etc. without having to recompile the entire model.
From the File menu, select New, then select Model. Alternatively, press Ctrl + N.
In the newly created Model Workspace, notice the Parameter Block automatically added to the model. By default, the Parameter Block is named sysParams.
From the Library Components panel, add the following components to the Model Workspace:
From 1-D Mechanical, select Common, then add an Inertia component.
From 1-D Mechanical, select Common, then add a Rotational Spring Damper component.
From 1-D Mechanical, select Common, then add a Rotational Fixed Component.
Connect the components as shown below.
Attach a probe to the Inertia component
Double-click sysParams. Notice this brings up the Parameter settings window.
In the Name field, enter Damping, then select Rotational Damping Constant for the Type, enter 1 for the Default Value and select for the Default Units. Press Enter. This creates another row to which you can add another Parameter.
In the newly created row, enter Inertia in the Name field, Inertia [[kg m2]] in the Type field, enter 1 for the Default Value and select kg m2 for the Default Units.
Click Diagram View (Home) ( ) to return to the Model Workspace.
In the Model Workspace, click the Inertia component, then select Simulation Settings ( ).
Under Parameters-> General, change the Moment of Inertia value from the default to Inertia (the same as the Name field in step 8).
Similarly, in the Model Workspace, click the Rotational Spring Damper, then select Simulation Settings ( ).
Under Parameters-> General, change the Damping Constant value from the default to Damping (the same as the Name field in step 7).
Now, you are automatically using the values in the model as defined in the Parameter Block.
Notice that the Make Parameters Available for Rerun option has been selected. This means that, after the model has run one complete simulation, the parameters that are defined in the Parameter Block can be retuned and used in follow up simulation, without having to recompile the entire model.
You can turn off this option by clearing the Make Parameters Available for Rerun check box.
Press Play ( ) to run the simulation.
Once the simulation has finished running, click Rerun ( ) to open the Rerun Simulation panel.
In the Rerun Simulation panel, change the Initial Velocity to 10 rad/s.
Click Rerun Simulation ( ).
After the simulation has finished you can examine your results in the Analysis Window.
Note, in the Rerun Simulation panel, in addition to the parameters defined in the Parameter Block and the initial conditions, you can also change simulation settings such as, the duration of the simulation and error tolerances.
To save these Rerun results, first select the Simulation Results tab on the side of the Analysis Window. This will open the Simulation Results panel.
In the Stored Results section, right-click on Latest Rerun.
Assign a name to this Rerun Simulation.
Go back to the Rerun Simulation panel and change the Damping value to 10.
Rerun the simulation.
Notice the new rerun simulation, plotted alongside the named simulation from step 22.
See Also
Using Parameter Blocks
The Rerun Simulation Results Tab
Download Help Document