If Condition
The If Condition node () evaluates a condition of device parameters and constants during the instantiation of a device hierarchy. An if sequence is a sequence of nodes starting with an if condition followed by zero or more else-if conditions and finally an optional else statement. Only one of the conditions can be true for the entire sequence. The main difference compared to a normal Usage Condition feature is that the Usage Condition is always an individual condition that evaluates independently of other nodes. Another difference is that a Usage Condition never accepts device parameters or constants.
There are several kinds of if-sequence conditions, and this particular kind, called If-Sequence Condition for Devices on the Devices submenu, only applies to device and port models in a device hierarchy. It only allows the following device nodes to be part of the condition: Device Equations, Port Connections, Explicit Device Events, Implicit Device Events, other If-Sequence Condition for Devices, and For Loop for Devices.
To add an If-Sequence Condition for Devices node, right-click a Device Model, Port Model, Device Package, or Device Model Feature node and choose If-Sequence Condition for Devices from the Devices submenu.
To add an If Condition node to a physics feature or physics property node, right-click the node and choose If-Sequence Condition for Devices from the Devices submenu. If added under any of these nodes or a Component node, the if condition belongs to the device models closest in the hierarchy. For most cases this will be the device model added by the physics interface.
The Settings window has the following sections:
Condition
From the Type list, specify the kind of node it is in the if sequence. The options are If, Else if, and Else. The options Else if and Else are only allowed when the preceding is another if-sequence node using the type If or Else if. When you move nodes, an invalid option will be kept but displays an error decoration until you fix the problem. Leaving a sequence in this state will cause an error when using the physics interface.
The Condition field contains the condition that should evaluate to true. Any variable in the expression without a prefix will be treated as a device variable, although it is allowed to use the device prefix too (dev.A, for example). Most other prefixes are allowed but not all makes sense to use in a condition. Normal physics variables (like phys.A) can never be evaluated in an if condition (just like in a Usage Condition).
Extra Restrictions on Context
The section contains a few extra restrictions that must be fulfilled for the condition to evaluate to true. The Invert condition on restriction checkbox inverts the conditions when selected. Note that this only applies to the conditions in this section. It does not affect the condition in the Condition section. In the Restrict to space dimensions list, select the dimensions that the current context must be in, or not be in when the Invert condition on restriction checkbox is selected. Similarly, the Restrict to study types list requires that the context solves for an equation form equivalent to the selected study types.