0% found this document useful (0 votes)
4 views95 pages

Chapter 1

This chapter provides an overview of building models in COMSOL Multiphysics, detailing the Model Builder's functionalities, including navigation, adding nodes, and managing model components. It covers essential topics such as the sequence of operations, working with physics feature nodes, and the importance of unit systems. Additionally, it explains how to create, copy, and manage components within the model, emphasizing the structured approach necessary for effective modeling.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views95 pages

Chapter 1

This chapter provides an overview of building models in COMSOL Multiphysics, detailing the Model Builder's functionalities, including navigation, adding nodes, and managing model components. It covers essential topics such as the sequence of operations, working with physics feature nodes, and the importance of unit systems. Additionally, it explains how to create, copy, and manage components within the model, emphasizing the structured approach necessary for effective modeling.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

3

Building a COMSOL Multiphysics Model

This chapter explains a range of methods and topics used when building models
in COMSOL Multiphysics®: From working with the Model Builder and
fundamental concepts for building a model to the use of units. For examples of how
to build a complete model and application step by step, see the application libraries
for COMSOL Multiphysics and the add-on modules.

In this chapter:

• Building Models in the Model Builder


• Modeling Development Tools
• Working with Nodes in the Model Builder
• Modeling Guidelines
• Multiphysics Modeling Workflow
• Specifying Model Equation Settings
• Boundary Conditions
• Computing Accurate Fluxes
• Using Load Cases

157
• Numerical Stabilization
• Using Units

158 | CHAPTER 3: BUILDING A COMSOL MULTIPHYSICS MODEL


B ui l di ng M ode ls in t he Mo de l Bui l der
The power of COMSOL Multiphysics is the ease of working with all the features and functionality required to build
a model in The Model Builder. The sections About the Sequence of Operations, The Component Node, Branches
and Subbranches in the Tree Structure, Settings and Properties Windows for Feature Nodes, and Opening Context
Menus and Adding Nodes further introduce you to key concepts about navigating in the Model Builder, the
structure of the tree, and how to add features (nodes) as you build your model.

The physics feature nodes that are added to physics interfaces are flexible and several sections describe the ways to
identify changes, status updates, and other ways to work with these nodes: The Physics Nodes, Physics Interface
Default Nodes, Physics Feature Nodes by Space Dimension, Physics Interface Node Context Menu Layout, Physics
Exclusive and Contributing Node Types, Physics Node Status, Dynamic Nodes in the Model Builder, and Errors
and Warnings.

• The Root Settings Windows


• Creating a New Model
• The COMSOL Desktop

The Model Builder


The modeling procedure is controlled through the Model Builder window, which is essentially a model tree with all
the functionality and operations for building and solving models and displaying the results. These are introduced
to your modeling procedure by adding a branch, such as the Geometry branch. Branches can have further nodes
(or subbranches) that relate to their parent node. It is all About the Sequence of Operations. See Figure 3-2 for an
example.

A node has its own properties and Settings window that are characteristic to it. Branches and subbranches can also
contain properties and settings. See Branches and Subbranches in the Tree Structure and Settings and Properties
Windows for Feature Nodes for examples.

The Model Builder has many types of nodes to help you create models and visualize the model structure — for
example, the Component node is categorized by space dimension, and nodes are dynamic, which helps you identify
nodes that change status. See Component Nodes by Space Dimension, Physics Interface Default Nodes, and
Dynamic Nodes in the Model Builder for more information.

Also learn about the context menu available when you right-click a node in the Model Builder (Opening Context
Menus and Adding Nodes). In the next section (Working with Nodes in the Model Builder), there is also
information about Going to the Source Node, Copying, Pasting, and Duplicating Nodes, Undoing and Redoing
Operations, Clearing Sequences and Deleting Sequences or Nodes, and Disabling or Enabling Nodes.

• The Root Settings Windows


• Creating a New Model
• Basic Navigation
• The COMSOL Desktop

BUILDING MODELS IN THE MODEL BUILDER | 159


Filtering the Model Builder Tree
At the top of the Model Builder window, a text field for a filter text is available. Type any text into that field to filter
the model tree so that only nodes that match the filter are displayed. The matching is not case sensitive. Such a filter
can make it easier for you to find a node in a large model tree. Any new node that you add to the model or any
action that selects a node makes that node visible even if it does not match the filtering.

Click the cross to the right in the text field or press Escape to clear the filtering, returning the model tree to its
normal state. To the right of the text field there is a Refresh button ( ), which refreshes the filtering by hiding
any nodes that no longer match the filter.

When the focus is in the Model Builder window or the Settings window, press Ctrl+L to move the focus to the text
field for the filter text.

Use the options on the Filter Options menu ( ) to the right in the Model Builder window toolbar to control these
parts of the model tree filtering:

• Select Show Children ( ) to also display the subnodes to the nodes that match the filter.
• Select Contains Word ( ) to change the filter to only match exact words.
• The Show Filter Text Field ( ) option is selected by default. Clear it to hide the text field for the filter text.

About the Sequence of Operations


COMSOL Multiphysics operates through sequencing and evaluates most of the branch nodes in the Model Builder
from the top down as a sequence of operations. By adding nodes to a branch in the Model Builder in a certain order,
you set up such sequences of operations, which makes it possible to, for example, parameterize a model and rerun
the simulation. COMSOL Multiphysics then reevaluates each sequence, automatically updating the geometry,
mesh, physics interfaces and features, and solution. A solver sequence, for example, could define your model with
one solver and then, using the returned solution, solve it with an alternative solver.

For most sequences, you run the sequence by right-clicking the top node of the branch and selecting
Build All (geometry) and Build (mesh), Compute (studies), or Plot (plot groups), or by
pressing F8. These buttons are also in the Settings window and in the respective toolbars.

Some nodes under a physics interface branch can override other nodes higher up in the sequence. How the
COMSOL Multiphysics software treats those nodes depends on whether they are contributing or exclusive nodes
(see Physics Exclusive and Contributing Node Types).

The sequence of operations means that the order of the nodes in the tree is important. In the following branches
of the model tree, the node order makes a difference, and you can move nodes up and down to change the sequence
of operations for these nodes: Geometry, Material, physics interfaces and features, Mesh, and Solver.

Also, the order can have some importance in the plot groups in the Results branch and also for the Perfectly
Matched Layer and Infinite Element Domain nodes in the Definitions branch (those nodes are available with some
of the add-on modules).

• Physics Node Status


• Physics Exclusive and Contributing Node Types
• Creating a Geometry for Analysis and Working with Geometry Sequences
• Moving Nodes in the Model Builder

160 | CHAPTER 3: BUILDING A COMSOL MULTIPHYSICS MODEL


The Global Definitions Node
Under the Global Definitions node ( ) you can add functionality that is global and applies to the entire mode.
Right-click the Global Definitions node to add global parameters, variables and variable utilities, user-defined
functions, load and constraint groups, global materials, default model inputs, and more. See Global Definitions.

The Component Node


A model component is a fundamental part of the model and contains a geometry with its associated physics
interface, mesh, and variables and other definitions that are local to that component. The Component node defines
the namespace for each part of a model that is defined in a model component. A model can have several Component
nodes. For example, if you are setting up a system model using both a 2D simplification — represented in one 2D
Component branch — and a full 3D description in another Component, these can both be added to the Model
Builder to represent different aspects or parts of the model. You can couple variables between different components
in a model using coupling operators.

To Add Physics and Add Mesh to the Component, from the Home toolbar, or for any operating system,
right-click the Component node. See The Add Physics Window, and Meshing Overview for more
information.

The Component node icon also indicates the space dimension:


TABLE 3-1: SPACE DIMENSION ICONS IN THE MODEL BUILDER.

ICON SPACE DIMENSION

3D

2D axisymmetric

2D

1D axisymmetric

1D

0D (space-independent models for chemical


reactions and other ODEs and DAEs)

ADDING A COMPONENT TO A MODEL


You can create models with multiple geometries by adding one or more Component nodes to the Model Builder.
Typically a component is added to the model in the Model Wizard when you select a space dimension.

To add a Component node or nodes:

• Right-click the root node (the topmost node) in the Model Builder and select Add Component (see The Root
Settings Windows).
• In The Model Wizard on the Select Space Dimension page, select 3D, 2D axisymmetric, 2D, 1D axisymmetric, or 1D.
Continue defining the model as in Creating a New Model.

COPYING, PASTING, AND INSERTING COMPONENTS


You can copy and paste model components within a COMSOL Multiphysics session and also between COMSOL
Multiphysics sessions, as long as the copied component information remains in the clipboard.

BUILDING MODELS IN THE MODEL BUILDER | 161


To copy a component with all its subnodes, right-click the Component node and choose Copy (or, for Windows
users, click Copy on the Quick Access Toolbar). You can then paste it in the same or a new COMSOL Desktop
session by right-clicking the root node and choosing Paste Multiple Items (or, for Windows users, click Paste Multiple
Items on the Quick Access Toolbar).

It is also possible to insert components from another COMSOL Multiphysics model. To do so, right-click the top
node (root node) and choose Insert Components ( ) or Insert Components From ( ).

• In the first case, an Insert Components dialog box appears where you can browse or type the path and name of
the COMSOL Multiphysics model file from which you want to insert model components in the Model field.
Select one or more of the components in the model from the Components list and then click OK to insert them
into the current model.
• In the last case, a fullscreen Select Model window opens, where you can insert model components from an existing
database, add a new database, or browse for a model to insert components from. See also The Select Model
Window.

Some aspects when inserting or pasting a component into an existing model:

• Existing components in the open model may conflict with the inserted ones. In such cases, the inserted
component will be renamed (for example, from comp1 to comp2). Because inserting a component also inserts
many other nodes (geometry, physics, materials, coordinate systems, and so on), these will also be renamed if
there are existing ones in the open model.
• Most of the nodes under a component only requires that the other nodes under the same component is inserted
with them. However, there are some situations when items outside the component must be included. Especially,
the geometry sequence depends on such items. When inserting or pasting a component, the process
automatically includes necessary global parameters, global functions, and geometry parts. It will not include
references to items in other components.
• File references are inserted as is, and no attempt is made to check if the file exists. When inserting or pasting a
component, the process does not include stored files but rely on the original file path to be valid.
• Global parameters, global variables, and global functions in variable expressions (either in other variables or in
physics settings) will not be inserted or pasted automatically.
• Deformed geometries and their associated meshes are not included in the insertion or paste operation. These
geometries and meshes are typically the result of computing a solution and contain binary data that is not
included in the insertion either. They should appear again after re-solving, which you need to do after the
insertion anyway.

Altogether, these aspects may cause an insert or paste operation to be incomplete to some degree. In some cases,
the difference is reported in a message dialog box after the insertion process has finished. Click Cancel in this dialog
box to revert the insertion process.

SWITCHING TO ANOTHER COMPONENT


In a model with more than one component, you can switch the focus to another component by selecting from the
list of components in the Home toolbar’s Model section. You can also switch to another component by clicking its
Component node in the model tree (or any other node inside that component).

162 | CHAPTER 3: BUILDING A COMSOL MULTIPHYSICS MODEL


THE DEFAULT NODES

Figure 3-1: An example of the Model Builder default nodes for the Electric Currents, Heat Transfer in Solids, and
Electromagnetic Heating interfaces.

These default nodes are normally added under a Component node:

• Definitions: Contains user-defined variables, selections, views, pairs, functions, probes, nonlocal couplings, and
coordinate systems, which are defined locally for the model. See Global Definitions, Geometry, Mesh, and
Materials for information about using these local Definitions ( ) and Global Definitions ( ). Use Global
Definitions to define Parameters, Variables, Functions, and loads and constraint groups with a global scope — that
is, groups that are not specific to one Component node.
• Geometry ( ): Contains the sequence of geometric objects and operations (or imported CAD data) that defines
the model geometry.
• Materials ( ): Contains the materials and material properties used as sources for material data in the
component. See Materials for detailed information.
• Physics interfaces ( ): Any added physics interface displays as a node under Component (Solid Mechanics in
Figure 3-1 for example).
• Multiphysics ( ): When a multiphysics interface is added to the Model Builder, this node contains all the
relevant multiphysics coupling features for that interface. See Multiphysics Modeling Workflow for more
information.
• Meshes ( ): Contains the sequences of meshing operations that defines the computational meshes for the
model. When there is only one mesh in the model, its Mesh node appears directly under the Component node.

Branches and Subbranches in the Tree Structure

The Settings window has the following sections (also see Figure 3-3):

The label appears on the node as the default node name. The default label is Component 1, but you can change it
in the Label field.

BUILDING MODELS IN THE MODEL BUILDER | 163


The name is a string used to define a namespace for the model component and identify variables defined in that
component. The default component name is comp1, comp2, and so on, but you can change it in the Name field. See
Settings and Properties Windows for Feature Nodes and Displaying Node Names, Tags, and Types in the Model
Builder for more information.

UNIT SYSTEM
The default setting in the Unit system list — Same as global system (SI) if the global unit system is the SI unit system
— is to use the global unit system, which you specify in the root node’s Settings window. The global unit system
appears in parentheses. If you want to use another unit system in a component, select it from this list. The unit
system in the list that is used as the global unit system appears as, for example, SI (global system); that is, the
information that it is the global system is appended to the unit system’s name.

FRAMES
In this section, you can define the coordinates for the frames in a model component if you do not want to keep the
default names. All frames are always defined. See About Frames for more information about frames.

Spatial frame coordinates


For Spatial frame coordinates, the default names are x, y, and z for 3D as well as planar 1D and 2D geometries. For
axisymmetric geometries, the default names for the spatial frame coordinates are r,  (phi), and z. If you use the
geometry to represent something other than space, or if you for some other reason want to use other names for the
spatial coordinates, you can change the names in the fields for the First, Second, and Third coordinate under Spatial
frame coordinates.

Material frame coordinates


For Material frame coordinates, the default names are X, Y, and Z for 3D as well as planar 1D and 2D geometries.
For axisymmetric geometries, the default names for the material frame coordinates are R,  (PHI), and Z. You can
change the names in the fields for the First, Second, and Third coordinate under Material frame coordinates.

Geometry frame coordinates


For Geometry frame coordinates, the default names are Xg, Yg, and Zg for 3D as well as planar 1D and 2D
geometries. For axisymmetric geometries, the default names for the geometry frame coordinates are Rg,  g (PHIg),
and Zg. You can change the names in the fields for the First, Second, and Third coordinate under Geometry frame
coordinates.

Mesh frame coordinates


For Mesh frame coordinates, the default names are Xm, Ym, and Zm for 3D as well as planar 1D and 2D geometries.
For axisymmetric geometries, the default names for the mesh frame coordinates are Rm,  m (PHIm), and Zm. You
can change the names in the fields for the First, Second, and Third coordinate under Mesh frame coordinates.

You cannot use the variable for the time, t, as a frame coordinate name.

If you have opened a model originally created in version 5.2 or earlier, click the Permanently Define All
Frames button to, for example, enable the possibility to use a deformed geometry manually.

CURVED MESH ELEMENTS

Geometry Shape Function


The setting in the Geometry shape function list determines the shape function and order of the curved mesh elements
that determine the geometry shape. The default setting is Automatic, but it is also possible to select one of the

164 | CHAPTER 3: BUILDING A COMSOL MULTIPHYSICS MODEL


following geometry shape functions: Linear Lagrange, Quadratic Lagrange, Cubic Lagrange, Quartic Lagrange, Quintic
Lagrange, Sextic Lagrange, Septic Lagrange, Linear serendipity, Quadratic serendipity, Cubic serendipity, or Quartic
serendipity. The default setting allows for automatic reduction of the order in some cases. For a model with a single
physics interface, the geometry shape function is usually the same as the discretization shape function for the physics
field as long as the default setting, Automatic, is used. This setting ensures isoparametric elements.

By default, the software avoids inverted elements by an optimization of the element shapes. To deactivate that
functionality, clear the Avoid inverted elements by curving interior domain elements check box. See Avoiding Inverted
Mesh Elements for more information.

• Creating a New Model


• The Root Settings Windows
• Editing Node Properties, Names, and Labels
• About Frames
• Setting the Unit System for Models
• Using Extra Dimensions
• Curved Mesh Elements

GEOMETRIC MODEL
This section is only available if there is at least one meshing sequence which defines its own geometric model. A
meshing sequence that defines its own geometric model typically includes one or several mesh Import nodes (see
Importing Meshes).

Use the setting Physics defined on to specify on which geometric model the physics is defined. It can be either the
geometry sequence or a meshing sequence which defines its own geometric model. Meshes conforming with the
geometry will not be available in the list. The geometry or meshing sequence selected here will be indicated with
a green or yellow frame around its icon ( or ).

Adding Extra Dimensions to a Model


To add an extra, abstract spatial dimension to a model, right-click the Global Definitions node ( ), and then from
the Extra Dimensions context menu, choose 3D, 2D Axisymmetric, 2D, 1D Axisymmetric, or 1D to add an extra
dimension to the selected space dimension (requires that Extra Dimensions is selected in the Show More Options
dialog box). An Extra Dimension node, in the chosen space dimension, is then added under the Global Definitions
node in the Model Builder. You can add one or several Extra Dimension nodes. It is also possible to attach an extra
dimension to several components. Extra dimensions can be useful, for example, to model transport and reactions
in two different scales, where one scale is the homogenized scale of a set of larger pores between particles or larger
cracks in rocks, and a second smaller scale is the one inside porous particles or in porous rock.

The added node then contains these default nodes: Definitions, Geometry, and Mesh. The settings for the Extra
Dimension node are the same as for the Component node, except it has a unique Name.

The default nodes associated to the Extra Dimension are considered the extra dimension geometry and
extra dimension mesh. The original geometry and mesh are called the base geometry and base mesh.

Before you can use the extra dimensions in physics interfaces, they must be attached on a selection in
the base geometry.

BUILDING MODELS IN THE MODEL BUILDER | 165


The default node label in the Label field is Extra Dimension 1 for the first Extra Dimension node. The component
name is a string used to identify variables in the model. The default Extra Dimensions component name is xdim1,
xdim2, and so on, but you can change it in the Name field.

Using Extra Dimensions

Branches and Subbranches in the Tree Structure


You can proceed through your modeling in the Model Builder by selecting the branches in the order suggested by
the default positions, from the top down, or selecting and defining each branch as needed. One level below the
main Component branch are subbranches as described in Table 3-2 and shown in Figure 3-2. The node appearance
can also change depending on many factors. See Dynamic Nodes in the Model Builder for examples.
TABLE 3-2: THE MODEL BUILDER BRANCHES AND SUBBRANCHES.

FIGURE ICON NAME DESCRIPTION AND LINK TO MORE INFORMATION


REF.

Main Branches

1 Global Define global parameters, and right-click to define global Variables, Functions,
Definitions Load and Constraint Groups, a Materials branch, and optional Geometry Parts.
Mesh Parts, and Extra Dimension branches, which are globally available in all
model components. See The Global Definitions Node.
2 Various Component This branch includes the subbranches Definitions, Geometry, Materials, physics
interfaces, and Mesh. You can also right-click the node to Add Physics and Add
Mesh at this level. See The Component Node.
3 Study This subbranch is where you set up study steps and solver configurations to
solve a model using one or more study types for different analyses. See Studies
and Solvers.
4 Results The features contained in the subbranches for Datasets, Derived Values, Tables,
Export, and Reports are used to present and analyze results. See Results
Analysis and Plots.
Subbranches

5 Definitions This subbranch is used to create Variables, Functions, Selections, Coordinate


(Local) Systems, Nonlocal Couplings, and Probes as well as other definitions that are
local to a specific component in your model. See Global and Local Definitions.
6 Geometry This branch contains the definition of the model’s geometry, where you can
(Local) import a geometry or build one yourself using the available tools. See
Geometry Modeling and CAD Tools.
7 Materials This branch makes it possible to add materials and a material switch for material
(Global) sweeps at the global level. You can add materials in the same way as you do
under a Component branch, but materials on the global level are available
throughout the model and therefore have no Geometric Entity Selection
section. See Global Materials.
7a Materials Collect all material properties organized in Material nodes with a defined
(Local) geometric scope. Material properties required by any of the physics interfaces
and features show up automatically in the defined material’s Settings window.
See Materials.
8 Various Physics Each physics interface forms its own branch based on the model definition
interfaces requirements. See The Physics Interfaces and Creating a New Model to start.

166 | CHAPTER 3: BUILDING A COMSOL MULTIPHYSICS MODEL


TABLE 3-2: THE MODEL BUILDER BRANCHES AND SUBBRANCHES.

FIGURE ICON NAME DESCRIPTION AND LINK TO MORE INFORMATION


REF.

8a Multiphysics This is a main branch but is associated directly with the physics interface
branches above it. It contains multiphysics coupling nodes. See The
Multiphysics Branch.
9 Mesh This subbranch collects all meshes defined for a model. If there is only a single
mesh in a model, its Mesh node appears directly under the corresponding
Component node. See Meshing.
10 Datasets Datasets refer to the source of data for creating Plots and Reports. It can be a
Solution, a Mesh, or some transformation or cut plane applied to other
datasets; that is, you can create new datasets from other datasets.
Views If enabled in the Show More Options dialog box, you can add extra views for
postprocessing purposes here. See User-Defined Views.
Derived Used to define evaluations of numerical results — globally, in a point, or
Values integrated quantities. For 2D and 3D plots, you can also get numerical results
directly in a table by clicking the plot. See About Derived Values.
Tables This subbranch displays the results from integral and variable evaluations
defined in Derived Values nodes or by probes and stored in Table nodes. See
The Table Window and Tables Node.
Color Tables Used to define new color tables for use in the model. See Custom Color
Tables.
Various Plot Groups After adding a 3D, 2D, or 1D Plot Group, plots are added and defined under
this subbranch. See Plot Groups and Plots.
Evaluation After adding an Evaluation Group, you can add evaluation features under this
Group subbranch. See About Evaluation Groups.
Export After a model is completed, you can add various components to this and then
generate outputs (animations, data, images, or export), or export the
information to your computer as image, movie, or data files for use in external
documents or for other purposes. See Export Types.
Reports This subbranch opens the Report Generator, which is a tool for reporting and
documenting models created in COMSOL. It creates a record of the entire
model including all the settings made during the modeling process. The report is
an overview of the model and includes model properties, geometry, physics
interfaces and features, mesh, studies, and results and visualization. See Reports
and Presentations.

BUILDING MODELS IN THE MODEL BUILDER | 167


1

7
2
5

7a

8a

9
3
4

10

Figure 3-2: An example of the Model Builder tree structure showing the many different types of branches and
subbranches available in a model. Refer to Table 3-2 to learn more about a node. Use the numbers to locate the node in
the table.

168 | CHAPTER 3: BUILDING A COMSOL MULTIPHYSICS MODEL


Settings and Properties Windows for Feature Nodes

SETTINGS WINDOW
For all operating systems, and when any node is clicked in the Model Builder (except a few container nodes such
as Definitions and Datasets), a corresponding Settings window opens with the same name as the node. The Settings
window contains settings for defining operations and properties specific to a node, as shown in Figure 3-3.

Figure 3-3: An example of a node Settings window. In this example, the Settings window for the Component node opens
when the node of the same name is clicked. You can also toggle between the Settings and Properties window from the
context menu.

SETTINGS WINDOW FUNCTIONALITY


When an operation or property is updated in the Settings window, its effect on the model is displayed in the
Graphics window either instantaneously or by clicking the applicable button, which are available in some of the
Settings window toolbars. If you update settings for the physics interfaces and features, you must recompute the
solution to reflect the changes in the physics interface and features.

For most sequences, you can run the sequence by right-clicking the top node of the branch and
selecting Build All (geometry) and Build (mesh), Compute (studies), or Plot (plot
groups), or by pressing F8. These buttons are also in the Settings window and in the respective toolbars.

To select the parts of the model to define in a specific Settings window, select the relevant geometric entities directly
in the displayed model in the Graphics window, from the Selection List window, or as, for example, All domains in
the Settings window.

BUILDING MODELS IN THE MODEL BUILDER | 169


LABELS AND NAMES IN THE SETTINGS WINDOW
Every Settings window has the option to change the node Label. The Label is the default node description (it defaults
to the node Type followed by an index suffix). For example, it might be the Electric Currents interface, or in
Figure 3-3 it is Component. You can also right-click and choose Rename or press F2.

Some Settings windows have the option to change the Name. These include physics interfaces, components (as in
Figure 3-3), multiphysics couplings, and some Definitions features, where that field in some cases is called Function
name (for functions), Variable name (for probes), Operator name (for nonlocal couplings), or Pair name (for pairs).
The Name is used primarily as a scope prefix for variables defined by the physics interface. Refer to such physics
interface variables in expressions using the pattern <name>.<variable_name>. In order to distinguish between
variables belonging to different physics interfaces, the name string must be unique. Only letters, numbers, and
underscores (_) are permitted in the Name field. The first character 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 between 0 and
9, or an underscore (_). See Variable Naming Convention and Namespace for more information.

You can choose to display any combination of the Name, Tag, and Type in the Model Builder. See
Displaying Node Names, Tags, and Types in the Model Builder.

In most Settings windows, there is also a Create Shortcut button ( ) next to the Label field. Click it (or press
Ctrl+K) to create a shortcut to that node for use in the Application Builder (see the Application Builder
documentation for more information). If a shortcut already exists, you can click the Rename Shortcut button ( )
(or press Ctrl+K) to rename the shortcut.

THE PROPERTIES WINDOW

Figure 3-4: An example of a node Properties window. In this example, the Properties window for the Component node
opens when you right-click the node and select Properties from the context menu. You can also toggle between the Settings
and Properties window from this context menu.

170 | CHAPTER 3: BUILDING A COMSOL MULTIPHYSICS MODEL


The Properties window ( ) in Figure 3-4 is accessed by right-clicking the node and choosing Properties from the
context menu. The information listed includes the Label, Name, Tag, and the Node Properties.

• The Label can be edited in the Settings window. The default or edited name is displayed here but cannot be
changed in this window.
• The Name is available for Component, functions, and other nodes under Definitions, Material, and physics
interface and multiphysics coupling nodes. You can edit the name in the Settings window for Component nodes,
the main physics interface nodes, and for some functions and other nodes under Definitions, where the name
serves as an identifier in the namespace for variables or as the function name, for example.
• The Tag is unique for each node and is assigned automatically. Tags are primarily used when running COMSOL
models in Java or MATLAB. To display the Tag in the Model Builder, click Model Builder Node Text in the
toolbar and choose Tag. See Displaying Node Names, Tags, and Types in the Model Builder for more
information.
• The Node Properties section includes the following information: Created, Author, Version, and Comments (the root
node is a special case; see The Root Settings Windows). The Created field is automatically assigned by the
software. You can edit the Author, Version, and Comments fields in this window. For the Comments field, you can
add formatting and special characters, including bullet lists and numbered lists at multiple levels, that will appear
in reports and presentations for report nodes whose Comments setting is From referenced node; see Node
Properties for Reports and Presentations.

• Toolbars and Keyboard Shortcuts


• About Selecting Geometric Entities
• The Graphics Window

Displaying Node Names, Tags, and Types in the Model Builder

SELECTING THE MODEL BUILDER NODE CONTENTS


The Model Builder always shows the label for the nodes. To add more information, in the Model Builder toolbar
click Model Builder Node Text . Then select any combination of options from the list: Name, Tag, and Type. See
Figure 3-5 for examples.

• A Name is only used in the Model Builder for short names (descriptions) of the nodes. The Name can only be
changed for the top Component, physics interface nodes and multiphysics couplings, and for Definitions nodes.
Some Settings windows have the option to change the Name. See Settings and Properties Windows for Feature
Nodes for information about Label versus Name. The Name and Tag for top level features are often the same.

For Definitions features, the Name is displayed differently for Functions, Probes, Nonlocal Couplings,
and Pairs. See Common Settings for the Definitions Nodes for more information.

• A Tag is unique for each node and is assigned automatically. Tags are primarily used when running COMSOL
models in Java or MATLAB. Select Tag to display each node’s feature name with the predefined tag in curly
braces using an italic font. The Name and Tag can be the same.
• A Type is automatically assigned by the software and cannot be changed. Select Type to display each node’s feature
type (predefined name). This is the most useful if a node Label is renamed or if you use a local language other
than English and want to see the predefined name; otherwise, the type and the label are the same (except that
the label typically includes a number, such as Boundary System 1).

BUILDING MODELS IN THE MODEL BUILDER | 171


Tag
Name

Type

Label edited in the


Settings window

Figure 3-5: Examples of the available combinations on the Model Builder Node Label menu. The second example of a
Type shows how this is useful when the Label is edited in the Settings window and you need to know the original type of
node.

LABELS
Node Settings windows have a Label field where you can change the default node description for all levels (except
the root node, which gets its name from the model filename). The label can also be changed by right-clicking and
choosing Rename or by pressing F2.

The Label can also be displayed in the Model Builder where it is called a Tag. See Settings and Properties
Windows for Feature Nodes.

• Editing Node Properties, Names, and Labels


• The Root Settings Windows

172 | CHAPTER 3: BUILDING A COMSOL MULTIPHYSICS MODEL


Opening Context Menus and Adding Nodes
In addition to using the toolbars and menus (see The COMSOL Desktop Menus and Toolbars), you can right-click
a node to open a context menu. The context menu lists all the functionality available as properties and subnodes
to a particular node in a branch of the tree. Figure 3-6 shows the context menu for some of the Geometry node
options. From the menu you can add additional, and relevant, functionality, operations, or attributes to the
sequence. Often there is a mixture of submenus, keyboard shortcuts, or specific features to choose from as in
Figure 3-6 and Figure 3-7. There are also standard options such as Rename, Properties, and Help.

The context menu is also further divided and categorized for physics interfaces, as in the section Physics Interface
Node Context Menu Layout and Figure 3-7.

To add physics feature nodes to physics interfaces, in general, go to the Physics toolbar, no matter what
operating system you are using. Subnodes are available by clicking the parent node and selecting it
from the galleries that open.

The layout of the context menu (especially for physics interfaces) depends on whether the nodes are
grouped by space dimension. The default is ungrouped nodes. See Grouping Nodes by Space
Dimension and Type for an example comparing the different context menus.

OPENING THE CONTEXT MENU


• Right-click any node in the Model Builder to open the context menu
• Once a node is highlighted, right-click anywhere in the Model Builder to open it.
• Use the shortcuts based on operating system:
- Windows: Press Shift+F10.
- macOS: Press Ctrl+F10.
- Linux: Press Shift+F10.

After selecting an option from the list, an associated Settings window opens to the right (by default) of the Model
Builder window. See Figure 3-3 for an example.

BUILDING MODELS IN THE MODEL BUILDER | 173


A keyboard shortcut

Click to add a specific node


or open a window.

Submenus to
additional options

Standard options on all


context menus.

Figure 3-6: A context menu opens when you right-click any node in the Model Builder. In this example, the options
available for the Geometry node are shown.

• Settings and Properties Windows for Feature Nodes


• Grouping Nodes by Space Dimension and Type
• Clearing Sequences and Deleting Sequences or Nodes
• Disabling or Enabling Nodes
• About Geometric Entities

The Physics Nodes


An important part of building a model is where you add physics branches. For example, when Creating a New
Model. This branch (see Figure 3-2 for an example) contains the nodes that define the material properties,
equations, loads, initial values, boundary conditions, and other parts of the physics that the model describes. All
Settings windows for the specification of the physics and equations accept parameters and variables as input data.

174 | CHAPTER 3: BUILDING A COMSOL MULTIPHYSICS MODEL


SPECIFYING PHYSICS INTERFACE SETTINGS
Each physics interface includes nodes for specifying all input data for a specific physics in a model:

• Material properties and material models


• Boundary and physics interface conditions
• Equations (for equation-based modeling)
• Initial conditions

In addition, you can specify weak form contributions and element types for additional flexibility.

Specifically, the settings are available on the following parts of the geometry:

• Domains
• Boundaries
• Edges
• Points
• Additional properties that are independent of the geometry

Not all of these options are available for all geometry types and physics interfaces.

PHYSICS FEATURE NODES BY SPACE DIMENSION


The physics feature nodes indicate the geometric entity level (domains, boundaries, edges, points, or pairs) based
on the space dimension of the Component (see Table 3-3). The nodes also correspond to The Graphics Toolbar
Buttons and Navigation, some of which are also based on space dimension.

See Physics Exclusive and Contributing Node Types and Physics Node Status for examples of other
differences to how the nodes display in the Model Builder.

TABLE 3-3: PHYSICS FEATURE NODES BY SPACE DIMENSION.

NAME 3D 2D AND 2D 1D AND 1D


AXISYMMETRIC AXISYMMETRIC

Domain level

Domain level, default node

Boundary level

Boundary level, default node

Boundary level, Pairs

Point level —

Edge level — —

BUILDING MODELS IN THE MODEL BUILDER | 175


• The Physics Interfaces
• Physics Interface Default Nodes
• Physics Interface Node Context Menu Layout
• Physics Node Status

Physics Interface Default Nodes


When you add a physics interface, the software automatically adds a corresponding physics interface branch in the
tree, which typically includes a number of default nodes, including but not limited to:

• A model equation or material model node, typically on the domain level. This node defines the domain equations
(except optional sources, loads, reactions, and similar contributing domain quantities) and the related material
properties or coefficients.
• A boundary condition node. For multiphysics interfaces there is one boundary condition for each participating
physics.
• For axisymmetric models, the symmetry axis has an Axial Symmetry boundary condition (see Physics Interface
Axial Symmetry Node).
• An Initial Values node for specifying initial values for a time-dependent simulation or an initial guess for the
solution to a nonlinear model (see Specifying Initial Values).

In most cases, the default nodes’ initial selections include all domains or all boundaries (or all instances of another
geometric entity level). Their selection is always every instance that is not overridden by another node on the same
geometric entity level. It is not possible to delete such default nodes, but you can copy and duplicate all default
nodes. Some multiphysics interfaces also add default nodes with no initial selection, which are possible to delete
from the model. Default nodes include a D (for “default”) in the upper-left corner ( ) to indicate their special
status. The copy or duplicate of a default node is a node of the same type but behaves as a normal node with an
initially empty selection.

For example, for a geometry with four boundaries, the default boundary condition’s initial selection includes all
four boundaries. If another exclusive boundary condition for Boundary 3 is added, that boundary becomes
overridden (inactive) in the default boundary condition’s selection. If you disable or remove that boundary
condition, the default boundary condition becomes active for Boundary 3 again. You cannot change a default
node’s selection.

Some physics interfaces also add standard nodes directly when you add them to a model. They
represent functionality that is likely to be useful but that you might want to make only active on a part
of the geometry or delete. Such nodes do not include a D in the upper-left corner.

• Physics Feature Nodes by Space Dimension


• Physics Node Status
• Physics Exclusive and Contributing Node Types
• Dynamic Nodes in the Model Builder

Physics Interface Node Context Menu Layout


The context menu opens when you right-click a physics interface node, or any node in the Model Builder (see
Opening Context Menus and Adding Nodes). Depending on the space dimension, this menu is divided into these

176 | CHAPTER 3: BUILDING A COMSOL MULTIPHYSICS MODEL


sections for most physics interfaces: the first section contains domain settings, the second boundary settings, the
third edge settings, and the fourth has point settings.

There can be menu items with the same name but applied at different geometric entity levels.

To add physics feature nodes to physics interfaces, in general, go to the Physics toolbar, no matter what
operating system you are using. Subnodes are available by clicking the parent node and selecting it from
the gallery that opens.

An example of the context help menu


when the nodes are not grouped by
space dimension (the default).

Domain level settings for


ungrouped nodes

Boundary level settings for


ungrouped nodes

Edges and Points submenus

Common options on physics


interface context menus.

Figure 3-7: An example of a Heat Transfer in Solids interface context menu. The choices are based on the Component
dimension (in this example it is 3D) as well as the physics interface. The menu is further divided by geometric entity level
(domains, boundaries, edges, and points).

As shown in Figure 3-7, the context menu layout is also based on whether the nodes are not grouped (the default)
or if Group by Space Dimension is selected.

BUILDING MODELS IN THE MODEL BUILDER | 177


Physics Exclusive and Contributing Node Types
The nodes for the physics interfaces and features are in a sequence, which acts like a macro that the software runs
in a top-down order. Depending on the selection for each node, a node can totally or partially override, or shadow,
a node earlier in the sequence. How the software treats these nodes depends on the relationship. There are two
different types of nodes: exclusive and contributing.

The exclusive and contributing nodes maintain the described behavior only in relation to similar types
of nodes within the same physics interface (for example, you can have a temperature constraint and a
pressure constraint for the same boundary in the same model component).

What the node looks like in the Model Builder is based on the space dimension. See Physics Feature
Nodes by Space Dimension.

EXCLUSIVE NODES
The use of an exclusive node means that only one can be active for a given selection. That is, if you add another
exclusive node (for example, an identical node) with the same selection, the first exclusive node is overridden and
thus has no effect.

Typical exclusive nodes include model equations, initial values, and boundary conditions that are constraints, such
as prescribed values for displacements, temperatures, pressures, and so on, or other Dirichlet-type conditions,
including special variants of these such as ground conditions in electromagnetics and fixed constraints in structural
mechanics. Also some boundary conditions that are not constraints but have a definitive meaning are exclusive
nodes — for example, electric insulation, thermal insulation, and no-flow conditions. Depending on the selections
for each node, an exclusive node can override another node partially. Nodes are exclusive only within their specific
physics interface. When a node is selected in the Model Builder tree, nodes that are overridden by the selected node
have a red arrow in the lower-left corner of the icon ( ), and nodes that override the selected node display a red
arrow in the upper-left corner of the icon ( ).

CONTRIBUTING NODES
A contributing node means you can have more than one of these nodes with the same selection and that the
software adds these together when evaluating the model. Typical contributing nodes are loads, fluxes, and source
terms, where you can have more than one of each type that is active on the same domain or boundary, for example.
The total effect is then a sum of each contributing node. When a node is selected in the Model Builder tree, the
tree shows other nodes, which the current node contributes with, indicated using a yellow dot to the left of the
icon (for example, in this boundary level icon ). See also Figure 3-8 for an example.

ORDER OF EXCLUSIVE AND CONTRIBUTING NODES


An exclusive node typically overrides all other nodes that share some common geometric entity and that appear
above it in the list of nodes under a physics interface. Conversely, a contributing node can contribute with an
exclusive node that appears above it. For example, in a heat transfer interface, a Temperature exclusive node
overrides a Heat Flux contributing node defined above it (when defined on some common boundaries). If you
switch the order of those nodes, so that the Heat Flux node appears below the Temperature node, it then contributes
with the Temperature node. Because the Temperature node imposes a constraint on the temperature, the computed
solutions are identical when evaluating the temperature. However, the contributing heat flux changes the reaction
force of the temperature condition, which you can verify by integrating the reaction force on a boundary using the
reacf operator, for example.

178 | CHAPTER 3: BUILDING A COMSOL MULTIPHYSICS MODEL


LISTING OVERRIDES AND CONTRIBUTIONS
If your preferences include showing the Override and Contribution section in the Settings windows for physics nodes,
you can find the following information about how exclusive and contributing nodes interact in the model. Click
the Show More Options button ( ) and select the Selection Information in the Show More Options dialog box to
display the information as in Figure 3-8 and described below.

• The Overridden by list contains the names of the nodes that the selected node is overridden by. The selected node
is then overridden by these nodes at least partially, and the Selection list contains (overridden) for the geometric
entities (boundaries, for example) where it is overridden. The nodes that the selected node is overridden by are
indicated using a red arrow in the lower-left corner of the icon such as in this boundary level icon .
• The Overrides list contains the names of the nodes that the selected node overrides (where the current node is
active). The nodes that the selected node overrides are indicated using a red arrow in the upper-left corner of the
icon such as in this boundary level icon .
• The Contributes with list contains the names of the nodes that the selected node contributes with for at least some
shared selection. The nodes that the selected node contributes with are indicated using a yellow dot to the left
of the icon such as in this boundary level icon .

If a physics node is disabled locally in a study step using the Physics and Variables Selection section in
the study step’s Settings window, the indications of overrides and contributions in the Model Builder
are unchanged (but disabled physics nodes get an asterisk to indicate that their state has been changed
in at least one study step). However, the local variables and physics tree in the study step’s Settings
window displays the overrides and contributions taking the disabled nodes into account.

BUILDING MODELS IN THE MODEL BUILDER | 179


Figure 3-8: The Override and Contribution section lists other physics nodes that the selected node is overridden by,
overrides, or contributes with.

• Physics Node Status


• Physics and Variables Selection
• Physics Interface Default Nodes

Physics Node Status


The status of a physics node depends on if it is a default node, the selection that it applies to, and other nodes in
the same branch that can override nodes earlier in the sequence. You can change the order of nodes (except the
default nodes) by moving them up or down.

OVERRIDDEN SELECTIONS
A node can be partially or completely overridden by another node further down in the same branch of the model
tree that is of a similar, exclusive type. For example, if you specify a temperature boundary condition on boundary
1 and boundary 3, and then add another temperature boundary condition for boundary 3, the first temperature
boundary condition is overridden on boundary 3. In the Settings window for the Temperature nodes that define the
temperature boundary condition, the Selection list then shows 3 (overridden) to indicate that the temperature
boundary condition defined on this selection is overridden for boundary 3 but is still active on boundary 1.
Deleting or disabling the other temperature boundary condition on boundary 3 reactivates the original
temperature boundary condition, and then shows 3 (without the (overridden) indication).

180 | CHAPTER 3: BUILDING A COMSOL MULTIPHYSICS MODEL


SELECTIONS THAT ARE NOT APPLICABLE
For selections that are not applicable for a node (such as interior boundaries for a boundary condition that is only
applicable for exterior boundaries), the Selection list then shows (not applicable) next to entries that are, in this case,
interior boundaries.

SELECTIONS THAT ARE USED AS FALLBACK FOR PAIRS


For selections where the physics node serve as a fallback feature for a pair, a decoration appears on the node, such
as in this example: . Also, the Selection list then shows (fallback) next to entries where the physics node is fallback
feature. See Identity and Contact Pairs for more information about pairs.

EMPTY SELECTIONS
For physics nodes that you add to a model (that is, not for default nodes), a warning appears on the physics node
when the node has no selection. An added source or boundary condition, for example, has no effect on the model,
so leaving an added physics node with an empty selection might be an unintended state, leading to unexpected
simulation results.

Figure 3-9: The warning and tooltip for an added physics node with an empty selection.

The warning for an empty selection does not appear in the following cases:

• For completely overridden selections.


• When no applicable entities are available.
• When selections are set to all entities, but the geometry has no entities on the given entity level (for example, no
geometry or domain selection on a surface geometry).

ENABLING AND DISABLING NODES


By enabling or disabling physics nodes, you can activate and deactivate (shadow) other physics interface nodes that
appear higher up in the physics interface branches.

• Physics Interface Default Nodes


• Physics Exclusive and Contributing Node Types
• Physics Feature Nodes by Space Dimension
• Clearing Sequences and Deleting Sequences or Nodes
• Disabling or Enabling Nodes

Dynamic Nodes in the Model Builder


The Model Builder is a dynamic environment. As your model is built and analyzed, there are numerous ways to
quickly identify nodes that change status during the process. Table 3-4 lists generic examples and links to the
dynamic visual aids that are used to help you.

• Branches and Subbranches in the Tree Structure


• The Component Node

BUILDING MODELS IN THE MODEL BUILDER | 181


TABLE 3-4: DYNAMIC NODES — VISUAL AIDS TO IDENTIFICATION.

ICON TYPE NODE EXAMPLE AND LINK TO MORE INFORMATION (WHERE APPLICABLE)

Error For example, on a Material node . See Errors Relating to the Material Nodes.

Error node Errors and Warnings

Current node, not For example, on a Geometry node ( ). This node is also displaying the asterisk
built (yellow frame) indicating the node is being edited. The asterisk also appears on plot nodes when
the plot has not been updated to reflect changes in the data or settings (for
example, after re-solving), See The Current Node in Geometry Sequences.
Current node (green A current node is used for Geometry and Meshing nodes and indicates that the
frame) feature or sequence of steps has been built. It is a green line on the left and upper
edges of the node. For example, on a Geometry node , after building. Also see
The Current Node in Geometry Sequences.
Enabled sequence During solution processing, the particular sequence that is enabled and runs when
selecting Compute has a green border around its icon ( ). See Computing a
Solution.
Harmonic For example, on a boundary level node for the Electric Currents interface, Electric
Perturbation Ground node . See Harmonic Perturbation, Prestressed Analysis, and
Small-Signal Analysis.
Warning For example, on a Mesh node .

Editing, or in process For example, on a Mesh node . This node is also displaying the asterisk
of editing, a node indicating the node is being Edited. Also indicates physics interface nodes that have
been disabled in a study step. See Editing and Building Geometry Nodes for
Geometry nodes for example.
Pairs For example, on a 3D Boundary Level node . See Identity and Contact Pairs.

Pairs — Fallback For example, on a 3D Boundary Level pair node . See Identity and Contact
Features Pairs.
Contributing node For example, on a 3D boundary level node . See Physics Exclusive and
Contributing Node Types and Physics Node Status.
Default node For example, on a 2D boundary level node . See Physics Interface Default
Nodes.
Override For example, on a 3D boundary level node . See Physics Exclusive and
Contributing Node Types.
Overridden For example, on a 3D boundary level node . See Physics Exclusive and
Contributing Node Types
STUDY STEPS ANALYSIS

Solve For For example, a Laminar Flow interface where the green dot in the lower-right
corner indicates that the study solves for the degrees of freedom in this physics
interface. See Physics and Variables Selection.
Disable in Solvers For example, a Laminar Flow interface is enabled (not dimmed), shows that the
study step provides degrees of freedom (the yellow dot in the lower-right corner),
and has a change of state indicated by the asterisk. The yellow dot means that the
study step provides degrees of freedom but does not solve for the physics
interface. See Physics and Variables Selection.
Change of State An asterisk appears in the upper-right corner of nodes for which you change their
(editing) state in the study step’s selection tree compared to their state in the main model
tree in the Model Builder. For example, for the Joule Heating interface .

182 | CHAPTER 3: BUILDING A COMSOL MULTIPHYSICS MODEL


TABLE 3-4: DYNAMIC NODES — VISUAL AIDS TO IDENTIFICATION.

ICON TYPE NODE EXAMPLE AND LINK TO MORE INFORMATION (WHERE APPLICABLE)

Disabled in Model In this example, a Transport in Diluted Species interface is disabled


(provides no degrees (unavailable), provides no degrees of freedom (red dot in the lower-right corner),
of freedom) and and has a change of state indicated by the asterisk. See Physics and Variables
shows a change of Selection.
state
LOAD AND CONSTRAINT GROUPS

Load Group This is an example of a Boundary Load node with a load group . This is for a 2D
model at the boundary level. See Load Group and Using Load Cases.
Constraint Group This is an example of a Fixed Constraint node with a constraint group . This is
for a 2D model at the boundary level. See Constraint Group and Using Load
Cases.

Physics Symbols
There are physics symbols available with structural mechanics and some other physics features in 2D, 2D
axisymmetric, and 3D components to help you to graphically indicate boundary conditions, loads, and other
physics features:

• Physics Symbols for Structural Mechanics and Other Physics


• About Coordinate Systems and Physics Symbols
• Displaying Physics Symbols in the Graphics Window — An Example

• Solid Mechanics and Using Load Cases


• The Graphics Window

PHYSICS SYMBOLS FOR STRUCTURAL MECHANICS AND OTHER PHYSICS


To display the physics symbols listed in Table 3-5, select the Enable physics symbols check box under Physics Symbols
in the main physics interface node’s Settings window. This check box is not selected by default.

Once you have turned on the physics symbols for a certain physics interface, you can fine-tune the display. Every
feature that has associated physics symbols now has a Show physics symbols check box, by which you can control the
display of the symbols for that specific feature.

In the Physics Symbols section in the settings for the physics interface, you can click the Select All button, which
displays all symbols in that physics interface by selecting all Show physics symbols check boxes in the Settings
windows for the physics features that include symbols. Similarly, the Clear All button clears all Show physics symbols
check boxes in the individual physics features.

The following symbols are available with the applicable structural mechanics feature nodes and with some other
physics interfaces (this table is a partial list of available symbols).
TABLE 3-5: PHYSICS SYMBOLS.

SYMBOL SYMBOL NAME DISPLAYED BY NODE NOTES

Added Mass1 Added Mass

Antisymmetry1 Antisymmetry

Body Load1 Body Load

3D Coordinate System Green indicates the Y direction, blue indicates the


Z direction, and red indicates the X direction.

BUILDING MODELS IN THE MODEL BUILDER | 183


TABLE 3-5: PHYSICS SYMBOLS.

SYMBOL SYMBOL NAME DISPLAYED BY NODE NOTES

2D Coordinate System Green indicates the Y direction and red indicates


the X direction.
Distributed Force Boundary Load Can be displayed together with the Distributed
Face Load Moment symbol, depending on the values given in
the node.
Edge Load
Damping1 Spring Foundation Can be displayed together with the Spring symbol,
depending on the values given in the node.
Distributed Moment1 Boundary Load Can be displayed together with the Distributed
Face Load Force symbol, depending on the values given in the
node.
Edge Load
Fixed Constraint Fixed Constraint

No Rotation1 No Rotation

Pinned1 Pinned

Point Force Point Load Can be displayed together with the Point Moment
symbol, depending on the values given in the node.
Point Mass1 Point Mass

Point Moment1 Point Load Can be displayed together with the Point Force
symbol, depending on the values given in the node.
Prescribed Prescribed Displacement
Displacement
Prescribed Velocity1 Prescribed Velocity

Prescribed Prescribed Acceleration


Acceleration1
Rigid Connector1 Rigid Connector A line is drawn to each connected boundary,

Roller Roller

Spring1 Spring Foundation Can be displayed together with the Damping


Thin Elastic Layer symbol, depending on the values given in the node.
Symmetry Symmetry

Thin-Film Damping2 Thin-Film Damping

1
Requires the Structural Mechanics Module
2 Requires the MEMS Module

ABOUT COORDINATE SYSTEMS AND PHYSICS SYMBOLS


Physics symbols connected to a node for which input can be given in different coordinate systems are shown
together with a coordinate system symbol. This symbol is either a triad or a single arrow. The triad is shown if data
are to be entered using vector components, as for a force. The single arrow is displayed when a scalar value, having
an implied direction, is given. An example of the latter case is a pressure.

In both cases, the coordinate directions describe the direction in which a positive value acts. The coordinate
direction symbols do not change with the values actually entered for the data.

184 | CHAPTER 3: BUILDING A COMSOL MULTIPHYSICS MODEL


Physics symbols are in most cases displayed even if no data values have been entered in the node.

In some cases, a single feature can display more than one symbol. An example is the Point Load node in the Beam
interface, which can display either the Point Force symbol ( ), the Point Moment symbol ( ), or both,
depending on the data entered. In those cases, no symbol is shown until nonzero data is entered.

For cases when physics symbol display is dependent on values given in the node, it can be necessary to
move to another node before the display is updated on the screen.

DISPLAYING PHYSICS SYMBOLS IN THE GRAPHICS WINDOW — AN EXAMPLE


1 Add a physics interface, for example, Solid Mechanics, from the Structural Mechanics branch.
2 In the Solid Mechanics node’s Settings window, under Physics Symbols, select the Enable physics symbols check
box and then click the Select All button.
3 Add any of the feature nodes listed in Table 3-5 to the physics interface. Availability is based on license and
physics interface.

The physics symbols also display for any multiphysics interface that includes Structural Mechanics
feature nodes or other physics feature nodes with symbols.

BUILDING MODELS IN THE MODEL BUILDER | 185


4 When adding the boundary, edge, or point (a geometric entity) to the Selection list in the feature Settings window,
the symbol displays in the Graphics window. See Figure 3-10 and Figure 3-11.

Figure 3-10: Example of Boundary Load physics symbols as displayed in the COMSOL Multiphysics model
“Deformation of a Feeder Clamp”.

Figure 3-11: Example of Roller and Boundary Load physics symbols as displayed in the COMSOL Multiphysics model
“Tapered Cantilever”.

Errors and Warnings


COMSOL Multiphysics reports problems of two types: errors and warnings.

ERRORS
Errors prevent the program from completing a task. For errors, a COMSOL Error window appears with a brief error
description and, in some cases, an Open Log File button for additional information. Under the node where the error
occurred there is, in most cases, also an Error subnode ( ) that contains an error message that generally provides

186 | CHAPTER 3: BUILDING A COMSOL MULTIPHYSICS MODEL


additional information. Also, for many error types, the icon for the node where the error occurred appears with a
red cross in the lower-right corner. For some errors there is also a link to more diagnostic information on the
COMSOL website.

LICENSE ERRORS
It is possible to open and postprocess models that include functionality that you have blocked or that your license
does not include. Nodes with functionality that requires a license for a product that is blocked or not available get
a License Error subnode ( ), where you find information about the missing but required product license. Unless
you disable or remove such nodes, it is not possible to re-solve such models.

Some specialized plot types require a license for an add-on product and are then also unavailable if you
postprocess models that include such plots and your license does not include the required product.

It is not possible to open models that require a license for the Material Library, ECAD Import Module,
CAD Import Module, LiveLink™ for MATLAB®, or any of the CAD LiveLink™ products if your license
does not include this required product.

WARNINGS
Warnings are problems that do not prevent the completion of a task but that might affect the accuracy or other
aspects of the model. Warnings typically appear in the Log window ( ). The warning message also appears as a
Warning subnode ( ) under the node from which the warning was sent.

INDICATION OF UNEXPECTED, UNKNOWN, OR INCONSISTENT UNITS


The unit display appears underlined with an orange squiggly (wavy) line for the properties in the settings for the
physics interface, physics features, and materials that have invalid or inconsistent units or a different unit than
expected.

Inconsistent Units
An inconsistent unit can occur by summing terms with units that represent different physical quantities, such as
273[K]+3[ft]. A tooltip displays a message at the corresponding field.

Unexpected Unit of Input


In the case of a valid but unexpected unit, this message contains the deduced and expected units in the current unit
system.

Unknown Unit
This message appears when a unit bracket contains invalid units.

Evaluating Unexpected or Inconsistent Units


If an unexpected or inconsistent unit appears in a text field for a physical property, the COMSOL Multiphysics
software ignores the unit and uses the numerical value, including an SI prefix if present, as the input to the model.
For example, in a text field for density using SI units, the software interprets 2930[K] as 2930 kg/m3 and
2930[mK] as 2.930 kg/m3.

SYNTAX ERRORS
A unit display or other expression that appears underlined with a red squiggly (wavy) line contains a syntax error,
which can be due to, for example, missing or misplaced parentheses or unknown or misspelled variable names,
function names, or units.

BUILDING MODELS IN THE MODEL BUILDER | 187


ERRORS AND WARNINGS IN A GEOMETRY SEQUENCE
If an error occurs when you build a node, the build stops. The node with the problem then gets an Error
subnode ( ) that contains the error message. Also, the node’s icon displays with a red cross in the lower-left
corner.

After a successful build of a node, a warning message can sometimes display as a Warning subnode ( ). If a
warning message exists, the node’s icon displays with an orange triangle in the lower-right corner.

ERROR, WARNING, AND INFORMATION NODES IN MESHING SEQUENCES


Information ( ) and Warning ( ) nodes can occur even though meshing completed successfully. They serve as
an indication that something can turn into a problem when running the solver or to get accurate result. Error nodes
( ) always indicate that an operation has failed, either for individual geometric entities or that the build failed
completely. For more information, see Information, Warning, and Error Nodes for Meshing Operations.

The Error, Warning, and Information nodes and their subnodes often contain selections that highlight
where the problem is located in the geometry.

ERRORS AND WARNINGS IN SOLVER SEQUENCES


Issues encountered when running a solver or generating a mesh are treated in two different ways depending on if
it is possible to avoid the problem and continue the operation or if the operation must be stopped. In the first case,
a Warnings node ( ) appears under the node in the model tree that caused the problem. In the second case, an
Error node ( ) appears under the node in the model tree that caused the error.

A Warnings node ( ) can also appear under a Compile Equations node if some input to the solvers uses inconsistent
units, for example.

WARNINGS DURING POSTPROCESSING


For things like empty plots, Warnings nodes ( ) can appear in the Results branch during postprocessing. However,
you do not get any warnings in these cases:

• Plotting with the Dataset list set to None or a dataset that cannot be evaluated (for example, because the model
does not contain any solution).
• Plotting without having set any expressions.

If you still have problems, contact technical support from the Support Center page at
[Link]/support.

• Using Units
• Unit Systems
• Dynamic Nodes in the Model Builder

188 | CHAPTER 3: BUILDING A COMSOL MULTIPHYSICS MODEL


M o del i ng De vel op men t Too l s
Overview
In addition to the available functionality in COMSOL Multiphysics and the add-on products included in your
license, you can add custom functionality by defining methods and settings forms and by combining them into
add-ins for general use in any model. There are also built-in tools for comparing the contents of two models. All
this functionality is available from the Developer toolbar (see Developer Toolbar). There is also an Add-in Libraries
window for adding existing add-ins to a model. See the following sections for more information:

• Creating and Running Methods in Models


• Method Calls
• Creating and Using Settings Forms and Dialogs
• Creating Add-ins
• The Add-in Libraries Window
• Comparing Models and Applications

Creating and Running Methods in Models


You can use the method editor capabilities in the Application Builder to create methods that you can run to
automate or extend operations in the Model Builder tree such as creating a geometry or running some special solver
sequence. To add a method, go to the Developer ribbon and click New Method ( ) in the Create Methods section.
In the New Method window, specify a method name in the Name field and click OK. The Application Builder then
opens, and the new model method appears under Methods ( ) in the Application Builder tree. You can then record
or write code for the method in the model editor window. See the Application Builder documentation for more
information about methods. By default, the Show in Model Builder check box is selected in the settings for the Method
node. All methods with that check box selected appear under Run Method in the Model Builder.

To run a method in the Model Builder, click Run Method ( ) in the Run Methods section and choose the method
to run. The Model Builder tree is updated according to the changes that the method includes. Click Stop ( ) to
stop a running method to debug it, for example. You can open the Debug Log window from the Windows menu to
view debug information. You can also add breakpoints for debugging purposes. You can also click Run Method Call
( ) to run a method call in a Method Call node (see Method Calls below). Method calls support input arguments
for the model methods, so that you, for example, can use two instances of the same model method with different
input values. Model methods with inputs are not available for Run Method. For methods without inputs, running a
method directly or through a method call is equivalent.

Make sure that the model tree is in a state that is compatible with the method that you run. Otherwise,
the method code may not work or may produce unexpected results. Also, there is no undo operation
after running a model method.

See the Introduction to Application Builder for an example of a model method and the Application
Builder Reference Manual for information about the Model Method node and about creating and
debugging methods in general.

MODELING DEVELOPMENT TOOLS | 189


Method Calls
You can add any available model method as a Method Call node ( ), which appears under Global Definitions. If the
Group by Type option is enabled, the Method Call nodes are grouped under the Method Calls node ( ). In the
Settings window, the model method that this Method Call node calls is listed as, for example, Model method:
modelmethod1.

At the top of the Settings window, click the Run button ( ) or press F8 to run the model method for this method
call. Click the Stop button ( ) to stop a running model method (this button is unavailable if a model method is
not running).

Click the Edit Method button ( ) to open the model method in a method editor window in the Application
Builder, where you can make changes and additions to the model method.

You can also right-click the Method Call node and choose Run (or press F8) or Edit Method .

The Method Call node’s Settings window includes the following section:

INPUTS
In this section, any inputs that you have defined for the model method appear, using the input’s description as the
label and a text field for entering a value for the input (the text field contains a default value if it has been defined
for that input). If the input is a Boolean, it appears as a check box instead. If the input is a 2D array, Array 1D
Boolean, or Array 1D String, it is shown as a table, where you can add values and add rows and columns as
applicable. Contrary to running model methods directly, method calls can use model methods with inputs defined
in the Settings window for model methods in the Application Builder. That way you can, for example, use multiple
instances of a model method with different input values.

Creating and Using Settings Forms and Dialogs


Forms that you create in the Application Builder can also be used as settings forms in the Model Builder tree that
can provide custom settings connected to methods for performing some special task in a model. Such forms become
available in the Model Builder if you select the Show in Model Builder check box. You can add them as nodes in the
Forms section of the Developer toolbar by choosing them from the Settings Form list ( ). That form is then added
as a Settings Form node under Global Definitions (or Global Definitions>Settings Forms, if Group by Type is active).

You can also show such forms as modal dialog boxes by choosing them from the Show Dialog list ( in the Forms
section of the Developer toolbar.

Forms that include Graphics objects cannot be used as settings form or dialog boxes. Instead you can
plot in the main Graphics window or in other plots windows using the built-in selectNode method or
the window property for a plot group.

To make use of the latest definition of a form in the Application Builder when it is shown in the Model Builder,
click the Update Forms button ( ) in the Forms section of the Developer toolbar, which updates all settings forms’
features. You can also click the Update button ( ) in the Settings window for a Settings Form node to update that
particular settings form.

Click the Edit Form button ( ) in the Settings window for a Settings Form node to move to its form editor window
in the Application Builder.

See the Application Builder documentation for more information about creating forms and methods.

190 | CHAPTER 3: BUILDING A COMSOL MULTIPHYSICS MODEL


Figure 3-12: An added settings form under Global Definitions provides custom settings.

Creating Add-ins
Add-ins, or add-in programs, are extensions to the COMSOL Multiphysics software and make it possible to share
methods and settings forms between several models. An add-in consists of a regular COMSOL Multiphysics
MPH-file in which you have added forms and methods using the Application Builder to provide a settings window
with some functionality that can simplify or extend the built-in functionality in the COMSOL Multiphysics software
for some application that might be useful for a range of model files. You can collect add-ins into a user-defined
add-in library (see The Add-in Libraries Window below). There is also a default user-defined add-in library located
in C:\Users\Your_Name\.comsol\v62\addins to which valid add-ins will be copied automatically when added
in the Add-in Libraries window. Opening the add-ins that are included in the COMSOL Multiphysics as MPH-files
from the file system makes it possible to study the forms and methods in the Application Builder.

See the Application Builder documentation for more information about how to create an add-in in the Application
Builder and general information about forms and methods.

Using Add-ins
To use an add-in in the current model, choose it from the Add-ins list ( ) in the Developer ribbon toolbar. The
add-in will then be added to the current model under Global Definitions. To add an add-in to the Add-ins list, select
it in the Add-in Libraries window (see below). Once the add-in is available under Global Definitions, it works like any
other node with a Settings window. Depending on its contents, it will affect the model by some functionality
contained in the add-in.

The Add-in Libraries Window


The Add-in Libraries window contains available add-ins, which you can browse and add to the Model Builder by
selecting the check box for the add-in and then click Done. This way, you enable the add-in so that it becomes
available from the Add-ins menu. When you choose the add-in from that menu, it is imported and the selected form
is added or a selected method is run. You can also make add-ins available by importing them without adding any
form or running any methods. To do so, right-click an add-in and choose Import Add-in. Imported add-ins are
also available from the Add-ins menu. If the add-in includes documentation, click the Open PDF Document
button underneath the add-in description, or right-click the add-in and choose Open PDF Document.

MODELING DEVELOPMENT TOOLS | 191


Click the Add Add-in button ( ) to open a file-browser dialog box where you can select an add-in MPH-file. The
MPH-file will then be copied to the default add-in library and will show up at the top of the tree with add-ins,
under a User-Defined Library node. The add-in node will become selected and its check box will also be selected so
that you can use the add-in right away. The selected MPH-file must be a valid add-in that has been created through
the Create Add-in button ( ) in the Application Builder.

Click the Refresh button ( ) to update the list of add-ins. You can also add separate user-defined add-in libraries
(see below).

ADD-IN LIBRARY PREFERENCES


The following settings can be modified using the buttons at the bottom of the Add-in Libraries tree on the Add-in
Libraries page under Libraries in The Preferences Dialog Box and — if the Allow managing libraries in the Add-in
Libraries window check box on that page is selected (the default) — also in the Add-in Libraries window itself.

Add User Add-in Library


Click the Add User Add-in Library button ( ) to add customized folders. In the Add User Add-in Library dialog box,
navigate to a location on your computer and select an existing directory or click Make New Folder to create a custom
folder. Click OK to save the changes and exit, or Cancel to exit without saving. The user-defined add-in library
appears alongside the built-in add-in libraries,

It is not possible to add an add-in library identical to, containing, or being contained in, an already
used add-in library.

Optionally, you can replace the standard folder icon ( ) with custom icons of your choice that reflect the content
of your library folders. To use a custom icon for a folder, create a PNG-file with an image size of 16-by-16 pixels
and save it in the folder under the name [Link].

You can enable the Open PDF Document button for a user-library add-in by placing a PDF-file with
the same name (including case, up to the file extension) as the add-in MPH-file in the same folder.

Set the COMSOL Add-in Libraries Root


Click the Set COMSOL Add-in Libraries Root Directory button ( ) to edit or set the root folder. This redirects the
COMSOL software to a different folder where customized add-ins can be stored.

In the Set COMSOL Add-in Libraries Root Directory dialog box, navigate to the new root folder location or click Make
New Folder. Click OK to save the changes and exit, or click Cancel to exit without saving.

Remove Selected Library


This button is enabled after a user add-in library folder has been created. Select a user add-in library root folder in
the Add-in libraries tree and then the click the Remove Selected ( ) button to remove the library from the tree.

Comparing Models and Applications


It can be useful to compare two versions of the same model or application to get an overview of the differences
between the two versions. To do so, click the Compare with Saved button ( ) in the Compare section of the
Developer toolbar to make a direct comparison with the latest saved version of the same model or application. You
can also click the Compare button ( ). A Select Application window then opens, where you can select the Model
MPH-file (the remote file) to which you want to compare the current model in the COMSOL Desktop (the local
file).

192 | CHAPTER 3: BUILDING A COMSOL MULTIPHYSICS MODEL


A comparison then starts, and the results, if there are any differences, appear as a tree in the Comparison Result
window. The comparison tool compares all the settings in the entire model, including visible and invisible settings
in the Model Builder and the Application Builder. For comparing versions of a model or application in the Model
Manager, see The Versions Window in this book and Comparing Models Saved in Databases in the Model Manager
Reference Manual for more information.

The comparison does not include binary data such as solutions.

THE COMPARISON RESULT WINDOW


At the top of the Comparison Result window there is a toolbar with the following buttons:

• New Comparison ( ), to make a new comparison. A New Comparison dialog box opens, where the default is that
the Use open file check box is selected. Clear it to specify another Local file. Specify a Remote file and then click
OK to perform a new comparison.
• Update ( ), to update the comparison.
• Collapse ( ) and Expand ( ), where you can click to choose Collapse Selected or Expand Selected to collapse
or expand the selected tree branches (or use the divide and multiply keypad keys, respectively), Collapse Other to
collapse all tree branches except the selected ones, or Collapse All or Expand All to collapse or expand all branches
in the comparison tree.
• Show Table View ( ), to toggle between the view with the comparisons in a tree and a view with a list of the
differences.
• Load Comparison from File ( ), to load the results from another comparison from an XML-file.
• Save Comparison to File ( ), to save the results from the current comparison to an XML-file.
• Show Next Difference ( ), to move to the next difference in the tree with nodes that differ under Differences.
• Show Previous Difference ( ), to move to the previous difference in the tree with nodes that differ under
Differences.

Under Comparing files, you find the file paths to the local model and the remote model. The local model is typically
the model open in the COMSOL Desktop, and it can have been modified after the last save. The left column is
called Local file (Saved application) when the local model is the opened model or application. When the local model
is a new model that has not yet been saved, the left column is called Open application. The right column is called
Remote file. Both columns contain a path to the selected files, unless the Local file column contains the file that is
open in the COMSOL Desktop.

If you used the Compare with Saved button to compare the current model with the latest saved version of the same
model, this section is instead called Compare with saved, and the left column and right column are called Opened
and Saved, respectively

If you compare two versions of a model or application in a database, this section is instead called Compare versions,
and the left column and right column are called Older version and Newer version , respectively.

The icons to the left of the local and remote files or older and newer files indicate the type of file. For example,
for a COMSOL MPH-file and for a runnable COMSOL application. Also, for database files in the Model
Manager, information about the time and date when the file was saved and who saved it is displayed.

Under Differences, you can use the Filter results list to control filtering with the options No filter, Exclude all matching
labels (the default), and Include only matching labels. The entries in the Regular expression field define what node
labels to filter. You can make the filtering case sensitive by selecting the Case Sensitive button ( ) box next to the
list. The filter matching is done with regular expressions, and any label that contains a matching text will be either

MODELING DEVELOPMENT TOOLS | 193


included or excluded. Filtering can be disabled by choosing No filter from the Filter results list. Click the Show Only
Active Settings button ( ) next to the list to exclude inactive settings from the comparison. Such settings are not
actively used in the current model state and do not typically appear in the COMSOL Desktop. Select or clear the
Include Only Outgoing Changes ( ), Include Only Incoming Changes ( ), and Include Only Conflicting Changes ( )
buttons as desired to change the view to include one of those types of changes. Incoming changes here are changes
that someone has made to the remote file since the last update of the local file. Such incoming changes will be
merged to the local file during an update of that file. Outgoing changes are changes that someone has made to the
local file and that has not been committed to the remote file yet. Such outgoing changes will be merged to the
remote file during a commit of the file. The categorization of incoming and outgoing changes requires version
information (available for models that use version control in the Model Manager). For models without version
information the categorization have little meaning, and they both just represent a general difference.

The tree of nodes with differences has a structure according the structure of the underlying model object, not the
Model Builder or Application Builder trees. This means that the hierarchy can be somewhat different compared to
the hierarchy seen in the Model Builder and Application Builder windows. The comparison includes all nonbinary
differences in the model object that can be saved to disk, with some exceptions. For nodes that correspond to a
node in the Model Builder or Application Builder trees, double-click the node (or right-click and choose Go to
Source) in the tree of nodes with differences to display the corresponding node in one of those trees in the local file.

Below is a list of consequences of this design:

• The tree can show differences not visible in the Model Builder because they come from inactive settings hidden
by another setting.
• Some settings and nodes in the Model Builder are not saved in the model object and will therefore not show in
a comparison (Mesh Statistics, for example).
• No binary data are compared, so, for example, no differences in the solution will trigger a difference in the
comparison.

Selecting a node in the tree will update the table under Comparing values below the tree. This table shows the
attributes of the selected node, both in the local or older model (Local value or Value in older column) and the
remote or newer model (Remote value or Value in newer column). This table is particularly interesting for the nodes
labeled Properties differ, Variables differ, or Selections differ because they show the settings where there are
differences. Parent nodes can also show the same differences but typically with a larger number of attributes that
have the same local and remote or older and newer values. For differences that contain long entries or large arrays,
there is an option to show a more detailed difference in a separate window for a selected table. Either double-click
the table row or click the Detailed Comparison of Selected Attribute button ( ) below the table to open the Compare
Attribute window. When applicable, you can also right-click a node and choose Go to Remote Source, Go to Older
Version, or Go to Newer Version to display the corresponding node in one of those trees. For nodes where values
differ, right-click and choose Go to Node in Local File, Go to Node in Remote File, Override Difference in Local File, or
Override Difference in Remote File, where you can use the last two options to discard the local changes or to transfer
them to the remote file, respectively.

COMPARING TWO SELECTED NODES


When you select two nodes with settings in the Model Builder tree or Application Builder tree, right-click and
choose Compare Selected Nodes to compare the contents of the two nodes. The comparison appears in the
Comparison Results window just like other comparisons, with similar functionality as described above.

MERGING DIFFERENCES
There are two ways to merge differences in the Comparison Results window:

• For nodes that correspond to a node in the Model Builder tree, right-click the node and choose Override
Difference in Opened ( ) to overwrite that difference in the open model. After this operation, the open model

194 | CHAPTER 3: BUILDING A COMSOL MULTIPHYSICS MODEL


will be altered so it as close as possible matches the other model. When comparing two models that both can be
altered (for example, two models saved on your file system), you can also right-click and choose Override
Difference in Remote File ( ) to overwrite the difference in the other model instead.
• When the comparison has version information (for models that use version control in the Model Manager) and
the node corresponds to the root node in the Model Builder, you can right-click and choose Merge Changes to
Opened. This operation only merges the changes that has been done in the other version after you started editing
your version. An example is when you edit a model in a Model Manager database and another user has edited
the same model after you opened your version. For this merge operation, there is only one possible target that
can be altered.

The terminology of the menu items differ between comparisons. If you compare two models, there
is a local file and a remote file, while when you compare a saved database version with the open
model there is an opened model and a saved model. The top table in the Comparison Result
window shows the terminology used for the current comparison.

Some differences can be impossible to transfer when the models differ significantly, so a setting is not applicable in
the target. For example, when a material link refers to a material that does not exist in the target. The merge is
typically most successful when there are isolated changes that do not depend on other parts of the model. If there
are large structural differences with a lot of removed and added nodes, the merge will have more difficulties to
achieve a good result. Sometimes it can be necessary to update the comparison result and do several merge
operations. Also, pay attention to cases when merging differences for nodes that are automatically generated, such
as the solver sequence. Many models have an automatically generated solver sequence that depends on settings in
the study steps and physics interfaces.

MODELING DEVELOPMENT TOOLS | 195


W ork in g w i t h N od es i n t he M o del B ui l der
This section describes how you can move, copy, paste, duplicate, disable, and enable nodes in the model tree that
describes the contents of a model in the Model Builder window. There is also information about undoing and
redoing operations in the model tree.

Moving Nodes in the Model Builder


Many of the nodes under the branches and subbranches listed in Table 3-2 can be moved around in the model tree.
To move nodes use one of these methods:

• Select one node at a time (or by Ctrl-clicking or Shift-clicking to select more than one node at a time), and use
the mouse to drop them in another applicable position in the model tree. A horizontal line indicates where in
the model tree the moved (or copied) nodes get inserted when releasing the mouse.
• Right-click the selected nodes and select Move Up ( ) or Move Down ( ). Nodes that are the first or last of
its kind can only be moved down or up, respectively.
• Use the keyboard shortcuts Ctrl+up arrow or Ctrl+down arrow to move nodes up or down.
• You can also create custom grouping of nodes to organize the nodes in the model tree. See Custom Grouping
of Nodes.

For physics interface nodes it is not possible to move the default nodes (for the default boundary
condition, for example). It is possible to create a copy of a default node, which initially has no selection.
To click-and-drag a default node creates a copy whether or not the Ctrl key is pressed.

The order of the nodes in some of the branches affects the evaluation of the sequence that they define. In the
following branches and subbranches it is possible to move nodes up and down to control the evaluation of the
sequence or the order in which they appear within the branch or subbranch (also see Table 3-2):

• Definitions: nodes can be moved relative to other nodes of the same type (functions, selections, and so on).
• Geometry: The Geometry Nodes.
• Materials: Material nodes.
• Mesh: Mesh nodes (see Meshing).
• Physics interfaces: except for the default nodes, the nodes for physics interfaces (such as material models,
boundary conditions, domains, edges, points, and sources) can be moved within the physics interface branches
(see The Physics Interfaces).
• Study: Study and study step nodes can be moved (see Study and Study Step Types).
• Results: the order of the nodes can be rearranged within each of the subbranches (Derived Values, Tables, Plot
Groups, Export, and Reports). Exceptions under the Export node are the Plot, Mesh, and Table nodes (see
Results Analysis and Plots).

Copying, Pasting, and Duplicating Nodes


It is possible to copy and paste many of the nodes in the Model Builder to create additional nodes with identical
settings or to paste it into another model and between COMSOL Desktop sessions. That is, you can paste the node

196 | CHAPTER 3: BUILDING A COMSOL MULTIPHYSICS MODEL


into a model in a new COMSOL Desktop session. Some nodes can also be duplicated underneath the original node.
You can also move, copy, and duplicate nodes using “drag-and-drop” of nodes in the Model Builder.

Duplicate ( ) is a convenient way to copy and paste in one step. In other words, it combines the Copy
and Paste functions. When nodes are duplicated, the COMSOL Multiphysics software adds identical
nodes underneath the original nodes on the same branch. You can duplicate most but not all nodes.

Nodes that can be copied and duplicated include the following:

• Functions, which are possible to copy from one Definitions or Global Definitions branch to another. Also see
Functions and Global Definitions, Geometry, Mesh, and Materials.
• Parameters, variables, variable utilities, and physics utilities. Also see Predefined and Built-In Variables, Matrices
and Matrix Operations, Variable Utilities, and Physics Utilities.
• Selections. Also see Named Selections.
• Moving Mesh and Deformed Geometry nodes. Also see Deformed Geometry and Moving Mesh.
• Coordinate systems, nonlocal couplings, and mass properties. See also Coordinate Systems and Nonlocal
Couplings and Coupling Operators.
• Probes. Also see Probes.
• Material nodes. Also see Materials.
• Nodes for lighting and hiding in the View branch. Also see User-Defined Views.
• Physics and multiphysics feature nodes, which can be copied within the same physics interface or to another
identical physics interface. You can also copy an entire physics interface to another model, for example. Also see
The Physics Interfaces.
• Geometry sequences, for which there are two ways to copy and paste geometry objects. Using the
Transforms>Copy operation (that keeps the nodes linked to one another), or a standard copy and paste (see
Copying and Pasting Geometry Objects). It is also possible to copy, paste, and duplicate nodes corresponding
to operation features, such as the Union node.
• Study steps, which are possible to copy from one Study branch to another. Also see Studies and Solvers.
• Derived value nodes. Also see Derived Values, Evaluation Groups, and Tables.
• Export nodes. Also see Exporting Data and Images.
• Views. Also see User-Defined Views.
• Pairs. Also see Identity and Contact Pairs.
• Plot nodes, which are possible to copy from one plot group to another, and their attributes (subnodes). Also see
Plot Groups and Plots.

The copied object must be pasted into a model component with the same space dimension. For
example, a Sphere can only be pasted into a 3D model.

HOW TO COPY, PASTE, OR DUPLICATE NODES


• In the Quick Access Toolbar (Windows users) or from the main Edit menu (macOS and Linux users), click
Copy ( ), Paste ( ), or Duplicate ( ).
• Right-click a node and select Copy, Paste, or Duplicate or use the keyboard shortcuts Ctrl+C, Ctrl+V, or
Ctrl+Shift+D (or the corresponding shortcuts on macOS), respectively.
• To paste a node, and after selecting Copy, click the parent node and right-click to select Paste Heat Flux to paste
a copied node (a Heat Flux node in this case) to the parent node’s branch.

WORKING WITH NODES IN THE MODEL BUILDER | 197


• Create a copy of a node by Ctrl-clicking it and dragging a copy to an applicable location. A small plus sign at the
cursor indicates that you drag a copy of the selected node.
• Ctrl-click and drag a duplicate to an applicable location. A small plus sign at the cursor indicates that you drag
duplicates of the selected nodes.

Some nodes, typically default nodes in some physics interfaces, are so-called singleton nodes; that is,
there can only be one such node in one and the same physics interface. Such nodes, for example the
Gravity node in fluid flow interfaces, when copied, are not possible to paste into the model.

Undoing and Redoing Operations


It is possible to undo (and then redo) the last operations for operations like adding, disabling, moving, and deleting
nodes in the Model Builder as well as changing values in the Settings windows. You can undo and redo several
successive operations.

To undo the last operation or redo an undone operation:

• In the Quick Access Toolbar (Windows users) or from the main Edit menu (macOS and Linux users), select or
click Undo ( ) or Redo ( ). Clicking the downward-pointing arrow next to the button displays a menu
showing each step in the available undo and redo histories, and you can choose any step to perform multiple
undo or redo steps at once.
• Press Ctrl+Z (undo) or Ctrl+Y (redo).

• Copying, Pasting, and Duplicating Nodes


• Clearing Sequences and Deleting Sequences or Nodes
• Disabling or Enabling Nodes

Going to the Source Node


In the Settings window for many nodes, other nodes can be referenced in the model tree such as a component,
solution, study or study step, or dataset, which provide data to the node where they are referenced.

Nodes where you refer to other nodes include plot groups, datasets, and solvers; in such nodes’ Settings windows,
click the Go to Source button ( ) to move to the node that the selection in the list next to the button refers to.

• Settings and Properties Windows for Feature Nodes


• Studies and Solvers
• Results Analysis and Plots

Clearing Sequences and Deleting Sequences or Nodes


You can change the contents, and actions, of the sequences in the model tree by clearing a meshing sequence or
solution under a solver configuration, or delete nodes in the Model Builder.

CLEARING OR DELETING A MESH


Use a Clear function to keep the nodes and be able to recreate the mesh by rebuilding the meshing sequence.

198 | CHAPTER 3: BUILDING A COMSOL MULTIPHYSICS MODEL


Under the Component node where you want to clear or delete the mesh:

• In the Mesh toolbar, click Clear Built Mesh ( ) or right-click the Mesh node and select Clear Built Mesh ( ).
This clears the built mesh while it keeps all nodes and settings in the sequence so that the mesh can be rebuilt.
• To delete all operations and attribute nodes in a meshing sequence, in the Mesh toolbar click Clear Sequence ( )
or right-click the Mesh node and select Clear Sequence ( ).
• If you have a component with several meshes, you can clear all built meshes at the same time, right-click the
Meshes node and select Clear Built Meshes. This clears the built meshes of the component while it keeps all nodes
and settings in the sequences so that the meshes can be rebuilt.
• To clear all built meshes in the whole model at the same time, in the Mesh toolbar, click Clear All Built Meshes
( ).This clears the built meshes of the component while it keeps all nodes and settings in the sequences so that
the meshes can be rebuilt.

CLEARING OR DELETING A SOLUTION


Use a Clear function to keep the nodes and be able to recreate the solution by computing the solution again.

• To clear a set of solutions under a specific study, from the Study toolbar, click Clear Solutions ( ) or right-click
the Study node and select Clear Solutions ( ). Clicking Clear Solutions also purges imported interpolation file
data, for example.
• To delete all solver nodes, right-click the Solver Configurations node and select Delete Configurations ( ). You
can also choose whether or not to remove the Results nodes (datasets and plots, for example) associated with the
solver configuration.
• If you have a model geometry with several studies, you can clear all solutions in all studies at the same time. From
the Study toolbar, click Clear All Solutions ( ).

DELETING NODES
• To delete selected nodes, right-click the nodes and select Delete ( ) or press Del (the Delete key). Confirm the
deletion of nodes for it to take effect. Also see Clearing or Deleting a Mesh.
• To delete all nodes in a geometry sequence, in the Geometry toolbar click Clear Sequence ( ) or right-click the
Geometry node and select Clear Sequence ( ). You cannot use the Undo command.
• To delete geometry objects or entities, in the Geometry toolbar click Delete ( ) or right-click Geometry and
select Delete ( ). Or select objects in the Graphics window, and click the Delete button ( ) in the Graphics
window toolbar.

If you use the Delete button to delete objects, the software deletes the selected objects that correspond to primitive
features by deleting their nodes from the geometry sequence. If you delete objects that do not correspond to
primitive features or if you delete geometric entities, a Delete Entities node appears in the sequence.

Disabling or Enabling Nodes


A disabled node does not take part in the evaluation of a sequence; see Figure 3-6. Some nodes, such as container
nodes and default nodes in the physics interfaces (see Physics Interface Default Nodes), cannot be disabled (or
deleted). When this is the case, the context menu does not have these options available. You can use Shift-click and
Ctrl-click to select multiple nodes that you want to delete, disable, or enable.

• To disable selected nodes, right-click and select Disable ( ) or press F3. The nodes are unavailable (dimmed)
in the model tree to indicate that they are disabled. For a geometry or meshing sequence, disabled nodes do not
affect the finalized geometry or mesh.
• To enable disabled nodes, right-click and select Enable ( ) or press F4.

WORKING WITH NODES IN THE MODEL BUILDER | 199


Instead of disabling and enabling variables and physics nodes to simulate different analysis cases (using
different boundary conditions or sources, for example), use the selection of variables and physics
interfaces in the study steps’ Physics and Variables Selection sections, or use load cases for solving cases
with varying loads or constraints. See Physics and Variables Selection and Using Load Cases.

200 | CHAPTER 3: BUILDING A COMSOL MULTIPHYSICS MODEL


M o del i ng G ui de li ne s
To model large-scale problems and for successful modeling in general, the COMSOL Multiphysics software makes
it possible to tune solver settings and to use symmetries and other model simplifications to reach a solution or —
failing that — interrupt the solution process to retrieve a partial solution. This section provides some tips and
guidelines when modeling.

Selecting Physics Interfaces


When creating a model in COMSOL Multiphysics, you can select a single physics interface that describes one type
of physics or select several physics interfaces for multiphysics modeling and coupled-field analyses.

MODELING USING A SINGLE PHYSICS INTERFACE


Most physics interfaces contain Stationary, Eigenvalue, and Time Dependent (dynamic) study types. As already
mentioned, these physics interfaces provide features and windows where you can create models using material
properties, boundary conditions, sources, initial conditions, and so on. Each physics interface comes with a
template that automatically supplies the appropriate underlying equations.

If you cannot find a physics interface that matches a given problem, try one of the interfaces for PDEs, which makes
it possible to define a custom model in general mathematical terms using equation-based modeling. Indeed, the
COMSOL Multiphysics software can model virtually any scientific phenomena or engineering problems that
originate from the laws of science.

MULTIPHYSICS MODELING USING MULTIPLE PHYSICS INTERFACES


When modeling real-world systems, you often need to include the interaction between different kinds of physics:
multiphysics. For instance, an electric current produces heat, and the properties of an electronic component such
as an inductor vary with temperature. To solve such a problem, combine two or several physics interfaces into a
single model using the program’s multiphysics capabilities. For the example just mentioned, you can use the
predefined Joule Heating multiphysics coupling, which is a combination of the Electric Currents and Heat Transfer
interfaces. This way you create a system of two PDEs with two dependent variables: V for the electric potential and
T for the temperature. There are many other predefined multiphysics couplings that combine two or more coupled
physics interfaces for common multiphysics applications. If you have added physics interfaces for which predefined
multiphysics couplings exist, they are available in the Add Multiphysics window (see The Add Multiphysics Window).

You can also combine physics interfaces and equation-based modeling for maximum flexibility.

To summarize the proposed strategy for modeling processes that involve several types of physics: Look for physics
interfaces suitable for the phenomena of interest. If you find them among the available physics interfaces, use them;
if not, add one or more interfaces for equation-based modeling.

When coupling multiple physics interfaces in a multiphysics model (without using a predefined multiphysics
interface), the couplings can occur in domains and on boundaries. The COMSOL Multiphysics software recognizes
some common multiphysics couplings, which then appear under the Multiphysics node. The program also
automatically identifies potential model inputs for quickly forming couplings between physics interfaces. For
example, a velocity field from fluid flow is a model input for convective heat transport in heat transfer. In that case,
the model input automatically transfers the velocity field from the fluid to the heat transfer part.

Multiphysics Modeling Workflow

MODELING GUIDELINES | 201


Using Symmetries
By using symmetries in a model you can reduce its size by half or more, making this an efficient tool for solving
large problems. This applies to the cases where the geometries and modeling assumptions include symmetries.

The most important types of symmetries are axial symmetry, symmetry planes or lines, and antisymmetry planes or
lines:

• Axial symmetry is common for cylindrical and similar 3D geometries. If the geometry is axisymmetric, there are
variations in the radial (r) and vertical (z) direction only and not in the angular () direction. You can then solve
a 2D problem in the rz-plane instead of the full 3D model, which can save considerable memory and
computation time. Many physics interfaces are available in axisymmetric versions and take the axial symmetry
into account. During postprocessing, you can revolve the 2D axisymmetric solution to view the results in 3D.
• Symmetry and antisymmetry planes or lines are common in both 2D and 3D models. Symmetry means that a
model is identical on either side of a dividing line or plane. For a scalar field, the normal flux is zero across the
symmetry line. In structural mechanics, the symmetry conditions are different. Antisymmetry means that the
loading of a model is oppositely balanced on either side of a dividing line or plane. For a scalar field, the
dependent variable is 0 along the antisymmetry plane or line. Structural mechanics applications have other
antisymmetry conditions. Many physics interfaces have symmetry conditions directly available as nodes that you
can add to the model tree.

To take advantage of symmetry planes and symmetry lines, all of the geometry, material properties, and boundary
conditions must be symmetric, and any loads or sources must be symmetric or antisymmetric. You can then build
a model of the symmetric portion, which can be half, a quarter, or an eighth of the full geometry, and apply the
appropriate symmetry (or antisymmetry) boundary conditions.

Effective Memory Management


Especially in 3D modeling, extensive memory usage requires some extra precautions. First, check that you have
selected an iterative linear system solver. Normally you do not need to worry about which solver to use because the
physics interface makes an appropriate default choice. In some situations, it might be necessary to make changes to
the solver settings and the model. For details about solvers, see the Studies and Solvers chapter.

ESTIMATING THE MEMORY USE FOR A MODEL


Out-of-memory messages can occur when the COMSOL Multiphysics software tries to allocate an array that does
not fit sequentially in memory. It is common that the amount of available memory seems large enough for an array,
but there might not be a contiguous block of that size due to memory fragmentation.

In estimating how much memory it takes to solve a specific model, the following factors are the most important:

• The number of node points


• The number of dependent and independent variables
• The element order
• The sparsity pattern of the system matrices. The sparsity pattern, in turn, depends on the shape of the geometry
and the mesh but also on the couplings between variables in a model. For example, an extended ellipsoid gives
sparser matrices than a sphere.

The MUMPS and PARDISO out-of-core solvers can make use of available disk space to solve large models that do
not fit in the available memory.

You can monitor the memory use in the lower-right corner of the COMSOL Desktop, where the program displays
the amount of physical memory and total virtual memory used (see Information About Memory Use).

202 | CHAPTER 3: BUILDING A COMSOL MULTIPHYSICS MODEL


CREATING A MEMORY-EFFICIENT GEOMETRY
A first step when dealing with large models is to try to reduce the model geometry as much as possible. Often you
can find symmetry planes and reduce the model to half, a quarter, or even an eighth of the original size. Memory
usage does not scale linearly but rather polynomially (Cnk, k  1), which means that the model needs less than half
the memory if you find a symmetry plane and cut the geometry size by half. Other ways to create a more
memory-efficient geometry include:

• Avoiding small geometry objects where not needed and using Bé zier curves instead of polygon chains.
• Using linear elements if possible (this is the default setting in some physics interfaces). See Selecting an Element
Type.
• Making sure that the mesh elements are of a high quality. Mesh quality is important for iterative linear system
solvers. Convergence is faster and more robust if the element quality is high.
• Avoiding geometries with sharp, narrow corners. Mesh elements get thin when they approach sharp corners,
leading to poor element quality in the adjacent regions. Sharp corners are also unphysical and can lead to very
large (even infinite, in theory) stress concentrations.

INFORMATION ABOUT MEMORY USE


In the lower-right corner of the COMSOL Desktop is information about how much memory the COMSOL
Multiphysics software is currently using. The two numbers in Figure 3-13 displayed as 1.58 GB | 2.73 GB represent
the physical memory and the virtual memory, respectively. If you position the cursor above these numbers, the
tooltip includes the numbers with the type of memory explicitly stated:

• The Physical memory number is the subset of the virtual address space used by COMSOL Multiphysics that is
physically resident; that is, it is the amount of physical memory (RAM) in “active” use.
• The Virtual memory number is the current size of the virtual address space that the COMSOL Multiphysics
software uses.

Figure 3-13: An example of memory use displayed in the COMSOL Desktop.

Selecting an Element Type


As the default element type for most physics interfaces and features, the COMSOL Multiphysics software uses
first-order or second-order Lagrange elements (shape functions). Second-order elements and other higher-order
elements add additional degrees of freedom on midpoint and interior nodes in the mesh elements. These added
degrees of freedom typically provide a more accurate solution but also require more memory due to the reduced
sparsity of the discretized system and the added number of degrees of freedom (DOFs). For many application areas,
such as stress analysis in solid mechanics, the increased accuracy of a second-order element is important because
quantities such as stresses involve space derivatives and become constant within an element when using first-order
elements.

MODELING GUIDELINES | 203


COMSOL recommends that you use the default element types. For some applications, it might be possible to use
a lower-order element than the default element type, but you must then use care to ensure that the important
quantities are resolved.

For information about editing shape functions, see Equation View.

Analyzing Model Convergence and Accuracy


It is important that the numerical model accurately captures local variations in the solution such as stress
concentrations. In some cases you can compare your results to values from handbooks, measurements, or other
sources of data. Many Application Libraries examples are benchmark models that include comparisons to
established results or analytical solutions.

If a model has not been verified by other means, a convergence test is useful for determining if the mesh density is
sufficient. Here you refine the mesh and run the study again, and then check if the solution is converging to a stable
value as the mesh is refined. If the solution changes when you refine the mesh, the solution is mesh dependent, so
the model requires a finer mesh. You can use adaptive mesh refinement, which adds mesh elements based on an
error criterion, to resolve those areas where the error is large. See the “Stresses and Strains in a Wrench” model in
the Introduction to COMSOL Multiphysics book for an example of a convergence test.

For convergence, it is important to avoid singularities in the geometry.

Avoiding Singularities and Degeneracies in the Geometry

Achieving Convergence When Solving Nonlinear Equations


Nonlinear problems are often difficult to solve. In many cases, no unique solution exists. The COMSOL
Multiphysics software uses a Newton-type iterative method to solve nonlinear systems of PDEs. This solution
method can be sensitive to the initial estimate of the solution. If the initial conditions are too far from the desired
solution, convergence might be impossible, even though convergence might be possible from another, more
suitable starting value.

You can do several things to improve the chances for finding the relevant solutions to difficult nonlinear problems:

• Provide the best possible initial values.


• Solve sequentially and iterate between single-physics equations; finish by solving the fully coupled multiphysics
problem when you have obtained better starting guesses.
• Ensure that the boundary conditions are consistent with the initial solution and that neighboring boundaries
have compatible conditions that do not create singularities.
• Refine the mesh in regions of steep gradients.
• For convection-type problems, introduce artificial diffusion to improve the numerical properties. Most physics
interfaces for modeling of fluid flow and chemical species transport provide artificial diffusion as part of the
default settings.
• Scaling can be an issue when one solution component is zero. In those cases, automatic scaling might not work.
• Turn a stationary nonlinear PDE into a time-dependent problem. Making the problem time-dependent generally
results in smoother convergence. By making sure to solve the time-dependent problem for a time span long
enough for the solution to reach a steady state, you solve the original stationary problem.

204 | CHAPTER 3: BUILDING A COMSOL MULTIPHYSICS MODEL


• Use the parametric solver and vary a material property or a PDE coefficient starting from a value that makes the
equations less nonlinear to the value at which you want to compute the solution. This way you solve a series of
increasingly difficult nonlinear problems. The solution of a slightly nonlinear problem that is easy to solve serves
as the initial value for a more difficult nonlinear problem.
• The residual operator can provide insight into the location and development of the algebraic residual in models
with convergence issues.

• Stabilization Techniques
• Convergence Plots
• Introduction to Solvers and Studies

Avoiding Strong Transients


If you start solving a time-dependent problem with initial conditions that are inconsistent, or if you use boundary
conditions or sources that switch instantaneously at a certain time, you induce strong transient signals in a system.
The time-stepping algorithm then takes very small steps to resolve the transient, and the solution time might be
very long, or the solution process might even stop. Stationary problems can run into mesh-resolution issues such
as overshooting and undershooting of the solution due to infinite flux problems.

Unless you want to know the details of the transients, start with initial conditions that lead to a consistent solution
to a stationary problem. Only then turn on the boundary values, sources, or driving fluxes over a time interval that
is realistic for your model.

In most cases, turn on your sources using a smoothed step over a finite time using a Step function node under
Definitions. What you might think of as a step function is, in real-life physics, often a little bit smoothed because of
inertia. The step or switch does not happen instantaneously. Electrical switches take milliseconds, and solid-state
switches take microseconds.

• Step
• Introduction to Solvers and Studies
• Stationary and Time Dependent

Physics-Related Checks and Guidelines


There are some important checks and guidelines that primarily apply to different areas of physics. Making these
checks ensures that the model input is sufficient and increases the chances for successful modeling. See also the
modeling sections of the documentation for the physics interfaces and the modules for more information related
to modeling different physics.

FLUID FLOW AND TRANSPORT PHENOMENA


The following checks and guidelines primarily apply to fluid flow modeling but also to modeling of other transport
phenomena:

• If none of the boundary conditions include the pressure (most outlet conditions do, however), then you should
specify the pressure at some point in the fluid domain. Without a specified pressure, the problem is
underconstrained and it is difficult to get convergence.
• Make sure that the mesh if sufficiently fine, so that it contains at least 4–6 mesh elements across the thickness of
a channel, for example.

MODELING GUIDELINES | 205


• Make sure that the boundary conditions and the initial conditions match for time-dependent problems. For
example, instead of starting with a full velocity on the wall, compared to a zero initial velocity field in the fluid,
ramp up the velocity with a smoothed step function or a ramp function that takes the inlet velocity from zero,
which matches the initial value for the velocity field, to the full velocity. See Avoiding Strong Transients.
• For fluid flow models it is important to estimate the flow regime (laminar or turbulent) using the Reynolds
number, for example. If the flow is in the turbulent regime, a turbulence model is typically required.

ACOUSTIC, STRUCTURAL, AND ELECTROMAGNETIC WAVE PROPAGATION


For models that describe wave propagation, it is important to fully resolve the wave in both time and space. In
practice that means using a maximum mesh element size that provides about 10 linear or five second-order elements
per wavelength and also, for transient simulations, a fixed time step that is small enough.

STRUCTURAL MECHANICS
The following checks and guidelines primarily apply to modeling of structural mechanics:

• Make sure that the model is fully constrained. At a minimum, you typically need to constrain the model to avoid
all rigid-body movement, which for a 3D solid mechanics model means 6 constraints for three translations and
three rotations. Otherwise, the solution is not well defined and does not converge.
The structural mechanics interfaces include a Rigid Motion Suppression feature, which eliminates all rigid-body
movement. If you do not use that feature, it is not possible to add all 6 constraints in a single point, where you
can constrain at most three translational degrees of freedom. For a 3D solid model you can use a “3–2–1
approach” to constrain 3 degrees of freedom at one point (a fixed constraint), 2 at another point, and 1 at a third
point. To do so, select three convenient points (vertices) that are well separated. Then fix the first point in all
three directions. Constrain the second point in the two directions orthogonal (normal) to the vector from point
one to point two making sure that there is no restriction to deformation along the line from point one to point
two. Finally, constrain the third point in a direction normal to the plane formed by the three points. To test this
approach, the model should expand or contract under temperature loading and have small stresses throughout
with no stress concentrations. The corresponding minimum constraints for a 2D model are a fixed constraint at
one point for the 2 translational degrees of freedom and an additional constraint in one direction at another point
to constrain the single rotational degree of freedom.
• Consider if you can assume that the material is linear elastic and that the deformations are small. If not, consider
using a nonlinear material model.
• Avoid sharp corners in the geometry, which are unphysical and lead to unbounded stress concentrations.

Results With Unphysical Values

WHERE AND WHY DO UNPHYSICAL VALUES APPEAR?


In some models small unphysical values can occur due to numerical artifacts or other model-related reasons.
Examples include:

• Negative concentrations in mass transfer.


• A temperature that is slightly higher than the initial condition in time-dependent heat transfer studies.
• Small reaction forces that appear in unloaded directions in structural mechanics models.
• Small negative gaps in a contact analysis.
• Small negative effective plastic strain values.
• Stresses above the yield limit for an ideally plastic material in solid mechanics.

206 | CHAPTER 3: BUILDING A COMSOL MULTIPHYSICS MODEL


Some reasons for why these unphysical values occur:

• Numerical noise is a common cause. When the values of the dependent variables approach zero, the numerical
noise can become relatively significant and cause some of the results to be slightly negative even if that is not
physically possible.
• Interpolation and extrapolation of values can cause some values to become unphysical. Take care when using
interpolated data or a piecewise polynomial function to define a temperature-dependent material property, for
example. If you allow extrapolation outside of the defined range of input values, the material property values may
not be valid. Also, results for an elastoplastic material are correct (within some tolerance) at the integration points
(Gauss points) inside the finite elements, but values might become unphysical when extrapolating the data to the
element boundaries.

The Plasticity feature is available as a subnode to a Linear Elastic Material with the Nonlinear
Structural Materials Module.

• Discontinuities in the model is another source of, for example, small negative concentrations due to a
discontinuous initial value. With an initial value that is zero along a boundary for convective transport models,
for example, the physical interpretation is an initially sharp, gradually diffusing front moving away from the
boundary. However, for the default shape function (second-order Lagrange elements), only continuous
functions are admissible as solutions. COMSOL then modifies the discontinuous initial value before the time
stepping can begin. This often results in a small dip in the solution at the start time. In the example model that
the following figure shows, the concentration is locally slightly negative at t  0:

• Lack of mesh resolution is another cause of unphysical values such as negative concentrations. The resulting
convergence problems are often the underlying issue when negative concentrations are observed in high
convection regimes (high Peclet number) and in those with large reaction terms or fast kinetics (high Damkö hler
number).
• Incorrect physics in the model can also cause these types of problems. For mass transfer, for example, the use of
a constant sink in a reaction term is an approximation that only works for large concentrations. When the
concentration reaches zero, the reaction term continues to consume the species, finally resulting in a negative
concentration.

MODELING GUIDELINES | 207


AVOIDING UNPHYSICAL VALUES
This section contains some ways to avoid computing or displaying unphysical values:

• In some cases it is possible to add a baseline to the dependent variable so that the numerical noise does not affect
the solution in the same way as when the values of the dependent variable approach zero. This scaling is not
possible with, for example, a reaction term that depends on the concentration because then the scale and origin
do matter.
• Avoid discontinuities in the model using, for example, smoothed step functions.
• Formulate logarithmic variables as a way of eliminating mesh resolution problems and negative dips using the
logarithm of the original dependent variable (the concentration, for example) as the dependent variable. The
reason for this is that a linearly varying mesh sometimes does not capture the exponential behavior of the changes
in the dependent variable. Modeling the logarithm of the dependent variable also ensures that the real
concentration, for example, cannot become negative during the solution process.
• Avoid displaying small unphysical values due to numerical noise by clipping the values for the plot. You can do
this by plotting, for example, c*(c>0) instead of c, which evaluates to 0 everywhere where c is smaller than 0.
You can also adjust the range of the plot data and colors to only show nonnegative values. Parts of the plots where
values are outside the range then become empty.
• It can also be useful to check how the mesh affects the solution by refining the mesh and checking if the problem
with unphysical values gets better or worse. If it gets better, then continue to refine the mesh. If it gets worse,
you probably need to check the physics of the model.

208 | CHAPTER 3: BUILDING A COMSOL MULTIPHYSICS MODEL


M u lt i ph ys i cs M od el in g W orkf l ow
The ability to create multiphysics models — those with more than one type of physics or equation such as
coupled-field problems — is one of the most powerful capabilities of COMSOL Multiphysics. In such models, the
software can solve all the equations, taken from various areas of physics, as one fully coupled system.

Within the COMSOL software you can choose from several ways to work with multiphysics modeling and
coupled-field analysis, including predefined multiphysics interfaces, predefined multiphysics couplings, and setting
up user-defined multiphysics couplings using model inputs or expressions that include dependent variables or other
expressions from another physics interface.

In this section:

• Creating a Multiphysics Model


• Advantages of Using the Predefined Multiphysics Interfaces
• The Add Multiphysics Window
• The Multiphysics Branch
• Uncoupling a Multiphysics Coupling
• Model Inputs and Multiphysics Couplings

Creating a Multiphysics Model


There are two ways to create and use the available predefined multiphysics couplings: using Predefined Multiphysics
Interfaces or Adding Predefined Multiphysics Couplings to Physics Interfaces using The Add Multiphysics Window
or in The Multiphysics Branch. You can also create multiphysics couplings, in the physics interface settings, using
a model input or by directly typing an expression using a dependent variable from another physics interface, for
example (see Specifying Equation Coefficients and Material Properties for information about what you can include
in such expressions).

PREDEFINED MULTIPHYSICS INTERFACES


The Joule Heating Interface is an example of a predefined multiphysics interface. Many other multiphysics
interfaces are available depending on the products included in your COMSOL license. After Joule Heating is selected
from The Model Wizard, the Heat Transfer in Solids interface, the Electric Currents interface, and a Multiphysics node,
including the default feature applicable to the multiphysics coupling (Electromagnetic Heating), are displayed under
the Added physics interfaces list as in Figure 3-14. Figure 3-15 shows you what is included in the Model Builder
when a predefined multiphysics interface is added. Compare to Figure 3-16 where individual physics interfaces are
added, and these features are initially accessible only from the context menu. There can also be moving mesh nodes
added as part of a multiphysics interface; they then appear under Definitions in the Added physics interfaces list.

You can add physics interfaces when you start creating the model with The Model Wizard or at any
time with The Add Physics Window.

Figure 3-14: When Joule Heating is selected in the Model Wizard, the default physics interfaces and coupling feature
are displayed under Added physics interfaces.

MULTIPHYSICS MODELING WORKFLOW | 209


Figure 3-15: An example of what is added to the Model Builder when Joule Heating is selected in the Model Wizard.
The Electromagnetic Heating feature is automatically included under the Multiphysics node.

ADDING PREDEFINED MULTIPHYSICS COUPLINGS TO PHYSICS INTERFACES


An empty Multiphysics node is added automatically when two (or more) physics interfaces are set up in a model and
when there is the possibility to couple the physics interfaces. In other words, if you add physics interfaces one at a
time, and the software identifies these physics interfaces as being of the multiphysics category, the Multiphysics node
is automatically added to the Model Builder. The relevant predefined multiphysics coupling features are then
available from the context menu (right-click the Multiphysics node) as well as from the Physics toolbar, in the
Multiphysics menu. See Figure 3-16. You can also add predefined multiphysics couplings from the Add Multiphysics
window (see The Add Multiphysics Window), which then adds all necessary multiphysics coupling nodes under the
Multiphysics node. Using a workflow where you add physics interfaces and multiphysics couplings manually makes
it possible to analyze and validate one physics at the time before solving the full multiphysics model.

Figure 3-16: An example of when a Multiphysics node is automatically added to the model. The specific multiphysics
features are made available from the context menu (left) or (partially shown here) Physics toolbar, Multiphysics menu
(right) based on the physics interfaces in the model. The difference when the predefined Joule Heating interface is added
is that these features are included under Multiphysics and there are some modified settings automatically applied. In
either case, the available features depend on the COMSOL products that the license includes.

210 | CHAPTER 3: BUILDING A COMSOL MULTIPHYSICS MODEL


Advantages of Using the Predefined Multiphysics Interfaces
One advantage of using the predefined multiphysics interfaces is that specific or modified settings are included with
the physics interfaces and the multiphysics coupling features. If physics interfaces are added one at a time, followed
by the predefined multiphysics coupling features, these modified settings are not automatically included.

For example, if you add single Electric Currents and Heat Transfer in Solids interfaces to the Model Builder, the
COMSOL Multiphysics software adds an empty Multiphysics node. The applicable multiphysics couplings are then
available as subnodes that you can add. If you instead choose the predefined Joule Heating multiphysics coupling,
for example, which then adds the Electromagnetic Heating node under the Multiphysics node, so that you do not
need to remember which multiphysics coupling nodes to add for a specific type of multiphysics. See The Add
Multiphysics Window.

In general, it is useful to use any type of multiphysics coupling because you can turn multiphysics on and off (that
is, enable and disable features), giving you more flexibility to test and observe multiphysics effects.

Even if you do not start with a predefined coupling, another benefit of this approach is that you are no longer
constrained by the use of specific physics interfaces, nor do these have to be added in any specific order. The order
in which physics interfaces are added does not matter for the end result.

An example of this is if you start modeling by adding a Heat Transfer in Solids interface. As you continue to build
the model, you add an Electric Currents interface. At this stage of the process, you may have defined several
boundary conditions, chosen materials, or experimented with other settings. You may have also solved the model
successfully at this point and now you want to continue building on this design. The COMSOL Multiphysics
software recognizes this and adds a Multiphysics node, which you can right-click to access and add any of the
available predefined multiphysics couplings.

For multiphysics interfaces that consist of participating physics interfaces, the default solver settings use a segregated
solver approach with one segregated step for each physics interface and each of these steps calling an iterative solver.
These solver settings are suitable for large models, but if possible, a fully-coupled solver approach using direct
solvers can be more robust. You can switch to such solver settings by right-clicking the Study node and choosing
Show Default Solver. Then the solver nodes that the predefined multiphysics interface specifies appear under the
Solver Configuration node, and you can right-click the solver node to add a Fully Coupled solver node to replace the
Segregated node, for example.

For some multiphysics interfaces, a side effect of adding physics interfaces one at a time is that two
study types — Frequency-Stationary and Frequency-Transient — are not available for selection until
after at least one coupling feature is added. In this case, it is better to first add an Empty Study, then
add the coupling features to the Multiphysics node, and lastly, right-click the Study node to add the
study steps as needed.

The Add Multiphysics Window


The Model Wizard and the Add Physics window contain predefined multiphysics interfaces, which typically add two
or more physics interfaces and some predefined multiphysics coupling features that define the multiphysics
couplings between those physics interfaces. When building a model, it can sometimes be useful to start with a single
physics before adding other physics and the multiphysics couplings that connect them. To add any applicable
predefined multiphysics coupling in a model, open the Add Multiphysics window ( ) by right-clicking a Component
node or from the Physics ribbon toolbar. The predefined coupled multiphysics couplings that the selected physics
interfaces support then appear in the tree. Choose the wanted multiphysics couplings and add them to the
component under Multiphysics by pressing Enter, clicking the Add to Component button ( ), or right-clicking a
multiphysics coupling and choosing Add to Component. The required multiphysics coupling nodes are then added

MULTIPHYSICS MODELING WORKFLOW | 211


to the model, and the participating physics interfaces are modified by setting the correct physics property values
and adding any needed features for the selected multiphysics couplings.

You control which multiphysics couplings that appear using the settings under Select the physics interfaces you want
to couple. You can clear and select all physics interfaces in the current component. By default, all physics interfaces
are selected and appear with a check mark ( ) in the Couple column. The available multiphysics couplings depend
on which COMSOL Multiphysics products your license includes. If no multiphysics coupling is available, No
Coupling Features Available for the Selected Physics Interfaces appears. You must select at least two physics interfaces
for any multiphysics couplings to appear. With more than two physics interfaces in the component, any combination
of two or sometimes more physics interfaces typically results in a different set of available multiphysics couplings,
whereas most combinations of three or more physics interfaces result in no available multiphysics couplings.

The existing Studies are listed under Multiphysics couplings in study. By default, the studies appear with a check
mark ( ) in the Solve column, which indicates that the study solves for the equations that the multiphysics
couplings add. Click in the column to clear the check mark and exclude the equations in the multiphysics coupling
from that study. Some multiphysics couplings do not add any extra equations and are then not affected by this
setting.

The Multiphysics Branch


The Multiphysics branch ( ) contains, or has available, any predefined multiphysics coupling features that are
likely to be used as multiphysics couplings for a particular set of physics interfaces added to the Model Builder. See
Figure 3-16. There are no settings required for the node itself.

Predefined multiphysics interfaces provide you with a quick entry point for common multiphysics applications. You
can create the same multiphysics couplings using any of the other methods for multiphysics modeling, and you can
continue to add, modify, disable, and remove physics features or interfaces in a model when you start using one of
the predefined multiphysics interfaces. If you instead decide to add physics interfaces one by one, you can verify
that each type of physics or equation gives the expected results before adding more complexity to the model by
adding another physics interface, physics feature, or multiphysics coupling.

For links to more information about the add-on modules and the multiphysics interfaces available go
to [Link]/comsol-multiphysics.

Uncoupling a Multiphysics Coupling

Figure 3-17: Uncoupling a predefined multiphysics coupling feature.

For each multiphysics coupling feature (for example, Electromagnetic Heating), there is a section that defines the
physics interfaces involved in the multiphysics coupling. By default, the applicable physics interfaces are selected in
the lists to establish the coupling.

You can also select None from the lists to uncouple the node from a physics interface. If the physics interface is
removed from the Model Builder (for example, if a Heat Transfer in Solids interface is deleted), then the Heat transfer

212 | CHAPTER 3: BUILDING A COMSOL MULTIPHYSICS MODEL


list for the Electromagnetic Heating reverts to None (Figure 3-17) as there is no heat transfer interface to couple to.
To avoid that the multiphysics coupling is turned off unintentionally, a warning A coupled physics is set to 'None'
tooltip appears when you change a list under Coupled Interfaces to None.

Figure 3-18: A warning tooltip appears when a multiphysics coupling is turned off.

If a physics interface is deleted and then added to the model again, and in order to reestablish the
coupling, you need to choose the physics interface again from the lists. This is applicable to all
multiphysics coupling nodes that would normally default to the once present physics interface.

Model Inputs and Multiphysics Couplings


Model inputs can appear in an equation or material model node’s Model Inputs section. Model inputs are typically
fields such as temperature and velocities that act as inputs for material models and model equations, but they can
be any available physical property. They appear in the Model Inputs section if a material is defined so that a material
property becomes a function of the temperature, for example. The COMSOL Multiphysics software connects the
model input to an existing field (dependent variable) within the physics interface (but not to available fields in other
physics interfaces). Default model inputs are always available. You can define scalar values for default model inputs
under Global Definitions for use throughout the model (see Default Model Inputs).

For frequently used multiphysics couplings, predefined multiphysics coupling nodes are available under the
Multiphysics node (see The Multiphysics Branch). The following part of this section is mostly useful for cases when
such predefined couplings are not available.

With more than one physics interface in the model, coupling of the fields is easy: all applicable fields that can serve
as inputs in another physics interface automatically appear in the other physics interface’s Settings window’s Model
Inputs section. For example, with a Heat Transfer in Fluids (ht) interface and a Laminar Flow (spf) interface, you
can select Velocity field (spf), which the Fluid Properties 1 {fp1} node in the Laminar Flow branch defines, from the
Velocity field list in the Model Inputs section of the Settings window for the Fluid node under Heat Transfer in Fluids.
The velocity field from the Laminar Flow interface then becomes the velocity field for the convective heat transfer.
You can also choose Common model input to use its value to define the velocity field, or choose User defined to enter
a user-defined velocity field.

When you have selected a model input from one of the lists, click the Go to Source button ( ) next to the list to
move directly to the node in the other physics interface that provides the model input. If more than one node
contribute to the model input, choose which one to go to in the Contributing Entities dialog box. Then click OK to
move to the selected node.

You can also, if you have selected Common model input, click the Create Model Input button ( ) to create a local
Model Input node in the current component (see Model Input) for defining a model input for some or all of the
geometry in the current component, overriding the default model input.

By default, the Model Input section in the Fluid Properties node under the Laminar Flow node is empty. But if you,
for example, add a temperature-dependent material property such as the dynamic viscosity, a Temperature list
appears in the Model Input section where you can explicitly choose the Temperature (ht) field or use a user-defined
temperature or a Common model input like any other model input.

A list in the Model Inputs section becomes unavailable if the physics itself defines the field because it is then
automatically connected to that field. For example, with a Heat Transfer in Fluids (ht) interface the Temperature
list is unavailable in the Fluid node under Heat Transfer in Fluids. This automatic connection selects the

MULTIPHYSICS MODELING WORKFLOW | 213


Temperature (ht) field. As long as the list is unavailable, you cannot change it. If you want to use another
temperature field or an expression, you first make the list editable by clicking the Make All Model Inputs Editable
button ( ). Using this option can be useful in order to, perhaps temporarily, break a multiphysics coupling and
use a user-defined value instead to, for example, investigate a simulation that does not converge.

For this type of fluid-thermal coupling, the Multiphysics branch provides a predefined Nonisothermal
Flow node, which provides an easy way to set up this coupling without having to explicitly specify the
model input.

See Joule Heating of a Microactuator for an example of combining the Electric Currents and Heat
Transfer in Solids interfaces through a Joule Heating multiphysics interface (Application Library path
COMSOL_Multiphysics/Multiphysics/thermal_actuator_jh).

214 | CHAPTER 3: BUILDING A COMSOL MULTIPHYSICS MODEL


Spe ci fy in g M od el Eq uat i on Set t i ngs
The fundamental mathematical model, representing the physics in a physics interface, is contained in physics nodes
with selection on the same space dimension as the physics itself. The first node under a physics branch is of this type
and sets up default equations where the physics interface is active. These equations are controlled by specifying:

• Material properties, which COMSOL Multiphysics uses as coefficients in the equations


• A coordinate system, which makes it possible to specify anisotropic material properties and vectors in a more
convenient coordinate system than the global Cartesian coordinate system.
• A material model (a mathematical model for a constitutive relation, for example), which selects an equation
suitable for a given type of material

Not all physics features allow anisotropic materials or more than one material model. Therefore, these
settings cannot be present.

The default node uses the same material model, and thus the same equations, everywhere. Material properties can
vary between different parts of the feature’s selection, if the property is specified as taken From material. Add
additional nodes to use different material models for different parts of the geometry, or to use different User defined
material property values.

In equation-based modeling, provided by the Mathematics branch interfaces, the form of the equation is fixed for
each particular node type. Each given equation form contains a number of free PDE coefficients, which you can be
specify in the settings to define the specific equation that you want to solve.

Equation-Based Modeling

Specifying Equation Coefficients and Material Properties


To specify an equation coefficient or a material property, enter a value or an expression directly in the corresponding
field. The expressions in those fields are interpreted, providing the possibility to enter expressions that include
variables and coordinates in addition to constants and numerical values. Such expressions can contain:

• Numerical values.
• Units (see Using Units).
• Built-in Mathematical and Numerical Constants.
• Spatial coordinates, time, and the dependent variables in any physics feature in the model as well as the spatial
derivatives and time derivatives. Using such variables makes it possible to create user-defined multiphysics
couplings.
• Physical Constants — built-in universal physical constants.
• User-defined parameters, variables, coupling operators, and functions, including external functions and
MATLAB® functions (requires the COMSOL LiveLink™ for MATLAB®). See Operators, Functions, and
Constants.
• Built-in functions and operators such as d and mean.

You can use these types of variables, constants, functions, and operators in all settings for the physics interfaces;
many types of variables are also available anywhere in the model.

SPECIFYING MODEL EQUATION SETTINGS | 215


In most cases where you can enter an expression, you can press Ctrl+Space 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.

Modeling Anisotropic Materials


Anisotropic materials respond differently to an excitation depending on its direction. Because excitations are
generally vectors and the corresponding response is a vector density, material properties are usually rank-2 tensor
densities. For example, the following material properties are anisotropic tensor densities: diffusion coefficient,
permittivity, thermal conductivity, and electrical conductivity.

These properties are, in principle, specified in matrix form and defined by their components in the coordinate
system selected in the node settings. At most four components are used in 2D and at most nine components in 3D.
When the material contains symmetries, you can specify only a few coefficients, which are expanded to a matrix
using the following patterns:

• Isotropic (the default) — enter only one value c.

c 00
C = 0 c 0
0 0 c

• Diagonal — enter the diagonal components for an anisotropic material with the main axes aligned with the
model’s coordinate system.

c 11 0 0
C = 0 c 22 0
0 0 c 33

• Symmetric — enter a symmetric matrix using the diagonal components and the upper off-diagonal components.

c 11 c 12 c 13
C = c 12 c 22 c 23
c 13 c 23 c 33

• Full — enter the full 2-by-2 (2D) or 3-by-3 (3D) matrix for an anisotropic material:

c 11 c 12 c 13
C = c 21 c 22 c 23
c 31 c 32 c 33

Specifying Initial Values


An Initial Values node is added by default to each physics interface.

In some types of analyses initial values must be provided:

• As the initial condition for a time-dependent analysis.


• As an initial guess for the nonlinear stationary solver.
• As a linearization (equilibrium) point when solving a linearized stationary model or when performing an
eigenvalue study.

216 | CHAPTER 3: BUILDING A COMSOL MULTIPHYSICS MODEL


To enter initial values, in the Model Builder, click the Initial Values node under a physics interface node. In the Settings
window, enter the Initial Values for all dependent variables (fields) in the physics interface. The default initial values
are usually zero.

For some physics interfaces you can also enter initial values for the first time derivative of the dependent variables.
These are used when solving time-dependent problems containing second time derivatives (wave-type
applications). Like other default settings, these initial values apply to all domains where no other values are specified.

To use different initial values in different domains, add another Initial Values node from the Physics ribbon toolbar
(Windows users), Physics context menu (macOS or Linux users), or right-click to access the context menu (all
users).

See Dependent Variables for more information about handling and plotting initial values.

Equation View
Equation View ( ) is a subnode available for all physics feature nodes. To display these subnodes, click the Show
More Options button ( ) and select Equation View from the Show More Options dialog box.

The Settings window for Equation View contains detailed information about the implementation of each physics
feature: variables, shape functions, weak-form equation expressions, and constraints.

To update the values in the Settings window for Equation View to reflect the latest changes in a physics feature, click
the Refresh Equations button ( ) in the Settings window’s toolbar.

Editing the predefined expressions for variables, equations, and constraints means that the equations
are altered and that COMSOL Multiphysics solves the model using the new expressions.

You can edit the expressions or values of variables, weak-form expressions, and constraints in the corresponding
tables under Variables, Weak Expressions, and Constraints, respectively. This makes it possible to introduce custom
changes to the equations and variable definitions. If the expression that defines a variable, for example, does not fit
inside of the text field, a tooltip displays the entire expression. Press Ctrl+Space or use the Insert Expression button
( ) below the tables 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. In the table of variables under
Variables, you can click any of the column headers to sort the table contents alphabetically based on the contents
of that column (in ascending order; click again for descending order; click yet again to restore the original order).

For a changed definition of a variable or a change to a weak-form expression or constraint, a warning icon ( )
appears in the leftmost column, and a small padlock is added to the lower-right corner of the icon for the physics
node where you have made modifications in its equation view. To restore only the change in the selected variable,
weak-form expression, or constraint, click the Reset Selected button ( ) under the table in the Variables, Weak
Expression, or Constraints section. To reset all changes in the equation view, click the Reset All button ( ) in the
Settings window’s toolbar. If no changes remain, the padlock disappears from the corresponding physics node. An
orange color for the expression that defines the variable is a warning that the unit of the expression does not match
the expected unit for the variable that it defines. To store all information in the tables under Variables, Shape
Functions, Weak Expressions, or Constraints to a text file, click the corresponding Save to File button ( ).

For information about the Equation displays available, see Physics Nodes — Equation Section.

SPECIFYING MODEL EQUATION SETTINGS | 217


STUDY
From the Show equation view assuming list, choose No study or any of the available studies. The equation view of
the parent feature is then recomputed with the assumption that the selected study step was solved. This operation
also updates all children to the parent feature, so the lists in their equation views are also updated. When solving a
study (or study step), the list also changes to represent the last computed study step. The default is No study and
represents a default behavior, which computes the equations without any study type information. The equation
form used is then undefined and depends on the physics that the parent feature belongs to. The equation view
reverts to No study if you change some setting in the parent feature to indicate that the equation view no longer
represent a specific study step.

VARIABLES
This section has a table with the variables that the physics node defines. The table includes these columns:

• Name: the name of the variable.


• Expression: the expression, using COMSOL syntax, that defines the variable.
• Unit: the unit for the variable (in the active unit system). If the unit of the expression does not match the unit of
the variable, the expression is displayed in orange.
• Description: a description of the variable.
• Selection: the geometric entities (domains, boundaries, edges, or points) where the variable is defined (Domain 1,
for example).
• Details: this column contains some details about the variable’s behavior. See About the Details Column below.

If you click a single variable, its selection, as indicated in the Selection column, appears in the Graphics
window.

SHAPE FUNCTIONS
This section has a table with the dependent variables that the physics node defines and their shape functions. This
is primarily applicable to equation model nodes; for most physics nodes such as boundary conditions, the table is
empty. The table has these columns:

• Name: the name of the variable.


• Shape function: the type of shape function (element) for the variable (for example, Lagrange for Lagrange
elements, which are the most common elements).

Selecting an Element Type

• Unit: the unit for the variable (in the active unit system).
• Description: a description of the variable.
• Shape frame: the frame type (typically either a spatial or a material frame) for the shape function.
• Selection: the geometric entities (domains, boundaries, edges, or points) where the shape function is defined
(Domain 1, for example).
• Details: This column contains some details about the shape function’s behavior. See About the Details Column
below.

218 | CHAPTER 3: BUILDING A COMSOL MULTIPHYSICS MODEL


WEAK EXPRESSIONS
This section has a table with the weak-formulation equation contributions that the physics node generates. The
table consist of the following columns:

• Weak expression, the equation expressed in a weak formulation. It is possible to modify these expressions, but
you then override the equation as specified by the physics interface, and a warning appears in the leftmost column
of the table.
• Integration order, the order for the integration of the weak expression (see integration order in the Glossary).
Polynomials of at most the given integration order are integrated without systematic errors. For smooth
expressions, a sufficient integration order is typically twice the order of the shape function. For example, the
default integration order for second-order Lagrange elements is 4. You can modify the integration order if
desired. A warning then appears in the leftmost column of the table to indicate that the predefined order has
been changed.

See the following blog post for information about modifying the integration order:
[Link]/blogs/introduction-to-numerical-integration-and-gauss-points/

• Frame, the frame type (typically either a spatial or a material frame) used when integrating the expression.
• Selection: the geometric entities (domains, boundaries, edges, or points) where the weak expression is defined
(Domain 1, for example).

Each equation contribution appears on its own row under Weak expression, but the order is not significant.

The PDE interfaces and the ODEs and DAEs interfaces do not display any weak expressions. They are
either implemented using strong formulations, directly display the weak formulation, or define
equations discretized in the time domain only.

CONSTRAINTS
This section has a table with the constraints that the physics node generates. This is typically the case for boundary
conditions of constraint types, such as prescribed displacements, temperature, or velocities. Many other physics
nodes do not generate any constraints, and the table is then empty. The table consists of the following columns:

• Constraint: the expression for the constraint.


• Constraint force: the expression that defines the associated constraint force, which is typically the test function of
the constraint.
• Shape function: the type of shape function (element) for the constraint (for example, Lagrange for Lagrange
elements).
• Selection: the geometric entities (domains, boundaries, edges, or points) where the constraint is defined
(Boundaries 1–5, for example).

ABOUT THE DETAILS COLUMN


The Details column shows some information about the behavior of variables and shape functions. For variables:

• An empty cell indicates that overlapping contributions are overridden.


• + operation indicates that overlapping contributions are added.
• For some variables, Meta indicates that the variable definitions are not fully updated until you solve the model.
It is therefore not possible to edit the expressions for such variables.
• In rare cases, other operations (* operation, for example) can occur.

SPECIFYING MODEL EQUATION SETTINGS | 219


For shape functions:

• Slit means that the shape function creates a slit for the degree of freedom.

Physics Nodes — Equation Section


For each physics node there is an Equation section that is available by default in the Settings window. This section
has options to display mathematical equations applicable to the node.

If you do not want to display the Equation section, click the Show More Options button ( ) and clear
the Equation Sections check box in the Show More Options dialog box.

Equation View

The display options available from the lists depend on the study types and other physics-specific factors. See
Figure 3-20 for an example comparing the equations that display for a Stationary or Time Dependent study for a Heat
Transfer in Solids interface. Some Settings windows do not have any options and only display the relevant equation
and other windows have additional sections that become available for the Equation display based on the study type
selected.

Study and Study Step Types

Node Contributions Display a Dotted Line Under Part of the Equation


For all physics nodes (excluding the main physics interface node level), the equation that displays includes a dotted
line underneath where the node’s contribution is made to the equation. See Figure 3-19 for an example where a
section of the heat transfer equation is underlined, indicating where the Solid node contributes to it.

Figure 3-19: The Solid contribution to the equation for a 2D model.

Equation Form
When you add physics interfaces to a Component, the supported Study types are listed in the Equation form list.
Study controlled is the default; select another option as needed. When the setting is Study controlled, the study
controls the equation form — stationary or time dependent, for example — for the physics interface. In some cases,
that equation form might not be compatible with the physics covered by the physics interface; the physics interface

220 | CHAPTER 3: BUILDING A COMSOL MULTIPHYSICS MODEL


then uses its default equation form (typically, a stationary equation form). You can then instead choose one of the
supported study types.

Show Equation Assuming


The Show equation assuming option is available by default when Study controlled is selected (or left as the default)
as the Equation form. Options availability is based on the studies added and defined for the model.

For the following options — frequency and mode analysis frequency — you also have the option to use another
frequency than the one used by the solver. This can be necessary if you need two different frequencies for two
physics interfaces.

Frequency
This option is available if Frequency domain is selected as the Equation form. The default uses the frequency From
solver. If User defined is selected, enter another value or expression (SI unit: Hz).

Mode Analysis Frequency


This option is available if Mode Analysis or Boundary Mode Analysis is selected as the Equation Form. Enter a value or
expression in the field (SI unit: Hz). Specify a frequency (it is not present as a solver variable).

Port Name
This option is available with the RF Module Electromagnetic Waves interface and if Boundary Mode Analysis is selected
as the Equation Form. Enter a value in the field (unitless).

Figure 3-20: An example of the Equation section on a Heat Transfer interface. Selecting the study type updates the
equation accordingly.

SPECIFYING MODEL EQUATION SETTINGS | 221


B ou nda r y C ond i ti on s
In the interior of the selection where a physics feature is active, its behavior is governed by its model equations and
material properties. Boundary conditions apply to the geometric entities separating this region from the
unspecified outside and sometimes also to interior entities of the same dimension (interface conditions). Therefore,
boundary conditions on a 3D solid object apply to the exterior surfaces of the solid and to interior surfaces
embedded in the solid. On a shell geometry in 3D space, boundary conditions instead apply to the edges of the
shell surface. In general, boundary conditions apply to geometric entities whose dimension is one less than the
physics interface’s dimension.

All physics interface branches that contain a default model equation node also contain a default boundary condition
node. This boundary condition is active on all exterior boundaries of the physics’ selection, except on the symmetry
axis of axisymmetric 2D models. On interior boundaries, an implicit continuity condition applies, which makes the
physics field (the temperature, for example) continuous across interior boundaries.

In physics interfaces defined on shells, for example, the domain equations are defined on 3D
boundaries, and you define the interface conditions on edges as edge conditions rather than boundary
conditions.

Boundary Condition Types


There are two fundamental ways to specify what is happening at a boundary, and two corresponding fundamental
boundary condition types:

• Flux conditions specify how the surroundings affect and interact with the model at the boundary, often
expressed as an applied force, flux, or current. This type of boundary condition is also called a Neumann
boundary condition.
• Constraints specify the result of the interaction between the model and its surroundings, expressed as prescribed
values of the dependent variables. This type of boundary condition is also called a Dirichlet boundary condition.

The two types are closely related because in a well-posed model, every flux condition results in some unique values
of the dependent variables, and every constraint requires a unique flux to enforce the expected values. Which type
of condition to use depends on what is known about the conditions at the boundary: if the flux is known, the model
computes the dependent variables for you; if the values of the dependent variables are known, the model computes
the flux.

FLUX CONDITIONS
Flux boundary conditions specify the component of a vector or tensor quantity in the direction normal to the
boundary, per unit area of the boundary. Typical examples of flux conditions are the specification of:

• A Boundary Load in a solid model, which prescribes the stress acting on the boundary.
• Heat Flux in a heat transfer model, which prescribes the heat per unit area flowing into (or out of) the model
across the boundary.
• A Normal Current Density in an AC/DC model, which prescribes the electrical current per unit area entering
(or exiting) the model at the boundary.

222 | CHAPTER 3: BUILDING A COMSOL MULTIPHYSICS MODEL


There are also more advanced types of flux conditions, where the flux or force is calculated based on local values of
dependent variables and other parameters. For example, a Convective Heat Flux boundary condition on a heated
body computes the heat flux based on a heat transfer coefficient and the temperature difference to the
surroundings.

Convective Heat Flux requires the CFD Module or Heat Transfer Module.

In COMSOL Multiphysics, by convention, the force acting on the model or the flux into the model is
specified. That is, specify how the surroundings affect the model and not how the model affects its
surroundings. You can change the direction by reversing the sign before the numerical value of the force
or flux.

CONSTRAINTS
Constraint boundary conditions specify the value of one or more dependent variables at the boundary, or a
relationship between two or more dependent variables. Typical examples include specifying:

• A Prescribed Displacement of the boundary of a solid object.


• That the velocity is zero on a Wall boundary in a CFD model.
• The Temperature at the boundary of a heated solid.
• The Electric Potential on an electrode in an AC/DC model.

Examples specifying a relation between dependent variables include Roller conditions on solids and Wall conditions
for slip flow.

Because constraint conditions generally specify the value of a dependent variable, they also provide a reference level
for that variable, which a flux condition normally does not. In many types of physics, the model equations together
with only flux boundary conditions uniquely describe the local behavior of the dependent variable, but leave the
global level undefined. From a physical point of view, the absolute value of the dependent variables are often of less
interest, but the existence of a single, unique, solution is essential for some solvers.

Therefore it is often necessary to apply at least one constraint condition in a model, to provide a global reference
value for the dependent variables. For example, it is common to designate one of the electrodes in an AC/DC
model as Ground, which constrains the electric potential there to zero and gives a reference with which to compare
other parts of the model.

In most physics features, the default boundary condition is of a flux type and does not fix a reference
level for the dependent variable. Therefore, when solving certain study types (notably stationary
studies), you must manually add at least one boundary condition of constraint type (or a point
constraint) for the model to be well-defined.

SWITCHING OFF A CONSTRAINT


If you want to model a constraint that is active only for a certain period of time in a time-dependent simulation, for
example, you can use the fact that a 0 constraint (or a Dirichlet boundary condition u  u) means that there is no
constraint; instead, the boundary condition becomes a “no flux” or “insulation” condition. To implement such a
time-limited constraint, you can use the if operator: for example, for a Dirichlet boundary condition,

BOUNDARY CONDITIONS | 223


if(t<2,1,u) means that for t  2, u is equal to 1 but at t  2 the boundary condition is turned off by setting u 
u. For a Constraint node, the corresponding if statement is if(t<2,1-u,0).

• Constraint Reaction Terms


• Weak Constraints
• Constraint Settings

Physics Interface Boundary Types


There are different types of boundaries for the physics interfaces, which all support different types of boundary
conditions:

• Exterior boundaries, where most boundary conditions are applicable — see below.
• Interior boundaries, where special interface conditions can be applicable — see below.
• Axial symmetry boundaries, which are artificial boundaries representing the symmetry axis in axisymmetric
models.

If a selection for a boundary condition node, for example, contains boundaries of a type that is not applicable or
supported, the Selection list has (not applicable) next to those boundary numbers.

INTERIOR AND EXTERIOR BOUNDARIES


When specifying boundary and interface conditions, COMSOL Multiphysics differentiates between exterior and
interior boundaries:

• An exterior boundary is an outer boundary of the modeling domain.


• A interior boundary is a dividing interface between two domains in the geometry.

If an equation or physics interface is deactivated in one domain, the interior boundary between the active and
inactive domain becomes an exterior boundary for its variables because it then borders on the outside of the active
domain for those fields. The boundaries of the inactive domain are then void.

exterior interior
boundary boundary

Figure 3-21: Examples of exterior and interior boundaries.

For variables defined on a higher geometry dimension (domains, typically), evaluating such variables
on a lower dimension (boundaries, typically), the returned value is the mean value, if the values for the
variable differ on the different sides of the boundary (upside and downside of an interior boundary).
Use the up and down operators to evaluate the variable on one side of the boundary.

Continuity on Interior Boundaries


Unless a boundary condition is specified on interior boundaries (such as a contact resistance condition), the
COMSOL Multiphysics software ensures continuity in the field variables across interior boundaries. For assembly
geometries with identity pairs, select a Continuity node in the Pairs menu in the boundary part of the context menu
for most physics interfaces. The Continuity condition is only suitable for pairs where the boundaries match.

224 | CHAPTER 3: BUILDING A COMSOL MULTIPHYSICS MODEL


BOUNDARY SELECTION
The selection list in this section shows the boundaries for the selected pairs.

PAIR SELECTION
Select the pairs where you want to impose continuity across the pair boundaries by clicking the Add button ( )
and choose the pairs to add from the list in the Add dialog box that opens; then click OK.

Identity and Contact Pairs

Physics Interface Axial Symmetry Node


In axisymmetric components, boundaries on the symmetry axis are boundaries where only a condition for the axial
symmetry exists. The COMSOL Multiphysics software adds a default Axial Symmetry node that is active on all
boundaries on the symmetry axis. The condition on the symmetry axis is typically a zero Neumann or no-flux
condition.

BOUNDARY SELECTION
The selection list for boundaries is not available because this is a default boundary condition. In the list, boundaries
that are not on the symmetry axis have (not applicable) added after the boundary number.

Physics Feature Nodes by Space Dimension

Constraint Reaction Terms


Enforcing a constraint condition is more or less a matter of finding a corresponding flux condition that leads to the
desired values of the dependent variables. The hidden flux conditions introduced this way appear as reaction terms
in the system of equations modeling the physics. These reaction terms normally have a physical meaning and
correspond to a flux condition, for example:

• The reaction term enforcing a Prescribed Displacement on a solid model is a reaction force, similar to a
Boundary Load boundary condition.
• The reaction term enforcing a Pressure in an acoustics model is a Normal Acceleration.
• The reaction term enforcing a Temperature in a heat transfer model is a Heat Flux.

Weak Constraints

The reaction terms in the model equations can be scaled in different ways, affecting mainly the numerics and
solvers. In a model with more than one dependent variable, it is also possible to distribute the reaction fluxes, or
forces, over the variables in different ways — while still enforcing the original constraint.

SYMMETRIC REACTION TERMS


Most boundary conditions of constraint type, by default, introduce reaction terms in such a way that an otherwise
symmetric system of equations remains symmetric. This makes constraints bidirectional in the sense that all
dependent variables that appear in a constraint expression are also affected by the reaction terms.

BOUNDARY CONDITIONS | 225


To illustrate this, suppose a Prescribed Displacement boundary condition is applied on a solid model, specifying that
the x-displacement of the boundary, u, is proportional to the y-displacement, v, with a constant of proportionality,
k, which is a function of the boundary temperature T:

u = k Tv (3-1)

If fully symmetric reaction terms are used to enforce this constraint, reaction forces are applied on both
displacement components u and v, as well as a reaction heat flux in the heat transfer equation. Applying symmetric
reaction terms this way, on completely different equations, is usually not meaningful.

In particular, the solid displacement equation and the heat transfer equation have different units. Because you can
choose length and temperature unit independently, the relative scale of the equations is undefined and the
symmetry of the coupled system irrelevant. Further you would not, from a physical point of view, expect a
constraint on the displacement of a solid boundary to directly affect the temperature field in a model.

Symmetric and Nonsymmetric Constraints

RESTRICTED AND NONSYMMETRIC REACTION TERMS


As an alternative to the default (symmetric) application of reaction terms, you can choose to have these affect only
the equations and variables in the physics interface where the constraint boundary condition is added. For the
example in Equation 3-1, the reaction terms can be restricted to act on the displacement variables and equations in
the Solid Mechanics interface, leaving the temperature unaffected. Many different restrictions of this type are
possible, in principle, and the COMSOL Multiphysics software generally provides two alternatives:

• The most consistent and general way to avoid spurious reaction terms affecting other physics is to start from the
globally symmetric formulation and remove the terms entering equations belonging to other physics interfaces.
This limits the reaction terms to affecting the current physics as if there were no other physics in the model, so
the reaction terms preserve the symmetry. For Equation 3-1, this means that reaction terms are distributed over
both u and v equations, in proportions 1kT.
• The other alternative is to apply the reaction terms only on certain individual variables. Another way to look at
Equation 3-1 is to read it as prescribing a value for the x-displacement u, rather than prescribing a given relation
between u and v. Accepting that view, it is reasonable to insert reaction terms only acting on u. Such reaction
terms, in general, do not preserve symmetry even for a single physics interface.

Constraint Settings
Most constraint nodes include a Constraint Settings section, which is only available when Advanced Physics Options
is selected in the Show More Options dialog box. This section provides settings controlling how reaction terms are
applied, when applicable, and whether to use pointwise standard constraints or weak constraints.

Several constraint types are available under Constraints. When Pointwise constraints are selected, pointwise standard
constraints are used. A common alternative are Weak constraints (see Weak Constraints below). Note that this
option introduces additional equations and dependent variables.

When Weak constraints or Pointwise constraints are selected, choose to Apply reaction terms on:

• All physics (symmetric) to apply reaction terms symmetrically on all dependent variables taking part in the
constraint.

226 | CHAPTER 3: BUILDING A COMSOL MULTIPHYSICS MODEL


• Current physics (internally symmetric) to apply reaction terms symmetrically only on the dependent variables in
the physics where the constraint is added. This leaves other physics unaffected by the constraint.
• Individual dependent variables to apply reaction terms only on selected variables. For most physics, this makes the
constraint unidirectional and often nonsymmetric.

If you use pointwise constraints, then select a Constraint method for the pointwise constraints: Elemental or Nodal:

• Choose Elemental (the default) to make the software assemble the constraint on each node in each element; that
is, there are usually several constraints at the same global coordinates because elements in the computational
mesh overlap at nodes.
• Choose Nodal to make the software assemble a single constraint for each global node point. The nodal constraint
method provides an averaging of the constraints from adjacent elements, which can be beneficial when the
constraint has discontinuities between mesh elements (for example, due to discontinuities of the boundary
normal). Another case where nodal constraints can be useful is in boundary conditions involving a coupling
operator (such as continuity or periodic conditions). With elemental constraints, locking effects can sometimes
occur because the coupling operator might map to slightly different points in the source boundary when it is
applied to the same node point in different mesh elements.

Not all constraints provide all the above options. Some reaction term methods can be missing and weak
constraints are not allowed. Some constraint nodes can also implement additional options.

Excluded Surfaces, Excluded Edges, and Excluded Points


Some constraint nodes, especially for structural modeling, include (depending on the space dimension and the
geometry level of the constraint node) Excluded Surfaces, Excluded Edges, and Excluded Points sections, which are
only available when Advanced Physics Options is selected in the Show More Options dialog box. You can use the
settings in these sections to exclude some lower-level entities form being constrained for a certain boundary
condition or constraint on the domain level. Conflicting Dirichlet conditions, such as constraints, can cause
problems for several reasons:

• If constitutive properties differ a lot between two adjacent domains, the flux will be sensitive to whether a
Dirichlet condition on a boundary includes the common edge or not.
• When you want to mix weak and pointwise constraints on the same degree of freedom, they cannot coexist on
nodes shared at, for example, a corner.

The Excluded Surfaces, Excluded Edges, and Excluded Points sections contain settings for selecting surfaces (that is,
boundaries in 3D), edges (that is, boundaries in 2D and edges in 3D), and points, respectively. See About Selecting
Geometric Entities for information about selecting geometric entities such as edges.

Weak Constraints
The standard method to enforce constraints in the COMSOL Multiphysics software applies the constraints
pointwise at node points in the mesh. At each node point, only local values of the dependent variables are affected
by the constraint, making the constraints independent of each other. The solvers can therefore eliminate both the
constrained degrees of freedom and the constraint force terms, effectively reducing the system of equations and
decreasing the number of degrees of freedom being solved for.

Weak constraints enforce the constraint in a local average sense, using shape functions as weights. Reaction terms
are explicitly included in the system of equations, which is extended with Lagrange multiplier variables. These
Lagrange multipliers in general have a physical meaning and an interpretation as a constraint force or flux. Whereas

BOUNDARY CONDITIONS | 227


a standard constraint decreases the number of degrees of freedom by the number of unique constraints, weak
constraints increase the degrees of freedom by the same number.

A weak constraint is respected only on average over each Lagrange multiplier shape function, rather than pointwise
at mesh nodes. When it is possible to satisfy the constraint everywhere on each mesh element, standard and weak
constraints in general lead to the same solution. Conversely, when constraints are contradictory or impossible to
satisfy everywhere, standard and weak constraints can distribute the error differently, and therefore lead to slightly
different solutions.

Weak constraints can be of use in the following situations:

• Standard constraints must never contain time derivatives of the dependent variables. Weak constraints do not
have this limitation because they allow the same variables as any other term in the combined system of equations.
Note that reaction terms cannot be applied symmetrically to time derivatives but must be selectively applied to
individual variables.
• When the reaction force or flux is needed during a solution, because it enters into a coefficient somewhere, the
Lagrange multiplier from a weak constraint can provide an accurate value (see Computing Accurate Fluxes). The
corresponding variables computed from derivatives of the dependent variables are not as accurate and can, if
used, introduce considerable errors in the solution.
• When constraints are strongly nonlinear, weak constraints can allow faster and more robust convergence. For
nonlinear constraints, the true linearized subproblem solved in each solution step depends on the value of the
Lagrange multiplier variables from the previous step. When using standard constraints, this information is
discarded between solution steps. Using weak constraints, the Lagrange multiplier values are instead retained
between steps because they are part of the solution vector.

Compared to standard, eliminated, constraints, weak constraints can also have the following drawbacks:

• Discontinuous constraints result in (theoretically) infinite Lagrange multipliers. In practice, large oscillations
result.
• Pointwise and weak constraints on the same set of variables on adjacent boundaries (that is, boundaries that share
common node points in the mesh) do not work. This means that if all boundaries must be constrained on a solid
and you want to use a weak constraint on one boundary segment (one face), the weak constraint must be used
on the entire boundary of the solid (if the boundary is connected).
• Lagrange multipliers are in some cases difficult to interpret. For example, Lagrange multipliers from Dirichlet
conditions in axial symmetry are not equal to the reaction flux per area but rather per length and full revolution.
For separate Weak Constraints nodes in axial symmetry, the default quadrature settings include a multiplication
by 2 r, making the Lagrange multiplier represent flux per area.
• Because extra unknowns are introduced for the Lagrange multipliers, the size of the problem increases compared
to the standard constraint elimination method.
• The Lagrange multiplier variables added by the weak constraints have a different unit than the main system
variables and can therefore be of a different order of magnitude. This can lead to scaling problems. Usually the
automatic variable scaling in the solvers is sufficient, but there are cases when manual scaling is needed.
• Weak constraints introduce zeros on the main diagonal of the Jacobian matrix of the discretized system, which
therefore cannot be positive definite. This makes certain linear solvers and preconditioners unavailable for solving
problems with weak constraints. In particular, the conjugate gradients iterative solver does not work, and neither
does the SOR class of preconditioners and smoothers. Instead, try another iterative solver and use the Vanka

228 | CHAPTER 3: BUILDING A COMSOL MULTIPHYSICS MODEL


algorithm with the Lagrange multipliers as the Vanka variables, or use the incomplete LU factorization algorithm
as preconditioner.

Constraint Reaction Terms

Periodic Boundary Conditions


Use periodic boundary conditions to make the solution equal on two different (but usually equally shaped)
boundaries.

To add a periodic boundary condition, in the Model Builder, right-click a physics interface node and select Periodic
Condition. The periodic boundary condition typically implements standard periodicity so that ux0  ux1 (that is,
the value of the solution is the same on the periodic boundaries). In most cases you can also choose antiperiodicity
so that the solutions have opposing signs: ux0  ux1. Other options such as Floquet periodicity or cyclic
symmetry may be available. The periodicity is implemented in such a way that fluxes become periodic in the same
way as the solution itself.

For fluid flow physics interfaces, the Periodic Flow Condition provides a similar periodic boundary condition but
without a selection of periodicity. Instead, it allows specifying a pressure difference between the source and
destination boundaries.

Typically, the periodic boundary conditions determine the source and destination boundaries automatically, but
you can also add Destination Selection subnode to manually split the periodic boundary condition’s selection into
source and destination selections.

The KdV Equation and Solitons: Application Library path


COMSOL_Multiphysics/Equation_Based/kdv_equation.

ORIENTATION OF SOURCE AND DESTINATION


The periodic condition applies a constraint on the destination selection, constraining the solution at each
destination point rdst to be equal to the solution at a corresponding source point rsrc. When the periodic condition
is applied on surfaces in 3D or edges in 2D, the source point is computed using a rotation of the position relative
to the destination and source centers of mass, r0,dst and r0,src:

r src = r 0,src + R  r dst – r 0,src  (3-2)

where R is a rotation matrix encoding the relative orientation of the source and destination boundaries. It is
normally determined automatically from the cross product of the source and destination boundary normal
directions. That is, the rotation is performed about an axis perpendicular to the plane spanned by the normal
directions, which are evaluated at arbitrary points on each boundary.

When the periodic condition is applied on a shell or beam in 3D, the selection is edges or vertices without a
well-defined normal. An automatic mapping from destination point to source point is defined based on the

BOUNDARY CONDITIONS | 229


geometry parameterization. Each destination point is mapped on a source point with the same arc length parameter
value (see the image below).

The automatically computed relative orientation is in most cases the one expected. In particular, it is correct if the
source and destination have unique normal vectors which are parallel but pointing in opposite directions, unless the
geometry is twisted about that direction. But there are a number of situations when the automatic orientation is
not necessarily the one expected:

• The geometry is twisted in such a way that the destination selection cannot be represented as a rotation of the
source about a single axis.
• The source and destination boundaries are not planar, such that their normals are not unique.
• The source and destination selections are edges or points in 3D, and the arc length parameter values are growing
in opposite directions.
For most periodic boundary conditions in the physics interfaces, it is then possible to specify the relative orientation
of the source and destination selections using coordinate systems.

The orientation settings appear in Orientation of Source and Orientation of Destination sections in the Periodic
Condition node. To display the Orientation of Destination settings, first select Advanced Physics Options in the Show
More Options dialog box. It is also not visible when the Transform to intermediate map list in the Orientation of Source
section is set to its default value, Automatic. Other possible values represent coordinate systems, including all
coordinate system nodes defined in the component as well as the canonical Global coordinate system. The latter is
the default choice for the Orientation of Destination section.

The chosen source and destination coordinate systems define transformation matrices, Tsrc and Tdst, whose row
index refers to local coordinate system components, while the column index refers to global coordinates on the

230 | CHAPTER 3: BUILDING A COMSOL MULTIPHYSICS MODEL


source and destination selections, respectively. A rotation matrix as defined by Equation 3-2 is computed by
assuming that the source and destination coordinate system coordinates refer to the same basis:

T T –T
R = T src dst

MAPPING BETWEEN SOURCE AND DESTINATION


Some physics require that the meshes at that source and the destination are compatible. Here, compatible meshes
means two meshes that can be mapped to each other (node points to node points) by an affine transformation. To
make sure that source and destination are compatible you could, for instance, use the Copy mesh command.
Sometimes the discretization requires even stronger assumptions than compatible meshes — the mapping needs to
ensure that the mapped point is not only mapped to the correct physical point but also to the correct mesh element
for the node points that are shared between adjacent mesh elements. The elementwise mapping for compatible
meshes fulfills this requirement. One example that require the elementwise mapping is modeling of electromagnetic
waves using curl type 2 shape functions (whereas for type 1 curl shape functions it is sufficient just to ensure that
the meshes are indeed compatible).

In general, the Nodal constraint method is recommended for periodic conditions. When the Elemental constraint
method is used for periodic conditions, the elementwise mapping for compatible meshes can lead to locking effects.
This problem can be prevented by setting the value of the Elementwise mapping for compatible meshes list to Off
when the Elemental constraint method is used.

There is built-in logic for choosing if the software should try to use the elementwise mapping between the meshes
or not. This corresponds to choosing Automatic from the Elementwise mapping for compatible meshes list.

However, that logic is mainly based on the topology and does not consider the meshing sequence that you choose,
the constraint method you set, or all the shape functions you will apply the condition to. Therefore, you can
overwrite the built-in logic by choosing between the following alternatives from the Elementwise mapping for
compatible meshes list: On, Off, or Require compatible meshes.

• Choose On if you expect compatible meshes and want to use an elementwise mapping but you want to get a
mapping even if source and destination cannot be identified.
• Choose Off if you do not expect compatible meshes or if you want to use elemental constraints for continuous
fields.
• Choose Require compatible meshes if you expect compatible meshes and you rather fail than use noncompatible
meshes.

If you have selected On or Require compatible meshes, a Tolerance for compatible meshes field appears, where you can
specify the relative tolerance, compared to the mesh element size, for when the mesh elements are considered
compatible (default: 0.001).

PERIODIC BOUNDARY CONDITION MODEL EXAMPLES


In addition to the KdV Equation model example, other modules have examples using this feature.

BOUNDARY CONDITIONS | 231


AC/DC Module
Magnetotellurics: Application Library path: ACDC_Module/Devices,_Resistive/magnetotellurics

Acoustics Module
Porous Absorber: Application Library path:
Acoustics_Module/Building_and_Room_Acoustics/porous_absorber

RF Module or Wave Optics Module


Fresnel Equations: Application Library path: RF_Module/Verification_Examples/fresnel_equations

Fresnel Equations: Application Library path:


Wave_Optics_Module/Verification_Examples/fresnel_equations

Structural Mechanics Module


Vibrations of an Impeller: Application Library path:
Structural_Mechanics_Module/Dynamics_and_Vibration/impeller

232 | CHAPTER 3: BUILDING A COMSOL MULTIPHYSICS MODEL


C omp ut i ng A ccur a t e F lu xes
Flux Computation Methods
The COMSOL Multiphysics software provides three ways to compute accurate fluxes and reaction forces. See
below for more information about each method.

Flux Calculation Example — Heat Transfer Model

• The first approach involves the reaction force operator (reacf) that makes it possible to compute integrals of
reaction forces or fluxes during results analysis. The reacf operator gives the value of constraint forces per node,
which is a discrete version of the Lagrange multipliers. It can be summed over per node and is the traditional
way of computing reaction forces in FEA. The reacf operator always gives the “exact” reaction force of the
discretized version of the problem.
In a case where you have one type of constraint acting on the same dependent variable (DOF variable) then
Lagrange multipliers (see below) and reacf are more or less the same. In a case where you have several types of
constraints acting on the same dependent variable (DOF variable) — for example, some kind of control system
mechanism — then Lagrange multipliers give you individual control over each constraint force whereas reacf
will only give you control over the sum of all constraint forces.
The reacf operator is a pure postprocessing operation and does not affect the matrix structure or solvers.
See reacf for details.
• Some physics interfaces provide a second way of computing accurate fluxes. Those accurate fluxes are like a
continuous version of the reacf operator and have similar properties: they are pure postprocessing operations
and do not affect the matrix structure or solvers. They reconstruct a, typically continuous, field instead of giving
the “exact” reaction force per node for the discretized problem. So, although these fluxes will be nice and
continuous, as opposed to those computed using reacf, they may sometimes not be as accurate as reacf. They
also have to be integrated using some numerical quadrature rule, which can introduce numerical errors. Also
note that the flux variables are only accurate if the residual is small; a small solution error normally means a small
residual.
Under the Discretization section (if Advanced Physics Options is selected in the Show More Options dialog box),
select the Compute boundary fluxes check box. The solver then computes variables storing an accurate boundary
flux from each boundary into the adjacent domain (in addition to the standard extrapolated value). On interior
boundaries, there are two flux variables corresponding to the flux into the domains on either side of the
boundary. Unlike the other methods, these variables are available also on unconstrained boundaries. This
method is active by default in Coefficient Form PDE, General Form PDE, heat transfer, and mass transport
interfaces. There is also an Apply smoothing to boundary fluxes check box that is selected by default. The
smoothing can provide a more well-behaved flux value close to singularities. See also Boundary Flux Operators:
uflux and dflux.
• The third, more general approach for calculating reaction forces and fluxes is to use Lagrange multipliers (weak
constraints). Use this approach when you need reaction forces or fluxes in other contexts than calculating
integrals of reaction forces or fluxes. Lagrange multipliers give you more precise control over how the constraint
forces are acting and allow for creative ways of applying them. However, using Lagrange multipliers is not a pure
postprocessing operation, and they actually change the problem being solved. Lagrange multipliers can destroy
the matrix structure and may convert a converging or easy-to-solve problem into a problem that is more difficult
to solve. Also, using Lagrange multipliers can lead to conflicting constraints and singular matrices at corners or

COMPUTING ACCURATE FLUXES | 233


points, and they typically need to be applied all along a continuous boundary to avoid conflicting constraint
forces.

Weak Constraints

When using weak constraints in interfaces, the Lagrange multipliers are additional dependent variables in those
physics interfaces. When using the reaction force operator, the reaction force operator of a certain dependent
variable corresponds to the Lagrange multiplier of that dependent variable. The Lagrange multipliers correspond
to the following quantities in the physics interfaces:
TABLE 3-6: INTERPRETATION OF LAGRANGE MULTIPLIERS.

PHYSICS INTERFACE QUANTITY

Electrostatics Surface charge density


Magnetic Fields Surface current
Electric Currents Current density
Heat Transfer Heat flux
Transport of Diluted Species Flux
Solid Mechanics Force per area
Pressure Acoustics Normal displacement (acceleration for eigenfrequency studies)
Laminar Flow Total force per area

The sign of the Lagrange multiplier is the same as the one used when applying the corresponding quantity
explicitly in a flux condition. As a general rule, the sign corresponds to an action by the surroundings on the
model, rather than the opposite.
The program computes only the part of the boundary flux captured by the Lagrange multiplier. You might have
additional flux coming from boundary sources or nonidentity constraint matrices. This should not happen in the
physics interfaces, though.

Lagrange multipliers in axial symmetry are not equal to the reaction flux per area but rather per length
and full revolution.

Flux Calculation Example — Heat Transfer Model


Consider a heat transfer model where a heat flux of 1 W/m2 flows in through one boundary of a square 2D region.
All other boundaries are kept at a fixed temperature of 293.15 K. The material is copper. This example verifies that
the flux is conserved exactly using a Lagrange multiplier for computing the total flux over the boundaries with a
fixed temperature.

MODEL WIZARD
1 Open the Model Wizard (see Open a New Window to Begin Modeling).
2 On the Select Space Dimension page, click the 2D button .
3 In the list of physics interfaces, under Heat Transfer click Heat Transfer in Solids . Click Add.
4 Click the Study button . On the Select Study page under Preset Studies, click Stationary .
5 Click Done.

234 | CHAPTER 3: BUILDING A COMSOL MULTIPHYSICS MODEL


GEOMETRY
In the Geometry toolbar, from the Rectangle menu, click to add a Square (1-by-1 m).

MATERIALS
1 In the Material toolbar, click Browse Materials .
2 Under Built-in, click Copper then click Add to Component.
3 Click Done .

HEAT TRANSFER
The Heat Transfer in Solids node defines the material properties to be those from the material (copper) and does not
need to be changed, but the default boundary condition is thermal insulation. Instead, add a heat flux to the
bottom boundary and a fixed temperature on the other three boundaries.

1 In the Model Builder, click the Heat Transfer in Solids node .


2 In the Physics toolbar, from the Boundaries menu click Heat Flux .
3 In the Graphics window, click boundary 2 (the bottom boundary) to add it to the selection.
4 In the Settings window for Heat Flux, enter 1 (1 W/m2) in the General inward heat flux field for q0.
5 Right-click Heat Transfer in Solids node and select Temperature .
6 In the Graphics window, select the other three boundaries (1, 3, and 4) and add them to the selection for the
temperature condition.
7 This step is only needed to show how to use a Lagrange multiplier for an accurate flux. Built-in variables for
accurate fluxes are available directly also without this step.
To display the weak constraint option to add the Lagrange multipliers, click the Show More Options button ( )
and select Advanced Physics Options in the Show More Options dialog box. In the Model Builder click the
Temperature node. In the Settings window, keep the default value for the temperature, 293.15 K. Click to expand
the Constraint Settings section and choose Weak constraints. This adds a Lagrange multiplier for the heat flux as
an extra variable to compute.

COMPUTING THE SOLUTION


In the Home toolbar, click Compute . The resulting plot shows the temperature distribution in the domain.

RESULTS — FLUX EXPRESSION AND LAGRANGE MULTIPLIER


1 Under Results>Derived Values>Integration, click Line Integration .
2 Select the three boundaries with a fixed temperature (boundaries 1, 3, and 4) to add them to the selection in the
Settings window for Line Integration.
3 Click the Replace Expression button ( ) and select
Heat Transfer in Solids>Boundary fluxes>Normal total heat flux (the variable [Link]).
4 Click the Evaluate button ( ).
The total normal heat flux across these boundaries appears in the Table under Normal total heat flux (W/m) and
is exactly equal to the influx of 1 W/m (the normal flux is by convention positive in the direction of the normal).
If you were to clear the Compute boundary fluxes check box in the Discretization section (click the Show More
Options button and select Advanced Physics Options in the Show More Options dialog box first) for the Heat
Transfer in Solids node, and then re-solve the model, the same flux variable is not as accurate and has a value of
about 0.986 W/m. That value approaches 1 if you refine the mesh.
5 Click the Replace Expression button ( ) and select Heat Transfer>Lagrange multiplier for temperature (the
variable T_lm).

COMPUTING ACCURATE FLUXES | 235


6 Click the Evaluate button ( ).
The total heat flux across these boundaries appears in the Table under Lagrange multiplier for temperature and is
1, exactly equal to the influx (but with opposite sign) without the need for a computationally expensive
extremely fine mesh. This method is useful for physics where built-in accurate flux variables are not available.

236 | CHAPTER 3: BUILDING A COMSOL MULTIPHYSICS MODEL


U s in g Lo ad Cas e s
About Load Cases
For linear stationary problems it can be of interest to see the solution for several different loads F (right-hand side
of the basic PDE) on the same structure (a model where the geometry and materials are defined and do not
change). Typically this is used for studies using linear combinations of different loads — load cases. It is then
possible to solve for these load cases in a computationally efficient way because there is no need to reassemble the
stiffness matrix. Varying constraints can also be part of a general load case definition, and the COMSOL
Multiphysics software supports load cases that are combination of loads, with optional weights, and constraints.

• The Relationship Between Study Steps and Solver Configurations


• Physics Symbols
• Stationary study step

Defining Load Groups and Constraint Groups


For boundary conditions that represent loads and constraints, as well as other loads and constraints such as body
loads, you can define load groups and constraint groups, which contain the loads and constraints, respectively, that
you want to use as parts of load cases. All loads and constraints for structural mechanics as well as boundary
conditions such as heat flux (a load) and temperature (a constraint) in heat transfer support load groups and
constraint groups. You can create load groups and constraint groups in two ways: from the Global Definitions node’s
context menu or a physics node’s context menu. Both methods add the node under Global Definitions.

ADD A LOAD OR CONSTRAINT GROUP FROM THE GLOBAL DEFINITIONS CONTEXT MENU
Add a Load Group ( ) or Constraint Group ( ) under Global Definitions to create groups to which you can later
assign loads and constraints. If you group the nodes, the load and constraint groups display under the Load and
Constraint Groups node ( ). See Figure 3-22.

Figure 3-22: An example of the node grouping when Group by Type is selected (left) and when Ungroup is selected
(right).

ADD A LOAD OR CONSTRAINT GROUP FROM A PHYSICS NODE CONTEXT MENU


Right-click a physics node for any load or constraint (for example, a Fixed Constraint, Heat Source, or Boundary
Load node) and choose Load Group>New Load Group or Constraint Group>New Constraint Group, respectively. The
software creates a Load Group or Constraint Group under Global Definitions and at the same time assigns that
physics node (a load or a constraint) to that group.

USING LOAD CASES | 237


ASSIGN A LOAD OR CONSTRAINT TO A GROUP
To assign a load or a constraint to a load group or constraint group, right-click the physics node for a load or
constraint and from the Load Group or Constraint Group submenu choose one of the following (see Figure 3-23):

• Active in All Load Groups (or Active in All Constraint Groups). This is the default setting, which you can use for
some boundary conditions or other parts of the physics design that take part in all load cases.
• One of the defined load groups or constraint groups such as Load Group 1, Load Group 2, and so on.
• New Load Group (or New Constraint Group) to create a new group as described earlier in this section.

Figure 3-23: An example of the context menu options when a load or constraint physics node is right-clicked, in this case,
the Fixed Constraint node.

Define as many groups as you need for the load cases that you want to study. Each load or constraint can only
belong to one group. The next step is then to define the actual load cases as combinations of these groups (see
Defining and Evaluating Load Cases).

When the Load Group or Constraint Group is applied to a node under a physics interface, the node indicates this
visually. For example, the Fixed Constraint and Roller nodes have the blue Constraint Group symbol in the upper-right

238 | CHAPTER 3: BUILDING A COMSOL MULTIPHYSICS MODEL


corner and the Body Load and Boundary Load nodes have the red Load Group symbol in the upper-right corner as in
Figure 3-24.

Figure 3-24: An example of the Load and Constraint Groups defined under Global Definitions with loads and
constraints applied to nodes under Solid Mechanics.

• Tapered Cantilever with Two Load Cases: Application Library path


COMSOL_Multiphysics/Structural_Mechanics/tapered_cantilever
• If you have the Structural Mechanics Module, also see Pratt Truss Bridge: Application Library
path Structural_Mechanics_Module/Beams_and_Shells/pratt_truss_bridge.

Load Group
Add a Load Group ( ) under the Global Definitions node to create a load group to which you can assign one or
more loads. You can then activate the load group in one or more load cases for efficiently solving a structural
mechanics or heat transfer model to analyze the effects of various loads or sources.

SETTINGS
The Label is the default coordinate system name. The default Parameter name (for the first coordinate system in the
model) is lg. This can be modified if you want to use a more descriptive parameter name (for example, lgGravity).
You can also create load groups from physics nodes for structural mechanics that represent loads and support load
cases: Right-click the physics node and choose Load Group>New Load Group.

Constraint Group
Add a Constraint Group ( ) under the Global Definitions node to create a constraint group to which you can assign
one or more constraints. You can then activate the constraint group in one or more load cases for efficiently solving
a model to analyze the effects of various constraints.

Constraint groups only work for pointwise constraints. If the formulation for a certain constraint
is changed to a weak constraint, it is no longer possible to add it to a constraint group. Conversely,
if a constraint has been assigned to a constraint group, it will no longer be possible so select the
weak formulation.

USING LOAD CASES | 239


SETTINGS
The Label is the default coordinate system name. The default Parameter name (for the first coordinate system in the
model) is cg. This can be modified if you want to use a more descriptive parameter name (for example, cgForce).
You can also create constraint groups from physics nodes for structural mechanics that represent constraints and
support load cases: Right-click the physics node and choose Constraint Group>New Constraint Group.

If you select Group by Type from the context menu, either right-click the Global Definitions node or
the Loads and Constraints Groups node ( ) to add a Load Group or Constraint Group.

Defining and Evaluating Load Cases


You define load cases in the Settings window for the Stationary study. Follow these steps to create load cases:

1 In the Model Builder under Study, in the Settings window for Stationary ( ), click to expand the Study Extensions
section.
2 Select the Define load cases check box (see Figure 3-25).
3 In the Define load cases area, click the Add ( ) button underneath the table to add a load case.
4 The added load case appears last in the table of load cases. Use the Move Up ( ), Move Down ( ), and
Delete ( ) buttons to rearrange the load cases in the table, and click the Add ( ) button to add more load
cases.
5 For each load case, you can change its name from the default (Load case 2, for example) in the Load case column.
6 Include the load groups and constraint groups for each load case by clicking the in the columns for the
groups to include. The symbol changes to in order to indicate that the group participates in the load case.
7 For load groups, optionally change the weight from its default value of 1.0 in the corresponding Weight column
(the Weight column to the right of the load group that it affects). Use a positive value other than 1 to increase
or decrease the magnitude of the load; a negative value also reverses the load’s direction.

Figure 3-25: An example of the Stationary node’s Study Extensions section. Click in the table of load cases to select or
remove loads and constraints from the load case.

When you have defined all load cases, you can compute the solution. The COMSOL Multiphysics software then
solves for all load cases directly. In the plot groups that are created, a Load case list in the Data section of the Settings

240 | CHAPTER 3: BUILDING A COMSOL MULTIPHYSICS MODEL


window for Plot Group contains all load cases. To plot using the solution for a specific load case, select the load case
of interest from the Load case list, and then click Plot ( ).

• Introduction to Solvers and Studies


• Stationary study step

USING LOAD CASES | 241


N umer i ca l S ta bi li za ti o n
About Numerical Stabilization in COMSOL
This section discusses the numerical stability of the generic scalar convection-diffusion transport equation

-----
u- +    u =    c  u  + F (3-3)
t

where  is the convective velocity vector, c is the diffusion coefficient, u is a transported scalar, and F is a source
term. The underlying finite element discretization method in COMSOL Multiphysics is the Galerkin method.
When discretizing Equation 3-3 using the Galerkin method, the resulting numerical problem becomes unstable for
an element Pé clet number (Pe) larger than one (Ref. 1):

 h
Pe = ------------  1 (3-4)
2c

where h is the mesh element size. The Pé clet number is a measure of the relative importance of the convective
effects compared to the diffusive effects; a large Pé clet number indicates that the convective effects dominate over
the diffusive effects.

Oscillations can occur where any of the following conditions exist and the Pé clet number exceeds one:

• A Dirichlet boundary condition can lead to a solution containing a steep gradient near the boundary, forming a
boundary layer. If the mesh cannot resolve the boundary layer, this creates a local disturbance.
• A space-dependent initial condition that the mesh does not resolve can cause a local initial disturbance that
propagates through the computational domain.
• A small initial diffusion term close to a nonconstant source term or a nonconstant Dirichlet boundary condition
can result in a local disturbance.

As long as diffusion is present, there is — at least in theory — a mesh resolution beyond which the discretization
is stable. This means that the spurious oscillations can be removed by refining the mesh. In practice, this method
is seldom feasible because it can require a very dense mesh. Instead, it is common practice to use stabilization
methods — that is, methods that add artificial diffusion. The COMSOL products include several such methods,
some of which are described in An Example of Stabilization.

Consistent Stabilization and Inconsistent Stabilization Sections on Settings Windows


Numerical stabilization is available for physics interfaces that model transport such as fluid flow or convective heat
transfer, where the fundamental governing equations are less stable than, for example, conduction-dominated
models, solid mechanics models, and wave propagation in the frequency domain.

Several physics interfaces have these settings available, and below you find the common information about the
stabilization settings. Differences not described below are noted for the individual interface documentation.

CONSISTENT STABILIZATION
To enable this section, click the Show More Options button ( ) and select Stabilization in the Show More Options
dialog box.

There are two consistent stabilization methods: Streamline diffusion and Crosswind diffusion. Usually, both check
boxes for these methods are selected by default and should remain selected for optimal performance. Consistent
stabilization methods do not perturb the original transport equation.

242 | CHAPTER 3: BUILDING A COMSOL MULTIPHYSICS MODEL


Crosswind Diffusion and Lower Gradient Limit
In some cases, if the Crosswind diffusion check box is selected, the Lower gradient limit glim (SI unit: K/m) field is
available. This variable corresponds to the smallest concentration change across an element considered by the
stabilization, and is used to make sure that the crosswind diffusion expressions are valid also in regions with small
to negligible concentration changes.

Residual
In some cases, and for both consistent stabilization methods, select a Residual (or Equation Residual). Approximate
residual is the default setting and it means that derivatives of the diffusion tensor components are neglected. This
setting is usually accurate enough and is faster to compute. If required, select Full residual instead.

INCONSISTENT STABILIZATION
To enable this section, click the Show More Options button ( ) and select Stabilization in the Show More Options
dialog box.

There is usually just one inconsistent stabilization method — Isotropic diffusion. This method is equivalent to
adding a term to the diffusion coefficient in order to dampen the effect of oscillations by making the system
somewhat less dominated by convection. If possible, minimize the use of the inconsistent stabilization method
because by using it you no longer solve the original problem. By default, the Isotropic diffusion check box is not
selected because this type of stabilization adds artificial diffusion and affects the accuracy of the original problem.
However, this option can be used to get a good initial guess for underresolved problems.

If required, select the Isotropic diffusion check box and enter a Tuning parameter id as a scalar positive value. The
default value is 0.25 (a reasonable value to start with is roughly 0.5 divided by the element order). A higher value
adds more isotropic diffusion.

• An Example of Stabilization
• Stabilization Techniques

An Example of Stabilization
This example uses the Heat Transfer interface. To illustrate the concepts, consider the problem

 u  u 2u 2u
cos  --- ------ + sin  --- ------ = 10 – 4  --------- + --------- + 1 (3-5)
 3 x  3 y  x 2 y 2 

solved on the unit square. Equation 3-5 is discretized using 10 times 10 quadratic Lagrange elements. The
boundary conditions are:

• u  1 for x  0
• u  1 for y  0
• u  0 for x  1
• u  0 for y  1

Figure 3-26 shows the mesh and boundary conditions. In general, using uniform meshes for transport problems is
not recommended. Nevertheless, this example uses a uniform mesh to demonstrate the different stabilization
techniques.

The expected solution rises slowly and smoothly from the left and lower boundaries and has sharp boundary layers
along the upper and right boundaries. Figure 3-27 shows a reference solution obtained using 100-by-100 quadratic
Lagrange elements with streamline diffusion and crosswind diffusion (see the next section). The arrows indicate
the direction of .

NUMERICAL STABILIZATION | 243


u0

u1 u0

u1

Figure 3-26: The computation domain, mesh, and boundary condition for Equation 3-5.

Figure 3-27: Reference solution of Equation 3-5. Solved using 100 times 100 quadratic elements with streamline
diffusion and crosswind diffusion.

The cell Pé clet number for this example is

1  0.1
Pe = ------------------- = 500>>1
2  10 –4

Figure 3-28 displays the solution obtained using the mesh in Figure 3-26 and (unstabilized) Galerkin
discretization. As can be expected with such a high Pé clet number, the unstabilized solution shows little, if any,
resemblance to the reference solution in Figure 3-27. The right plot in Figure 3-28 shows a cross-sectional plot
along the dashed line, y  0.8 and the corresponding reference solution. Notice that the unstabilized solution is
destroyed by oscillations.

244 | CHAPTER 3: BUILDING A COMSOL MULTIPHYSICS MODEL


Figure 3-28: Equation 3-5 solved using unstabilized Galerkin formulation. The right plot compares the unstabilized
solution (dashed line) along the dashed line in the left plot (y = 0.8) with the reference solution (solid line).

The Stabilization Techniques section explores how different stabilization techniques affect the solution of this
example.

Stabilization Techniques
Several techniques for handling numerical instabilities without the need for mesh refinement are available. They all
have in common that they add terms to the transport equation. These terms introduce numerical diffusion (artificial
diffusion, artificial viscosity, or numerical viscosity are other common names) that stabilize the solution. To display
these sections, click the Show More Options button ( ) and select Stabilization in the Show More Options dialog box.

• Heat Transfer Consistent and Inconsistent Stabilization Methods


• Numerical Stability — Stabilization Techniques for Fluid Flow

CONSISTENT STABILIZATION
A consistent stabilization method adds numerical diffusion in such a way that if u is an exact solution to
Equation 3-3, then it is also a solution to the problem with numerical diffusion. In other words, a consistent
stabilization method gives less numerical diffusion the closer the numerical solution comes to the exact solution.

INCONSISTENT STABILIZATION
An inconsistent stabilization method adds numerical diffusion in such a way that if u is an exact solution to
Equation 3-3, then it is not necessarily a solution to the problem with numerical diffusion. In other words, an
inconsistent method adds a certain amount of diffusion independently of how close the numerical solution is to the
exact solution.

ISOTROPIC DIFFUSION
Adding isotropic diffusion is equivalent to adding a term,

c art =  id h 

to the physical diffusion coefficient, c. Here id is a tuning parameter. This means that you do not solve the original
problem, Equation 3-3, but rather the modified O(h)-perturbed problem

u
------ +    u =     c + c art  u  + F (3-6)
t

Hence, isotropic diffusion is an inconsistent stabilization method. If id  0.5, the new cell Pé clet number can be
expressed as

NUMERICAL STABILIZATION | 245


h  h 
Pe = --------------------------- = ------------------------
2  c + c art  2c + h 

Clearly, as  approaches infinity, Pe approaches, but never exceeds, one. While a solution obtained with isotropic
diffusion might not be satisfactory in all cases, the added diffusion definitely dampens the effects of oscillations and
impedes their propagation to other parts of the system. It is not always necessary to set id as high as 0.5 to get a
smooth solution, and its value should be smaller if possible. A good rule of thumb is to select   0.5p, where p is
the order of the basis functions. The default value is id  0.25

Figure 3-29 shows the effect of isotropic diffusion on Equation 3-5 with id  0.25. Although the solution is
smooth, the comparison with the reference solution in the right plot reveals that the isotropic diffusion introduces
far too much diffusion.

Figure 3-29: Equation 3-5 solved using isotropic diffusion. The right plot compares the stabilized solution (dashed line)
along y = 0.8 with the reference solution (solid line).

STREAMLINE DIFFUSION
The streamline diffusion method in the COMSOL Multiphysics software is a consistent stabilization method. When
applied to Equation 3-3, it recovers the streamline upwind Petrov–Galerkin (SUPG) method, but it can also
recover functionality from the Galerkin least-squares (GLS) method. Both methods are described below. For
theoretical details, see Ref. 1 and Ref. 2.

Streamline Upwind Petrov–Galerkin (SUPG)


The theory underlying SUPG is a bit too complicated to describe here, but the resulting expressions can be shown
to be closely related to upwinding schemes in finite difference and finite volume methods. SUPG can be shown to
add a smaller amount of stability than isotropic diffusion (see Ref. 3), but while the accuracy of isotropic diffusion
is at best O(h), the accuracy of SUPG can be shown to be at least O(hp+12) where p1 is the order of the basis
functions.

Figure 3-30 displays the effect of SUPG on the solution of Equation 3-5. The solution closely follows the reference
solution away from the boundary layers, but at the boundary layers, oscillations occur. This is a typical behavior for
streamline diffusion: the solution becomes smooth and exact in smooth regions but can contain local oscillations
at sharp gradients.

246 | CHAPTER 3: BUILDING A COMSOL MULTIPHYSICS MODEL


Figure 3-30: Equation 3-5 solved using streamline diffusion. The right plot compares the stabilized solution (dashed
line) along y = 0.8 with the reference solution (solid line).

Galerkin Least-Squares (GLS)


Galerkin least-squares (GLS) is a more advanced version of SUPG, with which it shares many features. GLS, for
example, is also a consistent method and has the same order of accuracy as SUPG. To understand the differences
between GLS and SUPG, consider the following extended form of Equation 3-3:

u
------ +    u =    c  u  + su + F (3-7)
t

where s is a production coefficient if s  0 and an absorption coefficient if s  0. If s  0, the numerical solution of


Equation 3-7 is characterized by the Pé clet number (see Equation 3-4) and the element Damkö hler number:

sh
Da = ---------

A new dimensionless number can be formed by combining the Damkö hler number and the Pé clet number:

s h2
2DaPe = ------------ (3-8)
c

The (unstabilized) Galerkin discretization becomes unstable if 2DaPe > 1 (Ref. 4), that is, if the
production/absorption effects dominate over the viscous effects. GLS differs from SUPG in that GLS relaxes this
requirement while SUPG does not.1

CROSSWIND DIFFUSION
Streamline diffusion introduces artificial diffusion in the streamline direction. This is often enough to obtain a
smooth numerical solution if the exact solution of Equation 3-3 (or Equation 3-7) does not contain any
discontinuities. At sharp gradients, however, undershoots and overshoots can occur in the numerical solutions (see
Figure 3-30). Crosswind diffusion addresses these spurious oscillations by adding diffusion orthogonal to the
streamline direction — that is, in the crosswind direction.

Crosswind diffusion methods are consistent, but they are also nonlinear. This means that the discrete equation
system becomes nonlinear even if the original equation (Equation 3-3 or Equation 3-7) is linear, which can increase
the computational cost.

Use crosswind diffusion if it is important to avoid undershoots or overshoots. Typical examples


are concentrations that must not become negative and mass fractions that must be between zero
and one.

1. The streamline diffusion stabilization in COMSOL Multiphysics is GLS but without any viscous terms in the test operator in the stabilization
term.

NUMERICAL STABILIZATION | 247


The crosswind diffusion option adds a weak contribution as suggested in Ref. 5. For the scalar example here, the
term reads

c c
–  h ------- g ij -------
x i x j

where gij is the covariant metric tensor. The coefficient h is for Navier–Stokes systems a modified version of the
Hughes-Mallet (HM) formulation of Ref. 6. In the scalar case, the modified HM formulation reduces effectively
to the form suggested in Ref. 6. Additionally, Ref. 7 suggests to reduce h for higher-order elements. The
formulation in the COMSOL Multiphysics software multiplies h with a factor

 2 1 – N

where N is the shape function order.

Figure 3-31 shows the example problem (Equation 3-5) solved using streamline diffusion and crosswind diffusion.
Oscillations at the boundary layers are almost completely removed (compare with Figure 3-30), but it has been
achieved by the introduction of some extra diffusion. In general, crosswind diffusion tries to smear out the
boundary layer so that it becomes just wide enough to be resolved on the mesh (Figure 3-26). To obtain a sharper
solution and remove the last oscillations, the mesh needs to be refined locally at the boundary layers.

Figure 3-31: Equation 3-5 solved using streamline diffusion and crosswind diffusion. The right plot compares the
stabilized solution (dashed line) along y = 0.8 with the reference solution (solid line).

References for Stabilization Techniques


1. O.C. Zienkiewicz, R.L. Taylor, and P. Nithiarasu, The Finite Element Method for Fluid Dynamics, 6th ed.,
Elsevier, 2005.

2. R. Codina, “Comparison of Some Finite Element Methods for Solving the Diffusion-Convection-Reaction
Equation”, Comput. Methods Appl. Mech. Engrg., vol. 156, pp. 185–210, 1998.

3. C. Johnson, Numerical Solution of Partial Differential Equations by the Finite Element Method, Student
literature, 1987.

4. G. Hauke, “A Simple Subgrid Scale Stabilized Method for the Advection-Diffusion-Reaction Equation”,
Comput. Methods Appl. Mech. Engrg., vol. 191, pp. 2925–2947, 2002.

5. G. Hauke and T.J.R. Hughes, “A comparative study of different sets of variables for solving compressible and
incompressible flows”, Computer Methods in Applied Mechanics and Engineering, vol. 153, pp. 1–44, 1998.

6. E.G.D. do Carmo and A.C. Galeão, “Feedback Petrov-Galerkin methods for convection-dominated problems”,
Computer Methods in Applied Mechanics and Engineering, vol. 88, pp. 1–16, 1991.

7. E.G.D. do Carmo and G.B. Alvarez, “A new upwind function in stabilized finite element formulations, using
linear and quadratic elements for scalar convection-diffusion problems”, Computer Methods in Applied Mechanics
and Engineering, vol. 193, pp. 2383–2402, 2004.

248 | CHAPTER 3: BUILDING A COMSOL MULTIPHYSICS MODEL


U s in g U ni t s
The COMSOL Multiphysics software supports a number of consistent unit systems, including the SI unit system,
which is the default unit system, unless you specify another unit system to be the default in new models on the
Model Builder page in the Preferences dialog box. The physics interface displays the unit for the physical quantities
entered in the selected unit system, but by Using Standard Unit Prefixes and Syntax you can use any available and
applicable unit or SI prefix to define your input quantities. In addition to SI units, many English units and units
from the CGS (or cgs) system are also available, regardless of the unit system used in the model. All data in the
material databases and Material Library product use SI units with declared units using the unit syntax (see
Materials). This makes it possible to use the material data also in models with non-SI unit systems. Regardless of
the selected unit system, you can always choose from a list of applicable units for plotting and results evaluation.

In the unit tables, “N/A” means that no unit symbol is available.

• Unit Systems
• Indication of Unexpected, Unknown, or Inconsistent Units
• Setting the Unit System for Models

Using Standard Unit Prefixes and Syntax

STANDARD UNIT PREFIXES


For SI units you can scale data using the standard prefixes for powers of 10 — kilo, mega, milli, or micro, for
example. Either the full prefix or the symbol can be used, but you must use the same form for the prefix and the
unit — that is, [milliampere] and [mA] are valid but not [mampere] or [milliA]). In the Settings windows for
plotting and numerical results, the Unit list contains the SI unit for the quantity, including the most common
prefixes. The lists also contain applicable non-SI units, which in some cases also support these prefixes — for
example, for g (gram), G (gauss), and M (molar).

Use Table 3-7 as a guide for the format to enter.


TABLE 3-7: SI PREFIXES.

FULL PREFIX SYMBOL FACTOR

yotta Y 1024
zetta Z 1021
exa E 1018
peta P 1015
tera T 1012
giga G 109
mega M 106
kilo k 103
hecto h 102
deca da 101
deci d 10-1
centi c 10-2

USING UNITS | 249


TABLE 3-7: SI PREFIXES.

FULL PREFIX SYMBOL FACTOR

milli m 10-3
micro u 10-6
nano n 10-9
pico p 10-12
femto f 10-15
atto a 10-18
zepto z 10-21
yocto y 10-24

STANDARD UNIT SYNTAX


You can use the unit syntax to specify a quantity with any applicable unit. To do so, append the unit to any constant
or variable in a model using a syntax where you enclose the unit in brackets, for example, 200[ft] and
3e6[kg/m^3].

Both the name and the symbol can be used for a unit (but only names that form a single word without spaces or
hyphens are possible to use). For example, 2.4[ampere] and 2.4[A] are both valid to indicate an electric current
in SI units. The SI units can also contain standard prefixes. Appending a unit means that you multiply the constant
or variable to the left of the unit declaration with this unit. This multiplication takes precedence over other
operators so, for example, 1/2[m] evaluates to 0.5 m1 (0.5[1/m]) whereas both (1/2)[m] and 1/2*1[m]
evaluate to 50 cm (0.5[m] or 50[cm]). Also, if L is a variable defined as 2[m], L[1/s] evaluates to 2[m/s].

The following examples show how to apply the unit syntax:

• Adding two quantities of the same kind that use different units: 0.5[ft]+33[mm]. The COMSOL Multiphysics
software converts the result to the base unit system’s length unit (0.1854 m for SI units, for example). A quantity
without a unit is treated as given in the base unit’s systems unit, so, for example, 0.5+33[mm] evaluates to
0.533 m when using SI units.
• Using multiplication with a unit to get consistent units for two quantities that you want to add, for example,
14[kg]+[Link][m^3], which works if [Link] represents the density for a heat transfer model. You can also
concatenate several units, for example, 3.6[N][m], which is equivalent to typing 3.6[N*m] and evaluates to
3.6 N·m.

For unit names with spaces and hyphens, such as British thermal unit and pound-force, only use the
symbols when declaring units.

It is possible to add constants (without units) to any quantity. The COMSOL Multiphysics software then assumes
that this value has the same unit as that quantity (as indicated in the Settings window).

All data in the material databases and Material Library product use SI units and this unit syntax.

DECLARING UNITS FOR PARAMETERS, VARIABLES, AND FUNCTIONS

It is important to be aware of the following aspects of unit handling.

250 | CHAPTER 3: BUILDING A COMSOL MULTIPHYSICS MODEL


When using parameters, variables, and functions in expressions:

• If user-defined parameters or variables are used in the physics, it is good practice to use the unit syntax to define
them. The Settings windows for parameters and variables display the resulting unit, in the models base unit
system, of user-defined parameters and variables. It is important to verify that the variables have the expected
unit before using them in the physics settings. The unit of parameters and variables is otherwise undefined.
• Most user-defined and built-in functions expect dimensionless inputs and outputs, so it is good practice to use
make inputs, such as time, dimensionless using unit syntax. If the input is not dimensionless, the COMSOL
Multiphysics software marks the expression in an orange color and reports an unexpected unit of input. For
example, to use the time t as input to a Rectangle function rect1, use [1/s] to make the input dimensionless:
rect1(t[1/s]).

• Using properties with undefined units in a model does not affect the numerical results during the analysis, but
undefined units are required in the results and visualization stages — expressions involving such parameters and
variables are also unitless.
• If other units than the base unit system’s units are used or if SI prefixes are included, the conversion to base units
also affects the value (quantity) using a scaling factor (and an offset for temperature units). The Value column in
a Settings window for Parameter displays the quantity and unit in the base unit system so that you can see the
result of the unit conversion. For example, a parameter is defined as 3[ft], the result in the Value column is
0.9144 m if the base unit system is SI.

SI Base, Derived, and Other Units


The SI units form an internationally accepted system with seven units for base quantities and a large number of
derived units. Use the symbols for these and other units when declaring units in COMSOL (for example, 10[m/s]
uses the SI unit for velocity).

• Table 3-8 lists the SI units for the seven base quantities.
• Table 3-9 lists the SI derived units supported in COMSOL Multiphysics.
• Table 3-10 lists additional units available in the COMSOL Multiphysics software regardless of the unit system
in the model. If more than one name or symbol is available, use any of them, except when names contain more
than one word or a hyphen. See also the tables with special units for other unit systems than the SI system; special
units that are not listed in Table 3-10 are only available when using such non-SI unit systems.
• Table 3-11 lists other SI derived units without special names or symbols.
TABLE 3-8: BASE SI UNITS.

BASE QUANTITY UNIT NAME SYMBOL

length meter, metre* m


mass kilogram kg
time second s
electric current ampere A
temperature kelvin** K
amount of substance mole mol
luminous intensity candela cd
* See About Editing Geometry Length and Angular Units
**See About Temperature Units

USING UNITS | 251

You might also like