Variable Naming Convention and Namespace
COMSOL Multiphysics uses a namespace with a hierarchical structure to control the access to variables within a model component and variables in other components within the same model. To access variables, use the following namespace syntax:
To refer to material properties, use the material node’s name, such as mat1, and the name of the property group for the material property group, which is typically def for the Basic property group. For example, to access the density ρ in Material 1 use mat1.def.rho (or, using the full name for Component 1, root.comp1.mat1.def.rho; see below). Use this pattern when referencing other material properties too.
The dependent variables (field variables) are unique within a model, and you do not need the Name to access them. For example, enter T to access the temperature in a Heat Transfer interface using the default name for the temperature.
When referring to a variable you only need to provide the part of the full name that makes the variable unique. For example, within a Solid Mechanics interface solid in Component 1 comp1, it is sufficient to type solid.disp, but comp1.solid.disp and the full name root.comp1.solid.disp are also correct. To access the same variable from another Component or from a Study, use comp1.solid.disp or root.comp1.solid.disp. The same mechanism applies to variables defined within a component. To access a global parameter param1, you can use param1 directly or root.param1.
These variable naming conventions mean that the syntax becomes shorter when defining variables locally in a Component branch instead of globally. For example, to access the x-component of the electric field, Ex, in an Electrostatics interface with the name es in a Component 1 with the name comp1, you can use es.Ex in a variable defined in Component 1, but for a variable defined globally, the syntax is comp1.es.Ex.