Partitions are components of a model that execute independently as atomic tasks. In multi-tasking models, partitions are created from model components. Periodic partitions are scheduled as a function of sample times in a model. In export-function models, the root function-call inputs are defined as partitions. These partitions have a schedule associated with it, which tells what order the partitions execute.
With partitions, you can separate parts of the model which you can explicitly control. You can think of periodic partitions as components that run at specific rates in a model. Aperiodic partitions are components that run at specified hit times. The schedule of these partitions have an impact on simulation and code generation.
The Schedule Editor enables you to partition the model and interact with those partitions. The Schedule Editor shows partitions, the connections between them, and the execution order of the partitions
There are three types of partitions:
|Types of Partitions||Image||Description|
||Automatically created by Simulink®. Blocks running at the base rate show up as an implicit partition.|
||User-defined partitions from the atomic subsystems and/or model blocks. Periodic partitions can also be defined by export-functions. These partitions execute based on their sample time and thus their execution is periodic.|
||Aperiodic partitions are partitions which have no constraints and
can be made to execute at any time. Specify the |
The blocks running at the base rate in the model is shown as an implicit partition in the Schedule Editor. The base rate is the fastest discrete rate in the model. D1 denotes the base rate. D1 annotation also appears in the Timing Legend. The D1 partition or implicit partition always remains the first discrete partition in the execution order.
The default partitions that are already present in the model are also implicit partitions.
The partition colors match their rate.
Partitioning is enabled only on multitasking, fixed-step solver models. To choose
multitasking execution mode, In Solver selection on the Solver pane, select the
Type to be
Fixed-step. Select the
Treat each discrete rate as a separate task check box on
the Solver pane of the Configuration Parameters dialog box.
For more information on multitasking execution mode, see Time-Based Scheduling and Code Generation (Embedded Coder).
As a best practice, enable the Automatically handle rate transition for data transfer setting in the solver pane. When you check Automatically handle rate transition for data transfer, Simulink inserts Rate Transition blocks between blocks when rate transitions are detected. Simulink handles rate transitions for asynchronous and periodic tasks. Simulink adds the hidden blocks configured to ensure data integrity and determinism for data transfers. When you check Treat each discrete rate as a separate task, Simulink selects multitasking execution for models operating at different rates. It also specifies that groups of blocks with the same execution priority are processed through each stage of simulation (for example, calculating output and updating states) based on task priority.
To see default partitions in the Schedule Editor, open the Schedule Editor by selecting View > Schedule Editor, and update the diagram by clicking the icon on the toolstrip. The default partitions in the model are called implicit partitions. You can also create partitions in the model through an atomic subsystem or a model block.
In the Schedule Editor, use the Manage Partitions panel to create partitions. The changes made in Manage Partitions are applied to the model to create partitions after updating the diagram. Manage Partitions shows the model hierarchy with the subsystem blocks and model blocks which can be explicitly partitioned.
To create partitions from subsystem blocks, select the subsystems and click the . To create partitions from model blocks, select the model blocks and click . Enter partition names in the column Partition Name, and sample times in the column Sample Time. Repeat the steps for all the subsystems and model blocks in the model that you want to partition. Update the diagram to see the created partitions in the Schedule Editor. The partitions appear in the graph with their deduced data dependencies and execution order.
Creating partitions using the Manage Partitions panel makes changes to the subsystem or model block parameters.
Following example shows how to configure a model for partitioning and create partitions from using Manage Partitions panel in the Schedule Editor.
Open the model
Open the Schedule Editor
Open the Schedule Editor from the Simulink View menu. To see the default partitions, click Update Diagram in the Schedule Editor. Two implicit partitions, created automatically by Simulink are seen in the Schedule Editor.
Open the Manage Partitions panel. In the panel, expand the
fuel_rate_control subsystem. Select the
airflow_calc subsystem and click . To change the default partition name and sample
time, click the default name and sample time.
To create a partition for the
fuel_calc subsystem, select the
fuel_calc subsystem and click .
The Manage Partitions panel gives you the default partition names and sample times.
Update the diagram to see the newly created partitions.
You can partition only an atomic subsystem. An atomic subsystem is treated by
Simulink as a unit when determining the
execution order of block methods. To create partitions from an atomic subsystem block, go
to the Block Parameters dialog box. Select
from the Schedule as drop-down. Give the partition a name and a
discrete sample time and click OK. This creates an explicit partition for this block. To
see this partition in the Schedule Editor, update the diagram. The partition appears in
the graph and in the Execution Order with the connections based on
the signals in the model.
To create partitions from a Model block, in the Model events
simulation, select Schedule rates and
Schedule Editor from the Schedule rates
with drop-down. When you enable partitioning from a referenced model,
partitions are created from all the model blocks present in the referenced model. These
partitions are scoped by the model block name. To see this partition in the Schedule
Editor, update the diagram. The partitions appear in the graph and in the
Execution Order with the connections based on the design of your
In export-function models, partitions are created from the function calls present in the model. To create partitions from the function calls in the export-function models, reference the export-function model in a top model. Schedule the Model block using the Schedule Editor through the block parameters. Partitions are then created from the function calls and their execution order is determined by the Schedule Editor.
Create an export-function model.
Add a Model block that references the export-function model.
Set the parameter to use partition the export-function model.
Referencing an export-function model from a Model block allows you to partition the function calls without changing the model itself. To create the model for this example, see Create Export-Function Model. Simulink functions in an export-functions models cannot be scheduled, and do not appear as partitions in the Schedule Editor.
Add a model block to a new Simulink model. In the Model name box, enter
export_function_model. To enable the use of the Schedule Editor,
configure the model to be multitasking. Open the Model Configuration Parameters. In
Solver selection on the Solver pane, set
the Type to
the Treat each discrete rate as a separate task and
Automatically handle rate transition for data transfer
parameters. Click OK. The model is enabled for
Do not convert a subsystem to create a model because it automatically creates inports.
Add Outport blocks to the output_100ms and
output_10ms ports for saving simulation data to MATLAB®. For this example, in the
the sample time of both the function calls to -1.
Add a Sine Wave block to provide data input. Set Amplitude to
2 and Sample time to
To partition the function calls of the export function model, in the
Block Parameters of the model block, select
Schedule Editor option from the Schedule Rates
with drop-down menu.
Open the Schedule Editor and update the diagram to see the function calls as partitions.