Physics Builder Tools > Variables > Variable Definition

Variable Definition
A Variable Definition () specifies the expression or shape of a variable and where the definition is valid.
A variable definition can exist in several places and has a slightly different user interface depending on where you use it. For example, it is not necessary to specify a variable name if the definition is a subnode to a variable declaration or user input. For a user input it is not even necessary to specify an expression because it is always set to the value entered by the user input (see User Inputs).
To add a Variable Definition, first add a Component node under Building Blocks>Components, then:
On the Component 1 toolbar, click Variable Definition ().
Right-click the Component node and select it from the Variables submenu.
To find the definitions of the variable, click the Find Declarations of this Variable button () on the Settings window, or click the node and press F7, or right-click the node and choose Search>Find Definitions.
The Settings window has the following sections:
Definition
For a standalone definition (not being a subnode to a declaration, for example), enter the Variable name. The Variable name follows the rules described in Entering Names and Expressions and must match the name of a variable declaration somewhere in the same physics interface.
For a subnode definition, there is no Variable name field, because it always uses the same name as the parent.
Select a Type: Expression, Shape function, or Available. For Expression, enter an Expression using the rules in Entering Names and Expressions.
For Shape function choose a Shape function and Shape order.
Shape Function Variables in the COMSOL Multiphysics Reference Manual
Selection
The options in the Selection list and Output entities list define the selection where this variable definition is valid. See Specifying Selections for more information.
Preferences
Select the Zero out components check box to enforce a symmetry to spatial vectors and matrices.
If you choose Zero out-of-plane, the out-of-plane component is set to zero in the space dimensions 1D, 2D, 1D axial symmetry, and 2D axial symmetry. The out-of-plane component in 2D axial symmetry is the second component (the φ-component).
The Zero in-plane setting does the opposite and has no effect in 3D, for scalars, or non-spatial tensors (length other than 3).
If you choose Property dependent, the you can choose to zero out some components for specific values of some property values.
For each row in the table of property values, choose Zero out-of-plane, Zero in-plane, or Keep all components from the list under Components to zero out for the corresponding property value under Property value.
From the Setting for other property values list, choose Zero out-of-plane, Zero in-plane, or Keep all components to control how other property values are zeroed out.
Select the Use the setting above for undefined references check box to use the default value even when the property does not exist.
Protection
Set preferences that enable protection of entered expressions. Select the Hide expression in equation view check box to remove the definition to display in the Equation View node, which is a subnode to a physics feature in the Model Builder. This disables any possibility to alter the expression; it also makes it harder to read the expression.
To further complicate reading of the expression, you can select the Encrypt expression check box. This turns on an encryption of the expression in the saved model file and when accessing the expression in a model file for Java code. It also encrypts the tensor expression when you compile the archive (see Compiling an Archive), so the expression in a distributed builder file (*.mphphb) cannot be read.
Advanced
This section is available when Shape function is selected as the Type.
Select the Create a slit for the selected shape check box to remove a shape function from the selection.
Select the Declare shapes for all frames check box to ensure that the spatial derivatives of the shape functions exist for all existing frames. The declaration of frame-specific time derivatives of the shape functions is disabled when this check box is selected. These have to be declared manually for necessary frames.
The Solver field type list specifies the type of degree of freedom the shape function declares. There are few cases when this setting needs to be something different than Normal. The option Control is used for optimization and sensitivity problems, whereas the Discrete and Quadrature options are used for solver events; see Event.
Select a Value type: Complex or Real.