Solution Number: 913
Title: Computing Time and Space Integrals
Platform: All Platforms
Applies to: All Products
Versions: All versions
Categories: Physics, Postprocessing
Keywords: time integral time-integral scalar

Problem Description

How do I compute integrals over space or time? What if I want to use the result of these integrals elsewhere in my model?

Solution

This is a general description of how to use Integral operators. A more thorough walkthrough on integral operators can be found in this blog post.

Evaluating Integrals

Space Integrals

If you have solved a model and want to calculate a spatial integral of some result, your most convenient option is to right-click Derived Values and select Integration. You can integrate over volumes, surfaces, or lines. On the Settings tab, make a selection, choose or type in the Expression you want to integrate, and click the Evaluate button.

Time Integrals

The timeint operator, timeint(t1,t2,expr), integrates a time dependent expression expr between times t1 and t2. You can use it in any Expression text field in a plot or under Derived Values. There is also a timeavg operator, timeavg(t1,t2,expr) for extracting the time average of the expression between the same times.

If you type timeavg(2,5,T) in the Expression field of a surface plot, the plot will show the local time average of the temperature between 2 and 5 seconds. You can also use expressions such as timeint(0,t,T) in for example a point graph to plot the integral versus time.

Reusing Integrals

Space Integrals

In case you need to use the result of a spatial integration elsewhere in your model, you can make it accessible through Definitions > Component Couplings > Integration. Defining an integral operator intop1 lets you evaluate the integral of an expression expr over a set of domains, boundaries, edges, or points, by entering intop1(expr). The Application Library has plenty of examples of how this works; see for example Automotive Muffler under COMSOL Multiphysics > Acoustics.

Time Integrals

The timeint and timeavg operators are only available during results evaluation. If you need access to a continuously evolving time integral as part of your model, you can introduce it as a new dependent variable, I. Assume that I is defined as the time integral of another quantity u.

Differentiating with respect to time then gives the following ordinary differential equation:

which is the equation to enter in COMSOL. Depending on your need, you can set up an integration of a point or global scalar value (use a Global or Point ODE), or a distributed integration of a field variable (Domain, Boundary, or Edge ODE). For an example, see PID Control, in the Application Library under COMSOL Multiphysics > Multiphysics.


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.