Adding Integration

Adding Integration

COMSOL Tips Featured Image

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)

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

Results

Next plot the relative L2 error between the numerical and analytical solutions over time.

1D Plot Group 2

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

Line Graph 1

  1. In the Relative L2 Error toolbar, click Line Graph.
  2. In the Settings window for Line Graph, locate the Selection section.
  3. From the Selection list, choose All domains.
  4. 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)).
  5. Select the Description check box.
  6. In the associated text field, type L2 error from analytical solution.
  7. Locate the x-Axis Data section. From the Parameter list, choose Expression.
  8. In the Expression text field, type t.
  9. Locate the Coloring and Style section. From the Color list, choose Black.
  10. 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.

Figure 3. L2 error between analytical and numerical solutions over time.
Figure 1. L2 error between analytical and numerical solutions over time.

Relative L2 Error

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


CMS
CMS Website
Computational Modeling and Simulation is the simulation center of Acamech that models Mechanical Engineering Problems, especially Multiphysics Simulation; including Fluid Flow (CFD), Structural Mechanics, Acoustics, Heat Transfer as a unique Multiphysics problem. We use COMSOL Multiphysics, MATLAB, and Autodesk Inventor.

Leave a Reply

Your email address will not be published. Required fields are marked *