tag:blogger.com,1999:blog-80850676440788222972018-05-12T03:25:16.307-07:00COMSOL ModellingC2EC- Swanseanoreply@blogger.comBlogger5125tag:blogger.com,1999:blog-8085067644078822297.post-84687266486618287512011-04-13T23:35:00.000-07:002011-04-13T23:37:37.742-07:00Code for Making a Coil in MATLABI have been asked several times how did I generated the Coil in FEMLAB. I created the coil in MATLAB and then imported it as an object in FEMLAB. I was able to dig out the code and here it is for those who might still be interested.<br /><br />function g = coil(h,r,s,n)<br />% Create a Coil Line Geometry Object<br />%<br />% Usage:<br />% g = coil(h,r,s,n)<br />%<br />% Arguments:<br />% h : height<br />% r : radius<br />% s : number of windings<br />% n : number of line segments per winding<br />% if n is not specified a spline is used to construct the coil<br />%<br />% Example:<br />% g = coil(0.1, 0.05, 5)<br />% geomplot(g)<br />%<br />% The coil is imported into FEMLAB by using the<br />% File->Import->Geometry Objects menu<br /><br />if nargin==4<br /> N = n*s;<br /> <br /> carr = {};<br /> for i=1:N<br /> t = 2*pi*(i-1)/n;<br /> x = r*cos(t);<br /> y = r*sin(t);<br /> z = h/N*(i-1);<br /> <br /> t2 = 2*pi*i/n;<br /> x2 = r*cos(t2);<br /> y2 = r*sin(t2);<br /> z2 = h/N*i;<br /> <br /> carr{end+1} = curve3([x x2], [y y2], [z z2]);<br /> end<br /> <br /> g = geomcoerce('curve',carr);<br /> <br />else<br /> n = 4;<br /> N = n*s;<br /> <br /> p = zeros(3,N+3);<br /> t = 2*pi*(-0.1)/n;<br /> x = r*cos(t);<br /> y = r*sin(t);<br /> z = h/N*(-0.1);<br /> p(:,1) = [x y z]';<br /> for i=1:N+1<br /> t = 2*pi*(i-1)/n;<br /> x = r*cos(t);<br /> y = r*sin(t);<br /> z = h/N*(i-1);<br /> <br /> p(:,i+1) = [x y z]';<br /> end<br /> t = 2*pi*(N+0.1)/n;<br /> x = r*cos(t);<br /> y = r*sin(t);<br /> z = h/N*(N+0.1);<br /> p(:,N+3) = [x y z]';<br /> <br /> g = geomspline(p);<br /> <br />endC2EC- Swanseanoreply@blogger.com173tag:blogger.com,1999:blog-8085067644078822297.post-61875926591341704762006-11-03T09:27:00.000-08:002006-11-03T10:04:45.502-08:00A COMSOL Multiphysics Application : Induction Stirred Ladle<div><div><div><div><div><div><div>Hi All,<br /></div><div align="justify">I am posting today a sample Comsol Multiphyiscs application Model. I am Presenting a model in Femlab of induction stirred ladle furnace. The geometry of the model is shown in figure 1. <img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger2/5017/986946733896340/320/Induction.1.jpg" border="0" /></div><div></div><div></div><div><br /></div><div align="justify">There is a induction coil which produces magnetic field. It is placed near a cylindrical ladle containing a conducting fluid or motlen steal. </div><div align="justify"></div><div><br /></div><div align="justify">The Basic governing equation are the well known Maxwells equation which gives the magnetic field in terms of a Magentic Diffusion equation given as:</div><div><br /><br /></div><div align="justify"></div><div align="justify"> d<strong>B</strong>/dt = 1/(sigma*mu)*(del^2(<strong>B</strong>)) --------------- (1)</div><div align="justify"> </div><div align="justify"></div><div align="justify">The Solution of the above Magnetic diffusion equation will give the Magnetic field Bx, By and Bz as a function of time. These Magnetic field can then be used to find the Lorenz Force which will induce motion of the Melt/molten liquid inside the ladle. Given as :</div><div><br /></div><div align="justify"></div><div align="justify"></div><img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger2/5017/986946733896340/320/induction2.jpg" border="0" />These force field are fed into the NS or K-e model as source term for obtaining the solution of the velocity field in the melt. The Modelling is then done as follows:<br /><br /><div align="justify"></div><div align="justify">I tried to model it in 2 D and 3 D. Although 3 D model is more accurate. While modelling in 2D I assumed that the magnetic filedis in Bx and By direction only. The interaction of magnetic field and induced current will produce <strong>Lorenz force </strong>which will rotate the liquid metal in the cylindrical ladle placed near the induction coil. In 3d the inductor is modelled as current carrying coil. The coil geometry is created in MATLAB and then imported into COMSOL. To compute the velocity field in the model, I have coupled the two models using multiphysics option. I have coupled 3D quasi Static and 3D incompressible Navierstokes while modelling in 3D. In 2D modelling I have coupled k-e model and perpendicular current in electomagnetics. Now to solve the problem the the solve manager is used separately. First you solve the Electromagnetics (QAV) problem only, calculating the forces. Then you only solve the Navier Stokes (NS) using these forces. The forces will be constant during this solution process. You do this with the Solver manager under the tab Solve for. Here you select the QAV mode when you solve the quasi statics and NS mode for Navier stokes. After the QAVsolution you must select Current solution as initial value. Your Navierstokes problem also need some help in defining the pressure, otherwise it will be undefined. Specify a point constraint in one point under pointsettings to a certain pressure. Also believe that you need denser mesh inthe container where you solve the NS problem.</div><br /><div align="justify"></div><br /><div align="justify">On running the solver now I do get the solution of the magnetic field and also the induced currents and the melt velocity field. The model here is described in very brief, if any one required more information about current density setting and how to make a coil in MATLAB and how to import in into COMSOL just write a querry on the blog. </div><div align="justify"></div><div align="justify"></div></div><div><br /><div align="justify">The Figure below shows the model in COMSOL in 2 and 3D.</div><div align="justify"></div><br /><div align="justify"><img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger2/5017/986946733896340/320/solver%20model%20in%203D.jpg" border="0" /><img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger2/5017/986946733896340/320/solver2.jpg" border="0" /></div></div></div></div></div></div><br /><br /><p></p><p></p><p>The Results are shown here in 2D and 3D </p><img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger2/5017/986946733896340/320/Result2d.jpg" border="0" /><br /><br /><p></p><br /><br /><p></p><img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger2/5017/986946733896340/320/result3d.jpg" border="0" /><br /><br /><p></p></div>C2EC- Swanseanoreply@blogger.com23tag:blogger.com,1999:blog-8085067644078822297.post-54937250260742599202006-11-02T03:37:00.000-08:002006-11-02T03:56:22.633-08:00A Crash Course on COMSOL/FEMLAB for Beginners<div align="justify"><br /></div><br /><br /><div align="justify">Here is a Crash Course on<strong> COMSOL/FEMLAB</strong> which is also offered at NADA-KTH for the Beginners by Prof Michael Hanke.</div><br /><br /><div align="justify">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.<br />For our purposes, it is sufficient to work with the </div><div align="justify"> </div><img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger2/5017/986946733896340/320/untitled1.jpg" border="0" />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<br /><br /><div align="justify"></div><img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger2/5017/986946733896340/320/untitled.jpg" border="0" /><p align="justify"> 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.<br /></p><p align="justify">1.) <strong>Example</strong>. As a running example take the one-dimensional heat equation </p><p><img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger2/5017/986946733896340/320/untitled1.jpg" border="0" />Here we have d a =1, c =1, f = Q, and all other coefficients are vanishing. </p><p><strong>Starting Comsol Multiphysics</strong></p><p>Comsol Multiphysics is available on all supported platforms. Under Solaris or Linux, issue the command<br /><br />> <em>module add comsol</em><br /></p><p align="justify">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: </p><p align="justify">> <em>comsol &</em></p><p align="justify"><br />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. </p><p align="justify"><br /><strong>Example</strong>. 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 </p><p align="justify"><em>Comsol Multiphysics --> PDE Modes --><br />PDE, Coefficient Form --> Time-Dependent Analysis</em></p><p align="justify">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. </p><p align="justify"><strong>Define your problem </strong></p><p align="justify">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! </p><p><br /></p><p align="justify"></p><p><strong>Options </strong></p><p>In the Options menu, you can define some global settings. The most important points are probably </p><p><br />• <em>Axes/Grid Setting</em>: Here you can define the area to be displayed in the graphics window.</p><p>• Constants: Very often, a problem contains a lot of parameters. Here, you can define them. They are later available in the physics modeling.</p><p><strong> Example</strong>. Define the strength of our heat source: </p><p><br /><em>Options --> Constants<br /></em>In the Name field, enter Q. In the respective Expression field, enter 1e2. Now, choose<br /><em>Options --> Axes/Grid Settings</em><br />Enter xminand xmaxas -0.1 and 1.1. </p><p><strong>Draw</strong> </p><p>In the 1D case, this menu contains only a few entries. I recommend to define the domain by hand rather than using the mouse.</p><p><br /><strong>Example.</strong> In oder to obtain the domain =[0,1], choose<br /><em>Draw --> Specify Object --> Line<br /></em>Insert 0and 1into the dialog box. </p><p><br /><strong>Physics</strong> </p><p align="justify"><br />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<br /></p><p align="justify"><br /></p><p align="justify">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.<br />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.<br /></p><div align="justify"></div><br /><br /><div align="justify"></div><p><strong>Example.</strong> Assume that we have Dirichlet boundary conditions at t =0 and Neumann boundary conditions at t =1. After selecting </p><p><em>Physics --> Boundary Settings</em><br /></p><p>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.<br /></p><p>The next step consists of<br /></p><p><em>Physics --> Subdomain Settings<br /></em></p><p>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. </p><p><br /><strong>Mesh </strong></p><p><br />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.<br /></p><p><strong>Solve </strong></p><strong><p align="justify"><br /></strong>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.<br /></p><div align="justify"></div><p><strong>Example</strong>. Select </p><p><br /><em>Solve --> Solver Parameters</em></p><p><br />Enter the values where you want to have the output in the Times field. It is convenient to use <strong>MATLAB’s</strong> 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. </p><p><br /><strong>Postprocessing</strong> </p><p><br />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.</p><p><br /><strong>Help </strong></p><p><strong><br /></strong>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... </p><p>If you are more experienced, you can use Comsol Multiphysics from within MATLAB. Here, you have immediate access to solution values.</p><p> </p><p><strong>DONE </strong></p><strong></strong><p align="justify"><br />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.<br /><br /></p><div align="justify"></div>C2EC- Swanseanoreply@blogger.com29tag:blogger.com,1999:blog-8085067644078822297.post-63260194834675096462006-11-01T12:10:00.000-08:002006-11-01T13:08:11.665-08:00FEMLAB To COMSOL<div align="justify">The First version of <strong>FEMLAB</strong> (now called as <strong>COMSOL</strong>) which I used was <strong>FEMLAB 2.3</strong> from then to now <strong>FEMLAB</strong> has become COMSOL and many new version have come with more capabilities and modelling capabilities and many new features, along with one of the most Important <strong>COMSOL Script</strong>.<br /><br />Partial differential equations form the mathematical foundation for a host of important areas in engineering and physics. <strong>FEMLAB </strong>provides a powerful interactive environment for modeling and solving scientific and engineering problems which base on partial differential equations.<br /><br />Using <strong>FEMLAB</strong> one can model strongly nonlinear coupled multiphysics applications with ease. There is no inherent limitation on the simultaneous simulation of many physical phenomena. <strong>FEMLAB</strong> can handle (systems of) second and first order partial differential equations in one, two and three space dimensions. They are discretized by the finite element method. The (extensible) element library uses mostly polynomial elements on triangles (in 2D) and tetrahedra (in 3D), respectively. Some elements are available which are adapted to be applied special applications.<br />From the point of view of applicability, it is the multiphysics feature and the extensibility which distinguish <strong>FEMLAB</strong>. A host of models from different areas of applications are prepared in an easily accessible manner (the so-called applications modes) which can be combined by simple drag-and-drop techniques into complex multiphysics models.<br />A graphical user interface allows for an efficient graphical design of rather complex geometries in one, two and three dimensions. The powerful capabilities of <strong>FEMLAB</strong> give immediately rise to the question whether the user has to pay in order to use such a convenient tool. There are a number of very advanced software packages on the market competing with <strong>FEMLAB</strong>. Often, they have some emphasis on certain applications areas. This allows for the use of numerical algorithms being more adapted to the application at hand. Compared to that, the algorithms in <strong>FEMLAB</strong> must be of a more general nature in order to cover the broad spectrum of applications <strong>FEMLAB</strong> is intended for. The latest version of <strong>FEMLAB</strong> is 3.0a. It distinguishes itself from all previous versions in that all computational kernels have been reimplemented in C++. The previous versions are implemented in <strong>MATLAB</strong>. While opening all the features of <strong>MATLAB </strong>to be used in <strong>FEMLAB </strong>it has the drawback of slowing down the numerics and increasing the memory requirements. Even if <strong>FEMLAB 3.0a</strong> can be run standalone, an interface to <strong>MATLAB</strong> is available such that the numerical kernel of <strong>FEMLAB</strong> can be used as a computing server.<br /><br />In the first <strong>FEMLAB </strong>conference held in 2005 at many paces around the world <strong>COMSOL </strong>announced that <strong>FEMLAB </strong>will now be called as <strong>COMSOL</strong> and a New feature was also released called Script which gives power to the user to write user defined function related to their simulation models.</div>C2EC- Swanseanoreply@blogger.com4tag:blogger.com,1999:blog-8085067644078822297.post-49365319464687303392006-11-01T09:25:00.000-08:002006-11-01T13:08:32.766-08:00Discussion on Comsol Modelling<div align="justify">Hello All Comsol users,<br /><br />This Blog is Created so that all <strong>CMOSOL Users </strong>can have a webspace for discission and COMSOL Users Across the GLOBE can Join in. We can have Discussions over Specific Issues and it is much easier to keep track of the discussions going on. As ,sometimes it is very Difficult to keep Track of discussions on yahoo group emails and some people might also face problem with there limited account space depending on which email they are using. Here all the <strong>COMSOL Users</strong> are invited to join this blog and start posting today. Also, if any one has any suggestion people feel free to post it as a comment. To join in as a memeber one just need to sign in using his/her gmail address. Looking forward to see more and more people posting in this blog.<br /><br />So lets get started.</div>C2EC- Swanseanoreply@blogger.com71