Main Content

Propagate Variant Conditions to Define Variant Regions in Virtual and Nonvirtual Subsystems

A Subsystem block can be either a virtual (grouped or ungrouped) or a nonvirtual (atomic) subsystem depending on the selections made in its Block Parameters dialog box. Using a virtual subsystem as opposed to a nonvirtual subsystem provides a graphical hierarchy in a model and does not impact the execution of a model. A nonvirtual subsystem executes as a single unit within a model. For more information, see Subsystem.

This example shows the propagation of variant conditions from a Variant Source block to Subsystem blocks. Simulink® propagates variant conditions to these types of subsystems different.

Explore the Model

Open the model slexVariantCondPropToSubsystems.

The model contains three Subsystems: Subsystem1, Subsystem2, and Atomic Subsystem. Subsystem1 is a grouped virtual subsystem, Subsystem2 is an ungrouped virtual subsystem, and Atomic Subsystem is a nonvirtual subsystem.

Simulate this model and observe the variant conditions propagated from the Variant Source blocks to their connecting blocks.

Propagate Variant Conditions to Conditionally Execute Grouped Subsystem Blocks

A grouped subsystem represents a system of equations. A grouped subsystem has a continuous boundary line. The variant conditions do not propagate inside the grouped subsystem. Instead, they stay on the boundary. However, all blocks inside that subsystem inherit the variant conditions from the grouped subsystem. A Subsystem block becomes a grouped subsystem when you select the Treat as grouped when propagating variant conditions check box in the Block Parameters dialog box.

In this example, the Variant Source2 block has a variant condition V == 1 that propagates to Subsystem1. Since Subsystem1 is a grouped virtual subsystem, the variant condition stays on the boundary and applies to the blocks within the subsystem. If Subsystem1 is active, the blocks within Subsystem1 are also active. If Subsystem1 is inactive, the blocks within Subsystem1 are also inactive, thus making Subsystem1 conditional.

Propagate Variant Conditions to Conditionally Execute Blocks Within Ungrouped Subsystem Blocks

An ungrouped subsystem does not represent a system of equations. The blocks within it have ungrouped semantics. An ungrouped subsystem has a dotted boundary line, and the variant conditions propagate into the subsystem. A Subsystem block becomes an ungrouped subsystem when you clear the Treat as group when propagating variant conditions check box in the Block Parameters dialog box.

In this example, the Variant Source2 block has a variant condition V == 1 that propagates to Subsystem2. Since Subsystem2 is an ungrouped subsystem, the variant condition propagates to the blocks within the subsystem.

The dotted lines on the Subsystem2 icon indicate that the subsystem is flattened during Simulink compilation, and hence you can see the variant conditions for the blocks inside it. Due to the unconditional block To Workspace1, the propagation stops and the condition V == 1 is set only to the Out1 port.

The To Workspace1 block illustrates a key concept of variant condition propagation: signals are variant only if explicitly set or when all paths can be proven to be variant. Here, Subsystem2 is unconditional because all paths within Subsystem2 cannot be proven variant due to the presence of the To Workspace1 block.

Propagate Variant Conditions to Conditionally Execute Atomic Subsystem Blocks

A nonvirtual (atomic) subsystem always represents a system of equations. Nonvirtual subsystems always behave like a single entity and its contents execute only when the variant condition assigned to the subsystem is satisfied. A nonvirtual subsystem has a continuous solid boundary line. The variant condition propagates the same as in the grouped subsystem blocks as the grouped subsystem blocks. A Subsystem block becomes a nonvirtual subsystem when you select the Treat as atomic unit check box in the Block Parameters dialog box.

In this example, the Variant Source3 block has a variant condition V == 1 that propagates to Atomic Subsystem. Since Atomic Subsystem is a nonvirtual subsystem, the variant condition applies to Atomic Subsystem and to all blocks within the subsystem. Like the grouped virtual subsystem Subsystem1, Atomic Subsystem is conditional.

Note

Since conditional subsystems are nonvirtual subsystems, variant conditions in conditional subsystems propagate the same as in atomic subsystems. For more information, see Propagate Variant Conditions to Control Execution of Conditional Subsystems.

Net Variant Condition on Subsystems

A Subsystem block can propagate variant conditions from its output port if that variant condition originates at a port inside the subsystem. The net variant condition is the combination of the local variant condition and its preceding variant condition. In the slex_netvariant model, Variant Source and Variant Source1 are two single-input, single-output Variant Source blocks with the variant conditions V == 1 and W == 1, respectively. When you simulate this model, the Variant Source1 block and the other blocks within the Subsystem block receive a local variant condition W == 1 propagated from the Variant Source1 block. The preceding condition V == 1 propagates from the Variant Source block onto the Subsystem block. Therefore, the net variant condition on the Variant Source1 block and other blocks within the Subsystem block is V == 1 && W == 1.

See Also

Propagate Variant Conditions to Define Variant Regions with Variant Blocks