Google
COMSOL Modelling: A Crash Course on COMSOL/FEMLAB for Beginners

Thursday, November 02, 2006

A Crash Course on COMSOL/FEMLAB for Beginners




Here is a Crash Course on COMSOL/FEMLAB which is also offered at NADA-KTH for the Beginners by Prof Michael Hanke.


Comsol Multiphysics is an integrated environment for solving systems of time-dependent or stationary second order in space partial differential equations in one, two, and three dimensions. Moreover, such equations may be coupled in an almost arbitrary way. Comsol Multiphysics provides sophisticated (and convenient) tools for geometric modeling. Therefore, for many standard problems, there exist predefined so-called application modes which act like templates in order to hide much of the complex details of modeling by equations. The application modes make use of the language used in the respective engineering discipline.
For our purposes, it is sufficient to work with the
core equation model because we do not need to use the advanced features of Comsol Multiphysics. There are two forms of the partial differential equations available, the coefficient form and the general form. They read

respectively. We will stick to the coefficient form. It can only be used for mildly nonlinear problems. For most nonlinear problems, the general form needs to be used. The coefficients of the coefficient form may depend both on x, t, and u. Observe that a dependence on u is not recommended.

1.) Example. As a running example take the one-dimensional heat equation

Here we have d a =1, c =1, f = Q, and all other coefficients are vanishing.

Starting Comsol Multiphysics

Comsol Multiphysics is available on all supported platforms. Under Solaris or Linux, issue the command

> module add comsol

in order to get access to the system. If you are using Comsol Multiphysics in other installations, please follow the instructions coming with the installation CD. In order to invoke Comsol Multiphysics, go to a directory of your choice and run the command:

> comsol &


You will be confronted with the Model Navigator. Here you can select the space dimension of the problem (1, 2, or 3), the application mode, the name of the dependent variable(s) (this may be more than one if you have a system of equations), and the type of the finite element to be used. I recommend that you do not change the name of the application mode. The Multiphysics button leads to the more advanced features of Comsol Multiphysics.1 If you want to load your own model, press OK without selecting a new application mode.


Example. Let us continue with our heat equation. We set the space dimension to 1D. Even if there is a predefined application mode for the heat equation, we will use the coefficient form for demonstration purposes. So select

Comsol Multiphysics --> PDE Modes -->
PDE, Coefficient Form --> Time-Dependent Analysis

On the right-hand side of the window, the form of the equation will be displayed. Do not touch all other parameters. The name of the unknown function will be u while the independent variables are x and t.

Define your problem

After you have accepted your choice in the Model Navigator, the main window of Comsol Multiphysics will appear. Its main contents is the a graphics window displaying the domain under construction (of course, it is empty in the beginning). The menu contains the main steps to be taken in obtaining a solution. Below the main menu, there is a button line providing shortcuts to the most important submenu items. If you stop with the mouse over a button, a bubble help will appear. As a rule of thumb, you have to traverse the main menu (or the button line) from left to right. In the Filemenu, you can save your project at any time, and reload it if you want to continue. 1Indeed, multiphysics is one of the main strengths of Comsol Multiphysics!


Options

In the Options menu, you can define some global settings. The most important points are probably


Axes/Grid Setting: Here you can define the area to be displayed in the graphics window.

• Constants: Very often, a problem contains a lot of parameters. Here, you can define them. They are later available in the physics modeling.

Example. Define the strength of our heat source:


Options --> Constants
In the Name field, enter Q. In the respective Expression field, enter 1e2. Now, choose
Options --> Axes/Grid Settings
Enter xminand xmaxas -0.1 and 1.1.

Draw

In the 1D case, this menu contains only a few entries. I recommend to define the domain by hand rather than using the mouse.


Example. In oder to obtain the domain =[0,1], choose
Draw --> Specify Object --> Line
Insert 0and 1into the dialog box.


Physics


This is the place where you define the equation as well as the boundary conditions. For all coefficients and initial guesses, you can use mathematical expressions with a MATLAB-like syntax. Many mathematical standard functions are available. Use simply their MATLAB name. If you should obtain an error about an undefined function, you should try to replace it by equivalent expressions if possible. Otherwise you to have to run Comsol Multiphysics in a MATLAB environment


The first menu item is the definition of the boundary conditions. You have the choice of Dirichlet and Neumann-type boundary conditions. Robin boundary conditions may be inserted using the Neumann boundary condition case. If you started the dialog, you will find a numbered set of boundary pieces. If you select one of it, it will be highlighted in the graphics window. Specify the boundary condition for that part of the boundary on the right-hand side. Cycle over all boundary pieces until you are done. The denotation used is specified in the headline.
The next step consists of defining the differential equation. Select the Subdomain Setting dialog box. Again, a list of subdomians is presented.4 Select it, and you can assign the expressions for the coefficients. A reminder about the denotation can be found in the headline. Note that there are different tabs available. Besides the Physics tab, you will need the Init tab. For time dependent problems, the initial value must be defined. If you have a nonlinear problem, an initial guess for the nonlinear solver should be provided here, too.



Example. Assume that we have Dirichlet boundary conditions at t =0 and Neumann boundary conditions at t =1. After selecting

Physics --> Boundary Settings

select boundary 1 by clicking on it. The left boundary point will be highlighted in red. Choose Dirichlet boundary conditions. Do the same with boundary 2 but use Neumann boundary conditions.

The next step consists of

Physics --> Subdomain Settings

Select subdomain 1 (there is only one), and the line will be indicated in red in the graph. In tab Physics, all coefficients have already their correct values with the exception of the right-hand side. Insert Qinto the dialog box near f. Remember that Qwas a constant defined in the options setting. Go to the Init tab. You may insert an expression for the initial condition. Let the proposal 0 alone, this is equivalent to u(t =0,x)=0.


Mesh


Click on the mesh button to create an initial mesh. It is often rather coarse. Use the refine button until the mesh is sufficiently fine. Note that, for stationary problems, you have the possibility to choose an adaptive solver which will generate a problem-adapted mesh according to your criteria.

Solve


Here, you can select the solver to be used and the solver parameters. This is accessible under the menu entry Parameters. Usually, all parameters have already reasonable values. The only exception may be the time-dependent solver where you have to adjust the interval for solving the problem as well as the output points. Then solve the problem! Some output of the solvers is available in the log window. After a shorter or longer while you will5 be switched automatically into the Postprocessingmode. If you are interested in knowing what is going on, choose View log from the Solve menu.

Example. Select


Solve --> Solver Parameters


Enter the values where you want to have the output in the Times field. It is convenient to use MATLAB’s colon notation, for example, 0:0.01:1.5. This will provide solutions for times between 0 and 1.5 with an increment of 0.01. Save it and solve the system.


Postprocessing


The Postprocessingmenu contains a lot of graphical output routines. Moreover, derived quantities can easily be computed, an example being integrals over surfaces and subdomains. Unfortunately, the function values of the solution are not accessible via dialog boxes. Instead, one has to rely on the solution plot. If you are moving the cursor over the solution graph, values of the solution are displayed in the lower left corner. If SNAP is set to on, only values on the grid defined in Axes/Grid Settingsare accessible. So either you switch off SNAPby double clicking on it, or you include the coordinates of the point you are interested in into the grid definition.


Help


Not really surprising, in this menu you will find a lot of help resources. I recommend that you read through the quick introduction. The user guide is rather long...

If you are more experienced, you can use Comsol Multiphysics from within MATLAB. Here, you have immediate access to solution values.

DONE


If you are ready or you want to interrupt your Comsol Multiphysics session, you can save your model using the File menu. I recommend to save it as an fl-file. The experienced user is probably more satisfied with an m-file because it is human readable. Then you can reload it at any time later modifying your model as you need.

28 comments:

Lubdhak said...

useful post..thank you

Lubdhak said...

useful post..thank you.

sunny said...

Hello friends,
Thanks in advance for your answers,

I am using genreal form of PDE to solve system of PDEs. I am dealing with cyllindrical co-ordinates under axisymmetric case. I am not able to understand how to implement boundary conditions such as,

DEL. Gamma=F is system of PDEs
where Gamma is function of (u, v, ur, uz,vr,vz..)

I would like to set u=0 and vr=0 on one of boundary, vr stands for derivative of v w.r.t. r.

can any one tell me how to set these boundary conditions in COMSOL 3.4?

Thanks again.
sunil

Hovden said...

Thanks. I wish there was more documentation on COMSOL. This post was a good first step.

YalcinKaymak said...

Hi, I am trying to solve a transient problem with comsol multiphysics. I would like to write an equation in scalar expressions which includes the time-increment dt. What is the name for dt in comsol?

thanks alot

Vohra said...

Hi All,

I am trying to solve a problem where the solutions are expected to be zero for a very long time.

I have refined the mesh with the maximum element size of 0.002 and am using the GMRES method with preconditioning quality of 0.01.

However, inspite of it, the system is unable to process the solution and gives an error for residual computation citing singular matrix as the problem.

Can anyone please suggest some ways to solve the problem?

Agenzie modelle milano said...

Great opportunity and informative article,Thanks.

Anonymous said...

thanks

RABEYA said...

I am new user of COMSOL multiphysics 4.0. I want to get field distribution when a potential is applied between two electrodes separated by a distance of 1 um gap. But it shows an error message:
Stationary(sol1/s1)
Error-Singular matrix.
How can I solve this problem ?

Raducu Roman said...

Hello all,

I'm a student, new to Comsol, and I'm trying to simulate a copper coil with a current of 100A, at 50Hz, and an Iron/Aluminum screen to see how it shields the electromagnetic field.

I have done the geometry of the screen and tried to draw a ring shaped coil, but I cannot manage to set the current through the coil. Can anyone guide me through the process so I can understand how to do it myself?

Thanks.

VPP said...

hi i m new to comsol and i have completed my geometry for microelectrodes in AC/DC electrostatics but i dont know how to apply ac signal to one of the electrode to get ac field.

Anonymous said...

whoah this blog is fantastic i really like reading
your articles. Stay up the great work! You recognize, many people are hunting around for this information, you can
aid them greatly.

Feel free to visit my page steinzeitdiät

Anonymous said...

This blog was... how do you say it? Relevant!! Finally I have found something that helped me.
Cheers!

Here is my homepage: wordpress installation
My site: google analytics wordpress

Anonymous said...

It's difficult to find knowledgeable people for this topic, but you seem like you know what you're talking about!
Thanks

my web page: rapsöl schädlich

Anonymous said...

It's difficult to find knowledgeable people for this topic, but you seem like you know what you're
talking about! Thanks

my website ... rapsöl schädlich
Also see my webpage :: paleo ziegenkäse

Anonymous said...

Wonderful items from you, man. I've take note your stuff prior to and you're simply too magnificent.
I really like what you have obtained here, really
like what you are stating and the way wherein
you assert it. You're making it entertaining and you still take care of to stay it sensible. I cant wait to learn far more from you. That is actually a tremendous web site.

Here is my website glutenfrei
my website - durchfall und bauchschmerzen

Anonymous said...

Hello! I just wanted to ask if you ever have any issues with hackers?
My last blog (wordpress) was hacked and I ended up losing many months of hard work
due to no backup. Do you have any solutions to
stop hackers?

my site; steuerberater homepage

Anonymous said...

Fastidious replies in return of this issue with genuine arguments and telling the whole thing regarding that.


my page: gute Thai Massage Wiesbaden
My page :: Thai Massage Wiesbaden bewertung

Anonymous said...

My relatives always say that I am killing my time here at net,
except I know I am getting experience all the time by reading
such good content.

Feel free to visit my web-site - gesund leben

Anonymous said...

Pretty portion of content. I just stumbled upon your website
and in accession capital to assert that I acquire in fact loved account your
weblog posts. Anyway I will be subscribing on your augment and even I fulfillment you get
entry to persistently fast.

Feel free to visit my web site; wordpress thems

Anonymous said...

It's very straightforward to find out any matter on net as compared to textbooks, as I found this piece of writing at this website.

Take a look at my web site: anlegen in mainz

Anonymous said...

Good day! Do you know if they make any plugins
to safeguard against hackers? I'm kinda paranoid about losing everything I've worked hard on.

Any tips?

My webpage: paleoernährung

Anonymous said...

Hi, i think that i saw you visited my blog thus i came to
“return the favor”.I'm trying to find things to enhance my website!I suppose its ok to use some of your ideas!!

My website: eiweißriegel ohne kohlenhydrate

Anonymous said...

Howdy! This blog post could not be written much better!
Looking through this article reminds me of my previous roommate!
He constantly kept preaching about this. I most certainly will
forward this information to him. Fairly certain he will have a great read.
Thanks for sharing!

Here is my homepage :: pegasus lenkmatten

Anonymous said...

Heya i'm for the primary time here. I came across this board and I in finding It truly useful & it helped me out much. I'm hoping
to offer something back and help others like you helped me.


Feel free to surf to my site paleo diät

Anonymous said...

Write more, thats all I have to say. Literally,
it seems as though you relied on the video to make your point.
You definitely know what youre talking about, why waste your intelligence on just
posting videos to your weblog when you could be giving us something informative to read?


Also visit my web site: south beach diat
my page :: paläo diät

Anonymous said...

You should be a part of a contest for one of the highest quality blogs on the internet.
I'm going to highly recommend this site!

Here is my page ... activity calorie calculator

Sourav Panigrahi said...

hello guys i mwprking on solution of heat transfer in human breast in comsol 3.4..my coloured surface plot is coming full green..with min and max tempeatures as same values....so i think i am doing some mistake in boundary ans subdomain settings..
can anyone please help me????


my id sourav1993theknight@gmail.com