About Parameters, Variables, Variable Utilities, Physics Utilities, and Expressions
Parameters and Variables
Parameters and variables are used to parameterize and organize your model. These are available for the Global Definitions node. Variables are also available in each model component.
Parameters
Parameters are user-defined constant scalars with a global scope that are available for use throughout the Model Builder tree. In particular, they can be used for parameterization in the Geometry, Mesh, and Study branches. Important uses include:
A parameter expression can contain: numbers, other parameters, mathematical constants, physical constants, user-defined functions, functions of parameter expressions, unary operators, and binary operators. Parameters can have units. For example, a parameter can be defined as (exp(-pi*i)+a)*c_const, where a is another parameter, but it is often a scalar numerical value for use in a parametric sweep, where that value is updated during the sweep.
Variables
A variable’s expression can contain numbers, parameters, mathematical constants, physical constants, other variables, functions of variable expressions, spatial variables, time, unary operators, and binary operators. Variables can also depend on dependent variables (the solution) and their derivatives, and they can have units. For example, a variable can be defined as pi*(R_tube^2-r_tube^2), where R_tube and r_tube are two other variables or parameters (for example, defined as 10[mm] and 25[mm], respectively). Variables must be defined so that they return a scalar value when evaluated; that is, the expression defining a variable can be a scalar-valued function such as 2*pi*x*y (in a 2D model), which evaluates to a scalar value for each call with a value of x and y.
Variables can have global or local scope depending on where they are defined. A variable with local scope is limited to a geometric entity level within a model component: the entire component’s geometry or selected domains, boundaries, edges (3D only), or points.
Variables can make a model easier to understand by introducing short and descriptive names for complicated expressions or to use a single variable for a quantity that is defined differently in some model domains. Most variables for material properties, coordinates, and other quantities defined on the computational domain are “field variables” — that is, they are defined so that they can vary in space and time and return a scalar value for each set of input values. For example, a built-in variable for the density in a Solid Mechanics interface, solid.rho, represents a density ρ as ρ(x, y, z, t) in 3D. You can visualize it in a surface or volume plot, for example, but you cannot use it in an ODE or a global evaluation, even if it should happen to be defined as a constant value. In such a situation, use a nonlocal coupling that computes an average quantity or a point probe to obtain a scalar quantity with a global evaluation scope.
Naming Conventions, Reserved Names, And errors
Parameter names and variable names are case sensitive and must begin with a lowercase or uppercase letter (a–z or A–Z). All other characters in the name must be a lowercase or uppercase letter, a number 0–9, or an underscore (_). Dots (.) are also allowed in names but have a special meaning as delimiters in the namespace. Therefore, specifying a variable name using a dot may lead to unexpected behavior. It is possible that the first part of a variable name containing a dot is misinterpreted as a dot symbol for accessing a variable in a namespace.
It is good practice to use descriptive names that are different from the names of built-in functions and constants. Some fundamental built-in mathematical and numerical constants and built-in variables have reserved names; defining a variable using a reserved name is not recommended because it can cause unexpected results. If you use a variable name that is a reserved name (see Summary of Built-In Variables with Reserved Names), the name appears in orange and if you move the cursor to the name, a tooltip such as j is a reserved name appears. The following names are reserved: eps, nan, NaN, inf, Inf, i, j, and pi. Also, when used in a model, errors about duplicate variable names occur if you defined parameter names using names of built-in variables for the geometry, mesh, and physics (h, dom, and similar names of built-in variables as well as the names of dependent variables and spatial coordinates in the model).
If the expression contains a syntax error, it appears in red. Syntax errors can be due to illegal characters, mismatched parentheses, and other syntactic errors. The Error node (), which occurs when trying to solve a model with a syntax error, typically contains information about the position and expression where the syntax error is located.