# How can I see the equations COMSOL is defining? How do I implement a user-defined Multiphysics coupling?

 Solution Number: 1259 Title: How can I see the equations COMSOL is defining? How do I implement a user-defined Multiphysics coupling? Platform: Versions: All versions Categories: General Keywords:

## Problem Description

I would like to define my own customized coupling between two existing physics interfaces. How can I do this? How can I find the names of the variables that I will need to use?

How can I see the names of all variables used internally by the software when solving a model?

## Solution

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, sometimes you will want to create your own. Here, it is shown how an existing coupling is introduced, and how to implement the same coupling manually. As a supplement to this article, also watch Adding Multiphysics.

### 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. An example of such a coupling is given in the Introduction to COMSOL Multiphysics® booklet. 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 feature available within the Multiphysics branch, as shown in the screenshot below.

The in-built 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 materials 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, watch this video: Use functions to define material properties.

### Viewing the Built-In Equations and Manually Implementing the Joule Heating Multiphysics coupling

To manually implement this same 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 out the full equation that we want to implement, the source term in the Heat Transfer governing equation:

where is usually just an isotropic (scalar) value but in the most general case can be an anisotropic tensor.

Next, we need to know what all of these variables are called, internal to the COMSOL Multiphysics® architecture. There are two ways to see these:

1. Enable the Equation View toggle underneath the Show Menu within the Model Builder window. Once enabled, there will be an Equation View subsection underneath each physics feature that contains a list of all internally defined variables. 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.

The equation view, showing the components of the electric conductivity tensor and its isotropic value.

1. Generate a Complete Report by going to Results > Reports, right-click to see the options for report generation. You can generate an HTML or Microsoft Word® report, or preview the report, as shown in the screenshot below.

The settings for the Report Generator.

An excerpt from this report is included below, and shows how 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 `Vx, Vy, Vz`, the partial derivatives in the x-, y-, and z-directions respectively.

``` Name ExpressionUnitDescriptionSelectionDetails ... ec.Ex -Vx V/m Electric field, x componentDomains 1-7 ec.Ey -Vy V/m Electric field, y componentDomains 1-7 ec.Ez -Vz V/m Electric field, z componentDomains 1-7 ... ```

An excerpt of a Report from a model including the Electric Currents physics.

Now that all internal variable names are known, all that remains is to manually add the heat source term to the Heat Transfer physics interface. The expression for the source term can of course be written several different ways using the variables shown above, but if we assume isotropic electric conductivity one convenient way to write it is:

` ec.sigma_iso*(ec.Ex^2+ec.Ey^2+ec.Ez^2) `

The expression can now be added as a domain Heat Source term within the Heat Transfer interface, as shown in the screenshot below. Note that once you add this coupling manually, you should remove the in-built 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.

### Implementing more general Multiphysics couplings

Regardless of the multiphysics couplings that you will want to implement, the approach will be similar to the approach described above. 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, you will need to define yourself all of the intermediate variables and nonlinear material relationships via Variables and Functions features underneath the Component > Definitions branch. Examples of models that demonstrate such manual couplings include:

If 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.

### Disclaimer

COMSOL makes every reasonable effort to verify the information you view on this page. Resources and documents are provided for your information only, and COMSOL makes no explicit or implied claims to their validity. COMSOL does not assume any legal liability for the accuracy of the data disclosed. Any trademarks referenced in this document are the property of their respective owners. Consult your product manuals for complete trademark details.