You are on page 1of 7

# CEE-268 Winter 2006 Introduction to Finite Element Modeling & COMSOL By Michael Cardiff Tips and Tricks What

t to do when your problem isnt solving correctly Background: Why does COMSOL hate me? In all of the previous example problems the instructions have been written such that when you solve the problem it will converge! But except for relatively simple problems (or sample problems that have been tested already by your very nice professor!), getting a model you have created to converge to a solution that looks correct may take a lot of time and effort. This can be a tedious, slow process and much like debugging code can lead to a lot of frustration. It is the hope of the author that the tips and tricks below will help to minimize these annoyances. If all of the below suggestions fail

relax, go get a cup of tea, and take a break from staring at your model!
this is often the best advice of all. What causes errors? A problem that will not run, will not converge, or gives an incorrectlooking solution may be caused by many different types of problems. When trying to debug a code or a model, it often helps to have a very structured approach for finding the error. With this in mind, lets divide the type of errors that may occur into several key areas. They are, in rough order of probability : User Error o General syntax errors o Boundary conditions or Subdomain settings not correctly defined o Direction of elevation not specified (and hence no gravity) o Multiphysics equations not linked correctly o Unreasonable initial conditions Solver Errors o Solver Tolerance not set low enough o Maximum # of Iterations reached

o Problem is Highly Nonlinear o Problem cannot be solved by the selected algorithm o Mesh is not fine enough in important areas COMSOL Error o Bug in COMSOL module or material definitions o Formula used by COMSOL is not correct or not general enough

Common User Errors (& how to fix them) Simple Typos The easiest-to-correct (and most common) errors are those that simply involve a typing mistake on the part of the user. If youve defined constants or variables in your problem, make sure you have entered these constants / variables correctly in any field where you use them. Errors relating to simple typos generally look something like those in Figure 1.

Figure 1: Common error window messages resulting from typos in variable or constant names.

A good way to check for this type of error is to look for the above error messages. Other Syntax Errors

A slightly more difficult-to-detect error set is when you have typed in an incorrect formula. In this case, you may have all of your constants and variable names correct but the formula itself does not make sense. For example, suppose we have the following code entered in a text box: Linspace(xmin,xmax,ymin,ymax) As long as xmin, xmax, ymin, and ymax are defined we do not have any variable or function name problems. HOWEVER, the function linspace only accepts 2 or 3 arguments, and we have supplied it with 4. Fortunately, MATLAB and COMSOL share a nearly identical language when it comes to defining formulas so: A good way to check for this type of error is to copy and paste any formula code into MATLAB and see if it gives you any unexpected errors. Boundary Conditions or Subdomain Settings not correctly defined Usually, its fairly easy to remember to enter all of your boundary conditions as youre going through a problem, but its often easy to forget subdomain conditions. Subdomain conditions are where you set properties of the medium itself, such as hydraulic conductivity, porosity, etc. In addition, when youve incorporated Multiphysics (for example, Darcys Law mixed with Solute Transport), its even easier to forget which menus you have visited, since they change each time you change physics. NEVER ASSUME that COMSOL has given you a reasonable value for all of your parameters. For example, if you start a new Richards Equation model for groundwater flow, the default value for Density of Fluid is 1 kg/m3. A good way to AVOID this type of error is to make sure you visit both boundary conditions and subdomain settings within each set of physics. Also, verify that physical constants chosen by COMSOL are reasonable. A good way to check for this type of error is to print out a COMSOL report using File Generate Report Direction of elevation not specified