Expressions and Predefined Quantities
When plotting and evaluating results, the COMSOL Multiphysics software provides a large number of predefined quantities that are specific to the physics interfaces in the model; mathematical functions and operators; and general quantities for the geometry, coordinate systems, and mesh.
The COMSOL Multiphysics software does not limit the results calculations to predefined quantities; you can plot and evaluate any function by entering the corresponding expression. You can combine numbers, parameters, mathematical constants, physical constants, variables, mathematical functions, unary operators, and binary operators. The Expression field or list is available for most plot types as well as for integration and data display and evaluation. You can enter any expression directly in the field or insert variables from a list of predefined quantities that you open by pressing Ctrl+Space or by clicking the Insert Expression () button below the table.
In the Settings window for many nodes under Derived Values, for example, you can enter and evaluate multiple expressions in the Expressions section:
Click the Replace Expression () button to select a predefined quantity from the tree of expressions that opens and then replace the contents of the current row in the Expression table with the corresponding variable. For postprocessing features where you input an array of expressions (for example, Global plots and most numerical evaluation features), choose All expressions in this group for groups with many related quantities such as vector and tensor components to add all quantities in the group to the table of expressions.
Click the Add Expression () button to add the corresponding variable to the next row in the Expression table. Otherwise, this option is similar to the Replace Expression option.
The Unit for the expression appears automatically if you replace or add a predefined expression. You can click in the unit’s text field and type a compatible unit for the quantity if there is no unit defined or if you want to change the unit. If you use an incompatible unit, it is ignored and replaced by the default unit.
Click in the Description field in a row to enter a description (or edit the default) for the corresponding expression.
Use the Move Up (), Move Down (), Delete () buttons and the fields under tables to edit the table contents. Or right-click a table cell and select Move Up, Move Down, or Delete. In addition, use the Clear Table button () to clear the entire table and the Insert Expression button () to insert an available model variable or expression into the current expression field at the cursor position.
In the Expression sections, in the Settings windows for plot nodes, for example, you can:
Click the Replace Expression () button to select a predefined quantity from the tree of expressions that opens and then replace the contents of the Expression field with the corresponding variable.
Click the Insert Expression () button to insert the corresponding variable at the current position in the Expression field (you can also use Ctrl+Space).
Select a Unit from the list. You can select from a predefined number of applicable units for the quantity that the variable represents, but you can also click in the unit’s text field and type any compatible unit for that quantity to use a unit that is not in the list (for example, mi/h for miles per hour as a unit for a velocity quantity).
Select the Description check box to enter a description (or edit the default).
When applicable, use the Plot Previous Expression () and Plot Next Expression () buttons to step through all expressions available in the same group of expressions at the lowest level of expressions that you can choose from in the tree of expressions that opens when clicking the Insert Expression or Replace Expression button.
When there are parameters that can affect the plotted quantities, they are listed under Parameters with their name value, unit, and description. You can change the values of the parameters to plot quantities using a specific set of parameter values. Click the Insert Expression button () at the bottom of the section or press Ctrl+Space to insert a predefined expression or variable into the selected cell in the Value column.
Predefined Quantities
The predefined quantities that you get access to by clicking one of the above buttons are divided into categories based on where in the model they belong:
A Built In group with built-in functions and operators:
-
A list of available Mathematical Functions such as trigonometric functions.
-
A list of available Operators, divided into Differentiation; Evaluation; Expressions; Integral, average, and sum; Linearization, Other; and Scoped evaluation.
A Model group with quantities and variables related to the model:
-
For Component 1 (and any other components in the model), each physics interface has its own list of predefined quantities. In addition, there is a Definitions list with variables for coordinate systems and user-defined variables, a Geometry list with geometry variables local to the component such as normal and tangent components, and, if applicable, a Global list with global (scalar) quantities defined by the physics interfaces.
-
A Geometry list with geometry variables such as the spatial coordinates and the domain index.
-
A Global Definitions list with user-defined parameters and variables and a variable for the number of DOFs.
-
A Mesh list with mesh variables such as element size and element quality.
-
A Solver list with variables for the time, eigenvalue, and frequency (when applicable).
Double-click or press Enter to add the selected predefined quantity to the active text field.
Type a filter text in the text field at the top of the list of predefined expressions to filter the list to only include the quantities that match the filter text. Using a filter text can help you find a predefined quantity of interest without having to search through the full list of quantities. You can type the name of the predefined expression (for example, atan2) or the description (for example, inverse tangent) in the filter text for the Insert Expression and Replace Expression lists to search for a specific predefined expression. When you type Ctrl+Space in a text field, you can filter the list using the name of the predefined expression.
Evaluation of Undefined Quantities
During the evaluation of expressions, by default COMSOL Multiphysics does not report partially undefined quantities, and the program plots a quantity where it is defined. The plot is empty where the plotted data is undefined or “not-a-number” (NaN). The plot is also empty where the plotted data quantity is infinity or negative infinity. If a results quantity is undefined everywhere, an error occurs for all plot types.
Evaluation on Lower Geometry Dimensions
For variables defined on a higher geometry dimension such as domains, evaluating such variables on a lower dimension such as boundaries, the returned value is the mean value, if the values for the variable differ on the different sides of the boundary (such as the upside and downside of an interior boundary). Use the up and down operators to evaluate the variable on one side of the boundary.
Accessing Other Solutions than the Selected Solution
When you use the names of the dependent variables in a results expression, COMSOL Multiphysics uses the solution associated with the selected parameter value; eigenvalue; or time for a parametric analysis, eigenvalue analysis, or time-dependent analysis, respectively. To access other solutions in the model, use the with operator.
Processing Solutions with a Stored Linearization Point
If the solution being processed has a stored linearization point (such as for a harmonic perturbation or a small-signal analysis), several options are available for how to evaluate the expression in the Expression evaluated for list.
Specifying a Coordinate System for Vector Plots
For vector plots based on some specific datasets, it is possible to choose a global Cartesian or a local cylindrical or cut-plane coordinate system to evaluate vectors in revolutions of axisymmetric models.
Vector Plots of Revolutions of 2D Axisymmetric Geometries
A Coordinate system list is available in the Expression section for plots that use a Revolution 1D or Revolution 2D dataset that has the default axis settings and points to a Solution, Mesh, Shell, or Layered Material dataset for an axisymmetric geometry. It is also available for plots using a Mirror dataset applied on a Revolution 2D dataset. From that list, choose Global Cartesian to enter a vector in the global Cartesian coordinate system or Cylindrical to enter a vector in a cylindrical coordinate system, which can be more convenient for a revolved (and possibly mirrored) axisymmetric geometry. The Coordinate system list is available for these plot types, when applicable:
Arrow plots (Arrow Volume, Arrow Surface, and Arrow Line)
Deformation subnodes
Principal stress/strain plots (Principal Stress Volume, Principal Stress Surface, and Principal Stress Line)
Scatter plots (Scatter Volume and Scatter Surface)
Streamline plots
2D Vector Plots on Cut Planes
A Coordinate system list is available in the Expression section for 2D vector plots (Arrow Surface plots, for example) that use a Cut Plane dataset that points to a 3D Solution or Mesh dataset. From that list, you can choose Cut Plane to enter a 2D vector in the local cut-plane coordinates, or Global Cartesian to enter a 3D vector in the global Cartesian coordinate system.