Propagate Variant Conditions from Variant Source Blocks to Subsystem Blocks
A Subsystem block can represent a virtual subsystem or a nonvirtual subsystem. A virtual subsystem provides 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. Simulink propagates variant conditions differently to these subsystems. This example shows the propagation of variant conditions from a Variant Source block to Subsystem blocks.
Explore the Model
Open the model, slexVariantCondPropToSubsystems
.
Click Simulation > Run to simulate this model and see the variant conditions being propagated from the Variant Source blocks to the blocks connected to it.
The variant condition annotation helps you visualize the propagated conditions. To be able to view the variant condition annotation, click Display > Blocks > Variant Condition Legend.
The model contains three Variant Source blocks: Variant Source1
, Variant Source2
, and Variant Source3
, respectively.
Variant Source1
contains conditions V = 1
and V = 2
at inport. The variant condition V = 1
propagates to GainA1
while V = 2
propagates to Sine2
. The Sine1
block does not get any propagated variant conditions because it is connected to a block, which is always consumed irrespective of the variant condition. If the To Workspace block1
did not exist or was commented-out before simulating the model, variant condition V = 1
propagates to Sine1
.
Variant Source2
is connected to virtual subsystems Subsystem1
and Subsystem2
that have identical contents, a Sine Wave
block connected to a To Workspace
and an Output
blocks. Subsystem1
is a grouped virtual subsystem ( Treat as grouped when propagating variant conditions is selected) while Subsystem2 ( Treat as grouped when propagating variant conditions is clear) is an ungrouped virtual subsystem.
A Subsystem block becomes a grouped virtual subsystem when you select the Treat as grouped when propagating variant conditions check box in the block parameters dialog box. When the Treat as grouped when propagating variant conditions check box is clear, the subsystem is an ungrouped virtual subsystem.
A grouped subsystem represents a system of equation and hence the propagated conditions also apply to the blocks within this system. A grouped subsystem has a continuous boundary line. An ungrouped subsystem does not represent a system of equation and the blocks within it have ungrouped semantics. An ungrouped subsystem has a dotted boundary line and the conditions are propagated into the subsystem.
The variant condition V = 1
propagates to Subsystem1
and further to the blocks within it as Subsystem1
is a grouped virtual subsystem (represents a system of equation). Since Subsystem1 is a system, the condition also applies the blocks within the system.
Subsystem2
that is an ungrouped virtual subsystem (does not represent a system of equation) also receives V = 1
as the propagated condition, and the propagated variant condition V = 1
propagates into Subsystem 2
as if the subsystem were expanded. The dotted lines on the Subsystem 2 icon indicates that it is flattened during Simulink compilation and hence you can see variant condition for those blocks inside it.
Variant Source3
is connected to a nonvirtual (atomic) subsystem with V = 1
as the propagated variant condition. A nonvirtual (atomic) subsystem always represents a system of equations. An atomic subsystem has a continuous solid boundary line. The variant condition does not propagate inside the nonvirtual subsystem. Instead, it stays on the boundary. However, all blocks inside that subsystem get same variant condition as the Subsystem. The nonvirtual subsystem behaves as an entity.
Virtual subsystems by default works like a grouped collection of blocks where all the blocks contained inside the subsystem have the same variant condition. This is true when the Treat as grouped when propagating variant conditions parameter is selected. Virtual subsystems behave like an ungrouped collection of blocks when the Treat as grouped when propagating variant conditions parameter is cleared. In this example, the behavior of the Subsystem2 (Ungrouped) may not be as expected as the block never becomes conditional. Nonvirtual subsystems always behave like an entity and the contents only execute when the condition assigned to the subsystem is satisfied. Nonvirtual subsystems, Model blocks, and grouped virtual subsystems behave the same.
Virtual Subsystems with Treat as Grouped when Propagating Variant Conditions
Treat as grouped when propagating variant conditions option is On: Consider an example with Variant Source block: Variant Source5
and a virtual subsystem Subsystem4
. The Variant Source5
has a condition V = 1
. Subsystem4
has a Sine Wave connected to a To Workspace1
and Outport
blocks.
Subsystem4 gets condition V = 1
as V = 1
is propagated from Variant Source5
. The blocks inside Subsystem4
indirectly inherits the condition from Subsystem4
. Subsystem4
is conditional as its inports/outports are conditional. To make the Subsystem4
as unconditional, add a new outport or clear the Treat as grouped when propagating variant conditions option.
Treat as grouped when propagating variant conditions option is Off: Consider an example with a Variant Source block: Variant Source4
and a virtual subsystem Subsystem3
. The Variant Source4
has condition V = 1
. Subsystem3
has a Sine Wave connected to a To Workspace
and Outport
blocks.
Subsystem3
gets the condition V = 1
as V = 1
propagates from Variant Source4
. However due to unconditional block To Workspace1
, the propagation stops and the condition V = 1
is set only to the Out1
port. Now the Subsystem3
is also unconditional due to presence of unconditional blocks within.