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 them, 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 or specified events. 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 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 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 and variable-step solver
models. To choose multitasking execution mode, in Solver selection on the
Solver pane, select the Type to be
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. On the Modeling tab, click Schedule Editor. 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. To open the Manage Partitions panel, click Manage Partitions, on the Schedule Editor toolstrip. 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 order.
Creating partitions using the Manage Partitions panel makes changes to the subsystem or model block parameters.
The following example shows how to configure a model for partitioning and create partitions by using Manage Partitions panel in the Schedule Editor.
Open the model.
Open the Schedule Editor.
Open the Schedule Editor On the Modeling tab, click Schedule Editor. 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 an atomic subsystem. An atomic subsystem is treated by Simulink as a unit when determining the execution order
of block methods(partitioning is enabled only on multitasking, fixed-step and
variable-step solver models). To create partitions from an atomic subsystem block, go to
the Block Parameters dialog box. Select
Periodic partition 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 Order with the connections based on the signals in the
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
Order column 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 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 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 an Export-Function Model. Simulink functions in an export-functions model 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 into a model because it automatically creates Inport blocks.
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
2 and Sample
To partition the function calls of the export-function model, in the Block
Parameters of the model block, select
option from the Schedule Rates with drop-down menu.
Open the Schedule Editor and update the diagram to see the function calls as partitions.