Viewing and Accessing the Equations and Variables for Physics Feature Nodes
In COMSOL Multiphysics®, you can see the underlying governing equations for the physics in a model, as well as the definitions of the variables. This enables you to:
- See how the variables are calculated by the software
- See the names of variables and the quantities each one defines
- Access and use the variables when formulating expressions
- Edit any variables and equation contributions defined and used internally by the software
- More easily search and find variables defined by each physics interface and physics feature node
- Define custom multiphysics couplings between physics interfaces
In this article, you will learn how to both view and access the equations and variables for physics feature nodes. We will also demonstrate how to perform all of the items listed above using an example toward the end of this article.
Seeing the Equations
You can see the equation for any physics node in your model by selecting the respective node and in the Settings window, expanding the Equation section.
The Settings window for the Current Conservation node, wherein the Equation section has been expanded.
In the Equation section, the mathematical equations applicable to the node, and the selected study type, are displayed. The terms being contributed to the equation by the node are also highlighted with a dotted line displayed under the respective part of the equation (as seen in the above screenshot), except for the parent physics interface node (shown below).
The Settings window for the Electric Currents physics interface, wherein the Equation section has been expanded.
Accessing the Equations and Variables
You can access the equations and variables used internally by COMSOL Multiphysics® by enabling the Equation View nodes to display in the model tree. Through the Model Builder toolbar, you can open the menu for showing more options, and then select the check box next to Equation View and click OK.
The Show More Options dialog box accessed through the Model Builder toolbar.
Enable displaying the Equation View nodes for all the physics feature nodes in your model tree by selecting the respective check box.
Once enabled, there will be an Equation View node underneath each physics node that contains a list of all internally defined variables for the respective node. In the settings, you can see the variable names, expressions, units, and descriptions, among other details. All the variables and equation contributions defined by each node in a physics interface become visible and editable (such as to couple physics). You can easily search this information to find the variables you are looking for using the Find tool.A screenshot of the Equation View Settings window with an expanded table of variables
The Equation View for the Current Conservation node, wherein the table listing the variables has been expanded.
The Report Node
You can also access the equations and variables used for the physics through using the Report Generator. This tool enables you to document all the details of your entire model. You can generate a report that displays within the software and includes this information by completing the following steps:
- Select and right-click the Report node
- Choose to generate a Complete Report
- Select the option in the settings to Preview All of the report
- A preview of the report will appear in a new tab in the Graphics window
- Navigate to the physics interface or physics feature node which you want to see the equations and variables for
Generating a complete report for a model and searching for the equations and variables for a specific physics feature node are demonstrated.
A screenshot of part of a report from a model that includes the Electric Currents interface, with columns for Name, Expression, Unit, Description, Selection, and Details.
The report Preview tab in the Graphics window provides you with a convenient, at-a-glance view of all the equations and variables for the physics nodes. The information is displayed all at once without needing to switch between selecting different nodes. In addition, the expanded table formatting used for the variables' sections enables you to easily see all the settings and details for each.
An excerpt of a report from a model including the Electric Currents interface.
In COMSOL Multiphysics®, the ability to see and access equations and variables for the physics feature nodes included in your model are necessary in order to make changes, such as for implementing manual, custom multiphysics couplings. Below, we show a brief demonstration of this, the full process for which is detailed in another Learning Center article.
User-Defined Multiphysics Couplings
The ability to define arbitrary, and user-defined, couplings between existing physics interfaces is one of the core capabilities of COMSOL Multiphysics®. Although there are many multiphysics couplings already built into the software, in some cases, you may want or need to create your own. Here, it is briefly shown how an existing coupling is introduced, and how to implement the same coupling manually using the aforementioned features. The Thermal Actuator tutorial model is used as our example. Further discussion of this topic, along with a comprehensive introduction, is provided in an article Defining Multiphysics Models Manually with User-Defined Couplings.
An Existing Multiphysics Coupling: Joule Heating
One of the more common examples of a multiphysics coupling is Joule heating, where the flow of electrical current through a conductive material leads to heat losses, which lead to a rise in temperature. In short, to solve for Joule heating, one must solve for both the electric currents as well as the heat transfer governing equations. The stationary (time-invariant) form of the partial differential equation for electric currents is:
where is the current, is the electric field, is the electric conductivity, and is the electric potential.
For heat transfer, the governing equation is:
where is the thermal conductivity and is the temperature field.
The Joule heating effect introduces a heat load of the form:
The above coupling is automatically included via the Electromagnetic Heating multiphysics coupling feature, as shown in the screenshot below.
The predefined multiphysics coupling for Joule heating.
Simply by adding this feature and applying it to all relevant domains, the above multiphysics coupling will be included in the model. It is also important to note that this feature will automatically account for any nonlinear material properties, such as, for example, thermal and electrical conductivities that are temperature dependent. To learn how to define material properties that are dependent upon variables being solved for, you can watch a tutorial video on using functions to define material properties.
Manually Implementing a Multiphysics Coupling: Joule Heating
To manually implement this same multiphysics coupling, you will need to be aware of the full equation that you want to implement, as well as how variables are implemented within the COMSOL Multiphysics® architecture. First, we expand the full equation that we want to implement, the source term in the Heat Transfer governing equation:
where here is an isotropic (scalar) value.
In the most general case, it can be an anisotropic tensor:
Next, we need to know what all of these variables are called, internal to the COMSOL Multiphysics® architecture. As aforementioned, this can be done either through enabling Equation View or using the Report Generator. The screenshot below shows the variable name, expression, unit, and description for the components of the electric conductivity tensor, as well as the isotropic value. We can use the Find tool to search for these quantities and locate the respective variables and expressions that define them. If we are only interested in searching within the report preview, we can select the respective tab for it in the Graphics window and use the keyboard shortcut Ctrl+F to search locally within the generated report preview text.A screenshot of the Settings window for the Equation View node, with the Study and Variables sections expanded.
The equation view, showing the components of the electric conductivity tensor and its isotropic value.
An excerpt from this report is included below, and shows the names of the electric field components and how they are defined. The partial derivatives of
V (the field variable representing the electric potential) are given by the notation
Vz, the partial derivatives in the x-, y-, and z directions, respectively.
An excerpt of a report from a model including the Electric Currents interface.
Now that all internal variable names are known, all that remains is to manually add the heat source term to the Heat Transfer in Solids interface. The expression for the source term can be written several different ways using the variables shown above. However, if we assume isotropic electric conductivity, one convenient way to write it is:
The expression can now be added as a domain Heat Source term within the Heat Transfer in Solids interface, as shown in the screenshot below. Note that once you add this coupling manually, you should remove the built-in coupling from the Multiphysics branch, which was shown earlier. Again, keep in mind that any nonlinearities present in the materials will be automatically incorporated into this definition.
A manual implementation of the Joule heating multiphysics coupling.
Regardless of the multiphysics couplings that you will want to implement manually, the approach will be similar to what has been briefly described above and discussed in detail separately. The overall approach is the same if implementing couplings on domains or as boundary conditions. Note that such couplings will almost always result in a nonlinear problem. If you are not using the existing physics interfaces in the software, you will need to manually create and define yourself all of the intermediate variables and nonlinear material relationships via variables and functions features underneath the Definitions node. For this and other reasons, we highly recommend taking advantage of the software's predefined multiphysics interfaces or predefined multiphysics couplings whenever possible. Some examples of models that demonstrate manual couplings include:
- Transport and Adsorption
- Vacuum Drying
- Tubular Reactor with Jacket
- Chemical Etching
- The Shallow Water Equations
If you are solving such models as a stationary (time-invariant) problem, see: Improving Convergence of Nonlinear Stationary Models. Or, if solving in the time domain, see: Controlling the Time Dependent solver timesteps.