## Adding Integration

**How to define an integration in COMSOL Multiphysics**

Adding an integration definition is one of the practical step in manipulation and simulation process in numerical and computational modeling. In this tip * Heat Transfer from Infinite Plate-Time Dependence CMS* is used in order to illustrate it and show how we can use it in Results steps (post-processing).

Adding an integration operator for the computation of the relative L2 error between numerical and analytical solutions is intended.

- In the
**Definitions**toolbar, click**Component Couplings**and choose**Integration**.

**Integration 1 (intop1)**

- In the
**Model Builder**window, under**Component 1 (comp1)>Definitions**click**Integration 1**(intop1). - In the
**Settings**window for**Integration**, locate the**Source Selection**section. - From the
**Selection**list, choose**All domains**.

**Results**

Next plot the relative L^{2} error between the numerical and analytical solutions over time.

**1D Plot Group 2**

- In the
**Home**toolbar, click**Add Plot Group**and choose**1D Plot Group**. - In the
**Settings**window for**1D Plot Group**, type*Relative L2 Error*in the**Label**text field.

**Line Graph 1**

- In the
**Relative L2 Error**toolbar, click**Line Graph**. - In the
**Settings**window for**Line Graph**, locate the**Selection**section. - From the
**Selection**list, choose**All domains**. - Locate the
**y-Axis Data**section. In the**Expression**text field, type sqrt(intop1((T2*sum((1)^n/((n+0.5)*pi)*exp((n+0.5)^2*pi^2*t)*cos((n+0.5)*pi*x),n,0,1000))^2))/sqrt(intop1(T^2)). - Select the
**Description**check box. - In the associated text field, type
*L2 error from analytical solution*. - Locate the
**x-Axis Data section**. From the**Parameter**list, choose**Expression**. - In the
**Expression**text field, type t. - Locate the
**Coloring and Style**section. From the**Color**list, choose**Black**. - In the
**Relative L2 Error**toolbar, click**Plot**.

As the analytical solution shows oscillations at initial time, change the settings of the graph for a better readability, to get the plot of Figure 1.

**Relative L2 Error**

- In the
**Model Builder**window, under**Results**click**Relative L2 Error**. - In the
**Settings**window for**1D Plot Group**, locate the**Axis**section. - Select the
**Manual axis limits**check box. - In the
**x minimum**text field, type 1e-3. - In the
**x maximum**text field, type 1. - In the
**y minimum**text field, type 0. - In the
**y maximum**text field, type 1e-3. - In the
**Relative L2 Error**toolbar, click**Plot**.