Variables
You can add Variables () from either the Global Definitions node or the Definitions node under the Component (local) nodes.
From the Model (Windows users) or Main (Mac and Linux users) toolbar click Variables and choose Global Variables or Local Variables.
Right-click Global Definitions and choose Variables.
Under Component right-click Definitions and choose Variables.
Use the Variables node to define expressions as user-defined variables. Global variables can be used in any context that accepts variable expressions, in all Components and on all geometric entities — provided that their expressions are also global expressions. In contrast, local variables have a specific geometry domain of definition. Such variables can only be used and evaluated in a specific Component, or on selected domains, boundaries, edges, or points.
Global variables are primarily useful for expressions involving parameters that do not depend on the geometry, such as time, or dependent variables in an ODE or algebraic equation. Whenever possible, define variables under Definitions in a Component to minimize the risk of variable name conflicts in the global namespace.
Which variables are available for evaluation in postprocessing is decided at the time a solution is created. This means that variables you define do not immediately show up as predefined quantities in results nodes or become available for use in expressions when postprocessing an existing solution. To access the new variables, you must solve the model or update an existing solution by right-clicking a Study node () and selecting Update Solution ().
Geometric Entity Selection (Local Definitions Only)
Select the geometric scope from the Geometric entity level list: Entire model, Domain, Boundary, Edge (3D only), or Point. For all levels except Entire model, you must also specify the variables domain of definition either by adding entities to a Manual selection or choosing All boundaries, for example, from the Selection list.
Variables defined in a Component but with Geometric entity level set to Entire model are in fact global; they can be used anywhere using their full name. For example, if you define variable a in Component 1 in this way, you can refer to it in another Component as comp1.a.
Variables
In the Variables table or the fields under the table, enter variables by defining a variable name under Name, an expression that define the variable under Expression (see  About Parameters, Variables, and Expressions), and (optionally) a description that explains the variable under Descriptions. Alternately, you can import variable definitions from a text file. For the expression, press Ctrl+Space (or Ctrl+/) or use the Insert Expression button () below the table to choose from a number of applicable variables, parameters, functions, operators, and constants that you can insert into the expression at the position of the cursor. Use other buttons underneath the table to move and remove rows and to clear the table.
Additionally, the Save to File button () saves variables to a text file (or to a Microsoft Excel Workbook spreadsheet if the license includes LiveLink™ for Excel®) for reuse in other models. The information is saved in space-separated columns in the same order as displayed on screen. When saving to Excel, an Excel Save dialog box appears where you can specify the sheet and range and whether to overwrite existing data, include a header, or use a separate column for units.
Using the Load from File button (), you can import or load data in text files created, for example, by a spreadsheet program. Data must be separated by spaces or tabs. If the license includes LiveLink™ for Excel® you can also load variables from a Microsoft Excel Workbook spreadsheet. Then an Excel Load dialog box appears where you can specify the sheet and range, whether to overwrite existing data, and declare if the data is stored using a separate column for units.
For an example of global variables, see Effective Diffusivity in Porous Materials: Application Library path COMSOL_Multiphysics/Diffusion/effective_diffusivity
Automotive Muffler: Application Library path COMSOL_Multiphysics/Acoustics/automotive_muffler
Tubular Reactor with Nonisothermal Cooling Jacket: Application Library path COMSOL_Multiphysics/Chemical_Engineering/tubular_reactor
Fluid Valve: Application Library path COMSOL_Multiphysics/Fluid_Dynamics/fluid_valve