# Tips and Tricks, COMSOL News 2009

• Browse by Category
 All solutions Boundary Conditions (3)Chemical Engineering (4)Documentation (2)Electromagnetics (3)Error Messages (68)Fluid Dynamics (6)General (12)Geometry (19) Import (19)Installation (60)Mesh (12)Multiphysics (1)PDEs, ODEs, and other equations (3)Physics (21)Postprocessing (11)Product Information (1)Solver (19)
 Solution Number: 1042 Title: Tips and Tricks, COMSOL News 2009 Platform: Windows Versions: 3.5a Categories: Keywords: global equations ode pde integration

## Problem Description

This solution is a is a review of the support column in COMSOL News 2009, and makes the example files available for download. To access the entire issue of the magazine, please contact your local COMSOL representative.

## Solution

The inaugural live demo session of "20 Tips & Tricks" at the COMSOL Conference in Boston 2008 triggered a great deal of positive feedback. We're thrilled to share some of the session's highlights here. Here is an excerpt of the discussed tricks.

### Global Constraint

It is easy to add a global constraint to a model through the Global Equations interface. Let’s look at an example: You have a heat conduction problem and you want only to allow a maximum temperature at some part of the body, perhaps due to materials limits. This maximum temperature is not included in the boundary conditions or materials settings of a PDE model. It needs to be added as an additional equation.

Global equations are useful for many interesting model applications, of which the above is maybe the simplest

That single equation needs to be fulfilled at the system level, which is why we call it a global equation. Since we add an extra equation, the constraint, to the system, we need to add an extra unknown. In this case we use the distributed heat source Q_0 in the heat conduction PDE and make it a global dependent variable instead. This type of problem is sometimes referred to as a backward problem. Here are the necessary steps:

1. Probe the temperature at the point of interest and make it globally available though the menu Options > Integration Coupling Variables > Boundary Variables. Call it T_probe. Note: In a 1D model, like this example it should be a Boundary Variable, but in 2D and 3D, a Point Variable.
2. Create a global equation where you define Q_0 as the dependent variable and specify the simple equation T_probe = T_max. Note that the dependent variable needs not be included in the equation itself.

### Space Integration

Your COMSOL Multiphysics model will typically give answers in field variables, such as the spatial distribution of temperature or velocity field. However, many times you are interested in system scalars like total heat duty (in kW) or mole flow (in moles/s). If you have a flow conduit, the mole flow Fm of a chemical species out across the exit boundary is

where N is the molar flux and n is the normal vector to the outlet boundary. To set this up: Use the boundary integration tool from the menu Options->Integration Coupling Variables->Boundary variables. The integrand is often available as a predefined application variable for you to use. For example, in a convection and diffusion application mode, the normal flux, N·n is available as the name ntflux_c_cd.

### Time integration

This is an extension to the first tip in that it involves setting up a global equation, but this time we solve a global ordinary differential equation (ODE). Let's stick to the flow problem and, in a similar way as above, set up the mass flow at the exit as Fmass (kg/s). In a time-dependent problem, you may be interested in how much mass M has exited at a certain time t1:

This type of time integration can be performed by setting up the differentiated version of the above equation as a global ODE

This is done in the Global Equations dialog box the same way as in the first tip.

### Stop Condition

When you have performed the previous step to track the total mass that has exited in every time instant, you can tell the the solver to stop when you reach a certain value. Use the Stop condition in the Time Stepping page of the Solver Parameters dialog box. The solver will stop when the expression in the edit field becomes negative.

### Sweep 2D Axisymmetric Solution to 3D

If you wish to visualize an axisymmetric 2D solution in 3D, extrusion coupling variables will do the trick. The image below shows the principle. Note that this solution applies to COMSOL 3.5a, for information relating to COMSOL 4.0 and later, please refer to Knowledge Base solution 982.

The picture above shows the modeling domain

This plot shows the solution revolved to 3D, and postprocessed with streamlines.

## Related Files

 1_forward.mph 78 KB Forward heat transfer problem 1_backward_global_constraint.mph 78 KB Backward heat transfer problem with global constraint 2_flowint.mph 881 KB Mole flow integration 3_flowint_timeint.mph 882 KB Total mass integration 4_stop_condition.mph 618 KB Stop condition 6_2D_to_3D_Flow.mph 1.2 MB Sweep of 2D solution to a 3D plot

## Feedback

 Poor | Excellent Document quality? How can we improve this document? My e-mailaddress: (optional) Verify Email

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