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 discretization.
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 nonspatial tensors (length other than 3).
If you choose Property dependent, 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, Keep all components or Explicit 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, Keep all components or Explicit 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.
The Explicit setting to defined which components to zero out (default: 0, 1, 2 as zero-based indexes to elements in a vector). The explicit setting is useful when the number of components is not three.
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 (and always in a Dependent Variable Definition node’s Settings window). The Base vector system list is always available.
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.
Select the Define derivatives for all frames check box to automatically add explicit expression variables that represent the derivatives on all frames, except the frame that the shape function lives on because the shape function defines the derivatives for its frame. Selecting this check box disables the Declare shapes for all frames check box, and selecting that check box disables this one.
The Define derivatives for all frames check box is usually a better option than the Declare shapes for all frames check box if you only need access to derivatives on other frames.
Select the Disable accurate boundary flux check box (in Variable Definition nodes only) to disable accurate boundary fluxes for a specific shape variable. A shape variable gets several important settings from a Dependent Variable Declaration node or a Discretization node in the physics interface. You control this by using the Shape discretization list in the Variable Definition node’s Definition section above. The discretization also controls if a shape function uses accurate boundary fluxes, which is not of interest for all shape variables.
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.
The Base vector system setting controls the evaluation context of the definition. As a subnode of a Variable Declaration node, it is equivalent to adding three definition nodes, each with the Base vector system setting set to different frames (Geometry coordinate system, Material coordinate system, and Spatial coordinate system). The Base vector system setting also controls the preferred variable to add the contribution to. If there are multiple declarations for a variable named A, for example, the evaluation context will first try to find a declaration in the same context. In case no matching context can be found, it will automatically transform the evaluated expression to the context of the first declaration.