pol lahuerta manauta fem modelization using gmsh and...

146
Pol Lahuerta Manauta FEM Modelization Using Gmsh and GetDP: Examples and Guidelines FINAL DEGREE WORK supervised by Prof. Jordi Garcia Amorós Degree in Electrical Engineering Tarragona 2015

Upload: dinhminh

Post on 03-May-2018

242 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

Pol Lahuerta Manauta

FEM Modelization Using Gmsh and GetDP: Examples and Guidelines

FINAL DEGREE WORK

supervised by Prof. Jordi Garcia Amorós

Degree in Electrical Engineering

Tarragona

2015

Page 2: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

Index:

Introduction - 2 - Gmsh - 2 - GetDP - 2 -

How Gmsh works - 3 - To create a meshed geometry - 4 - To create a meshed geometry with codes - 19 - Input parameter setting - 29 -

How GetDP works - 78 - GetDP example - 80 -

Problems detected - 95 - Gmsh problems - 95 - Getdp problems - 98 -

Conclusion - 101 -

References - 102 - WebPages - 102 - Bibliography - 102 -

- 1 -

Page 3: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

Introduction The purpose of this project consist in creating an easy following tutorial, which a beginner user could follow it. The project includes some examples which the user can learn it step by step. In there, people can get the knowledge of Gmsh and GetDP programs.

Gmsh Gmsh is an open-source software with a build-in CAD engine and post-processor. It was developed by:

The Department of Electrical Engineering and Computer Science of the University of Liège.

The Institute for Mechanical, Materials and Civil Engineering of the Université catholique de Louvain.

According to them, its design goal is to provide a fast, light and user-friendly meshing tool with parametric input and advanced visualization capabilities.

GetDP

GetDP is a finite elements program created by Patrick Dular and Christophe Geuzaine at the University of Liège. Its name means: General environment for the treatment of Discrete Problems. GetDP, as their creators says, is a scientific software environment for the numerical solution of integro-differential equations, open to the coupling of physical problems (electromagnetic, thermal, etc.) as well as of numerical methods (finite element method, integral methods, etc.). It can deal with such problems of various dimensions (1D, 2D or 3D) and time states (static, transient or harmonic). Its purpose could be related in researching, education collaborating, training and industrial studies.

- 2 -

Page 4: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

How Gmsh works Gmsh is a three-dimensional finite element grid software, which is able to meshing a geometrical definite meshes:

Its geometries can be created by Gmsh or introduced by a code. In the following points, it will be explained.

- 3 -

Page 5: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

To create a meshed geometry In the light of the above, people can create a geometry using the Gmsh program. We will explain how to do it creating the previous meshed bolt.

1. Point definition In order to introduce a point, you have to go to Modules, inside there, go to Geometry, then to Elementary entities, next to Add and finally go to Add a Point:

The next windows will appear if you click in Point button:

In there you can introduce the coordinates of each point.

- 4 -

Page 6: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

We will start with the 0,0,0 point:

We will use 1.0 mesh size. Next we will put the (1,0,0), the (0,1,0), the (-1,0,0) and the (0,-1,0) points:

- 5 -

Page 7: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

After that, we will put the (1,0,-5), the (0,1,-5), the (-1,0,-5) and the (0,-1,-5) points:

The picture is rotated in order to see these points. Then, we will put the ending point (0,0,-5.5):

- 6 -

Page 8: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

Now, we will start with the bolt head. Firstly, we will put the 6 head down points. These will be (0,1.5,0), (1.299,0.75,0), (1.299,-0.75,0), (0,-1.5,0), (-1.299,-0.75,0) and (-1.299,0.75,0):

2. To copy a elementary entity

This step is included to show how to copy some points. We will copy the last 6 points introduced. We will do following the next steps. First of all, we have to go to Elementary entities:

- 7 -

Page 9: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

In there, we have to choose translate, and in there we choose Duplicate point:

When we did it, we have to select the points to move and put the translation vector. In this case will be (0,0,1):

- 8 -

Page 10: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

Finally, we will have the copy of those points one unit up:

Furthermore, there is the possibility to move or copy an elementary entity with a rotation, scale or symmetry:

3. Join the points with lines or arcs

Points can be joined with lines, arcs or splines. In the following part we will join all the points in order to create the geometry. For creating a line, we have to click on Straight line and select the two points which you want to join:

- 9 -

Page 11: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

First of all, we will join the up points:

Secondly, we will joint it with the down hexagon points:

Thirdly, we will joint the down hexagon points:

- 10 -

Page 12: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

Finally, we will create the rest of the lines:

Now, we will start with the arcs. For create an arc we have to go to Circle arc and select the 1st point, the arc centre and the 2nd point in this order:

Now, we will create the up circle:

- 11 -

Page 13: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

Next, we will create the down arcs. We will do those down arcs with the ending point:

Note: these arcs do not do a circle, is the bolt end.

4. Delete a elementary entity Now, the (0,0,0) point is unnecessary, for this reason we can delete it. To delete a point we have to go to Elementary entities and next to Delete. In there we have to click Point and select the point which you want to delete:

Unfortunately, this point cannot be deleted because the up arcs are formed by it. We only say it for showing how to do it.

- 12 -

Page 14: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

In addition, you can delete lines, surfaces and volumes:

5. Define surfaces

Before meshing the geometry, we have to define the surfaces. For defining the surfaces, the following steps are required. First of all, we have to click Plane surface and select the lines which delimitate each surface:

- 13 -

Page 15: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

When we delimitate one surface, we have to press the e button of the keyboard:

And we will have a plane surface:

Next, we can do it with the other plane surfaces of our geometry:

- 14 -

Page 16: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

Look out! In the down part of the head of the bolt, we have to select the outside limits and inside limits:

Now, we have to define the lateral surfaces. To do it, we have to click in Ruled surface:

- 15 -

Page 17: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

Finally, we will have finished all the surfaces:

6. Mesh the geometry

When we will have finished the previous steps, we will be able to mesh the figure. For meshing it, we have to go to Mesh and click 3D:

Note: we can also click 2D for meshing the surfaces or 1D for meshing lines.

Now we have the geometry meshed:

- 16 -

Page 18: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

In addition, on Tool panel, clicking Option, we can change the view:

In option view we can enable/unable the following views:

If we enable the Surface faces, we can see the following view:

- 17 -

Page 19: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

- 18 -

Page 20: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

To create a meshed geometry with codes Gmsh is a software which reads texts in .geo files. If we open the previous bolt example, we will see this code:

Point(1) = {0, 0, 0, 1.0}; Point(2) = {‐1, 0, 0, 1.0}; Point(3) = {1, 0, 0, 1.0}; Point(4) = {0, 1, 0, 1.0}; Point(5) = {0, ‐1, 0, 1.0}; Point(6) = {‐1, 0, ‐5, 1.0}; Point(7) = {1, 0, ‐5, 1.0}; Point(8) = {0, 1, ‐5, 1.0}; Point(9) = {0, ‐1, ‐5, 1.0}; Point(10) = {0, 0, ‐5.5, 1.0}; Point(11) = {0, 1.5, 0, 1.0}; Point(12) = {1.299, 0.75, 0, 1.0}; Point(13) = {1.299, ‐0.75, 0, 1.0}; Point(14) = {0, ‐1.5, 0, 1.0}; Point(15) = {‐1.299, ‐0.75, 0, 1.0}; Point(16) = {‐1.299, 0.75, 0, 1.0};  Translate {0, 0, 1} {   Duplicata { Point{11, 12, 13, 14, 15, 16}; } }   Line(1) = {17, 18}; Line(2) = {18, 19}; Line(3) = {19, 20}; Line(4) = {20, 21}; Line(5) = {21, 22}; Line(6) = {22, 17}; Line(7) = {17, 11}; Line(8) = {18, 12}; Line(9) = {19, 13}; Line(10) = {20, 14}; Line(11) = {21, 15}; Line(12) = {22, 16}; Line(13) = {11, 12}; Line(14) = {12, 13}; Line(15) = {13, 14}; Line(16) = {14, 15}; Line(17) = {15, 16}; Line(18) = {16, 11}; Line(19) = {4, 8}; Line(20) = {5, 9}; Line(21) = {3, 7}; Line(22) = {2, 6}; Line(23) = {8, 10}; Line(24) = {7, 10}; Line(25) = {9, 10}; 

- 19 -

Page 21: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

Line(26) = {6, 10}; Circle(27) = {4, 1, 3}; Circle(28) = {3, 1, 5}; Circle(29) = {5, 1, 2}; Circle(30) = {2, 1, 4}; Circle(31) = {8, 10, 7}; Circle(32) = {7, 10, 9}; Circle(33) = {9, 10, 6}; Circle(34) = {6, 10, 8};  Delete {   Point{1}; }  Line Loop(35) = {6, 1, 2, 3, 4, 5}; Plane Surface(36) = {35}; Line Loop(37) = {4, 11, ‐16, ‐10}; Plane Surface(38) = {37}; Line Loop(39) = {3, 10, ‐15, ‐9}; Plane Surface(40) = {39}; Line Loop(41) = {2, 9, ‐14, ‐8}; Plane Surface(42) = {41}; Line Loop(43) = {1, 8, ‐13, ‐7}; Plane Surface(44) = {43}; Line Loop(45) = {6, 7, ‐18, ‐12}; Plane Surface(46) = {45}; Line Loop(47) = {5, 12, ‐17, ‐11}; Plane Surface(48) = {47}; Line Loop(49) = {16, 17, 18, 13, 14, 15}; Line Loop(50) = {33, 26, ‐25}; Plane Surface(51) = {50}; Line Loop(52) = {32, 25, ‐24}; Plane Surface(53) = {52}; Line Loop(54) = {24, ‐23, 31}; Plane Surface(55) = {54}; Line Loop(56) = {23, ‐26, 34}; Plane Surface(57) = {56}; Line Loop(58) = {29, 30, 27, 28}; Plane Surface(59) = {49, 58}; Line Loop(60) = {20, ‐32, ‐21, 28}; Ruled Surface(61) = {60}; Line Loop(62) = {21, ‐31, ‐19, 27}; Ruled Surface(63) = {62}; Line Loop(64) = {19, ‐34, ‐22, 30}; Ruled Surface(65) = {64}; Line Loop(66) = {22, ‐33, ‐20, 29}; Ruled Surface(67) = {66}; 

For this reason, we can program any geometry.

- 20 -

Page 22: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

Now, we will do an example of a meshed geometry with codes. This example will be a coil and a core in an air shell:

As you can see, we only used a quarter of a circle. Its reason is to show how we can do it. In addition, we do not put the figure in the centre of the circle in order to show better it.

- 21 -

Page 23: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

1. To create a .geo file

First of all we have to create a .txt file and change .txt for .geo. In this case we will call it “Coil&core.geo”. The file you can open it with notepad or notebook from windows, but I recommend downloading the notepad++. It can show your notes as a program code, and you can chose the language:

2. To define variables

The variables can be defined in any line. But these cannot be used before being assigned their value. For creating a variable we need to put their name, a space, a symbol of equal, another space, their value and a”;”. These will be our values for this example:

 //VARS:  //Pole vars: wpole = 1;    //Pole width hpole = 2;    //Pole height ppole = 5;    //Pole position (in x axis) dpole = 1;    //Pole depth  

- 22 -

Page 24: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

//Coil vars: wcoil = 1;    //Coil width hcoil = 1;    //Coil height wgap = 0.1;   //Gap between the pole and the coil hgap = 0.1;   //Gap between the pole and the coil  //Air vars: Rin = 10;    //Inner air radius Rex = Rin+1;  //External air radius  //Mesh density vars: NM = 0.1;    //Normal mesh SM = 0.01;    //Small mesh  We have added some comments using “//” in order to explain what each var mean or each heading.

3. To define the geometry First of all, for defining the geometry, we will create the centre point. For creating a point we must write “Point” followed by a number inside brackets. This number cannot be repeated or the program only will read the last point with the same number. Next brackets, we will put a space, a symbol of equal and another space. After that, we will open a brace, putting inside it the x coordinate, a coma, the y coordinate, another coma, the z coordinate, the last coma and the mesh size; next we will close the brace and add a semicolon. This is the centre point: Point(1) = {0, 0, 0, NM};  

4. Core geometry In order to create the core geometry, we have to introduce the pole points:  Point(2) = {ppole‐(wpole/2),       0,   0, NM}; Point(3) = {ppole+(wpole/2),      0,   0, NM}; Point(4) = {ppole+(wpole/2),  hpole,   0, NM}; Point(5) = {ppole‐(wpole/2),  hpole,   0, NM};  As you can see, we add more spaces between coordinates in order to have better appearance. This is permitted by the program.

- 23 -

Page 25: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

After that, we will joint the previous points. We will do it with lines: Line(1) = {2,3}; Line(2) = {3,4}; Line(3) = {4,5}; Line(4) = {5,2};  At the end, we will create a line loop for joining these lines and, with it, we will create a surface: Line Loop(100) = {1,2,3,4}; Plane Surface(101) = {100};  Now, we have completed the core geometry.

5. Coil geometry The coil geometry steps are similar than the core geometry. We will only add an additional step at the end. Firstly, we will introduce the points: Point(6) = {   ppole‐(wpole/2)‐wgap,     0, 0, NM}; Point(7) = {ppole‐(wpole/2)‐wgap‐wcoil,     0, 0, NM}; Point(8) = {ppole‐(wpole/2)‐wgap‐wcoil,     hcoil, 0, NM}; Point(9) = {   ppole‐(wpole/2)‐wgap,     hcoil, 0, NM};  Secondly, we will joint these points: Line(5) = {6,7}; Line(6) = {7,8}; Line(7) = {8,9}; Line(8) = {9,6};  Thirdly, we will joint the lines and create a surface: Line Loop(102) = {5,6,7,8}; Plane Surface(103) = {102};  Finally, we will add another step which consists in copy the previous surface in the other site: Translate {wpole+2*wgap+wcoil, 0, 0} {   Duplicata { Surface{103}; } } 

- 24 -

Page 26: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

The program will call this second geometry as surface 104. The lines it will add 100 in their number, for example the line 5 will be the line 105. The points will be point 10, 11, 15 and 19; for this reason we cannot call another point with this name. The program does not say which numbers put in each elementary entity when we copy geometries. But we can see its numbers if we activate in option panel:

In addition, if we put the cursor on an elementary entity, it will appear a window explaining its parameters:

Note: Physical: 204 is a parameter which we will add after.

6. Air geometry In the light of above, we will create a quarter of a circular air shell. First of all, we will put the two points for the circle arc: Point(12) = {Rin, 0, 0, NM}; Point(13) = {0, Rin, 0, NM}; 

- 25 -

Page 27: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

Secondly, we will create the arc with point 1 as a centre: Circle(9) = {12,1,13};  Thirdly, we will write the vertical and horizontal lines: Line(10) = {1,7}; Line(11) = {6,2}; Line(12) = {3,11}; Line(13) = {10,12}; Line(14) = {13,1};  Note: Line 10, 11, 12 and 13 make the horizontal line; line 14 makes the vertical line. Finally, we will joint the lines and create a surface: Line Loop(109) = {10,6,7,8,11,‐4,‐3,‐2,12,106,107,108,13,9,14}; Plane Surface(110) = {109};  Note: the surface must not include the coils and the core, if not it will do mistakes in the calculation. For this reason we include, in the line loop, the core and coils lines.

7. Air infinity geometry The air infinity region represents the air which is as far as the fields do not arrive in it. The value of these will be zero in it. The steps are similar than air region. Initially we have to put the points of its arc: Point(14) = {Rex, 0, 0, NM}; Point(16) = {0, Rex, 0, NM};  Next we have to put the arc: Circle(15) = {16,1,14};  After it, we will create a vertical line and horizontal line which will follow the vertical and horizontal lines of the air: Line(16) = {14,12};  Line(17) = {13,16}; 

- 26 -

Page 28: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

At last, we will joint the lines and the circle, and we will create another surface: Line Loop(111) = {16,9,17,15}; Plane Surface(112) = {111}; 

8. Physical entities This part, which is mentioned in the note at the end of coil geometry explanation, is for delimitating different regions between each other. If we definite a physical region, we will be able to put proprieties of this region with another program. We will define the different surfaces like this: Physical Surface(1001) = {101};  /*  Pole  */ Physical Surface(1003) = {103};  /*  Coil+ */ Physical Surface(1004) = {104};  /*  Coil‐ */ Physical Surface(1010) = {110};  /*   Air  */ Physical Surface(1012) = {112};  /* AirInf */  Also we can definite the different physical lines: Physical Line(1000) = {11,1,12};                   /*   Cut   */ Physical Line(1001) = {11,12};                /*  CutAir */ Physical Line(202)  = {2,3,4};              /* SkinCore*/ Physical Line(203)  = {6,7,8};            /*SkinCoil+*/ Physical Line(204)  = {106,107,108};         /*SkinCoil‐*/ Physical Line(1100) = {10,‐5,11,1,12,‐105,13,‐16}; /*  Xaxis  */ Physical Line(1101) = {‐14,17};             /*  Yaxis  */ Physical Line(1102) = {‐15};                  /*  ArcInf */  As you can see, in Gmsh we can add comments between this “/*” and this “*/”. In there, we put what represents each entity.

- 27 -

Page 29: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

Finally, we have the geometry created, and if we open it with Gmsh we will be able to see it:

And if we mesh it, we will have:

- 28 -

Page 30: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

Input parameter setting Now we are going to show an example of the geometry of a Double-Sided Linear Switcher Reluctance Motor. In its code we will program it in order to have input parameter setting. These will be able to permit modify its structure with Gmsh program. Also, we will show how to create more functions such as boucles or subroutines. For doing it, we have to follow the next steps:

1. To create the main program

This step consists in creating a file which we will call all subroutines. We will call it “DSLSRM.geo”. DSLSRM are the capital letters of Double-Sided Linear Switcher Reluctance Motor. For calling a subroutine we have to write the word “Include”, one or more spaces, the name of the file between quotation marks. In our example we will include a routine of the variables, a primary of the motor routine, a secondary of the motor routine, a routine of the coils and a routine of the air and the infinity. Also, in this main code, we will definite the [0,0,0] axis point. The code will be like this: //‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐    //Var's definition:  Include "DSLSRM_var_def.geo";   //‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐     //          ‐ GEOMETRY ‐  //‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐//Centre of Geometry:  centre = newp; Point(newp) = {0, 0, 0, NM};   //‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐//Primary:  Include "DSLSRM_Primary.geo";   

- 29 -

Page 31: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐//Secondary:  Include "DSLSRM_Secondary.geo";   //‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐//Coils:  Include "DSLSRM_Coils.geo";   //‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐//Air and Infinity:  Include "DSLSRM_Air_&_AirInf.geo";   //‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐ 

2. To create the variable definition subroutine In this subroutine we will define the variables which we will use in the whole of the program. These will be the variables used:

//‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐  //              ‐ VAR definition ‐   //‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐ //Geometric VARs:  pp  = "Input/10Geometric dimensions/0";  ppm = "Input/11Mesh control (Nbr of divisions)/";   DefineConstant[                Flag_m = {3, Choices{2,3,4,5},                Name  StrCat[pp,"1number  of  phases"],  Highlight "Red"},                m = Flag_m                ];  DefineConstant[                PoleStroke = {3,  Min 2, Max 10, Step 0.5,          Name  StrCat[pp,  "2pole  stroke  [mm]"], Highlight "LightGrey"},                PS = PoleStroke                ]; 

- 30 -

Page 32: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

          DefineConstant[ alpha_p = {0.42}];              // alpha_p = relation between bp and Tp DefineConstant[ beta_p = {2.5}];              // beta_p = relation between lp and Tp DefineConstant[ Tp = {(m‐1)*PS}];             // Tp = primary pole pitch [mm] DefineConstant[ bp = {alpha_p*Tp}];          // bp = primary pole width [mm] DefineConstant[ cp = {Tp‐bp}];               // cp = primary slot width [mm] DefineConstant[ lp = {beta_p*Tp}];          // lp = primary pol lenth [mm] DefineConstant[ alpha_s = {0.5}];           // alpha_s = relation between bs and Ts DefineConstant[ beta_s = {1.5}];           // beta_s = relation between ls and Tp DefineConstant[ Ts = {m*PS}];            // Ts = secondary pole pitch [mm] DefineConstant[ bs = {alpha_s*Tp}];          // bs = secondary pole width [mm] DefineConstant[ cs = {Ts‐bs}];             // cs = secondary slot widtch [mm] DefineConstant[ Ns = {2*(m‐1)}];           // Ns = number of passive poles per side (Secondary) DefineConstant[ ls = {beta_s*Tp}];          // ls = secondary pol lenth [mm] DefineConstant[ dy = {0.54}];            // dy = relation between hy and Tp DefineConstant[ hy = {dy*Tp}];             // hy = primary yoke height [mm] DefineConstant[ Lw = {30}];               // Lw = stack length [mm] DefineConstant[ g  = {0.5}];            // g  = air gap length [mm] DefineConstant[ wr = {0.2}];            // wr = Horizontal dielectric width [mm] DefineConstant[ ws = {0.5}];            // ws = Up dielectric width [mm] DefineConstant[ wi = {0.5}];            // wi = Down dielectric width [mm] DefineConstant[ L  = {(m‐1)*((2*m‐1)+alpha_p)*PS}];     // L  = stator length [mm] DefineConstant[ H  = {lp+hy+g+ls/2}];         // H  = Stator height/2 [mm] DefineConstant[ Sp = {(L/2)+(bs‐bp)/2}];        // Sp = Stator start position  DefineConstant[ Rin  = {4*L}];             // Rin = Inner shell radius [mm] DefineConstant[ Rext = {5*L}];             // Rext = External shell radius [mm]  

- 31 -

Page 33: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

 //‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐//Mesh VARs:  DefineConstant[        Mesh = { 1, Min 0.01, Max 10, Step 0.1,        Name  StrCat[ppm,  "Mesh  density"],  Highlight "Yellow"},        NM = Mesh         ];           //‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐//Physical Region VARs:  Primaryd = 11;    //Primary down  Primaryu = 12;    //Primary up    For k In {1:3*m}   Secondary[k] = 200 + k; EndFor    CoilAp1 = 311;  CoilAp2 = 312;                  CoilAp3 = 313;                  CoilAp4 = 314;                   CoilAn1 = 321;                  CoilAn2 = 322;                  CoilAn3 = 323;                  CoilAn4 = 324;                   CoilBp1 = 331;                  CoilBp2 = 332;                  CoilBp3 = 333;                  CoilBp4 = 334;                   

- 32 -

Page 34: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

CoilBn1 = 341;                  CoilBn2 = 342;                  CoilBn3 = 343;                  CoilBn4 = 344;   CoilCp1 = 351;  CoilCp2 = 352;  CoilCp3 = 353;                  CoilCp4 = 354;   CoilCn1 = 361;    CoilCn2 = 362;  CoilCn3 = 363;  CoilCn4 = 364;   CoilDp1 = 371;  CoilDp2 = 372;  CoilDp3 = 373;                  CoilDp4 = 374;   CoilDn1 = 381;    CoilDn2 = 382;  CoilDn3 = 383;  CoilDn4 = 384;   CoilEp1 = 391;  CoilEp2 = 392;  CoilEp3 = 393;  CoilEp4 = 394;   

- 33 -

Page 35: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

CoilEn1 = 301;  CoilEn2 = 302;  CoilEn3 = 303;  CoilEn4 = 304;    Air = 4;  Inf = 5;  As you can see, the variables of the number of phases, the pole stroke and the mesh density have a different format. Its format consist in introduce the word “DefineConstant” and open a square bracket. Inside the square bracket, in the first line, we have to put a name of the variable, an equal and their value. Its value will be inside braces and the first number will be the predetermined value. Next we have to put a comma. After it, we can put an interval, such as in the pole stroke and mesh density, or a real number of choices like the number of phases. In the second line, without closing the first brace, we can put a string. Inside it, we can determinate in which input group will be and the name of its input. Next, we can put a color in their input window. In the third line, we can assign the letter (or letters) used for representing its variable. Finally, at the fourth line, we can close the first square bracket and add a semicolon. These will be our input windows in Gmsh:

- 34 -

Page 36: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

Clicking and moving the mouse on those windows, we will be able to change the values:

3. To create the primary geometry subroutine First of all, we have to say that in DSLSRM example we will use another method to define points. We will write the word “pnt”, next the number which we want and, after it, we write “[] += newp;”. When we will want to use the value of that point, we will have to write “Point(newp) =” and the coordinates of it. You will see it in the down stator points: pnt11[] += newp; Point(newp) = {           L/2,         ‐H, 0, NM}; pnt11[] += newp; Point(newp) = {            ‐L/2,      ‐H, 0, NM}; pnt11[] += newp; Point(newp) = {      (‐L/2), ‐H + lp + hy, 0, NM}; pnt11[] += newp; Point(newp) = {    (‐L/2) + bp, ‐H + lp + hy, 0, NM}; pnt11[] += newp; Point(newp) = {    (‐L/2) + bp,     ‐H + hy, 0, NM}; pnt11[] += newp; Point(newp) = {     (‐L/2) + bp + cp,     ‐H + hy, 0, NM}; pnt11[] += newp; Point(newp) = {    (‐L/2) + bp + cp, ‐H + lp + hy, 0, NM}; pnt11[] += newp; Point(newp) = {   (‐L/2) + 2*bp + cp, ‐H + lp + hy, 0, NM}; pnt11[] += newp; Point(newp) = {   (‐L/2) + 2*bp + cp,     ‐H + hy, 0, NM}; pnt11[] += newp; Point(newp) = {(‐L/2) + 2*bp + 2*cp,     ‐H + hy, 0, NM}; pnt11[] += newp; Point(newp) = {(‐L/2) + 2*bp + 2*cp, ‐H + lp + hy, 0, NM}; 

- 35 -

Page 37: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

pnt11[] += newp; Point(newp) = {(‐L/2) + 3*bp + 2*cp, ‐H + lp + hy, 0, NM}; pnt11[] += newp; Point(newp) = {(‐L/2) + 3*bp + 2*cp,     ‐H + hy, 0, NM}; pnt11[] += newp; Point(newp) = {(‐L/2) + 3*bp + 3*cp,     ‐H + hy, 0, NM}; pnt11[] += newp; Point(newp) = {(‐L/2) + 3*bp + 3*cp, ‐H + lp + hy, 0, NM}; pnt11[] += newp; Point(newp) = {(‐L/2) + 4*bp + 3*cp, ‐H + lp + hy, 0, NM};  Now, to continue with the points, if the number of phases were higher than 2, we would open an if boucle: If(m>2)   pnt11[] += newp;   Point(newp) = {(‐L/2) + 4*bp + 3*cp,   ‐H + hy, 0, NM};   pnt11[] += newp;   Point(newp) = {(‐L/2) + 4*bp + 4*cp,   ‐H + hy, 0, NM};   pnt11[] += newp;   Point(newp) = {(‐L/2) + 4*bp + 4*cp, ‐H + lp + hy, 0, NM};   pnt11[] += newp;   Point(newp) = {(‐L/2) + 5*bp + 4*cp, ‐H + lp + hy, 0, NM};   pnt11[] += newp;   Point(newp) = {(‐L/2) + 5*bp + 4*cp,    ‐H + hy, 0, NM};   pnt11[] += newp;   Point(newp) = {(‐L/2) + 5*bp + 5*cp,    ‐H + hy, 0, NM};   pnt11[] += newp;   Point(newp) = {(‐L/2) + 5*bp + 5*cp, ‐H + lp + hy, 0, NM};   pnt11[] += newp;   Point(newp) = {(‐L/2) + 6*bp + 5*cp, ‐H + lp + hy, 0, NM}; EndIf  And we will do the same for more than 3 phases: If(m>3)     pnt11[] += newp;   Point(newp) = {(‐L/2) + 6*bp + 5*cp,    ‐H + hy, 0, NM};   pnt11[] += newp;   Point(newp) = {(‐L/2) + 6*bp + 6*cp,    ‐H + hy, 0, NM};   pnt11[] += newp;   Point(newp) = {(‐L/2) + 6*bp + 6*cp, ‐H + lp + hy, 0, NM};   pnt11[] += newp;   Point(newp) = {(‐L/2) + 7*bp + 6*cp, ‐H + lp + hy, 0, NM};   pnt11[] += newp;   Point(newp) = {(‐L/2) + 7*bp + 6*cp,    ‐H + hy, 0, NM};   pnt11[] += newp;   Point(newp) = {(‐L/2) + 7*bp + 7*cp,    ‐H + hy, 0, NM};   pnt11[] += newp;   Point(newp) = {(‐L/2) + 7*bp + 7*cp, ‐H + lp + hy, 0, NM};   pnt11[] += newp;   Point(newp) = {(‐L/2) + 8*bp + 7*cp, ‐H + lp + hy, 0, NM}; EndIf 

- 36 -

Page 38: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

 If(m>4)   pnt11[] += newp;   Point(newp) = {(‐L/2) + 8*bp + 7*cp,    ‐H + hy, 0, NM};   pnt11[] += newp;   Point(newp) = {(‐L/2) + 8*bp + 8*cp,    ‐H + hy, 0, NM};   pnt11[] += newp;   Point(newp) = {(‐L/2) + 8*bp + 8*cp, ‐H + lp + hy, 0, NM};   pnt11[] += newp;   Point(newp) = {(‐L/2) + 9*bp + 8*cp, ‐H + lp + hy, 0, NM};   pnt11[] += newp;   Point(newp) = {(‐L/2) + 9*bp + 8*cp,    ‐H + hy, 0, NM};   pnt11[] += newp;   Point(newp) = {(‐L/2) + 9*bp + 9*cp,    ‐H + hy, 0, NM};   pnt11[] += newp;   Point(newp) = {(‐L/2) + 9*bp + 9*cp, ‐H + lp + hy, 0, NM};   pnt11[] += newp;   Point(newp) ={(‐L/2) + 10*bp + 9*cp, ‐H + lp + hy, 0, NM}; EndIf  For joining the points with lines, we will open a for boucle: For i In {0:#pnt11[]‐1}      ln11[]+=newl;  Line(newl)  =  {pnt11[i],  pnt11[(i==#pnt11[]‐1)?0:i+1]}; EndFor  Next we will create the line loop: lnl11[] += newll; Line Loop(newll) = {ln11[]};  Finally we will define the surface, we will add colour in its mesh and finally we will define as a physical surface: surf_Primaryd[] += news;      //Surface: Primary down Plane Surface(news) = {newll‐1};  Color Grey {Surface{surf_Primaryd[]};}    //Adding  colour in primary mesh  Physical Surface(Primaryd) = surf_Primaryd[];  Now we will do the same steps with the up stator: pnt12[] += newp; Point(newp) = {              L/2,       H, 0, NM}; pnt12[] += newp; Point(newp) = {             ‐L/2,      H, 0, NM}; 

- 37 -

Page 39: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

pnt12[] += newp; Point(newp) = {      (‐L/2), H ‐ lp ‐ hy, 0, NM}; pnt12[] += newp; Point(newp) = {     (‐L/2) + bp, H ‐ lp ‐ hy, 0, NM}; pnt12[] += newp; Point(newp) = {     (‐L/2) + bp,    H ‐ hy, 0, NM}; pnt12[] += newp; Point(newp) = {    (‐L/2) + bp + cp,    H ‐ hy, 0, NM}; pnt12[] += newp; Point(newp) = {    (‐L/2) + bp + cp, H ‐ lp ‐ hy, 0, NM}; pnt12[] += newp; Point(newp) = {  (‐L/2) + 2*bp + cp, H ‐ lp ‐ hy, 0, NM}; pnt12[] += newp; Point(newp) = {  (‐L/2) + 2*bp + cp,    H ‐ hy, 0, NM}; pnt12[] += newp; Point(newp) = {(‐L/2) + 2*bp + 2*cp,    H ‐ hy, 0, NM}; pnt12[] += newp; Point(newp) = {(‐L/2) + 2*bp + 2*cp, H ‐ lp ‐ hy, 0, NM}; pnt12[] += newp; Point(newp) = {(‐L/2) + 3*bp + 2*cp, H ‐ lp ‐ hy, 0, NM}; pnt12[] += newp; Point(newp) = {(‐L/2) + 3*bp + 2*cp,    H ‐ hy, 0, NM}; pnt12[] += newp; Point(newp) = {(‐L/2) + 3*bp + 3*cp,    H ‐ hy, 0, NM}; pnt12[] += newp; Point(newp) = {(‐L/2) + 3*bp + 3*cp, H ‐ lp ‐ hy, 0, NM}; pnt12[] += newp; Point(newp) = {(‐L/2) + 4*bp + 3*cp, H ‐ lp ‐ hy, 0, NM};  If(m>2)   //Additional poles for 3 or more phases in the stator   pnt12[] += newp;   Point(newp) = {(‐L/2) + 4*bp + 3*cp,     H ‐ hy, 0, NM};   pnt12[] += newp;   Point(newp) = {(‐L/2) + 4*bp + 4*cp,     H ‐ hy, 0, NM};   pnt12[] += newp;   Point(newp) = {(‐L/2) + 4*bp + 4*cp,  H ‐ lp ‐ hy, 0, NM};   pnt12[] += newp;   Point(newp) = {(‐L/2) + 5*bp + 4*cp,  H ‐ lp ‐ hy, 0, NM};   pnt12[] += newp;   Point(newp) = {(‐L/2) + 5*bp + 4*cp,     H ‐ hy, 0, NM};   pnt12[] += newp;   Point(newp) = {(‐L/2) + 5*bp + 5*cp,     H ‐ hy, 0, NM};   pnt12[] += newp;   Point(newp) = {(‐L/2) + 5*bp + 5*cp,  H ‐ lp ‐ hy, 0, NM};   pnt12[] += newp;   Point(newp) = {(‐L/2) + 6*bp + 5*cp,  H ‐ lp ‐ hy, 0, NM}; EndIf  If(m>3)    //Additional poles for 4 or 5 phase stator   pnt12[] += newp;   Point(newp) = {(‐L/2) + 6*bp + 5*cp,     H ‐ hy, 0, NM};   pnt12[] += newp;   Point(newp) = {(‐L/2) + 6*bp + 6*cp,     H ‐ hy, 0, NM};   pnt12[] += newp; 

- 38 -

Page 40: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

  Point(newp) = {(‐L/2) + 6*bp + 6*cp,  H ‐ lp ‐ hy, 0, NM};   pnt12[] += newp;   Point(newp) = {(‐L/2) + 7*bp + 6*cp,  H ‐ lp ‐ hy, 0, NM};   pnt12[] += newp;   Point(newp) = {(‐L/2) + 7*bp + 6*cp,     H ‐ hy, 0, NM};   pnt12[] += newp;   Point(newp) = {(‐L/2) + 7*bp + 7*cp,     H ‐ hy, 0, NM};   pnt12[] += newp;   Point(newp) = {(‐L/2) + 7*bp + 7*cp,  H ‐ lp ‐ hy, 0, NM};   pnt12[] += newp;   Point(newp) = {(‐L/2) + 8*bp + 7*cp,  H ‐ lp ‐ hy, 0, NM}; EndIf  If(m>4)    //Additional poles for 5 phase stator   pnt12[] += newp;   Point(newp) = { (‐L/2) + 8*bp + 7*cp,     H ‐ hy, 0, NM};   pnt12[] += newp;   Point(newp) = { (‐L/2) + 8*bp + 8*cp,     H ‐ hy, 0, NM};   pnt12[] += newp;   Point(newp) = { (‐L/2) + 8*bp + 8*cp, H ‐ lp ‐ hy, 0, NM};   pnt12[] += newp;   Point(newp) = { (‐L/2) + 9*bp + 8*cp, H ‐ lp ‐ hy, 0, NM};   pnt12[] += newp;   Point(newp) = { (‐L/2) + 9*bp + 8*cp,     H ‐ hy, 0, NM};   pnt12[] += newp;   Point(newp) = { (‐L/2) + 9*bp + 9*cp,     H ‐ hy, 0, NM};   pnt12[] += newp;   Point(newp) = { (‐L/2) + 9*bp + 9*cp, H ‐ lp ‐ hy, 0, NM};   pnt12[] += newp;   Point(newp) = {(‐L/2) + 10*bp + 9*cp, H ‐ lp ‐ hy, 0, NM}; EndIf   For j In {0:#pnt12[]‐1}     //joint the points   ln12[]+=newl;  Line(newl)  =  {pnt12[j],  pnt12[(j==#pnt12[]‐1)?0:j+1]}; EndFor   lnl12[] += newll; Line Loop(newll) = {ln12[]};  surf_Primaryu[] += news;      //Surface: Primary up Plane Surface(news) = {newll‐1};  Color Grey {Surface{surf_Primaryu[]};}    //Adding  colour in primary mesh  Physical Surface(Primaryu) = surf_Primaryu[]; 

- 39 -

Page 41: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

4. To create the secondary geometry subroutine The secondary geometry will consist in creating poles as many times as it is required. The number of poles will be three times the number of phases. This will be the code: //‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐ //Secondary:   //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐    pnt201[] += newp; Point(newp) = {       Sp,  ‐ls/2,   0, NM}; pnt201[] += newp; Point(newp) = {       Sp,   ls/2,   0, NM}; pnt201[] += newp; Point(newp) = { Sp ‐ bs,   ls/2,   0, NM}; pnt201[] += newp; Point(newp) = { Sp ‐ bs,  ‐ls/2,   0, NM};  For r In {#pnt201[]‐4:#pnt201[]‐1}   ln201[]+=newl;  Line(newl)  =  {pnt201[r],  pnt201[(r==#pnt201[]‐1)?r‐3:r+1]}; EndFor  lnl201[] += newll; Line Loop(newll) = {ln201[]};  surf_Secondary201[] += news; Plane Surface(news) = {newll‐1};  Color Black {Surface{surf_Secondary201[]};}    //Adding colour in secondary mesh  Physical Surface(Secondary[1]) = surf_Secondary201[];  //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐      pnt202[] += newp; Point(newp) = {       Sp ‐ Ts,  ‐ls/2,   0, NM}; pnt202[] += newp; Point(newp) = {       Sp ‐ Ts,   ls/2,   0, NM}; pnt202[] += newp; Point(newp) = { Sp ‐ bs ‐ Ts,   ls/2,   0, NM}; pnt202[] += newp; Point(newp) = { Sp ‐ bs ‐ Ts,  ‐ls/2,   0, NM};  For r In {#pnt202[]‐4:#pnt202[]‐1}   ln202[]+=newl;  Line(newl)  =  {pnt202[r],  pnt202[(r==#pnt202[]‐1)?r‐3:r+1]}; EndFor 

- 40 -

Page 42: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

 lnl202[] += newll; Line Loop(newll) = {ln202[]};  surf_Secondary202[] += news; Plane Surface(news) = {newll‐1};  Color Black {Surface{surf_Secondary202[]};}    //Adding colour in secondary mesh  Physical Surface(Secondary[2]) = surf_Secondary202[];  //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐    pnt203[] += newp; Point(newp) = {       Sp ‐ Ts*2,  ‐ls/2,  0, NM}; pnt203[] += newp; Point(newp) = {       Sp ‐ Ts*2,   ls/2,  0, NM}; pnt203[] += newp; Point(newp) = { Sp ‐ bs ‐ Ts*2,   ls/2,   0, NM}; pnt203[] += newp; Point(newp) = { Sp ‐ bs ‐ Ts*2,  ‐ls/2,   0, NM};  For r In {#pnt203[]‐4:#pnt203[]‐1}   ln203[]+=newl;  Line(newl)  =  {pnt203[r],  pnt203[(r==#pnt203[]‐1)?r‐3:r+1]}; EndFor  lnl203[] += newll; Line Loop(newll) = {ln203[]};  surf_Secondary203[] += news; Plane Surface(news) = {newll‐1};  Color Black {Surface{surf_Secondary203[]};}    //Adding colour in secondary mesh  Physical Surface(Secondary[3]) = surf_Secondary203[];  //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐    pnt204[] += newp; Point(newp) = {       Sp ‐ Ts*3,  ‐ls/2,  0, NM}; pnt204[] += newp; Point(newp) = {       Sp ‐ Ts*3,   ls/2,  0, NM}; pnt204[] += newp; Point(newp) = { Sp ‐ bs ‐ Ts*3,   ls/2,   0, NM}; pnt204[] += newp; Point(newp) = { Sp ‐ bs ‐ Ts*3,  ‐ls/2,   0, NM};  For r In {#pnt204[]‐4:#pnt204[]‐1}   ln204[]+=newl;  Line(newl)  =  {pnt204[r],  pnt204[(r==#pnt204[]‐1)?r‐3:r+1]}; EndFor 

- 41 -

Page 43: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

 lnl204[] += newll; Line Loop(newll) = {ln204[]};  surf_Secondary204[] += news; Plane Surface(news) = {newll‐1};  Color Black {Surface{surf_Secondary204[]};}    //Adding colour in secondary mesh  Physical Surface(Secondary[4]) = surf_Secondary204[];  //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐    pnt205[] += newp; Point(newp) = {       Sp ‐ Ts*4,  ‐ls/2,  0, NM}; pnt205[] += newp; Point(newp) = {       Sp ‐ Ts*4,   ls/2,  0, NM}; pnt205[] += newp; Point(newp) = { Sp ‐ bs ‐ Ts*4,   ls/2,   0, NM}; pnt205[] += newp; Point(newp) = { Sp ‐ bs ‐ Ts*4,  ‐ls/2,   0, NM};  For r In {#pnt205[]‐4:#pnt205[]‐1}   ln205[]+=newl;  Line(newl)  =  {pnt205[r],  pnt205[(r==#pnt205[]‐1)?r‐3:r+1]}; EndFor  lnl205[] += newll; Line Loop(newll) = {ln205[]};  surf_Secondary205[] += news; Plane Surface(news) = {newll‐1};  Color Black {Surface{surf_Secondary205[]};}    //Adding colour in secondary mesh  Physical Surface(Secondary[5]) = surf_Secondary205[];  //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐    pnt206[] += newp; Point(newp) = {       Sp ‐ Ts*5,  ‐ls/2,  0, NM}; pnt206[] += newp; Point(newp) = {       Sp ‐ Ts*5,   ls/2,  0, NM}; pnt206[] += newp; Point(newp) = { Sp ‐ bs ‐ Ts*5,   ls/2,   0, NM}; pnt206[] += newp; Point(newp) = { Sp ‐ bs ‐ Ts*5,  ‐ls/2,   0, NM};  For r In {#pnt206[]‐4:#pnt206[]‐1}   ln206[]+=newl;  Line(newl)  =  {pnt206[r],  pnt206[(r==#pnt206[]‐1)?r‐3:r+1]}; EndFor 

- 42 -

Page 44: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

 lnl206[] += newll; Line Loop(newll) = {ln206[]};  surf_Secondary206[] += news; Plane Surface(news) = {newll‐1};  Color Black {Surface{surf_Secondary206[]};}    //Adding colour in secondary mesh  Physical Surface(Secondary[6]) = surf_Secondary206[];  //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐    If(m>2)    //Secondary  poles  for  stators  of  3  or  more phases  //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐      pnt207[] += newp;   Point(newp) = {       Sp ‐ Ts*6,  ‐ls/2,  0, NM};   pnt207[] += newp;   Point(newp) = {       Sp ‐ Ts*6,   ls/2,  0, NM};   pnt207[] += newp;   Point(newp) = { Sp ‐ bs ‐ Ts*6,   ls/2,   0, NM};   pnt207[] += newp;   Point(newp) = { Sp ‐ bs ‐ Ts*6,  ‐ls/2,   0, NM};    For r In {#pnt207[]‐4:#pnt207[]‐1}     ln207[]+=newl;  Line(newl)  =  {pnt207[r], pnt207[(r==#pnt207[]‐1)?r‐3:r+1]};   EndFor    lnl207[] += newll;   Line Loop(newll) = {ln207[]};    surf_Secondary207[] += news;   Plane Surface(news) = {newll‐1};    Color Black {Surface{surf_Secondary207[]};}   //Adding colour in secondary mesh    Physical Surface(Secondary[7]) = surf_Secondary207[];  //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐      pnt208[] += newp;   Point(newp) = {       Sp ‐ Ts*7,  ‐ls/2,  0, NM};   pnt208[] += newp;   Point(newp) = {       Sp ‐ Ts*7,   ls/2,  0, NM};   pnt208[] += newp;   Point(newp) = { Sp ‐ bs ‐ Ts*7,   ls/2,   0, NM};   pnt208[] += newp;   Point(newp) = { Sp ‐ bs ‐ Ts*7,  ‐ls/2,   0, NM}; 

- 43 -

Page 45: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

   For r In {#pnt208[]‐4:#pnt208[]‐1}     ln208[]+=newl;  Line(newl)  =  {pnt208[r], pnt208[(r==#pnt208[]‐1)?r‐3:r+1]};   EndFor    lnl208[] += newll;   Line Loop(newll) = {ln208[]};    surf_Secondary208[] += news;   Plane Surface(news) = {newll‐1};    Color Black {Surface{surf_Secondary208[]};}   //Adding colour in secondary mesh    Physical Surface(Secondary[8]) = surf_Secondary208[];  //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐      pnt209[] += newp;   Point(newp) = {       Sp ‐ Ts*8,  ‐ls/2,  0, NM};   pnt209[] += newp;   Point(newp) = {       Sp ‐ Ts*8,   ls/2,  0, NM};   pnt209[] += newp;   Point(newp) = { Sp ‐ bs ‐ Ts*8,   ls/2,   0, NM};   pnt209[] += newp;   Point(newp) = { Sp ‐ bs ‐ Ts*8,  ‐ls/2,   0, NM};    For r In {#pnt209[]‐4:#pnt209[]‐1}     ln209[]+=newl;  Line(newl)  =  {pnt209[r], pnt209[(r==#pnt209[]‐1)?r‐3:r+1]};   EndFor    lnl209[] += newll;   Line Loop(newll) = {ln209[]};    surf_Secondary209[] += news;   Plane Surface(news) = {newll‐1};    Color Black {Surface{surf_Secondary209[]};}   //Adding colour in secondary mesh    Physical Surface(Secondary[9]) = surf_Secondary209[];  //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐    EndIf   //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐    If(m>3)    //Secondary  poles  for  stators  of  4  or  more phases  //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐   

- 44 -

Page 46: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

   pnt210[] += newp;   Point(newp) = {       Sp ‐ Ts*9,  ‐ls/2,  0, NM};   pnt210[] += newp;   Point(newp) = {       Sp ‐ Ts*9,   ls/2,  0, NM};   pnt210[] += newp;   Point(newp) = { Sp ‐ bs ‐ Ts*9,   ls/2,   0, NM};   pnt210[] += newp;   Point(newp) = { Sp ‐ bs ‐ Ts*9,  ‐ls/2,   0, NM};    For r In {#pnt210[]‐4:#pnt210[]‐1}     ln210[]+=newl;  Line(newl)  =  {pnt210[r], pnt210[(r==#pnt210[]‐1)?r‐3:r+1]};   EndFor    lnl210[] += newll;   Line Loop(newll) = {ln210[]};    surf_Secondary210[] += news;   Plane Surface(news) = {newll‐1};    Color Black {Surface{surf_Secondary210[]};}   //Adding colour in secondary mesh    Physical Surface(Secondary[10]) = surf_Secondary210[];  //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐      pnt211[] += newp;   Point(newp) = {       Sp ‐ Ts*10,  ‐ls/2,   0, NM};   pnt211[] += newp;   Point(newp) = {       Sp ‐ Ts*10,   ls/2,   0, NM};   pnt211[] += newp;   Point(newp) = { Sp ‐ bs ‐ Ts*10,   ls/2,  0, NM};   pnt211[] += newp;   Point(newp) = { Sp ‐ bs ‐ Ts*10,  ‐ls/2,  0, NM};    For r In {#pnt211[]‐4:#pnt211[]‐1}     ln211[]+=newl;  Line(newl)  =  {pnt211[r], pnt211[(r==#pnt211[]‐1)?r‐3:r+1]};   EndFor    lnl211[] += newll;   Line Loop(newll) = {ln211[]};    surf_Secondary211[] += news;   Plane Surface(news) = {newll‐1};    Color Black {Surface{surf_Secondary211[]};}   //Adding colour in secondary mesh    Physical Surface(Secondary[11]) = surf_Secondary211[];  //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐   

- 45 -

Page 47: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

   pnt212[] += newp;   Point(newp) = {       Sp ‐ Ts*11,  ‐ls/2,   0, NM};   pnt212[] += newp;   Point(newp) = {       Sp ‐ Ts*11,   ls/2,   0, NM};   pnt212[] += newp;   Point(newp) = { Sp ‐ bs ‐ Ts*11,   ls/2,  0, NM};   pnt212[] += newp;   Point(newp) = { Sp ‐ bs ‐ Ts*11,  ‐ls/2,  0, NM};    For r In {#pnt212[]‐4:#pnt212[]‐1}     ln212[]+=newl;  Line(newl)  =  {pnt212[r], pnt212[(r==#pnt212[]‐1)?r‐3:r+1]};   EndFor    lnl212[] += newll;   Line Loop(newll) = {ln212[]};    surf_Secondary212[] += news;   Plane Surface(news) = {newll‐1};    Color Black {Surface{surf_Secondary212[]};}   //Adding colour in secondary mesh    Physical Surface(Secondary[12]) = surf_Secondary212[];  //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐    EndIf   //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐    If(m>4)    //Secondary poles for stators of 5 phases  //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐      pnt213[] += newp;   Point(newp) = {       Sp ‐ Ts*12,  ‐ls/2,   0, NM};   pnt213[] += newp;   Point(newp) = {       Sp ‐ Ts*12,   ls/2,   0, NM};   pnt213[] += newp;   Point(newp) = { Sp ‐ bs ‐ Ts*12,   ls/2,  0, NM};   pnt213[] += newp;   Point(newp) = { Sp ‐ bs ‐ Ts*12,  ‐ls/2,  0, NM};    For r In {#pnt213[]‐4:#pnt213[]‐1}     ln213[]+=newl;  Line(newl)  =  {pnt213[r], pnt213[(r==#pnt213[]‐1)?r‐3:r+1]};   EndFor    lnl213[] += newll;   Line Loop(newll) = {ln213[]};  

- 46 -

Page 48: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

  surf_Secondary213[] += news;   Plane Surface(news) = {newll‐1};    Color Black {Surface{surf_Secondary213[]};}   //Adding colour in secondary mesh    Physical Surface(Secondary[13]) = surf_Secondary213[];  //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐      pnt214[] += newp;   Point(newp) = {       Sp ‐ Ts*13,  ‐ls/2,   0, NM};   pnt214[] += newp;   Point(newp) = {       Sp ‐ Ts*13,   ls/2,   0, NM};   pnt214[] += newp;   Point(newp) = { Sp ‐ bs ‐ Ts*13,   ls/2,  0, NM};   pnt214[] += newp;   Point(newp) = { Sp ‐ bs ‐ Ts*13,  ‐ls/2,  0, NM};    For r In {#pnt214[]‐4:#pnt214[]‐1}     ln214[]+=newl;  Line(newl)  =  {pnt214[r], pnt214[(r==#pnt214[]‐1)?r‐3:r+1]};   EndFor    lnl214[] += newll;   Line Loop(newll) = {ln214[]};    surf_Secondary214[] += news;   Plane Surface(news) = {newll‐1};    Color Black {Surface{surf_Secondary214[]};}   //Adding colour in secondary mesh    Physical Surface(Secondary[14]) = surf_Secondary214[];  //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐      pnt215[] += newp;   Point(newp) = {       Sp ‐ Ts*14,  ‐ls/2,   0, NM};   pnt215[] += newp;   Point(newp) = {       Sp ‐ Ts*14,   ls/2,   0, NM};   pnt215[] += newp;   Point(newp) = { Sp ‐ bs ‐ Ts*14,   ls/2,  0, NM};   pnt215[] += newp;   Point(newp) = { Sp ‐ bs ‐ Ts*14,  ‐ls/2,  0, NM};    For r In {#pnt215[]‐4:#pnt215[]‐1}     ln215[]+=newl;  Line(newl)  =  {pnt215[r], pnt215[(r==#pnt215[]‐1)?r‐3:r+1]};   EndFor    lnl215[] += newll;   Line Loop(newll) = {ln215[]};  

- 47 -

Page 49: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

  surf_Secondary215[] += news;   Plane Surface(news) = {newll‐1};    Color Black {Surface{surf_Secondary215[]};}   //Adding colour in secondary mesh    Physical Surface(Secondary[15]) = surf_Secondary215[];  //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐    EndIf 

5. To create the coils geometry subroutine In this file we will separate each coil. Also we will make a separation with the coils of different phases and the coils of different polarity. The A positive phase will have the numbers (of its coils) from 311 to 314 and the A negative phase will have the numbers from 321 to 324. The same patron will be in the others phases. B positive phase will go from 331 to 334 and B negative phase will go from 341 to 344 … E positive phase will go from 391 to 394 and E negative phase will go from 301 to 304. We put the same colour in all the coils of the same phase, but we put it darker in the negative coils. Also, as the primary and the secondary geometries, we put some if boucles, which avoid to create more coils depending the number of phases. The code will be this: //‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐  //Coil A:  //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  // A + //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐    pnt311[] += newp; Point(newp) = {  (‐L/2) ‐ cp/2 + wr, ‐H + lp + hy ‐ ws, 0, NM}; pnt311[] += newp; Point(newp) = {  (‐L/2) ‐ cp/2 + wr,     ‐H + hy + wi, 0, NM}; pnt311[] += newp; Point(newp) = {      (‐L/2) ‐ wr,     ‐H + hy + wi, 0, NM}; pnt311[] += newp; Point(newp) = {      (‐L/2) ‐ wr, ‐H + lp + hy ‐ ws, 0, NM};  For a In {#pnt311[]‐4:#pnt311[]‐1} 

- 48 -

Page 50: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

  ln311[]+=newl;  Line(newl)  =  {pnt311[a],  pnt311[(a==#pnt311[]‐1)?a‐3:a+1]}; EndFor  lnl311[] += newll; Line Loop(newll) = {ln311[]};  surf_CoilA11[] += news; Plane Surface(news) = {newll‐1};  Color Red {Surface{surf_CoilA11[]};}    //Adding  colour in coil mesh  Physical Surface(CoilAp1) = surf_CoilA11[];  //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐    pnt312[] += newp; Point(newp) = {  (‐L/2) ‐ cp/2 + wr,  H ‐ lp ‐ hy + ws, 0, NM}; pnt312[] += newp; Point(newp) = {  (‐L/2) ‐ cp/2 + wr,     H ‐ hy ‐ wi, 0, NM}; pnt312[] += newp; Point(newp) = {       (‐L/2) ‐ wr,     H ‐ hy ‐ wi, 0, NM}; pnt312[] += newp; Point(newp) = {       (‐L/2)  ‐  wr,    H  ‐  lp  ‐  hy  +  ws,  0, NM};  For a In {#pnt312[]‐4:#pnt312[]‐1}   ln312[]+=newl;  Line(newl)  =  {pnt312[a],  pnt312[(a==#pnt312[]‐1)?a‐3:a+1]}; EndFor  lnl312[] += newll; Line Loop(newll) = {ln312[]};  surf_CoilA12[] += news; Plane Surface(news) = {newll‐1};  Color Red {Surface{surf_CoilA12[]};}           //Adding colour in coil mesh  Physical Surface(CoilAp2) = surf_CoilA12[];  //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐    pnt313[] += newp; Point(newp) = {  (‐L/2) + cp/2 ‐ wr + bp + m*Tp, ‐H + lp + hy ‐ ws, 0, NM}; pnt313[] += newp; Point(newp) = {  (‐L/2) + cp/2 ‐ wr + bp + m*Tp,    ‐H  +  hy  + wi, 0, NM}; pnt313[] += newp; Point(newp) = {       (‐L/2) + wr + bp + m*Tp,   ‐H  +  hy  + wi, 0, NM}; 

- 49 -

Page 51: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

pnt313[] += newp; Point(newp) = {       (‐L/2) + wr + bp + m*Tp, ‐H + lp + hy ‐ ws, 0, NM};  For a In {#pnt313[]‐4:#pnt313[]‐1}   ln313[]+=newl;  Line(newl)  =  {pnt313[a],  pnt313[(a==#pnt313[]‐1)?a‐3:a+1]}; EndFor  lnl313[] += newll; Line Loop(newll) = {ln313[]};  surf_CoilA13[] += news; Plane Surface(news) = {newll‐1};  Color Red {Surface{surf_CoilA13[]};}           //Adding colour in coil mesh  Physical Surface(CoilAp3) = surf_CoilA13[];  //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐    pnt314[] += newp; Point(newp) = {  (‐L/2) + cp/2 ‐ wr + bp + m*Tp,  H ‐ lp ‐ hy + ws, 0, NM}; pnt314[] += newp; Point(newp) = {  (‐L/2) + cp/2 ‐ wr + bp + m*Tp,     H  ‐  hy  ‐ wi, 0, NM}; pnt314[] += newp; Point(newp) = {       (‐L/2) + wr + bp + m*Tp,    H  ‐  hy  ‐ wi, 0, NM}; pnt314[] += newp; Point(newp) = {       (‐L/2) + wr + bp + m*Tp,  H ‐ lp ‐ hy + ws, 0, NM};  For a In {#pnt314[]‐4:#pnt314[]‐1}   ln314[]+=newl;  Line(newl)  =  {pnt314[a],  pnt314[(a==#pnt314[]‐1)?a‐3:a+1]}; EndFor  lnl314[] += newll; Line Loop(newll) = {ln314[]};  surf_CoilA14[] += news; Plane Surface(news) = {newll‐1};  Color Red {Surface{surf_CoilA14[]};}           //Adding colour in coil mesh  Physical Surface(CoilAp4) = surf_CoilA14[];  //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐   // A ‐ //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐   

- 50 -

Page 52: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

 pnt321[] += newp; Point(newp) = {  (‐L/2) + cp/2 ‐ wr + bp, ‐H + lp + hy ‐ ws, 0, NM}; pnt321[] += newp; Point(newp) = {  (‐L/2) + cp/2 ‐ wr + bp,     ‐H  +  hy  +  wi, 0, NM}; pnt321[] += newp; Point(newp) = {       (‐L/2) + wr + bp,     ‐H  +  hy  +  wi, 0, NM}; pnt321[] += newp; Point(newp) = {       (‐L/2) + wr + bp, ‐H + lp + hy ‐ ws, 0, NM};  For a In {#pnt321[]‐4:#pnt321[]‐1}   ln321[]+=newl;  Line(newl)  =  {pnt321[a],  pnt321[(a==#pnt321[]‐1)?a‐3:a+1]}; EndFor  lnl321[] += newll; Line Loop(newll) = {ln321[]};  surf_CoilA21[] += news; Plane Surface(news) = {newll‐1};  Color DarkRed {Surface{surf_CoilA21[]};}   //Adding  colour in coil mesh  Physical Surface(CoilAn1) = surf_CoilA21[];  //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐    pnt322[] += newp; Point(newp) = {  (‐L/2) + cp/2 ‐ wr + bp,  H ‐ lp ‐ hy + ws, 0, NM}; pnt322[] += newp; Point(newp) = {  (‐L/2) + cp/2 ‐ wr + bp,     H ‐ hy ‐ wi, 0, NM}; pnt322[] += newp; Point(newp) = {       (‐L/2) + wr + bp,     H ‐ hy ‐ wi, 0, NM}; pnt322[] += newp; Point(newp) = {       (‐L/2) + wr + bp,  H ‐ lp ‐ hy + ws, 0, NM};  For a In {#pnt322[]‐4:#pnt322[]‐1}   ln322[]+=newl;  Line(newl)  =  {pnt322[a],  pnt322[(a==#pnt322[]‐1)?a‐3:a+1]}; EndFor  lnl322[] += newll; Line Loop(newll) = {ln322[]};  surf_CoilA22[] += news; 

- 51 -

Page 53: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

Plane Surface(news) = {newll‐1};  Color DarkRed {Surface{surf_CoilA22[]};}          //Adding colour in coil mesh  Physical Surface(CoilAn2) = surf_CoilA22[];   //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐    pnt323[] += newp; Point(newp) = {  (‐L/2) ‐ cp/2 + wr + m*Tp, ‐H + lp + hy ‐ ws, 0, NM}; pnt323[] += newp; Point(newp) = {  (‐L/2) ‐ cp/2 + wr + m*Tp,      ‐H  +  hy  + wi, 0, NM}; pnt323[] += newp; Point(newp) = {       (‐L/2) ‐ wr + m*Tp,     ‐H  +  hy  + wi, 0, NM}; pnt323[] += newp; Point(newp) = {       (‐L/2) ‐ wr + m*Tp, ‐H + lp + hy ‐ ws, 0, NM};  For a In {#pnt323[]‐4:#pnt323[]‐1}   ln323[]+=newl;  Line(newl)  =  {pnt323[a],  pnt323[(a==#pnt323[]‐1)?a‐3:a+1]}; EndFor  lnl323[] += newll; Line Loop(newll) = {ln323[]};  surf_CoilA23[] += news; Plane Surface(news) = {newll‐1};  Color DarkRed {Surface{surf_CoilA23[]};}          //Adding colour in coil mesh  Physical Surface(CoilAn3) = surf_CoilA23[];  //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐    pnt324[] += newp; Point(newp) = {  (‐L/2) ‐ cp/2 + wr + m*Tp,  H ‐ lp ‐ hy + ws, 0, NM}; pnt324[] += newp; Point(newp) = {  (‐L/2) ‐ cp/2 + wr + m*Tp,       H  ‐  hy  ‐ wi, 0, NM}; pnt324[] += newp; Point(newp) = {       (‐L/2) ‐ wr + m*Tp,      H  ‐  hy  ‐ wi, 0, NM}; pnt324[] += newp; Point(newp) = {       (‐L/2) ‐ wr + m*Tp,  H ‐ lp ‐ hy + ws, 0, NM};  

- 52 -

Page 54: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

For a In {#pnt324[]‐4:#pnt324[]‐1}   ln324[]+=newl;  Line(newl)  =  {pnt324[a],  pnt324[(a==#pnt324[]‐1)?a‐3:a+1]}; EndFor  lnl324[] += newll; Line Loop(newll) = {ln324[]};  surf_CoilA24[] += news; Plane Surface(news) = {newll‐1};  Color DarkRed {Surface{surf_CoilA24[]};}          //Adding colour in coil mesh  Physical Surface(CoilAn4) = surf_CoilA24[];   //‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐  //Coil B:  //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐    // B + //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐    pnt331[] += newp; Point(newp) = {  (‐L/2) ‐ cp/2 + wr + Tp, ‐H + lp + hy ‐ ws, 0, NM}; pnt331[] += newp; Point(newp) = {  (‐L/2) ‐ cp/2 + wr + Tp,    ‐H + hy + wi, 0, NM}; pnt331[] += newp; Point(newp) = {       (‐L/2) ‐ wr + Tp,    ‐H + hy + wi, 0, NM}; pnt331[] += newp; Point(newp) = {       (‐L/2) ‐ wr + Tp, ‐H + lp + hy ‐ ws, 0, NM};  For b In {#pnt331[]‐4:#pnt331[]‐1}   ln331[]+=newl;  Line(newl)  =  {pnt331[b],  pnt331[(b==#pnt331[]‐1)?b‐3:b+1]}; EndFor  lnl331[] += newll; Line Loop(newll) = {ln331[]};  surf_CoilB31[] += news; Plane Surface(news) = {newll‐1};  Color Green {Surface{surf_CoilB31[]};}           //Adding colour in coil mesh  Physical Surface(CoilBp1) = surf_CoilB31[]; 

- 53 -

Page 55: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

 //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐    pnt332[] += newp; Point(newp) = {  (‐L/2) ‐ cp/2 + wr + Tp,  H ‐ lp ‐ hy + ws, 0, NM}; pnt332[] += newp; Point(newp) = {  (‐L/2) ‐ cp/2 + wr + Tp,     H ‐ hy ‐ wi, 0, NM}; pnt332[] += newp; Point(newp) = {       (‐L/2) ‐ wr + Tp,     H ‐ hy ‐ wi, 0, NM}; pnt332[] += newp; Point(newp) = {       (‐L/2) ‐ wr + Tp,  H ‐ lp ‐ hy + ws, 0, NM};  For b In {#pnt332[]‐4:#pnt332[]‐1}   ln332[]+=newl;  Line(newl)  =  {pnt332[b],  pnt332[(b==#pnt332[]‐1)?b‐3:b+1]}; EndFor  lnl332[] += newll; Line Loop(newll) = {ln332[]};  surf_CoilB32[] += news; Plane Surface(news) = {newll‐1};  Color Green {Surface{surf_CoilB32[]};}           //Adding colour in coil mesh  Physical Surface(CoilBp2) = surf_CoilB32[];  //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐    pnt333[] += newp; Point(newp) = {  (‐L/2) + cp/2 ‐ wr + bp + (m+1)*Tp, ‐H + lp + hy ‐ ws, 0, NM}; pnt333[] += newp; Point(newp) = {  (‐L/2) + cp/2 ‐ wr + bp + (m+1)*Tp,    ‐H  + hy + wi, 0, NM}; pnt333[] += newp; Point(newp) = {       (‐L/2) + wr + bp + (m+1)*Tp,    ‐H  + hy + wi, 0, NM}; pnt333[] += newp; Point(newp) = {       (‐L/2) + wr + bp + (m+1)*Tp, ‐H + lp + hy ‐ ws, 0, NM};  For b In {#pnt333[]‐4:#pnt333[]‐1}   ln333[]+=newl;  Line(newl)  =  {pnt333[b],  pnt333[(b==#pnt333[]‐1)?b‐3:b+1]}; EndFor  lnl333[] += newll; Line Loop(newll) = {ln333[]}; 

- 54 -

Page 56: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

 surf_CoilB33[] += news; Plane Surface(news) = {newll‐1};  Color Green {Surface{surf_CoilB33[]};}           //Adding colour in coil mesh  Physical Surface(CoilBp3) = surf_CoilB33[];  //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐    pnt334[] += newp; Point(newp) = {  (‐L/2) + cp/2 ‐ wr + bp + (m+1)*Tp,  H ‐ lp ‐ hy + ws, 0, NM}; pnt334[] += newp; Point(newp) = {  (‐L/2) + cp/2 ‐ wr + bp + (m+1)*Tp,     H  ‐ hy ‐ wi, 0, NM}; pnt334[] += newp; Point(newp) = {       (‐L/2) + wr + bp + (m+1)*Tp,     H  ‐ hy ‐ wi, 0, NM}; pnt334[] += newp; Point(newp) = {       (‐L/2) + wr + bp + (m+1)*Tp,  H ‐ lp ‐ hy + ws, 0, NM};  For b In {#pnt334[]‐4:#pnt334[]‐1}   ln334[]+=newl;  Line(newl)  =  {pnt334[b],  pnt334[(b==#pnt334[]‐1)?b‐3:b+1]}; EndFor  lnl334[] += newll; Line Loop(newll) = {ln334[]};  surf_CoilB34[] += news; Plane Surface(news) = {newll‐1};  Color Green {Surface{surf_CoilB34[]};}           //Adding colour in coil mesh  Physical Surface(CoilBp4) = surf_CoilB34[];  //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐   // B ‐ //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐    pnt341[] += newp; Point(newp) = {  (‐L/2) + cp/2 ‐ wr + bp + Tp, ‐H + lp + hy ‐ ws, 0, NM}; pnt341[] += newp; Point(newp) = {  (‐L/2) + cp/2 ‐ wr + bp + Tp,     ‐H + hy + wi, 0, NM}; pnt341[] += newp; Point(newp) = {       (‐L/2) + wr + bp + Tp,     ‐H + hy + wi, 0, NM}; pnt341[] += newp; 

- 55 -

Page 57: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

Point(newp) = {       (‐L/2) + wr + bp + Tp, ‐H + lp + hy ‐ ws, 0, NM};  For b In {#pnt341[]‐4:#pnt341[]‐1}   ln341[]+=newl;  Line(newl)  =  {pnt341[b],  pnt341[(b==#pnt341[]‐1)?b‐3:b+1]}; EndFor  lnl341[] += newll; Line Loop(newll) = {ln341[]};  surf_CoilB41[] += news; Plane Surface(news) = {newll‐1};  Color DarkGreen {Surface{surf_CoilB41[]};}           //Adding colour in coil mesh  Physical Surface(CoilBn1) = surf_CoilB41[];  //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐    pnt342[] += newp; Point(newp) = {  (‐L/2) + cp/2 ‐ wr + bp + Tp,  H ‐ lp ‐ hy + ws, 0, NM}; pnt342[] += newp; Point(newp) = {  (‐L/2) + cp/2 ‐ wr + bp + Tp,     H  ‐  hy  ‐ wi, 0, NM}; pnt342[] += newp; Point(newp) = {       (‐L/2) + wr + bp + Tp,     H  ‐  hy  ‐ wi, 0, NM}; pnt342[] += newp; Point(newp) = {       (‐L/2) + wr + bp + Tp,  H ‐ lp ‐ hy + ws, 0, NM};  For b In {#pnt342[]‐4:#pnt342[]‐1}   ln342[]+=newl;  Line(newl)  =  {pnt342[b],  pnt342[(b==#pnt342[]‐1)?b‐3:b+1]}; EndFor  lnl342[] += newll; Line Loop(newll) = {ln342[]};  surf_CoilB42[] += news; Plane Surface(news) = {newll‐1};  Color DarkGreen {Surface{surf_CoilB42[]};}           //Adding colour in coil mesh  Physical Surface(CoilBn2) = surf_CoilB42[];  //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐    pnt343[] += newp; 

- 56 -

Page 58: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

Point(newp) = {  (‐L/2) ‐ cp/2 + wr + (m+1)*Tp, ‐H + lp + hy ‐ ws, 0, NM}; pnt343[] += newp; Point(newp) = {  (‐L/2) ‐ cp/2 + wr + (m+1)*Tp,      ‐H  + hy + wi, 0, NM}; pnt343[] += newp; Point(newp) = {       (‐L/2) ‐ wr + (m+1)*Tp,      ‐H  + hy + wi, 0, NM}; pnt343[] += newp; Point(newp) = {       (‐L/2) ‐ wr + (m+1)*Tp, ‐H + lp + hy ‐ ws, 0, NM};  For b In {#pnt342[]‐4:#pnt342[]‐1}   ln343[]+=newl;  Line(newl)  =  {pnt343[b],  pnt343[(b==#pnt343[]‐1)?b‐3:b+1]}; EndFor  lnl343[] += newll; Line Loop(newll) = {ln343[]};  surf_CoilB43[] += news; Plane Surface(news) = {newll‐1};  Color DarkGreen {Surface{surf_CoilB43[]};}           //Adding colour in coil mesh  Physical Surface(CoilBn3) = surf_CoilB43[];  //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐    pnt344[] += newp; Point(newp) = {  (‐L/2) ‐ cp/2 + wr + (m+1)*Tp,  H ‐ lp ‐ hy + ws, 0, NM}; pnt344[] += newp; Point(newp) = {  (‐L/2) ‐ cp/2 + wr + (m+1)*Tp,       H  ‐ hy ‐ wi, 0, NM}; pnt344[] += newp; Point(newp) = {       (‐L/2) ‐ wr + (m+1)*Tp,       H  ‐ hy ‐ wi, 0, NM}; pnt344[] += newp; Point(newp) = {       (‐L/2) ‐ wr + (m+1)*Tp,  H ‐ lp ‐ hy + ws, 0, NM};  For b In {#pnt344[]‐4:#pnt344[]‐1}   ln344[]+=newl;  Line(newl)  =  {pnt344[b],  pnt344[(b==#pnt344[]‐1)?b‐3:b+1]}; EndFor  lnl344[] += newll; Line Loop(newll) = {ln344[]};  surf_CoilB44[] += news; Plane Surface(news) = {newll‐1};  

- 57 -

Page 59: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

Color DarkGreen {Surface{surf_CoilB44[]};}           //Adding colour in coil mesh  Physical Surface(CoilBn4) = surf_CoilB44[];   //‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐  //Coil C:  If(m>2)    //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐     // C +   //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐      pnt351[] += newp;   Point(newp) = {  (‐L/2) ‐ cp/2 + wr + 2*Tp, ‐H + lp + hy ‐ ws, 0, NM};   pnt351[] += newp;   Point(newp) = {  (‐L/2) ‐ cp/2 + wr + 2*Tp,    ‐H  +  hy  + wi, 0, NM};   pnt351[] += newp;   Point(newp) = {       (‐L/2) ‐ wr + 2*Tp,   ‐H  +  hy  + wi, 0, NM};   pnt351[] += newp;   Point(newp) = {       (‐L/2) ‐ wr + 2*Tp, ‐H + lp + hy ‐ ws, 0, NM};    For c In {#pnt351[]‐4:#pnt351[]‐1}     ln351[]+=newl;  Line(newl)  =  {pnt351[c], pnt351[(c==#pnt351[]‐1)?c‐3:c+1]};   EndFor    lnl351[] += newll;   Line Loop(newll) = {ln351[]};    surf_CoilC51[] += news;   Plane Surface(news) = {newll‐1};    Color Yellow {Surface{surf_CoilC51[]};}           //Adding colour in coil mesh             Physical Surface(CoilCp1) = surf_CoilC51[];    //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐      pnt352[] += newp;   Point(newp) = {  (‐L/2) ‐ cp/2 + wr + 2*Tp,  H ‐ lp ‐ hy + ws, 0, NM};   pnt352[] += newp;   Point(newp) = {  (‐L/2) ‐ cp/2 + wr + 2*Tp,     H  ‐  hy  ‐ wi, 0, NM};   pnt352[] += newp; 

- 58 -

Page 60: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

  Point(newp) = {       (‐L/2) ‐ wr + 2*Tp,    H  ‐  hy  ‐ wi, 0, NM};   pnt352[] += newp;   Point(newp) = {       (‐L/2) ‐ wr + 2*Tp,  H ‐ lp ‐ hy + ws, 0, NM};    For c In {#pnt352[]‐4:#pnt352[]‐1}     ln352[]+=newl;  Line(newl)  =  {pnt352[c], pnt352[(c==#pnt352[]‐1)?c‐3:c+1]};   EndFor    lnl352[] += newll;   Line Loop(newll) = {ln352[]};    surf_CoilC52[] += news;   Plane Surface(news) = {newll‐1};    Color Yellow {Surface{surf_CoilC52[]};}           //Adding colour in coil mesh    Physical Surface(CoilCp2) = surf_CoilC52[];    //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐      pnt353[] += newp;   Point(newp) = {  (‐L/2) + cp/2 ‐ wr + bp + (m+2)*Tp, ‐H + lp + hy ‐ ws, 0, NM};   pnt353[] += newp;   Point(newp) = {  (‐L/2) + cp/2 ‐ wr + bp + (m+2)*Tp,    ‐H + hy + wi, 0, NM};   pnt353[] += newp;   Point(newp) = {       (‐L/2) + wr + bp + (m+2)*Tp,    ‐H + hy + wi, 0, NM};   pnt353[] += newp;   Point(newp) = {       (‐L/2) + wr + bp + (m+2)*Tp, ‐H + lp + hy ‐ ws, 0, NM};      For c In {#pnt353[]‐4:#pnt353[]‐1}     ln353[]+=newl;  Line(newl)  =  {pnt353[c], pnt353[(c==#pnt353[]‐1)?c‐3:c+1]};   EndFor    lnl353[] += newll;   Line Loop(newll) = {ln353[]};    surf_CoilC53[] += news;   Plane Surface(news) = {newll‐1};    Color Yellow {Surface{surf_CoilC53[]};}           //Adding colour in coil mesh                 Physical Surface(CoilCp3) = surf_CoilC53[];    //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐   

- 59 -

Page 61: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

   pnt354[] += newp;   Point(newp) = {  (‐L/2) + cp/2 ‐ wr + bp + (m+2)*Tp,  H ‐ lp ‐ hy + ws, 0, NM};   pnt354[] += newp;   Point(newp) = {  (‐L/2) + cp/2 ‐ wr + bp + (m+2)*Tp,       H ‐ hy ‐ wi, 0, NM};   pnt354[] += newp;   Point(newp) = {       (‐L/2) + wr + bp + (m+2)*Tp,       H ‐ hy ‐ wi, 0, NM};   pnt354[] += newp;   Point(newp) = {       (‐L/2) + wr + bp + (m+2)*Tp,  H ‐ lp ‐ hy + ws, 0, NM};      For c In {#pnt354[]‐4:#pnt354[]‐1}     ln354[]+=newl;  Line(newl)  =  {pnt354[c], pnt354[(c==#pnt354[]‐1)?c‐3:c+1]};   EndFor    lnl354[] += newll;   Line Loop(newll) = {ln354[]};    surf_CoilC54[] += news;   Plane Surface(news) = {newll‐1};    Color Yellow {Surface{surf_CoilC54[]};}           //Adding colour in coil mesh    Physical Surface(CoilCp4) = surf_CoilC54[];    //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐     // C ‐   //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐      pnt361[] += newp;   Point(newp) = {  (‐L/2) + cp/2 ‐ wr + bp + 2*Tp, ‐H + lp + hy ‐ ws, 0, NM};   pnt361[] += newp;   Point(newp) = {  (‐L/2) + cp/2 ‐ wr + bp + 2*Tp,     ‐H + hy + wi, 0, NM};   pnt361[] += newp;   Point(newp) = {       (‐L/2) + wr + bp + 2*Tp,    ‐H + hy + wi, 0, NM};   pnt361[] += newp;   Point(newp) = {       (‐L/2) + wr + bp + 2*Tp, ‐H + lp + hy ‐ ws, 0, NM};    For c In {#pnt361[]‐4:#pnt361[]‐1}     ln361[]+=newl;  Line(newl)  =  {pnt361[c], pnt361[(c==#pnt361[]‐1)?c‐3:c+1]};   EndFor    lnl361[] += newll;   Line Loop(newll) = {ln361[]}; 

- 60 -

Page 62: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

   surf_CoilC61[] += news;   Plane Surface(news) = {newll‐1};    Color {186,177,35} {Surface{surf_CoilC61[]};}           //Adding colour in coil mesh       //DarkYellow does not exist    Physical Surface(CoilCn1) = surf_CoilC61[];    //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐      pnt362[] += newp;   Point(newp) = {  (‐L/2) + cp/2 ‐ wr + bp + 2*Tp,  H ‐ lp ‐ hy + ws, 0, NM};   pnt362[] += newp;   Point(newp) = {  (‐L/2) + cp/2 ‐ wr + bp + 2*Tp,     H  ‐ hy ‐ wi, 0, NM};   pnt362[] += newp;   Point(newp) = {       (‐L/2) + wr + bp + 2*Tp,    H  ‐ hy ‐ wi, 0, NM};   pnt362[] += newp;   Point(newp) = {       (‐L/2) + wr + bp + 2*Tp,  H ‐ lp ‐ hy + ws, 0, NM};    For c In {#pnt362[]‐4:#pnt362[]‐1}     ln362[]+=newl;  Line(newl)  =  {pnt362[c], pnt362[(c==#pnt362[]‐1)?c‐3:c+1]};   EndFor    lnl362[] += newll;   Line Loop(newll) = {ln362[]};    surf_CoilC62[] += news;   Plane Surface(news) = {newll‐1};    Color {186,177,35} {Surface{surf_CoilC62[]};}           //Adding colour in coil mesh       //DarkYellow does not exist    Physical Surface(CoilCn2) = surf_CoilC62[];    //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐      pnt363[] += newp;   Point(newp) = {  (‐L/2) ‐ cp/2 + wr + (m+2)*Tp, ‐H + lp + hy ‐ ws, 0, NM};   pnt363[] += newp;   Point(newp) = {  (‐L/2) ‐ cp/2 + wr + (m+2)*Tp,      ‐H + hy + wi, 0, NM};   pnt363[] += newp;   Point(newp) = {       (‐L/2) ‐ wr + (m+2)*Tp,      ‐H + hy + wi, 0, NM};   pnt363[] += newp; 

- 61 -

Page 63: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

  Point(newp) = {       (‐L/2) ‐ wr + (m+2)*Tp, ‐H + lp + hy ‐ ws, 0, NM};    For c In {#pnt362[]‐4:#pnt362[]‐1}     ln363[]+=newl;  Line(newl)  =  {pnt363[c], pnt363[(c==#pnt363[]‐1)?c‐3:c+1]};   EndFor    lnl363[] += newll;   Line Loop(newll) = {ln363[]};    surf_CoilC63[] += news;   Plane Surface(news) = {newll‐1};    Color {186,177,35} {Surface{surf_CoilC63[]};}           //Adding colour in coil mesh       //DarkYellow does not exist    Physical Surface(CoilCn3) = surf_CoilC63[];    //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐      pnt364[] += newp;   Point(newp) = {  (‐L/2) ‐ cp/2 + wr + (m+2)*Tp,  H ‐ lp ‐ hy + ws, 0, NM};   pnt364[] += newp;   Point(newp) = {  (‐L/2) ‐ cp/2 + wr + (m+2)*Tp,       H ‐ hy ‐ wi, 0, NM};   pnt364[] += newp;   Point(newp) = {       (‐L/2) ‐ wr + (m+2)*Tp,       H ‐ hy ‐ wi, 0, NM};   pnt364[] += newp;   Point(newp) = {       (‐L/2) ‐ wr + (m+2)*Tp,  H ‐ lp ‐ hy + ws, 0, NM};    For c In {#pnt364[]‐4:#pnt364[]‐1}     ln364[]+=newl;  Line(newl)  =  {pnt364[c], pnt364[(c==#pnt364[]‐1)?c‐3:c+1]};   EndFor    lnl364[] += newll;   Line Loop(newll) = {ln364[]};    surf_CoilC64[] += news;   Plane Surface(news) = {newll‐1};    Color {186,177,35} {Surface{surf_CoilC64[]};}           //Adding colour in coil mesh       //DarkYellow does not exist    Physical Surface(CoilCn4) = surf_CoilC64[];  EndIf  

- 62 -

Page 64: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

 //‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐  //Coil D:  If(m>3)    //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐     // D +   //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐      pnt371[] += newp;   Point(newp) = {  (‐L/2) ‐ cp/2 + wr + 3*Tp, ‐H + lp + hy ‐ ws, 0, NM};   pnt371[] += newp;   Point(newp) = {  (‐L/2) ‐ cp/2 + wr + 3*Tp,    ‐H  +  hy  + wi, 0, NM};   pnt371[] += newp;   Point(newp) = {       (‐L/2) ‐ wr + 3*Tp,   ‐H  +  hy  + wi, 0, NM};   pnt371[] += newp;   Point(newp) = {       (‐L/2) ‐ wr + 3*Tp, ‐H + lp + hy ‐ ws, 0, NM};    For d In {#pnt371[]‐4:#pnt371[]‐1}     ln371[]+=newl;  Line(newl)  =  {pnt371[d], pnt371[(d==#pnt371[]‐1)?d‐3:d+1]};   EndFor    lnl371[] += newll;   Line Loop(newll) = {ln371[]};    surf_CoilD71[] += news;   Plane Surface(news) = {newll‐1};    Color Pink {Surface{surf_CoilD71[]};}           //Adding colour in coil mesh                  Physical Surface(CoilDp1) = surf_CoilD71[];    //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐      pnt372[] += newp;   Point(newp) = {  (‐L/2) ‐ cp/2 + wr + 3*Tp,  H ‐ lp ‐ hy + ws, 0, NM};   pnt372[] += newp;   Point(newp) = {  (‐L/2) ‐ cp/2 + wr + 3*Tp,        H  ‐ hy ‐ wi, 0, NM};   pnt372[] += newp;   Point(newp) = {       (‐L/2) ‐ wr + 3*Tp,      H  ‐ hy ‐ wi, 0, NM};   pnt372[] += newp; 

- 63 -

Page 65: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

  Point(newp) = {       (‐L/2) ‐ wr + 3*Tp,  H ‐ lp ‐ hy + ws, 0, NM};    For d In {#pnt372[]‐4:#pnt372[]‐1}     ln372[]+=newl;  Line(newl)  =  {pnt372[d], pnt372[(d==#pnt372[]‐1)?d‐3:d+1]};   EndFor    lnl372[] += newll;   Line Loop(newll) = {ln372[]};    surf_CoilD72[] += news;   Plane Surface(news) = {newll‐1};    Color Pink {Surface{surf_CoilD72[]};}           //Adding colour in coil mesh                  Physical Surface(CoilDp2) = surf_CoilD72[];    //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐      pnt373[] += newp;   Point(newp) = {  (‐L/2) + cp/2 ‐ wr + bp + (m+3)*Tp, ‐H + lp + hy ‐ ws, 0, NM};   pnt373[] += newp;   Point(newp) = {  (‐L/2) + cp/2 ‐ wr + bp + (m+3)*Tp,    ‐H + hy + wi, 0, NM};   pnt373[] += newp;   Point(newp) = {       (‐L/2) + wr + bp + (m+3)*Tp,    ‐H + hy + wi, 0, NM};   pnt373[] += newp;   Point(newp) = {       (‐L/2) + wr + bp + (m+3)*Tp, ‐H + lp + hy ‐ ws, 0, NM};      For d In {#pnt373[]‐4:#pnt373[]‐1}     ln373[]+=newl;  Line(newl)  =  {pnt373[d], pnt373[(d==#pnt373[]‐1)?d‐3:d+1]};   EndFor    lnl373[] += newll;   Line Loop(newll) = {ln373[]};    surf_CoilD73[] += news;   Plane Surface(news) = {newll‐1};    Color Pink {Surface{surf_CoilD73[]};}           //Adding colour in coil mesh    Physical Surface(CoilDp3) = surf_CoilD73[];    //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐      pnt374[] += newp; 

- 64 -

Page 66: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

  Point(newp) = {  (‐L/2) + cp/2 ‐ wr + bp + (m+3)*Tp,  H ‐ lp ‐ hy + ws, 0, NM};   pnt374[] += newp;   Point(newp) = {  (‐L/2) + cp/2 ‐ wr + bp + (m+3)*Tp,     H ‐ hy ‐ wi, 0, NM};   pnt374[] += newp;   Point(newp) = {       (‐L/2) + wr + bp + (m+3)*Tp,     H ‐ hy ‐ wi, 0, NM};   pnt374[] += newp;   Point(newp) = {       (‐L/2) + wr + bp + (m+3)*Tp,  H ‐ lp ‐ hy + ws, 0, NM};          For d In {#pnt374[]‐4:#pnt374[]‐1}     ln374[]+=newl;  Line(newl)  =  {pnt374[d], pnt374[(d==#pnt374[]‐1)?d‐3:d+1]};   EndFor    lnl374[] += newll;   Line Loop(newll) = {ln374[]};    surf_CoilD74[] += news;   Plane Surface(news) = {newll‐1};    Color Pink {Surface{surf_CoilD74[]};}           //Adding colour in coil mesh    Physical Surface(CoilDp4) = surf_CoilD74[];    //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐     // D ‐   //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐      pnt381[] += newp;   Point(newp) = {  (‐L/2) + cp/2 ‐ wr + bp + 3*Tp, ‐H + lp + hy ‐ ws, 0, NM};   pnt381[] += newp;   Point(newp) = {  (‐L/2) + cp/2 ‐ wr + bp + 3*Tp,    ‐H  + hy + wi, 0, NM};   pnt381[] += newp;   Point(newp) = {       (‐L/2) + wr + bp + 3*Tp,   ‐H  + hy + wi, 0, NM};   pnt381[] += newp;   Point(newp) = {       (‐L/2) + wr + bp + 3*Tp, ‐H + lp + hy ‐ ws, 0, NM};    For d In {#pnt381[]‐4:#pnt381[]‐1}     ln381[]+=newl;  Line(newl)  =  {pnt381[d], pnt381[(d==#pnt381[]‐1)?d‐3:d+1]};   EndFor    lnl381[] += newll;   Line Loop(newll) = {ln381[]};    surf_CoilD81[] += news; 

- 65 -

Page 67: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

  Plane Surface(news) = {newll‐1};    Color Purple {Surface{surf_CoilD81[]};}           //Adding colour in coil mesh       //DarkPink does not exist      Physical Surface(CoilDn1) = surf_CoilD81[];    //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐      pnt382[] += newp;   Point(newp) = {  (‐L/2) + cp/2 ‐ wr + bp + 3*Tp,  H ‐ lp ‐ hy + ws, 0, NM};   pnt382[] += newp;   Point(newp) = {  (‐L/2) + cp/2 ‐ wr + bp + 3*Tp,     H  ‐ hy ‐ wi, 0, NM};   pnt382[] += newp;   Point(newp) = {       (‐L/2) + wr + bp + 3*Tp,    H  ‐ hy ‐ wi, 0, NM};   pnt382[] += newp;   Point(newp) = {       (‐L/2) + wr + bp + 3*Tp,  H ‐ lp ‐ hy + ws, 0, NM};    For d In {#pnt382[]‐4:#pnt382[]‐1}     ln382[]+=newl;  Line(newl)  =  {pnt382[d], pnt382[(d==#pnt382[]‐1)?d‐3:d+1]};   EndFor    lnl382[] += newll;   Line Loop(newll) = {ln382[]};    surf_CoilD82[] += news;   Plane Surface(news) = {newll‐1};    Color Purple {Surface{surf_CoilD82[]};}           //Adding colour in coil mesh       //DarkPink does not exist      Physical Surface(CoilDn2) = surf_CoilD82[];     //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐      pnt383[] += newp;   Point(newp) = {  (‐L/2) ‐ cp/2 + wr + (m+3)*Tp, ‐H + lp + hy ‐ ws, 0, NM};   pnt383[] += newp;   Point(newp) = {  (‐L/2) ‐ cp/2 + wr + (m+3)*Tp,      ‐H + hy + wi, 0, NM};   pnt383[] += newp;   Point(newp) = {       (‐L/2) ‐ wr + (m+3)*Tp,      ‐H + hy + wi, 0, NM};   pnt383[] += newp; 

- 66 -

Page 68: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

  Point(newp) = {       (‐L/2) ‐ wr + (m+3)*Tp, ‐H + lp + hy ‐ ws, 0, NM};    For d In {#pnt383[]‐4:#pnt383[]‐1}     ln383[]+=newl;  Line(newl)  =  {pnt383[d], pnt383[(d==#pnt383[]‐1)?d‐3:d+1]};   EndFor    lnl383[] += newll;   Line Loop(newll) = {ln383[]};    surf_CoilD83[] += news;   Plane Surface(news) = {newll‐1};    Color Purple {Surface{surf_CoilD83[]};}           //Adding colour in coil mesh       //DarkPink does not exist      Physical Surface(CoilDn3) = surf_CoilD83[];    //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐      pnt384[] += newp;   Point(newp) = {  (‐L/2) ‐ cp/2 + wr + (m+3)*Tp,  H ‐ lp ‐ hy + ws, 0, NM};   pnt384[] += newp;   Point(newp) = {  (‐L/2) ‐ cp/2 + wr + (m+3)*Tp,       H ‐ hy ‐ wi, 0, NM};   pnt384[] += newp;   Point(newp) = {       (‐L/2) ‐ wr + (m+3)*Tp,       H ‐ hy ‐ wi, 0, NM};   pnt384[] += newp;   Point(newp) = {       (‐L/2) ‐ wr + (m+3)*Tp,  H ‐ lp ‐ hy + ws, 0, NM};    For d In {#pnt384[]‐4:#pnt384[]‐1}     ln384[]+=newl;  Line(newl)  =  {pnt384[d], pnt384[(d==#pnt384[]‐1)?d‐3:d+1]};   EndFor    lnl384[] += newll;   Line Loop(newll) = {ln384[]};    surf_CoilD84[] += news;   Plane Surface(news) = {newll‐1};    Color Purple {Surface{surf_CoilD84[]};}           //Adding colour in coil mesh       //DarkPink does not exist      Physical Surface(CoilDn4) = surf_CoilD84[];  EndIf  

- 67 -

Page 69: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

 //‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐  //Coil E:  If(m>4)    //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐    // E +   //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐      pnt391[] += newp;   Point(newp) = {  (‐L/2) ‐ cp/2 + wr + 4*Tp, ‐H + lp + hy ‐ ws, 0, NM};   pnt391[] += newp;   Point(newp) = {  (‐L/2) ‐ cp/2 + wr + 4*Tp,    ‐H  +  hy  + wi, 0, NM};   pnt391[] += newp;   Point(newp) = {       (‐L/2) ‐ wr + 4*Tp,   ‐H  +  hy  + wi, 0, NM};   pnt391[] += newp;   Point(newp) = {       (‐L/2) ‐ wr + 4*Tp, ‐H + lp + hy ‐ ws, 0, NM};    For e In {#pnt391[]‐4:#pnt391[]‐1}     ln391[]+=newl;  Line(newl)  =  {pnt391[e], pnt391[(e==#pnt391[]‐1)?e‐3:e+1]};   EndFor    lnl391[] += newll;   Line Loop(newll) = {ln391[]};    surf_CoilE91[] += news;   Plane Surface(news) = {newll‐1};    Color Orange {Surface{surf_CoilE91[]};}           //Adding colour in coil mesh    Physical Surface(CoilEp1) = surf_CoilE91[];    //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐      pnt392[] += newp;   Point(newp) = {  (‐L/2) ‐ cp/2 + wr + 4*Tp,  H ‐ lp ‐ hy + ws, 0, NM};   pnt392[] += newp;   Point(newp) = {  (‐L/2) ‐ cp/2 + wr + 4*Tp,        H  ‐ hy ‐ wi, 0, NM};   pnt392[] += newp;   Point(newp) = {       (‐L/2) ‐ wr + 4*Tp,      H  ‐ hy ‐ wi, 0, NM};   pnt392[] += newp;   Point(newp) = {       (‐L/2) ‐ wr + 4*Tp,  H ‐ lp ‐ hy + ws, 0, NM}; 

- 68 -

Page 70: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

   For e In {#pnt392[]‐4:#pnt392[]‐1}     ln392[]+=newl;  Line(newl)  =  {pnt392[e], pnt392[(e==#pnt392[]‐1)?e‐3:e+1]};   EndFor    lnl392[] += newll;   Line Loop(newll) = {ln392[]};    surf_CoilE92[] += news;   Plane Surface(news) = {newll‐1};    Color Orange {Surface{surf_CoilE92[]};}           //Adding colour in coil mesh    Physical Surface(CoilEp2) = surf_CoilE92[];    //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐      pnt393[] += newp;   Point(newp) = {  (‐L/2) + cp/2 ‐ wr + bp + (m+4)*Tp, ‐H + lp + hy ‐ ws, 0, NM};   pnt393[] += newp;   Point(newp) = {  (‐L/2) + cp/2 ‐ wr + bp + (m+4)*Tp,    ‐H + hy + wi, 0, NM};   pnt393[] += newp;   Point(newp) = {       (‐L/2) + wr + bp + (m+4)*Tp,    ‐H + hy + wi, 0, NM};   pnt393[] += newp;   Point(newp) = {       (‐L/2) + wr + bp + (m+4)*Tp, ‐H + lp + hy ‐ ws, 0, NM};      For e In {#pnt393[]‐4:#pnt393[]‐1}     ln393[]+=newl;  Line(newl)  =  {pnt393[e], pnt393[(e==#pnt393[]‐1)?e‐3:e+1]};   EndFor    lnl393[] += newll;   Line Loop(newll) = {ln393[]};    surf_CoilE93[] += news;   Plane Surface(news) = {newll‐1};    Color Orange {Surface{surf_CoilE93[]};}           //Adding colour in coil mesh    Physical Surface(CoilEp3) = surf_CoilE93[];    //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐      pnt394[] += newp;   Point(newp) = {  (‐L/2) + cp/2 ‐ wr + bp + (m+4)*Tp,  H ‐ lp ‐ hy + ws, 0, NM};   pnt394[] += newp; 

- 69 -

Page 71: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

  Point(newp) = {  (‐L/2) + cp/2 ‐ wr + bp + (m+4)*Tp,     H ‐ hy ‐ wi, 0, NM};   pnt394[] += newp;   Point(newp) = {       (‐L/2) + wr + bp + (m+4)*Tp,     H ‐ hy ‐ wi, 0, NM};   pnt394[] += newp;   Point(newp) = {       (‐L/2) + wr + bp + (m+4)*Tp,  H ‐ lp ‐ hy + ws, 0, NM};          For e In {#pnt394[]‐4:#pnt394[]‐1}     ln394[]+=newl;  Line(newl)  =  {pnt394[e], pnt394[(e==#pnt394[]‐1)?e‐3:e+1]};   EndFor    lnl394[] += newll;   Line Loop(newll) = {ln394[]};    surf_CoilE94[] += news;   Plane Surface(news) = {newll‐1};    Color Orange {Surface{surf_CoilE94[]};}           //Adding colour in coil mesh    Physical Surface(CoilEp4) = surf_CoilE94[];    //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐     // E ‐   //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐      pnt301[] += newp;   Point(newp) = {  (‐L/2) + cp/2 ‐ wr + bp + 4*Tp, ‐H + lp + hy ‐ ws, 0, NM};   pnt301[] += newp;   Point(newp) = {  (‐L/2) + cp/2 ‐ wr + bp + 4*Tp,    ‐H  + hy + wi, 0, NM};   pnt301[] += newp;   Point(newp) = {       (‐L/2) + wr + bp + 4*Tp,   ‐H  + hy + wi, 0, NM};   pnt301[] += newp;   Point(newp) = {       (‐L/2) + wr + bp + 4*Tp, ‐H + lp + hy ‐ ws, 0, NM};    For e In {#pnt301[]‐4:#pnt301[]‐1}     ln301[]+=newl;  Line(newl)  =  {pnt301[e], pnt301[(e==#pnt301[]‐1)?e‐3:e+1]};   EndFor    lnl301[] += newll;   Line Loop(newll) = {ln301[]};    surf_CoilE01[] += news;   Plane Surface(news) = {newll‐1};  

- 70 -

Page 72: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

  Color {186,88,0} {Surface{surf_CoilE01[]};}           //Adding colour in coil mesh       //Dark Orange is so light                Physical Surface(CoilEn1) = surf_CoilE01[];    //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐      pnt302[] += newp;   Point(newp) = {  (‐L/2) + cp/2 ‐ wr + bp + 4*Tp,  H ‐ lp ‐ hy + ws, 0, NM};   pnt302[] += newp;   Point(newp) = {  (‐L/2) + cp/2 ‐ wr + bp + 4*Tp,     H  ‐ hy ‐ wi, 0, NM};   pnt302[] += newp;   Point(newp) = {       (‐L/2) + wr + bp + 4*Tp,    H  ‐ hy ‐ wi, 0, NM};   pnt302[] += newp;   Point(newp) = {       (‐L/2) + wr + bp + 4*Tp,  H ‐ lp ‐ hy + ws, 0, NM};    For e In {#pnt302[]‐4:#pnt302[]‐1}     ln302[]+=newl;  Line(newl)  =  {pnt302[e], pnt302[(e==#pnt302[]‐1)?e‐3:e+1]};   EndFor    lnl302[] += newll;   Line Loop(newll) = {ln302[]};    surf_CoilE02[] += news;   Plane Surface(news) = {newll‐1};    Color {186,88,0} {Surface{surf_CoilE02[]};}           //Adding colour in coil mesh            //Dark Orange is so light    Physical Surface(CoilEn2) = surf_CoilE02[];     //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐      pnt303[] += newp;   Point(newp) = {  (‐L/2) ‐ cp/2 + wr + (m+4)*Tp, ‐H + lp + hy ‐ ws, 0, NM};   pnt303[] += newp;   Point(newp) = {  (‐L/2) ‐ cp/2 + wr + (m+4)*Tp,      ‐H + hy + wi, 0, NM};   pnt303[] += newp;   Point(newp) = {       (‐L/2) ‐ wr + (m+4)*Tp,      ‐H + hy + wi, 0, NM};   pnt303[] += newp;   Point(newp) = {       (‐L/2) ‐ wr + (m+4)*Tp, ‐H + lp + hy ‐ ws, 0, NM};  

- 71 -

Page 73: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

  For e In {#pnt303[]‐4:#pnt303[]‐1}     ln303[]+=newl;  Line(newl)  =  {pnt303[e], pnt303[(e==#pnt303[]‐1)?e‐3:e+1]};   EndFor    lnl303[] += newll;   Line Loop(newll) = {ln303[]};    surf_CoilE03[] += news;   Plane Surface(news) = {newll‐1};    Color {186,88,0} {Surface{surf_CoilE03[]};}           //Adding colour in coil mesh            //Dark Orange is so light    Physical Surface(CoilEn3) = surf_CoilE03[];    //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐      pnt304[] += newp;   Point(newp) = {  (‐L/2) ‐ cp/2 + wr + (m+4)*Tp,  H ‐ lp ‐ hy + ws, 0, NM};   pnt304[] += newp;   Point(newp) = {  (‐L/2) ‐ cp/2 + wr + (m+4)*Tp,       H ‐ hy ‐ wi, 0, NM};   pnt304[] += newp;   Point(newp) = {       (‐L/2) ‐ wr + (m+4)*Tp,       H ‐ hy ‐ wi, 0, NM};   pnt304[] += newp;   Point(newp) = {       (‐L/2) ‐ wr + (m+4)*Tp,  H ‐ lp ‐ hy + ws, 0, NM};    For e In {#pnt304[]‐4:#pnt304[]‐1}     ln304[]+=newl;  Line(newl)  =  {pnt304[e], pnt304[(e==#pnt304[]‐1)?e‐3:e+1]};   EndFor    lnl304[] += newll;   Line Loop(newll) = {ln304[]};    surf_CoilE04[] += news;   Plane Surface(news) = {newll‐1};    Color {186,88,0} {Surface{surf_CoilE04[]};}           //Adding colour in coil mesh            //Dark Orange is so light    Physical Surface(CoilEn4) = surf_CoilE04[];  EndIf   //‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐ 

- 72 -

Page 74: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

As you can see, some colour names are recognised by Gmsh, but others must be introduced by its byte vector.

6. To create the air geometry Despite of putting the air and the air infinity in the same file, it will be explained separately. In this step we will explain the air geometry. First of all we will define the points of the shell: pnt4[] += newp; Point(newp) = {  Rin,   0,    0, NM}; pnt4[] += newp; Point(newp) = {     0,  Rin,   0, NM}; pnt4[] += newp; Point(newp) = { ‐Rin,   0,    0, NM}; pnt4[] += newp; Point(newp) = {     0, ‐Rin,   0, NM};  Next we will join it and we will create the line loop: For t In {0:#pnt4[]‐1}   ln4[]+=newl;  Circle(newl)  =  {pnt4[t],  centre, pnt4[(t==#pnt4[]‐1)?0:t+1]}; EndFor  lnl4[] += newll; Line Loop(newll) = {ln4[]};  After it, we will create the surface. For creating the surface, we have to include the shell without the inter elements. Inter elements are the primary, the secondary and the coils. These elements are not the same depending of the number of phases. For this reason we have to create an if boucle which includes more or less loops depending of the number of phases. These are those boucles: surf_Air[] += news;  If(m==2)   Plane  Surface(news)  =  {lnl4[],  lnl311[],  lnl312[], lnl313[],  lnl314[],  lnl321[],  lnl322[],  lnl323[],  lnl324[], lnl331[],  lnl332[],  lnl333[],  lnl334[],  lnl341[],  lnl342[], lnl343[],  lnl344[],  lnl201[],  lnl202[],  lnl203[],  lnl204[], lnl205[], lnl206[], lnl11[], lnl12[]}; EndIf  

- 73 -

Page 75: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

If(m==3)   Plane  Surface(news)  =  {lnl4[],  lnl311[],  lnl312[], lnl313[],  lnl314[],  lnl321[],  lnl322[],  lnl323[],  lnl324[], lnl331[],  lnl332[],  lnl333[],  lnl334[],  lnl341[],  lnl342[], lnl343[],  lnl344[],  lnl351[],  lnl352[],  lnl353[],  lnl354[], lnl361[],  lnl362[],  lnl363[],  lnl364[],  lnl201[],  lnl202[], lnl203[],  lnl204[],  lnl205[],  lnl206[],  lnl207[],  lnl208[], lnl209[], lnl11[], lnl12[]}; EndIf  If(m==4)   Plane  Surface(news)  =  {lnl4[],  lnl311[],  lnl312[], lnl313[],  lnl314[],  lnl321[],  lnl322[],  lnl323[],  lnl324[], lnl331[],  lnl332[],  lnl333[],  lnl334[],  lnl341[],  lnl342[], lnl343[],  lnl344[],  lnl351[],  lnl352[],  lnl353[],  lnl354[], lnl361[],  lnl362[],  lnl363[],  lnl364[],  lnl371[],  lnl372[], lnl373[],  lnl374[],  lnl381[],  lnl382[],  lnl383[],  lnl384[], lnl201[],  lnl202[],  lnl203[],  lnl204[],  lnl205[],  lnl206[], lnl207[],  lnl208[],  lnl209[],  lnl210[],  lnl211[],  lnl212[], lnl11[], lnl12[]}; EndIf  If(m==5)   Plane  Surface(news)  =  {lnl4[],  lnl311[],  lnl312[], lnl313[],  lnl314[],  lnl321[],  lnl322[],  lnl323[],  lnl324[], lnl331[],  lnl332[],  lnl333[],  lnl334[],  lnl341[],  lnl342[], lnl343[],  lnl344[],  lnl351[],  lnl352[],  lnl353[],  lnl354[], lnl361[],  lnl362[],  lnl363[],  lnl364[],  lnl371[],  lnl372[], lnl373[],  lnl374[],  lnl381[],  lnl382[],  lnl383[],  lnl384[], lnl391[],  lnl392[],  lnl393[],  lnl394[],  lnl301[],  lnl302[], lnl303[],  lnl304[],    lnl201[],  lnl202[],  lnl203[],  lnl204[], lnl205[],  lnl206[],  lnl207[],  lnl208[],  lnl209[],  lnl210[], lnl211[],  lnl212[],  lnl213[],  lnl214[],  lnl215[],  lnl11[], lnl12[]}; EndIf  Finally we can add colour in the mesh and define it as a physical surface: Color SkyBlue {Surface{surf_Air[]};} 

//Adding colour in air mesh            Physical Surface(Air) = surf_Air[]; 

7. To create the infinity geometry In this surface we will not have that problem with the number of phases. This region goes from line loop 5 to line loop 4.

- 74 -

Page 76: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

This is the code: //Air Inf:  pnt5[] += newp; Point(newp) = {  Rext,     0,   0, NM}; pnt5[] += newp; Point(newp) = {      0,  Rext,    0, NM}; pnt5[] += newp; Point(newp) = { ‐Rext,     0,   0, NM}; pnt5[] += newp; Point(newp) = {      0, ‐Rext,    0, NM};  For tt In {0:#pnt4[]‐1}   ln5[]+=newl;  Circle(newl)  =  {pnt5[tt],  centre, pnt5[(tt==#pnt5[]‐1)?0:tt+1]}; EndFor  lnl5[] += newll; Line Loop(newll) = {ln5[]};  surf_AirInf[] += news; Plane Surface(news) = {lnl5[], lnl4[]};  Color Blue {Surface{surf_AirInf[]};}    //Adding  colour in infinity mesh                  Physical Surface(Inf) = surf_AirInf[]; 

Also, at the end, we will add a physical line too: Physical Line(Inf+1) = {ln5[]};      /* SurfaceGInf */  It is the external line.

- 75 -

Page 77: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

These will have the meshed geometries:

2 phases:

3 phases:

- 76 -

Page 78: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

4 phases:

5 phases:

- 77 -

Page 79: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

How GetDP works GetDP is a finite element software which can open .geo files and analyze them. It can solve magnetostatic problems, as the example which we will do; but also it can solve magnetodynamic, thermal, acoustics or ... problems.

Magnetic potential vector (as a magnetostatic example):

Waveguides (as a magnetodynamic example):

Source [26/08/2015]: http://onelab.info/wiki/Waveguides

- 78 -

Page 80: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

Thermal contactor (as a thermal example):

Source [26/08/2015]: http://onelab.info/wiki/Thermal_conduction

Acoustic scattering (as acoustics example):

Source [26/08/2015]: http://onelab.info/wiki/Acoustic_scattering

- 79 -

Page 81: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

GetDP example As we said before, GetDP can open a .geo file and work with calculate it. For this reason we will do an electromagnetism analysis with the second Gmsh geometry example.

1. To create a post-processing file

The first step consists in creating a post-processing file. Its name has to be ended by “.pro”. Is recommended to call it by the same name as the “.geo” file, but ended by “.pro”. In our example we call it “Coil&core.pro”:

We can open this file with notepad++ too.

2. To define regions and domains In GetDP, we can define as a region each physical entity. In order to do it, we have to open a group and introduce them inside it. In our example we have defined the core, the coils, the air and the infinity as physical surfaces in .geo file. Also we have defined the axes and the Infinity arc as physical lines. Now we will define these entities in Coil&core.pro file:

- 80 -

Page 82: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

Group {    Core   = Region[ 1001 ];   Coilp  = Region[ 1003 ];    //Coil +   Coiln  = Region[ 1004 ];    //Coil ‐   Air    = Region[ 1010 ];   AirInf = Region[ 1012 ];    Xaxis  = Region[ 1100 ];   Yaxis  = Region[ 1101 ];      ArcInf = Region[ 1102 ];  Furthermore, in .geo file, we included these physical lines too: Physical Line(1000) = {11,1,12};      /*     Cut     */ Physical Line(1001) = {11,12};        /*    CutAir   */ Physical Line(202)  = {2,3,4};        /*   SkinCore  */ Physical Line(203)  = {6,7,8};       /*  SkinCoil+  */ Physical Line(204)  = {106,107,108};  /*  SkinCoil‐  */  But in this case we do not need it. Later, we will explain for what we need them. Next, we have to define the domain of each region will be included. In our example, we will have a domain for all regions, it will be called DomainA_Mag. Also we have to include an empty domain. Later we will explain its purpose. It will be called DomainE_Mag. In addition, we will define a domain only for the coils. It will be called DomainC_Mag. Additionally, we have to include the infinity region in another domain. In this case, we will call it as DomainInf. Finally, we need to create a domain which includes the DomainA_Mag and the DomainA_Mag. If we do not do it, the post-processing will never work. We will call it Domain_Mag. The complete group will be like this: Group {    Core   = Region[ 1001 ];   Coilp  = Region[ 1003 ];    //Coil +   Coiln  = Region[ 1004 ];    //Coil ‐   Air    = Region[ 1010 ];   AirInf = Region[ 1012 ];    Xaxis  = Region[ 1100 ];   Yaxis  = Region[ 1101 ];    

- 81 -

Page 83: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

  ArcInf = Region[ 1102 ];    DomainA_Mag  = Region[ {Air, AirInf, Core, Coilp, Coiln} ];   DomainE_Mag  = Region[ {} ];      //empty domain   DomainC_Mag  = Region[ {Coilp, Coiln} ];   //coils domain   DomainInf    = Region[ {AirInf} ];   Domain_Mag   = Region[ {DomainA_Mag, DomainE_Mag} ];   } 

3. To define functions for post-processing The fourth step consist in introduce the constant functions which will be used. In our example will use the vacuum permeability, the iron permeability and the equivalent conduction surface: Function {      mu0 = 4.e‐7 * Pi;   nu0 = 1. / mu0;     murCore = 5000;   nucore = 1. / (mu0*murCore);    nu [ Region[{Air, Coilp, Coiln, AirInf}] ]  = nu0;   nu [ Core ]  = 1. / (murCore * mu0);       wcoil = 1;   hcoil = 1;   Ks  = 0.5;      Sc[ Region[{Coilp, Coiln}] ] = wcoil * hcoil * Ks;   //Equivalent conduction surface   } 

4. Boundaries constraints In this step we will define the limits which we will work. In our example we will define the limits of our work area and the limits of the electric current. The limits of the work area will be the Y axis and the external air infinity arc. We do not put the X axis arc as a limit because we want to represent that we cut the coil and the core on it. If we did it, we would see the values decreasing near the X axis, because its value would be 0. In GetDP problems section it can be found.

- 82 -

Page 84: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

The limits of the electric current will be the coils. Outside them, there cannot be electric current. In order to determinate those limits, we must introduce the following text in the code: Constraint {    { Name MagneticVectorPotential_2D;     Case {       { Region Yaxis;  Value 0.; }       { Region ArcInf; Value 0.; }     }   }      I = 0.1;            //Current[A]   N = 1000;           //Number of turns      Val_Coil1 = I * N;        //Coil +   Val_Coil2 = I * N * (‐1);      //Coil ‐       { Name SourceCurrentDensityZ;     Case {       { Region Coilp; Value (Val_Coil1/Sc[]);}       { Region Coiln; Value (Val_Coil2/Sc[]);}     }   }   }  As you can see, apart from the limits, we introduce some constants. These are the current, the number of turns and the values of each coil. We introduce the current and the number of turns for making the value of each coil. Also, in the second coil, we put the negative sign in order to determinate its direction. The value is used to determinate the current density in coils area. Because we have divided the value by the section of the conductor.

5. To include others post-processing files

Including others post processing files is so easy, you only have to write the word “include” and the name of the fine between quotation marks. In our example we will include a Jacobian library, an Integration library and another pos-process file which we called “Magneto-static.pro”. This is the format which we have to write: Include "Jacobian_Lib.pro" Include "Integration_Lib.pro" Include "Magneto‐static.pro" 

- 83 -

Page 85: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

6. Jacobian library Jacobian library is a file where we can express the Jacobian method which we want to apply. There are different types of Jacobians, such as Jacovian Vol, Jacobian Sur, Jacobian Lin, etc. Also, inside one of them, we can define if we work with a spherical shell or with a rectangular shell. Jacobian Voll is used for working with the dimensions of our geometry. Its dimensions can be 1, 2 or 3. Jacobian Sur is used for working with one dimension less than our geometry dimensions. For example: if we have a 3D geometry and we want to work with one surface of it. Jacobian Lin is used for working with two dimensions less than our geometry dimensions. For example: if we have a 3D geometry and we want to work with one line of it. In our example we will work with the Jacobian Voll in a spherical shell. In order to do that, first of all we have to open a group and define the limits where we will work. Our limits will be the infinity area. For this reason, this area will have a 0 value. In order to define that limit, inside the group, we have to write the domain infinity and the radius of this spherical area. We will write like this: Group {   DefineGroup[ DomainInf ];   DefineVariable[ Val_Rin, Val_Rext ]; }  Next, we will have to define the value of the Rin and Rext. For this reason we will introduce these constants: Val_Rin = 10; Val_Rext = Val_Rin + 1;  Finally, we can introduce the Jacobian formulation. It will be wrote like this: Jacobian {      { Name Vol ;       Case {      { Region DomainInf ;              Jacobian VolSphShell {Val_Rin, Val_Rext} ; }         { Region All ; Jacobian Vol ; } 

- 84 -

Page 86: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

    }      }    } 

7. Integration library In integration library we can introduce two different types of integration: the Gauss integration and the Gauss Legendre integration. The difference between them is that the Gauss Legendre integration is a numerical Gauss integration obtained by application of a multiplicative rule on the one-dimensional Gauss integration. In addition, inside one integration method, we have to define which elements we will use. These elements can be points, lines, triangles, quadrangles, tetrahedrons, hexahedrons, prisms or pyramids.

In our example we will use the Gauss method and we will use points, lines, triangles, quadrangles and hexahedrons as geometrical elements: Integration {    { Name Gauss ;     Case {       {       Type Gauss ;       Case {                { GeoElement Point     ; NumberOfPoints 1; }         { GeoElement Line      ; NumberOfPoints 2; }         { GeoElement Triangle  ; NumberOfPoints 3; }         { GeoElement Quadrangle; NumberOfPoints 4; }         { GeoElement Hexahedron; NumberOfPoints 6; }        }       }       }   }  } 

8. To create the resolution post-process This step consists in creating a file which will do the operations. In our case we will call it as "Magneto-static.pro".

- 85 -

Page 87: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

9. Group definition In this last file, we have to say which regions of the first post-process file will use. In our case this regions will be the Domain_Mag and the DomainC_Mag. Group {   DefineGroup[ Domain_Mag, DomainC_Mag ]; } 

10. Function definition Next, in this file, we have to define which functions will use in this post-process. In the example, we will use only the nu (the inverse of the permeability): Function {   DefineFunction[ nu ]; } 

11. Function space definition This group consists in defining the functions which we will apply in each area. The area and the functions must be the same that we defined in boundaries constrains of the first post-process. In our example these will be the magnetic vector potential and the current density. You can see them below: FunctionSpace {    //Magnetic vector potential a (b = curl a):   { Name Hcurl_a_Mag_2D; Type Form1P;     BasisFunction {        { Name se; NameOfCoef ae; Function BF_PerpendicularEdge;         Support Domain_Mag; Entity NodesOf[ All ]; }     }     Constraint {       { NameOfCoef ae; EntityType NodesOf;         NameOfConstraint MagneticVectorPotential_2D; }     }   }    //Current density js:   { Name Hregion_j_Mag_2D; Type Vector;     BasisFunction {       { Name sr; NameOfCoef jsr; Function BF_RegionZ;         Support DomainC_Mag; Entity DomainC_Mag; } 

- 86 -

Page 88: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

    }     Constraint {       { NameOfCoef jsr; EntityType Region;         NameOfConstraint SourceCurrentDensityZ; }     }   }    } 

12. Formulation This step consists in defining the calculations of the previous areas. In there we can apply advanced numerical methods using the integrations and the Jacobians defined in the libraries. In our case, we will do the following calculation: Formulation {   { Name Magnetostatics_a_2D; Type FemEquation;     Quantity {       { Name a ; Type Local; NameOfSpace Hcurl_a_Mag_2D; }       { Name js; Type Local; NameOfSpace Hregion_j_Mag_2D; }     }    Equation {       Galerkin { [ nu[] * Dof{d a} , {d a} ]; In Domain_Mag;                  Jacobian Vol; Integration Gauss; }       Galerkin { [ ‐ Dof{js} , {a} ]; In DomainC_Mag;                  Jacobian Vol; Integration Gauss; }     }   } } 

13. Resolution In this step we will solve the previous calculations. Resolution {   { Name MagSta_a_2D;     System {       { Name Sys_Mag; NameOfFormulation Magnetostatics_a_2D; }     }     Operation {       Generate[Sys_Mag];     Solve[Sys_Mag];     SaveSolution[Sys_Mag];          CreateDir["res/"];     }   } } 

- 87 -

Page 89: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

Also, we write “CreateDir["res/"];” which mean that we will create a folder called res. In this folder we can put the post-processing files generated by the program.

14. Post-processing operation This operation consist in generate values through the previous formulate results. For example: we can calculate the magnetic field flux (B) through the magnetic vector potential (a). In our example, we will calculate the magnetic vector potential in Z axis direction, the magnetic field density, the magnetic field intensity and the magnetic energy through the magnetic vector potential. This will be the code: PostProcessing {   { Name MagSta_a_2D; NameOfFormulation Magnetostatics_a_2D;     Quantity {       { Name a;          Value {            Local { [ {a} ]; In Domain_Mag; Jacobian Vol; }          }       }       { Name az;          Value {            Local { [ CompZ[{a}] ]; In Domain_Mag; Jacobian Vol; }         }       }       { Name b;          Value {            Local { [ {d a} ]; In Domain_Mag; Jacobian Vol; }         }       }       { Name h;          Value {            Local { [ nu[] * {d a} ]; In Domain_Mag; Jacobian Vol; }         }     }     { Name js;          Value {            Local { [ {js} ]; In DomainC_Mag; Jacobian Vol; }         }       }     { Name We;     Value {       Integral{  [1/2*nu[]*Norm[{d  a}]*Norm[{d  a}]  ] ;       In  Domain_Mag;  Jacobian  Vol;  Integration Gauss;}     }     } 

- 88 -

Page 90: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

    }   } } 

15. Post operation This is the final step. This step consists in showing the results that we want. There are many different forms of showing results. We can show the values in all of their regions, across a line segment or as global quantity in an output window. In all of them we have to write “Print”, open a square bracket and introduce the post-processing value which we want to show. Next, depending of what we want to show, we have to write the following codes:

If we want to show the values in all of their regions, we have to continue writing with:

1. A comma. 2. An “OnElementsOf” word. 3. The domain in which we want to show it. 4. A comma. 5. A “File” word. 6. The name of the file we want (ended with “.pos”). 7. A closing square bracket. 8. A semicolon.

If we want to show the values across a line, we have to continue writing

with: 1. A comma. 2. An “OnLine” word. 3. An opening brace. 4. Another opening brace. 5. A “List” word. 6. An opening square bracket. 7. The first point of the line segment. 8. A closing square bracket. 9. A closing the brace. 10. An opening brace. 11. A “List” word again. 12. Another opening square bracket. 13. The second point of the line segment. 14. A closing square bracket. 15. A closing brace. 16. Another closing brace. 17. Another opening brace. 18. The number minus one of vectors or modules which we want. 19. A closing brace. 20. A comma.

- 89 -

Page 91: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

21. A “File” word. 22. The name of the file we want (without ending with “.pos”). 23. A closing square bracket. 24. A semicolon.

If we want to show a global quantity in an output window, we have to

continue with: 1. Opening another square bracket. 2. Writing the domain which we want to calculate the value. 3. Closing the square bracket. 4. Introducing a comma. 5. Writing “OnGlobal” if we want to calculate all the value of all

domains, or writing “OnRegion” followed by the domain which we want to work in square brackets.

6. Introducing another comma. 7. Writing “Format” and its format. Its format can be a Table,

SimpleTable, TimeTable, NodeTable, Gnuplot or an Adaptation. Format Table: if we open that file, we will see a different columns. Its columns will be: element-type element-index x-coord y-coord z-coord <x-coord y-coord z-coord> … real real real values. Format SimpleTable: its format will be like Table, but with only the x-coord y-coord z-coord and values columns. Format TimeTable: its format will be like Table too, but it will have the time-step time, x-coord y-coord z-coord, <x-coord y-coord z-coord> and values column. Format NodeTable: it will be a table of node values. The first value corresponds to the number of listed nodes and the columns of the following lines will be: node-number and node-value. Format Gnuplot: it will have a similar format than Table format, but with a new line created for each node of each element.

8. Introducing another comma. 9. Writing “File”. 10. Introducing a greater-than symbol. 11. Writing “StrCat”. 12. Opening a square bracket. 13. In square bracket we have to write the location of the file, the

name of the file, and the type of the file. 14. Closing the square bracket. 15. Introducing a comma. 16. Writing “LastTimeStepOnly” or “TimeStep” depending of what

we want. 17. Introducing another comma. 18. Writing SendToServer. 19. Writing “StrCat” and between square bracket we can write

“"Output/"”, a comma and the name which want to introduce in the output list; next we can close the square bracket.

- 90 -

Page 92: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

20. Before end, we can add color in the output window, if we want. In order to do this, we have to write the word “Color” and the color which we want between quotation marks.

21. Closing the first square bracket. 22. Introducing a semicolon.

In our example we introduce this:

hpole = 2;  p1 = {4.5,hpole,0}; p2 = {5.5,hpole,0}; 

  PostOperation {    { Name Map_a; NameOfPostProcessing MagSta_a_2D;     Operation {       Print[ az, OnElementsOf Domain_Mag, File "az.pos" ];       Print[ b, OnElementsOf Domain_Mag, File "B.pos" ];       Print[  b,  OnLine{{List[p1]}{List[p2]}}  {10},  File "b_in_line" ];       /*{10} + 1: represents the number of vectors*/       Print[ h, OnElementsOf Domain_Mag, File "H.pos" ];       Print[ js, OnElementsOf DomainC_Mag, File "js.pos" ];            Print[ We[Domain_Mag], OnGlobal, Format SimpleTable,     File > StrCat["res/","ME",".dat"], LastTimeStepOnly,     SendToServer  StrCat["Output/","Magnetic  Energy [W]"],     Color "LightYellow" ];    }    }  } 

As you can see, we defined the magnetic potential vector, the magnetic field density, the magnetic field intensity and the current density in their domains; the magnetic field density in a line too; and the Magnetic Energy in an output window.

Now we finally ended all GetDP codes and we can click the run button. If we do it we will have the following pictures.

- 91 -

Page 93: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

The magnetic potential vector:

The magnetic field density:

- 92 -

Page 94: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

The magnetic field density in a line:

The magnetic field intensity:

- 93 -

Page 95: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

The current density:

And the magnetic energy in an output window:

- 94 -

Page 96: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

Problems detected In the resolution of all examples, some issues have been detected. In this section these will be shown.

Gmsh problems In this program some boucles and surfaces duplication problems have been detected. These are found doing the Double-Sided Linear Switched Reluctance Motor example.

1. Duplication surface problem

In the process of doing the Double-Sided Linear Switched Reluctance Motor geometry, we try to copy the down stator in order to create the up stator. We replaced the up stator geometry for this rotating function: Rotate {{0, 0, 1}, {0, 0, 0}, Pi} {   Duplicata { Surface{news‐1}; } }  We write it between the surface definition and the colour definition. It is done in order to have the same colour and physical value in booth stator areas. This is its ubication:

In addition, we take off the line loop 2 and its previous comma of the air surface definition. In “DSLSRM_Air_&_AirInf.geo” file.

- 95 -

Page 97: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

This is what we have:

The area of up stator is not meshed. The problem is its area is not included in “surf_Primaryd[]”. If we wanted to keep the colour and the physical region, we would need to copy the points, creating a new line loop and include it in “surf_Primaryd[]”. As you can appreciate, these steps are more complicated than creating the up primary geometry. In secondary poles and in the coils we have the same problem.

2. Boucle problem In order to make easier the secondary geometry code, we created a boucle which creates all poles required. This was the boucle: For i In {1:3*m}        pnt0[] += newp;      Point(newp) = {   ‐Ts*i,  2, 0, 1};      pnt0[] += newp;      Point(newp) = {   ‐Ts*i, ‐2, 0, 1};      pnt0[] += newp;      Point(newp) = { ‐2‐Ts*i, ‐2, 0, 1};      pnt0[] += newp;      Point(newp) = { ‐2‐Ts*i,  2, 0, 1};       For k In {#pnt0[]‐4:#pnt0[]‐1}     lni[]+=newl;  Line(newl)  =  {pnt0[k], 

pnt0[(k==#pnt0[]‐1)?k‐3:k+1]};      EndFor 

- 96 -

Page 98: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

      lnl[] += newll;      Line Loop(newll) = {#lni[]‐3:#lni[]};       surf_Core[] += news;      Plane Surface(news) = {newll‐1};  EndFor  Color Black {Surface{surf_Core[]};}  Physical Surface(1) = surf_Core[];  But it meshes only these areas:

The problem was that before line 4:

It created line 7:

As it is a boucle we cannot control it. For this reason we have to define all the poles one by one.

- 97 -

Page 99: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

Getdp problems In GetDP example, on boundary constrains step, we said that we did not put 0 value in the X axis. If we have done it, the results near the X axis would be 0. These would be the results:

The magnetic potential vector:

The magnetic field density:

- 98 -

Page 100: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

The magnetic field density in a line:

The magnetic field intensity:

- 99 -

Page 101: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

Current density:

(It keeps equal)

Output magnetic energy:

It has been modified too, because it depends on the magnetic potential vector.

- 100 -

Page 102: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

Conclusion The pack of Gmsh and GetDP programs has been very interesting from working in electromagnetism. There are not so many free-software in this field. In addition, it is capable on working in the same areas in the same time. For example it can work in electromagnetism and thermals. On the other hand, it is so complicated for working on it and there are not many tutorials. For this reason I decided to do this project. All in all, despite of having to spend a lot of time in its programming, its results can be compared with the highest prices programs of this file.

- 101 -

Page 103: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

- 102 -

References

WebPages The following pages have been consulted:

Gmsh webpage [17/01/2015]: http://geuz.org/gmsh/

Gmsh manual [27/06/2015]:

http://geuz.org/gmsh/doc/texinfo/gmsh.html

Gmsh summary [28/06/2015]: http://geuz.org/gmsh/doc/preprints/gmsh_paper_preprint.pdf

GetDP webpage [26/06/2015]:

http://geuz.org/getdp/ GetDP manual [27/06/2015]:

http://geuz.org/getdp/doc/texinfo/getdp.html#Overview

Bibliography Electromagnetism equations and GetDP codes were looked for in the following books and projects:

Finite Elements Analysis of Electrical Machines, S. J. Salon. GetDP Reference Manual, Patrick Dular and Christophe Geuzaine

Thermal Performance Analysis of the Double-Sided Linear Switched Reluctance

Motor, J. García Amorós, R. Bargalló Perpiñà, P. Andrada and B. Blanqué.

Analysis of PMSM Using FE Analysis: a Didactical Approach for EMF Determination and Cogging Torque Reduction, R. Bargalló J. Sust J. Morón and J.C. Pujolras.

Estudio y Caracterización de Accionamientos Eléctricos de Reluctancia

Conmutada Mediante Elementos Finitos, David Gil Albalat. Disseny i Construcció d’un Prototip de Motor Lineal de Reluctancia

Autocommutat de Doble Cara (LSRM), Albert Artells Budesca.

Page 104: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization Using Gmsh and GetDP:

Examples and Guidelines

Appendix

Final Degree Project

Director:

Jordi García Amorós

Author: Pol Lahuerta Manauta

Page 105: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

Index:

Bolt Code - 2 -

Coil and Core - 4 - Coil Core Geometry - 4 - Coil Core Post-process - 6 - Jacobian Library - 8 - Integration Library - 9 - Magneto-static Post-process - 10 -

Double-Sided Linear Switcher Reluctance Motor - 12 - Main Geometry Code - 12 - Variables Definition Code - 13 - Primary Code - 16 - Secondary Code - 20 - Coils Code - 26 - Air and Infinity Codes - 41 -

- 1 -

Page 106: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

Bolt Code Point(1) = {0, 0, 0, 1.0}; Point(2) = {‐1, 0, 0, 1.0}; Point(3) = {1, 0, 0, 1.0}; Point(4) = {0, 1, 0, 1.0}; Point(5) = {0, ‐1, 0, 1.0}; Point(6) = {‐1, 0, ‐5, 1.0}; Point(7) = {1, 0, ‐5, 1.0}; Point(8) = {0, 1, ‐5, 1.0}; Point(9) = {0, ‐1, ‐5, 1.0}; Point(10) = {0, 0, ‐5.5, 1.0}; Point(11) = {0, 1.5, 0, 1.0}; Point(12) = {1.299, 0.75, 0, 1.0}; Point(13) = {1.299, ‐0.75, 0, 1.0}; Point(14) = {0, ‐1.5, 0, 1.0}; Point(15) = {‐1.299, ‐0.75, 0, 1.0}; Point(16) = {‐1.299, 0.75, 0, 1.0};  Translate {0, 0, 1} {   Duplicata { Point{11, 12, 13, 14, 15, 16}; } }   Line(1) = {17, 18}; Line(2) = {18, 19}; Line(3) = {19, 20}; Line(4) = {20, 21}; Line(5) = {21, 22}; Line(6) = {22, 17}; Line(7) = {17, 11}; Line(8) = {18, 12}; Line(9) = {19, 13}; Line(10) = {20, 14}; Line(11) = {21, 15}; Line(12) = {22, 16}; Line(13) = {11, 12}; Line(14) = {12, 13}; Line(15) = {13, 14}; Line(16) = {14, 15}; Line(17) = {15, 16}; Line(18) = {16, 11}; Line(19) = {4, 8}; Line(20) = {5, 9}; Line(21) = {3, 7}; Line(22) = {2, 6}; Line(23) = {8, 10}; Line(24) = {7, 10}; Line(25) = {9, 10}; Line(26) = {6, 10}; Circle(27) = {4, 1, 3}; Circle(28) = {3, 1, 5}; Circle(29) = {5, 1, 2}; Circle(30) = {2, 1, 4}; Circle(31) = {8, 10, 7}; Circle(32) = {7, 10, 9}; Circle(33) = {9, 10, 6}; Circle(34) = {6, 10, 8};  Delete {   Point{1}; }  Line Loop(35) = {6, 1, 2, 3, 4, 5}; Plane Surface(36) = {35}; Line Loop(37) = {4, 11, ‐16, ‐10}; Plane Surface(38) = {37}; Line Loop(39) = {3, 10, ‐15, ‐9}; Plane Surface(40) = {39}; Line Loop(41) = {2, 9, ‐14, ‐8}; Plane Surface(42) = {41}; Line Loop(43) = {1, 8, ‐13, ‐7}; 

- 2 -

Page 107: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE Plane Surface(44) = {43}; Line Loop(45) = {6, 7, ‐18, ‐12}; Plane Surface(46) = {45}; Line Loop(47) = {5, 12, ‐17, ‐11}; Plane Surface(48) = {47}; Line Loop(49) = {16, 17, 18, 13, 14, 15};  Line Loop(50) = {33, 26, ‐25}; Plane Surface(51) = {50}; Line Loop(52) = {32, 25, ‐24}; Plane Surface(53) = {52}; Line Loop(54) = {24, ‐23, 31}; Plane Surface(55) = {54}; Line Loop(56) = {23, ‐26, 34}; Plane Surface(57) = {56}; Line Loop(58) = {29, 30, 27, 28}; Plane Surface(59) = {49, 58}; Line Loop(60) = {20, ‐32, ‐21, 28}; Ruled Surface(61) = {60}; Line Loop(62) = {21, ‐31, ‐19, 27}; Ruled Surface(63) = {62}; Line Loop(64) = {19, ‐34, ‐22, 30}; Ruled Surface(65) = {64}; Line Loop(66) = {22, ‐33, ‐20, 29}; Ruled Surface(67) = {66}; 

- 3 -

Page 108: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

Coil and Core

Coil Core Geometry //GEOMETRICAL DEFINITION:  //‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐  //VARS:  //Pole vars: wpole = 1;    //Pole width hpole = 2;    //Pole hight  ppole = 5;    //Pole position (in x axis) dpole = 1;    //Pole depth  //Coil vars: wcoil = 1;    //Coil width hcoil = 1;    //Coil hight wgap = 0.1;    //Gap between the pole and the coil hgap = 0.1;    //Gap between the pole and the coil  //Air vars: Rin = 10;    //Inner air radius Rex = Rin+1;  //External air radius  //Mesh density vars: NM = 0.1;    //Normal mesh SM = 0.01;    //Small mesh  //‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐  //GEOMETRY:  Point(1) = {0, 0, 0, NM};    //Centre point   //Pole:  Point(2) = {ppole‐(wpole/2),     0, 0, NM}; Point(3) = {ppole+(wpole/2),    0, 0, NM}; Point(4) = {ppole+(wpole/2),  hpole, 0, NM}; Point(5) = {ppole‐(wpole/2),  hpole, 0, NM};  Line(1) = {2,3}; Line(2) = {3,4}; Line(3) = {4,5}; Line(4) = {5,2};  Line Loop(100) = {1,2,3,4}; Plane Surface(101) = {100};   //Coil:  Point(6) = {    ppole‐(wpole/2)‐wgap,    0, 0, NM}; Point(7) = {ppole‐(wpole/2)‐wgap‐wcoil,    0, 0, NM}; Point(8) = {ppole‐(wpole/2)‐wgap‐wcoil,  hcoil, 0, NM}; Point(9) = {    ppole‐(wpole/2)‐wgap,  hcoil, 0, NM};  Line(5) = {6,7}; Line(6) = {7,8}; Line(7) = {8,9}; Line(8) = {9,6};  Line Loop(102) = {5,6,7,8}; Plane Surface(103) = {102};  

- 4 -

Page 109: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE Translate {wpole+2*wgap+wcoil, 0, 0} {   Duplicata { Surface{103}; }  /* Surface(104) */    //Point(6)‐>Point(10)    //Point(7)‐>Point(11)    //Point(8)‐>Point(15)    //Point(9)‐>Point(19)    //Lines = (numbers in Surface{103})+100; example: Line(5) = Line(105) }   //Air:  Point(12) = {Rin, 0, 0, NM}; Point(13) = {0, Rin, 0, NM};  Circle(9) = {12,1,13};  Line(10) = {1,7};      //_ Line(11) = {6,2};      // | Line(12) = {3,11};      // |‐‐ Horizontal line  Line(13) = {10,12};      //_| Line(14) = {13,1};      //<‐‐‐ Vertical line  Line Loop(109) = {10,6,7,8,11,‐4,‐3,‐2,12,106,107,108,13,9,14}; Plane Surface(110) = {109};   //AirInf:  Point(14) = {Rex, 0, 0, NM}; Point(16) = {0, Rex, 0, NM};  Circle(15) = {16,1,14}; Line(16) = {14,12}; Line(17) = {13,16};  Line Loop(111) = {16,9,17,15}; Plane Surface(112) = {111};   //PHYSICAL SURFACES: Physical Surface(1001) = {101};  /*  Pole  */ Physical Surface(1003) = {103};  /*  Coil+ */ Physical Surface(1004) = {104};  /*  Coil‐ */ Physical Surface(1010) = {110};  /*   Air  */ Physical Surface(1012) = {112};  /* AirInf */  //PHYSICAL LINES: Physical Line(1000) = {11,1,12};                /*     Cut     */ Physical Line(1001) = {11,12};                  /*    CutAir   */ Physical Line(202)  = {2,3,4};                /*   SkinCore  */ Physical Line(203)  = {6,7,8};             /*  SkinCoil+  */ Physical Line(204)  = {106,107,108};            /*  SkinCoil‐  */ Physical Line(1100) = {10,‐5,11,1,12,‐105,13,‐16};       /*    Xaxis    */ Physical Line(1101) = {‐14,17};               /*    Yaxis    */ Physical Line(1102) = {‐15};                   /*    ArcInf   */ 

- 5 -

Page 110: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

Coil Core Post-process   Group {    Core   = Region[ 1001 ];   Coilp  = Region[ 1003 ];    //Coil +   Coiln  = Region[ 1004 ];    //Coil ‐   Air    = Region[ 1010 ];   AirInf = Region[ 1012 ];    Xaxis  = Region[ 1100 ];   Yaxis  = Region[ 1101 ];      ArcInf = Region[ 1102 ];    DomainA_Mag  = Region[ {Air, AirInf, Core, Coilp, Coiln} ];   DomainE_Mag  = Region[ {} ];              //empty domain   DomainC_Mag  = Region[ {Coilp, Coiln} ];           //coils domain   DomainInf    = Region[ {AirInf} ];   Domain_Mag   = Region[ {DomainA_Mag, DomainE_Mag} ];   }  Function {      mu0 = 4.e‐7 * Pi;   nu0 = 1. / mu0;     murCore = 5000;   nucore = 1. / (mu0*murCore);    nu [ Region[{Air, Coilp, Coiln, AirInf}] ]  = nu0;   nu [ Core ]  = 1. / (murCore * mu0);       wcoil = 1;   hcoil = 1;   Ks  = 0.5;      Sc[ Region[{Coilp, Coiln}] ] = wcoil * hcoil * Ks;    //Equivalent conduction surface   }  Constraint {    { Name MagneticVectorPotential_2D;     Case {       { Region Yaxis;  Value 0.; }       { Region ArcInf; Value 0.; }     }   }      I = 0.1;            //Current[A]   N = 1000;            //Number of turns      Val_Coil1 = I * N;      //Coil +   Val_Coil2 = I * N * (‐1);    //Coil ‐       { Name SourceCurrentDensityZ;     Case {       { Region Coilp; Value (Val_Coil1/Sc[]);}     { Region Coiln; Value (Val_Coil2/Sc[]);}     }   }   }   //‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐ //‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐ //‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐ 

- 6 -

Page 111: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE   Include "Jacobian_Lib.pro" Include "Integration_Lib.pro" Include "Magneto‐static.pro"  

- 7 -

Page 112: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

Jacobian Library   /*   Jacobian methods     Vol */  /* I N P U T    ‐‐‐‐‐‐‐‐‐    GlobalGroup :   ‐‐‐‐‐‐‐‐‐‐‐     DomainInf                Regions with Spherical Shell Transformation    Parameters :   ‐‐‐‐‐‐‐‐‐‐     Val_Rin, Val_Rext       Inner and outer radius of the Spherical Shell                             of DomainInf  */   //‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐  Group {   DefineGroup[ DomainInf ];   DefineVariable[ Val_Rin, Val_Rext ]; }  Val_Rin = 10; Val_Rext = Val_Rin + 1;  //‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐   Jacobian {      { Name Vol ;       Case {      { Region DomainInf ;              Jacobian VolSphShell {Val_Rin, Val_Rext} ; }         { Region All ; Jacobian Vol ; }     }      }    }  

- 8 -

Page 113: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

Integration Library   //Integration method   Integration {    { Name Gauss ;     Case {       {       Type Gauss ;       Case {                { GeoElement Point       ; NumberOfPoints  1 ; }         { GeoElement Line        ; NumberOfPoints  2 ; }         { GeoElement Triangle    ; NumberOfPoints  3 ; }         { GeoElement Quadrangle  ; NumberOfPoints  4 ; }         { GeoElement Hexahedron  ; NumberOfPoints  6 ; }        }       }       }   }  }  

- 9 -

Page 114: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

Magneto-static Post-process    Group {   DefineGroup[ Domain_Mag, DomainC_Mag ]; }  Function {   DefineFunction[ nu ]; }  FunctionSpace {    //Magnetic vector potential a (b = curl a):   { Name Hcurl_a_Mag_2D; Type Form1P;     BasisFunction {        { Name se; NameOfCoef ae; Function BF_PerpendicularEdge;         Support Domain_Mag; Entity NodesOf[ All ]; }     }     Constraint {       { NameOfCoef ae; EntityType NodesOf;         NameOfConstraint MagneticVectorPotential_2D; }     }   }    //Current density js:   { Name Hregion_j_Mag_2D; Type Vector;     BasisFunction {       { Name sr; NameOfCoef jsr; Function BF_RegionZ;         Support DomainC_Mag; Entity DomainC_Mag; }     }     Constraint {       { NameOfCoef jsr; EntityType Region;         NameOfConstraint SourceCurrentDensityZ; }     }   }    }  Formulation {   { Name Magnetostatics_a_2D; Type FemEquation;     Quantity {       { Name a ; Type Local; NameOfSpace Hcurl_a_Mag_2D; }       { Name js; Type Local; NameOfSpace Hregion_j_Mag_2D; }     }    Equation {       Galerkin { [ nu[] * Dof{d a} , {d a} ]; In Domain_Mag;                  Jacobian Vol; Integration Gauss; }       Galerkin { [ ‐ Dof{js} , {a} ]; In DomainC_Mag;                  Jacobian Vol; Integration Gauss; }     }   } }  Resolution {   { Name MagSta_a_2D;     System {       { Name Sys_Mag; NameOfFormulation Magnetostatics_a_2D; }     }     Operation {       Generate[Sys_Mag];     Solve[Sys_Mag];     SaveSolution[Sys_Mag];          CreateDir["res/"];     }   } }  PostProcessing { 

- 10 -

Page 115: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE   { Name MagSta_a_2D; NameOfFormulation Magnetostatics_a_2D;     Quantity {       { Name a;          Value {            Local { [ {a} ]; In Domain_Mag; Jacobian Vol; }          }       }       { Name az;          Value {            Local { [ CompZ[{a}] ]; In Domain_Mag; Jacobian Vol; }         }       }       { Name b;          Value {            Local { [ {d a} ]; In Domain_Mag; Jacobian Vol; }         }       }       { Name h;          Value {            Local { [ nu[] * {d a} ]; In Domain_Mag; Jacobian Vol; }         }     }     { Name js;          Value {            Local { [ {js} ]; In DomainC_Mag; Jacobian Vol; }         }       }     { Name We;     Value {       Integral{ [ 1/2 * nu[] * Norm[{d a}] * Norm[{d a}] ] ;       In Domain_Mag; Jacobian Vol; Integration Gauss;}     }     }     }   } }   hpole = 2;  p1 = {4.5,hpole,0};    //First point to show magnetic field flux  p2 = {5.5,hpole,0};    //Last point to show magnetic field flux    PostOperation {    { Name Map_a; NameOfPostProcessing MagSta_a_2D;     Operation {       Print[ az, OnElementsOf Domain_Mag, File "az.pos" ];     Print[ b, OnElementsOf Domain_Mag, File "B.pos" ];       Print[ b, OnLine{{List[p1]}{List[p2]}} {10}, File "b_in_line" ];       /* {10} + 1: represents the number of vectors */     Print[ h, OnElementsOf Domain_Mag, File "H.pos" ];     Print[ js, OnElementsOf DomainC_Mag, File "js.pos" ];            Print[ We[Domain_Mag], OnGlobal, Format SimpleTable,     File > StrCat["res/","ME",".dat"], LastTimeStepOnly,     SendToServer StrCat["Output/","Magnetic Energy [W]"],     Color "LightYellow" ];    }    }  }  

- 11 -

Page 116: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

Double-Sided Linear Switcher Reluctance Motor

Main Geometry Code   //‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐            //Var's definition:  Include "DSLSRM_var_def.geo";   //‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐          //            ‐ GEOMETRY ‐  //‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐            //Centre of Geometry:  centre = newp; Point(newp) = {0, 0, 0, NM};  //‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐            //Primary:  Include "DSLSRM_Primary.geo";  //‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐ //Secondary:  Include "DSLSRM_Secondary.geo";  //‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐ //Coils:  Include "DSLSRM_Coils.geo";  //‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐ //Air and Infinity:  Include "DSLSRM_Air_&_AirInf.geo";  //‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐    

- 12 -

Page 117: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

Variables Definition Code  //‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐  //              ‐ VAR definition ‐   //‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐  //Geometric VARs:  pp  = "Input/10Geometric dimensions/0";  ppm = "Input/11Mesh control (Nbr of divisions)/";   DefineConstant[                Flag_m = {4, Choices{2,3,4,5},                Name StrCat[pp,"1number of phases"], Highlight "Red"},                m = Flag_m                ];  DefineConstant[                PoleStroke = {3,  Min 2, Max 10, Step 0.5,          Name StrCat[pp, "2pole stroke [mm]"], Highlight "LightGrey"},                PS = PoleStroke                ];           DefineConstant[ alpha_p = {0.42}];      // alpha_p = relation between bp and Tp DefineConstant[ beta_p = {2.5}];          // beta_p = relation between lp and Tp DefineConstant[ Tp = {(m‐1)*PS}];      // Tp = primary pole pitch [mm] DefineConstant[ bp = {alpha_p*Tp}];      // bp = primary pole width [mm] DefineConstant[ cp = {Tp‐bp}];        // cp = primary slot width [mm] DefineConstant[ lp = {beta_p*Tp}];      // lp = primary pol lenth [mm] DefineConstant[ alpha_s = {0.5}];      // alpha_s = relation between bs and Ts DefineConstant[ beta_s = {1.5}];       // beta_s = relation between ls and Tp DefineConstant[ Ts = {m*PS}];        // Ts = secondary pole pitch [mm] DefineConstant[ bs = {alpha_s*Tp}];      // bs = secondary pole width [mm] DefineConstant[ cs = {Ts‐bs}];        // cs = secondary slot widtch [mm] DefineConstant[ Ns = {2*(m‐1)}];       // Ns = number of passive poles per side (Secondary) DefineConstant[ ls = {beta_s*Tp}];      // ls = secondary pol lenth [mm] DefineConstant[ dy = {0.54}];        // dy = relation between hy and Tp DefineConstant[ hy = {dy*Tp}];        // hy = primary yoke height [mm] DefineConstant[ Lw = {30}];        // Lw = stack length [mm] DefineConstant[ g  = {0.5}];        // g  = air gap length [mm] DefineConstant[ wr = {0.2}];        // wr = Horizontal dielectric width [mm] DefineConstant[ ws = {0.5}];        // ws = Up dielectric width [mm] DefineConstant[ wi = {0.5}];        // wi = Down dielectric width [mm] DefineConstant[ L  = {(m‐1)*((2*m‐1)+alpha_p)*PS}];  // L  = stator length [mm] DefineConstant[ H  = {lp+hy+g+ls/2}];      // H  = Stator height/2 [mm] DefineConstant[ Sp = {(L/2)+(bs‐bp)/2}];     // Sp = Stator start position  DefineConstant[ Rin  = {4*L}];        // Rin = Inner shell radius [mm] DefineConstant[ Rext = {5*L}];        // Rext = External shell radius [mm]   //‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐ //Mesh VARs:  DefineConstant[        Mesh = { 1, Min 0.01, Max 10, Step 0.1,        Name StrCat[ppm, "Mesh density"], Highlight "Yellow"},        NM = Mesh         ];         //‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐//Physical Region VARs:  Primaryd = 11;    //Primary down 

- 13 -

Page 118: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE  Primaryu = 12;    //Primary up    For k In {1:3*m}   Secondary[k] = 200 + k; EndFor    CoilAp1 = 311;  CoilAp2 = 312;                  CoilAp3 = 313;                  CoilAp4 = 314;                  CoilAn1 = 321;                  CoilAn2 = 322;                  CoilAn3 = 323;                  CoilAn4 = 324;                   CoilBp1 = 331;                  CoilBp2 = 332;                  CoilBp3 = 333;                  CoilBp4 = 334;                  CoilBn1 = 341;                  CoilBn2 = 342;                  CoilBn3 = 343;                  CoilBn4 = 344;   CoilCp1 = 351;  CoilCp2 = 352;  CoilCp3 = 353;                  CoilCp4 = 354;  CoilCn1 = 361;    CoilCn2 = 362;  CoilCn3 = 363;  CoilCn4 = 364;   CoilDp1 = 371;  CoilDp2 = 372;  CoilDp3 = 373;                  CoilDp4 = 374;  CoilDn1 = 381;    CoilDn2 = 382;  

- 14 -

Page 119: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE CoilDn3 = 383;  CoilDn4 = 384;   CoilEp1 = 391;  CoilEp2 = 392;  CoilEp3 = 393;  CoilEp4 = 394;  CoilEn1 = 301;  CoilEn2 = 302;  CoilEn3 = 303;  CoilEn4 = 304;     Air = 4;  Inf = 5;  

- 15 -

Page 120: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

Primary Code   //‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐ //Primary:  pnt11[] += newp; Point(newp) = {             L/2,          ‐H, 0, NM}; pnt11[] += newp; Point(newp) = {              ‐L/2,        ‐H, 0, NM}; pnt11[] += newp; Point(newp) = {        (‐L/2), ‐H + lp + hy, 0, NM}; pnt11[] += newp; Point(newp) = {     (‐L/2) + bp, ‐H + lp + hy, 0, NM}; pnt11[] += newp; Point(newp) = {     (‐L/2) + bp,     ‐H + hy, 0, NM}; pnt11[] += newp; Point(newp) = {    (‐L/2) + bp + cp,     ‐H + hy, 0, NM}; pnt11[] += newp; Point(newp) = {    (‐L/2) + bp + cp, ‐H + lp + hy, 0, NM}; pnt11[] += newp; Point(newp) = {  (‐L/2) + 2*bp + cp, ‐H + lp + hy, 0, NM}; pnt11[] += newp; Point(newp) = {  (‐L/2) + 2*bp + cp,     ‐H + hy, 0, NM}; pnt11[] += newp; Point(newp) = {(‐L/2) + 2*bp + 2*cp,     ‐H + hy, 0, NM}; pnt11[] += newp; Point(newp) = {(‐L/2) + 2*bp + 2*cp, ‐H + lp + hy, 0, NM}; pnt11[] += newp; Point(newp) = {(‐L/2) + 3*bp + 2*cp, ‐H + lp + hy, 0, NM}; pnt11[] += newp; Point(newp) = {(‐L/2) + 3*bp + 2*cp,     ‐H + hy, 0, NM}; pnt11[] += newp; Point(newp) = {(‐L/2) + 3*bp + 3*cp,     ‐H + hy, 0, NM}; pnt11[] += newp; Point(newp) = {(‐L/2) + 3*bp + 3*cp, ‐H + lp + hy, 0, NM}; pnt11[] += newp; Point(newp) = {(‐L/2) + 4*bp + 3*cp, ‐H + lp + hy, 0, NM};  If(m>2)   //Additional poles for 3 or more phases in the stator   pnt11[] += newp;   Point(newp) = {(‐L/2) + 4*bp + 3*cp,     ‐H + hy, 0, NM};   pnt11[] += newp;   Point(newp) = {(‐L/2) + 4*bp + 4*cp,     ‐H + hy, 0, NM};   pnt11[] += newp;   Point(newp) = {(‐L/2) + 4*bp + 4*cp, ‐H + lp + hy, 0, NM};   pnt11[] += newp;   Point(newp) = {(‐L/2) + 5*bp + 4*cp, ‐H + lp + hy, 0, NM};   pnt11[] += newp;   Point(newp) = {(‐L/2) + 5*bp + 4*cp,     ‐H + hy, 0, NM};   pnt11[] += newp;   Point(newp) = {(‐L/2) + 5*bp + 5*cp,     ‐H + hy, 0, NM};   pnt11[] += newp;   Point(newp) = {(‐L/2) + 5*bp + 5*cp, ‐H + lp + hy, 0, NM};   pnt11[] += newp;   Point(newp) = {(‐L/2) + 6*bp + 5*cp, ‐H + lp + hy, 0, NM}; EndIf  If(m>3)   //Additional poles for 4 or 5 phase stator   pnt11[] += newp;   Point(newp) = {(‐L/2) + 6*bp + 5*cp,     ‐H + hy, 0, NM};   pnt11[] += newp;   Point(newp) = {(‐L/2) + 6*bp + 6*cp,     ‐H + hy, 0, NM};   pnt11[] += newp;   Point(newp) = {(‐L/2) + 6*bp + 6*cp, ‐H + lp + hy, 0, NM};   pnt11[] += newp;   Point(newp) = {(‐L/2) + 7*bp + 6*cp, ‐H + lp + hy, 0, NM};   pnt11[] += newp;   Point(newp) = {(‐L/2) + 7*bp + 6*cp,     ‐H + hy, 0, NM};   pnt11[] += newp;   Point(newp) = {(‐L/2) + 7*bp + 7*cp,     ‐H + hy, 0, NM};   pnt11[] += newp; 

- 16 -

Page 121: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE   Point(newp) = {(‐L/2) + 7*bp + 7*cp, ‐H + lp + hy, 0, NM};   pnt11[] += newp;   Point(newp) = {(‐L/2) + 8*bp + 7*cp, ‐H + lp + hy, 0, NM}; EndIf  If(m>4)   //Additional poles for 5 phase stator   pnt11[] += newp;   Point(newp) = { (‐L/2) + 8*bp + 7*cp,      ‐H + hy, 0, NM};   pnt11[] += newp;   Point(newp) = { (‐L/2) + 8*bp + 8*cp,      ‐H + hy, 0, NM};   pnt11[] += newp;   Point(newp) = { (‐L/2) + 8*bp + 8*cp, ‐H + lp + hy, 0, NM};   pnt11[] += newp;   Point(newp) = { (‐L/2) + 9*bp + 8*cp, ‐H + lp + hy, 0, NM};   pnt11[] += newp;   Point(newp) = { (‐L/2) + 9*bp + 8*cp,      ‐H + hy, 0, NM};   pnt11[] += newp;   Point(newp) = { (‐L/2) + 9*bp + 9*cp,      ‐H + hy, 0, NM};   pnt11[] += newp;   Point(newp) = { (‐L/2) + 9*bp + 9*cp, ‐H + lp + hy, 0, NM};   pnt11[] += newp;   Point(newp) = {(‐L/2) + 10*bp + 9*cp, ‐H + lp + hy, 0, NM}; EndIf   For i In {0:#pnt11[]‐1}     //joint the points   ln11[]+=newl; Line(newl) = {pnt11[i], pnt11[(i==#pnt11[]‐1)?0:i+1]}; EndFor   lnl11[] += newll; Line Loop(newll) = {ln11[]};   surf_Primaryd[] += news;     //Surface: Primary down Plane Surface(news) = {newll‐1};  Color Grey {Surface{surf_Primaryd[]};}    //Adding colour in primary mesh  Physical Surface(Primaryd) = surf_Primaryd[];  //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐    // The above part: (We do not copy the bellow part because the program do not consider as the same group)  pnt12[] += newp; Point(newp) = {             L/2,          H, 0, NM}; pnt12[] += newp; Point(newp) = {              ‐L/2,        H, 0, NM}; pnt12[] += newp; Point(newp) = {        (‐L/2), H ‐ lp ‐ hy, 0, NM}; pnt12[] += newp; Point(newp) = {     (‐L/2) + bp, H ‐ lp ‐ hy, 0, NM}; pnt12[] += newp; Point(newp) = {     (‐L/2) + bp,     H ‐ hy, 0, NM}; pnt12[] += newp; Point(newp) = {    (‐L/2) + bp + cp,     H ‐ hy, 0, NM}; pnt12[] += newp; Point(newp) = {    (‐L/2) + bp + cp, H ‐ lp ‐ hy, 0, NM}; pnt12[] += newp; Point(newp) = {  (‐L/2) + 2*bp + cp, H ‐ lp ‐ hy, 0, NM}; pnt12[] += newp; Point(newp) = {  (‐L/2) + 2*bp + cp,     H ‐ hy, 0, NM}; pnt12[] += newp; Point(newp) = {(‐L/2) + 2*bp + 2*cp,     H ‐ hy, 0, NM}; pnt12[] += newp; Point(newp) = {(‐L/2) + 2*bp + 2*cp, H ‐ lp ‐ hy, 0, NM}; pnt12[] += newp; Point(newp) = {(‐L/2) + 3*bp + 2*cp, H ‐ lp ‐ hy, 0, NM}; pnt12[] += newp; Point(newp) = {(‐L/2) + 3*bp + 2*cp,     H ‐ hy, 0, NM}; pnt12[] += newp; Point(newp) = {(‐L/2) + 3*bp + 3*cp,     H ‐ hy, 0, NM}; 

- 17 -

Page 122: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE pnt12[] += newp; Point(newp) = {(‐L/2) + 3*bp + 3*cp, H ‐ lp ‐ hy, 0, NM}; pnt12[] += newp; Point(newp) = {(‐L/2) + 4*bp + 3*cp, H ‐ lp ‐ hy, 0, NM};  If(m>2)   //Additional poles for 3 or more phases in the stator   pnt12[] += newp;   Point(newp) = {(‐L/2) + 4*bp + 3*cp,     H ‐ hy, 0, NM};   pnt12[] += newp;   Point(newp) = {(‐L/2) + 4*bp + 4*cp,     H ‐ hy, 0, NM};   pnt12[] += newp;   Point(newp) = {(‐L/2) + 4*bp + 4*cp, H ‐ lp ‐ hy, 0, NM};   pnt12[] += newp;   Point(newp) = {(‐L/2) + 5*bp + 4*cp, H ‐ lp ‐ hy, 0, NM};   pnt12[] += newp;   Point(newp) = {(‐L/2) + 5*bp + 4*cp,     H ‐ hy, 0, NM};   pnt12[] += newp;   Point(newp) = {(‐L/2) + 5*bp + 5*cp,     H ‐ hy, 0, NM};   pnt12[] += newp;   Point(newp) = {(‐L/2) + 5*bp + 5*cp, H ‐ lp ‐ hy, 0, NM};   pnt12[] += newp;   Point(newp) = {(‐L/2) + 6*bp + 5*cp, H ‐ lp ‐ hy, 0, NM}; EndIf  If(m>3)   //Additional poles for 4 or 5 phase stator   pnt12[] += newp;   Point(newp) = {(‐L/2) + 6*bp + 5*cp,     H ‐ hy, 0, NM};   pnt12[] += newp;   Point(newp) = {(‐L/2) + 6*bp + 6*cp,     H ‐ hy, 0, NM};   pnt12[] += newp;   Point(newp) = {(‐L/2) + 6*bp + 6*cp, H ‐ lp ‐ hy, 0, NM};   pnt12[] += newp;   Point(newp) = {(‐L/2) + 7*bp + 6*cp, H ‐ lp ‐ hy, 0, NM};   pnt12[] += newp;   Point(newp) = {(‐L/2) + 7*bp + 6*cp,     H ‐ hy, 0, NM};   pnt12[] += newp;   Point(newp) = {(‐L/2) + 7*bp + 7*cp,     H ‐ hy, 0, NM};   pnt12[] += newp;   Point(newp) = {(‐L/2) + 7*bp + 7*cp, H ‐ lp ‐ hy, 0, NM};   pnt12[] += newp;   Point(newp) = {(‐L/2) + 8*bp + 7*cp, H ‐ lp ‐ hy, 0, NM}; EndIf  If(m>4)   //Additional poles for 5 phase stator   pnt12[] += newp;   Point(newp) = { (‐L/2) + 8*bp + 7*cp,      H ‐ hy, 0, NM};   pnt12[] += newp;   Point(newp) = { (‐L/2) + 8*bp + 8*cp,      H ‐ hy, 0, NM};   pnt12[] += newp;   Point(newp) = { (‐L/2) + 8*bp + 8*cp, H ‐ lp ‐ hy, 0, NM};   pnt12[] += newp;   Point(newp) = { (‐L/2) + 9*bp + 8*cp, H ‐ lp ‐ hy, 0, NM};   pnt12[] += newp;   Point(newp) = { (‐L/2) + 9*bp + 8*cp,      H ‐ hy, 0, NM};   pnt12[] += newp;   Point(newp) = { (‐L/2) + 9*bp + 9*cp,      H ‐ hy, 0, NM};   pnt12[] += newp;   Point(newp) = { (‐L/2) + 9*bp + 9*cp, H ‐ lp ‐ hy, 0, NM};   pnt12[] += newp;   Point(newp) = {(‐L/2) + 10*bp + 9*cp, H ‐ lp ‐ hy, 0, NM}; EndIf   For j In {0:#pnt12[]‐1}     //joint the points   ln12[]+=newl; Line(newl) = {pnt12[j], pnt12[(j==#pnt12[]‐1)?0:j+1]}; EndFor   lnl12[] += newll; Line Loop(newll) = {ln12[]};   surf_Primaryu[] += news;     //Surface: Primary up Plane Surface(news) = {newll‐1}; 

- 18 -

Page 123: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE  Color Grey {Surface{surf_Primaryu[]};}    //Adding colour in primary mesh  Physical Surface(Primaryu) = surf_Primaryu[];  //‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐   

- 19 -

Page 124: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

Secondary Code   //‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐//Secondary:   //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐    pnt201[] += newp; Point(newp) = {      Sp,  ‐ls/2,  0, NM}; pnt201[] += newp; Point(newp) = {      Sp,   ls/2,  0, NM}; pnt201[] += newp; Point(newp) = { Sp ‐ bs,   ls/2,  0, NM}; pnt201[] += newp; Point(newp) = { Sp ‐ bs,  ‐ls/2,  0, NM};  For r In {#pnt201[]‐4:#pnt201[]‐1}   ln201[]+=newl; Line(newl) = {pnt201[r], pnt201[(r==#pnt201[]‐1)?r‐3:r+1]}; EndFor  lnl201[] += newll; Line Loop(newll) = {ln201[]};  surf_Secondary201[] += news; Plane Surface(news) = {newll‐1};  Color Black {Surface{surf_Secondary201[]};}    //Adding colour in secondary mesh  Physical Surface(Secondary[1]) = surf_Secondary201[];  //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐    pnt202[] += newp; Point(newp) = {      Sp ‐ Ts,  ‐ls/2,   0, NM}; pnt202[] += newp; Point(newp) = {      Sp ‐ Ts,   ls/2,   0, NM}; pnt202[] += newp; Point(newp) = { Sp ‐ bs ‐ Ts,   ls/2,   0, NM}; pnt202[] += newp; Point(newp) = { Sp ‐ bs ‐ Ts,  ‐ls/2,   0, NM};  For r In {#pnt202[]‐4:#pnt202[]‐1}   ln202[]+=newl; Line(newl) = {pnt202[r], pnt202[(r==#pnt202[]‐1)?r‐3:r+1]}; EndFor  lnl202[] += newll; Line Loop(newll) = {ln202[]};  surf_Secondary202[] += news; Plane Surface(news) = {newll‐1};  Color Black {Surface{surf_Secondary202[]};}    //Adding colour in secondary mesh  Physical Surface(Secondary[2]) = surf_Secondary202[];  //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐    pnt203[] += newp; Point(newp) = {      Sp ‐ Ts*2,  ‐ls/2,  0, NM}; pnt203[] += newp; Point(newp) = {      Sp ‐ Ts*2,   ls/2,  0, NM}; pnt203[] += newp; Point(newp) = { Sp ‐ bs ‐ Ts*2,   ls/2,  0, NM}; pnt203[] += newp; Point(newp) = { Sp ‐ bs ‐ Ts*2,  ‐ls/2,  0, NM};  For r In {#pnt203[]‐4:#pnt203[]‐1}   ln203[]+=newl; Line(newl) = {pnt203[r], pnt203[(r==#pnt203[]‐1)?r‐3:r+1]}; EndFor  

- 20 -

Page 125: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE lnl203[] += newll; Line Loop(newll) = {ln203[]};  surf_Secondary203[] += news; Plane Surface(news) = {newll‐1};  Color Black {Surface{surf_Secondary203[]};}    //Adding colour in secondary mesh  Physical Surface(Secondary[3]) = surf_Secondary203[];  //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐    pnt204[] += newp; Point(newp) = {      Sp ‐ Ts*3,  ‐ls/2,  0, NM}; pnt204[] += newp; Point(newp) = {      Sp ‐ Ts*3,   ls/2,  0, NM}; pnt204[] += newp; Point(newp) = { Sp ‐ bs ‐ Ts*3,   ls/2,  0, NM}; pnt204[] += newp; Point(newp) = { Sp ‐ bs ‐ Ts*3,  ‐ls/2,  0, NM};  For r In {#pnt204[]‐4:#pnt204[]‐1}   ln204[]+=newl; Line(newl) = {pnt204[r], pnt204[(r==#pnt204[]‐1)?r‐3:r+1]}; EndFor  lnl204[] += newll; Line Loop(newll) = {ln204[]};  surf_Secondary204[] += news; Plane Surface(news) = {newll‐1};  Color Black {Surface{surf_Secondary204[]};}    //Adding colour in secondary mesh  Physical Surface(Secondary[4]) = surf_Secondary204[];  //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐    pnt205[] += newp; Point(newp) = {      Sp ‐ Ts*4,  ‐ls/2,  0, NM}; pnt205[] += newp; Point(newp) = {      Sp ‐ Ts*4,   ls/2,  0, NM}; pnt205[] += newp; Point(newp) = { Sp ‐ bs ‐ Ts*4,   ls/2,  0, NM}; pnt205[] += newp; Point(newp) = { Sp ‐ bs ‐ Ts*4,  ‐ls/2,  0, NM};  For r In {#pnt205[]‐4:#pnt205[]‐1}   ln205[]+=newl; Line(newl) = {pnt205[r], pnt205[(r==#pnt205[]‐1)?r‐3:r+1]}; EndFor  lnl205[] += newll; Line Loop(newll) = {ln205[]};  surf_Secondary205[] += news; Plane Surface(news) = {newll‐1};  Color Black {Surface{surf_Secondary205[]};}    //Adding colour in secondary mesh  Physical Surface(Secondary[5]) = surf_Secondary205[];  //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐    pnt206[] += newp; Point(newp) = {      Sp ‐ Ts*5,  ‐ls/2,  0, NM}; pnt206[] += newp; Point(newp) = {      Sp ‐ Ts*5,   ls/2,  0, NM}; pnt206[] += newp; Point(newp) = { Sp ‐ bs ‐ Ts*5,   ls/2,  0, NM}; pnt206[] += newp; Point(newp) = { Sp ‐ bs ‐ Ts*5,  ‐ls/2,  0, NM};  For r In {#pnt206[]‐4:#pnt206[]‐1}   ln206[]+=newl; Line(newl) = {pnt206[r], pnt206[(r==#pnt206[]‐1)?r‐3:r+1]}; EndFor 

- 21 -

Page 126: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE  lnl206[] += newll; Line Loop(newll) = {ln206[]};  surf_Secondary206[] += news; Plane Surface(news) = {newll‐1};  Color Black {Surface{surf_Secondary206[]};}    //Adding colour in secondary mesh  Physical Surface(Secondary[6]) = surf_Secondary206[];  //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐    If(m>2)   //Secondary poles for stators of 3 or more phases  //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐      pnt207[] += newp;   Point(newp) = {      Sp ‐ Ts*6,  ‐ls/2,  0, NM};   pnt207[] += newp;   Point(newp) = {      Sp ‐ Ts*6,   ls/2,  0, NM};   pnt207[] += newp;   Point(newp) = { Sp ‐ bs ‐ Ts*6,   ls/2,  0, NM};   pnt207[] += newp;   Point(newp) = { Sp ‐ bs ‐ Ts*6,  ‐ls/2,  0, NM};    For r In {#pnt207[]‐4:#pnt207[]‐1}     ln207[]+=newl; Line(newl) = {pnt207[r], pnt207[(r==#pnt207[]‐1)?r‐3:r+1]};   EndFor    lnl207[] += newll;   Line Loop(newll) = {ln207[]};    surf_Secondary207[] += news;   Plane Surface(news) = {newll‐1};    Color Black {Surface{surf_Secondary207[]};}  //Adding colour in secondary mesh    Physical Surface(Secondary[7]) = surf_Secondary207[];  //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐      pnt208[] += newp;   Point(newp) = {      Sp ‐ Ts*7,  ‐ls/2,  0, NM};   pnt208[] += newp;   Point(newp) = {      Sp ‐ Ts*7,   ls/2,  0, NM};   pnt208[] += newp;   Point(newp) = { Sp ‐ bs ‐ Ts*7,   ls/2,  0, NM};   pnt208[] += newp;   Point(newp) = { Sp ‐ bs ‐ Ts*7,  ‐ls/2,  0, NM};    For r In {#pnt208[]‐4:#pnt208[]‐1}     ln208[]+=newl; Line(newl) = {pnt208[r], pnt208[(r==#pnt208[]‐1)?r‐3:r+1]};   EndFor    lnl208[] += newll;   Line Loop(newll) = {ln208[]};    surf_Secondary208[] += news;   Plane Surface(news) = {newll‐1};    Color Black {Surface{surf_Secondary208[]};}  //Adding colour in secondary mesh    Physical Surface(Secondary[8]) = surf_Secondary208[];  //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐      pnt209[] += newp;   Point(newp) = {      Sp ‐ Ts*8,  ‐ls/2,  0, NM};   pnt209[] += newp;   Point(newp) = {      Sp ‐ Ts*8,   ls/2,  0, NM};   pnt209[] += newp;   Point(newp) = { Sp ‐ bs ‐ Ts*8,   ls/2,  0, NM};   pnt209[] += newp; 

- 22 -

Page 127: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE   Point(newp) = { Sp ‐ bs ‐ Ts*8,  ‐ls/2,  0, NM};    For r In {#pnt209[]‐4:#pnt209[]‐1}     ln209[]+=newl; Line(newl) = {pnt209[r], pnt209[(r==#pnt209[]‐1)?r‐3:r+1]};   EndFor    lnl209[] += newll;   Line Loop(newll) = {ln209[]};    surf_Secondary209[] += news;   Plane Surface(news) = {newll‐1};    Color Black {Surface{surf_Secondary209[]};}  //Adding colour in secondary mesh    Physical Surface(Secondary[9]) = surf_Secondary209[];  //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐    EndIf    //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐    If(m>3)   //Secondary poles for stators of 4 or more phases  //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐      pnt210[] += newp;   Point(newp) = {      Sp ‐ Ts*9,  ‐ls/2,  0, NM};   pnt210[] += newp;   Point(newp) = {      Sp ‐ Ts*9,   ls/2,  0, NM};   pnt210[] += newp;   Point(newp) = { Sp ‐ bs ‐ Ts*9,   ls/2,  0, NM};   pnt210[] += newp;   Point(newp) = { Sp ‐ bs ‐ Ts*9,  ‐ls/2,  0, NM};    For r In {#pnt210[]‐4:#pnt210[]‐1}     ln210[]+=newl; Line(newl) = {pnt210[r], pnt210[(r==#pnt210[]‐1)?r‐3:r+1]};   EndFor    lnl210[] += newll;   Line Loop(newll) = {ln210[]};    surf_Secondary210[] += news;   Plane Surface(news) = {newll‐1};    Color Black {Surface{surf_Secondary210[]};}  //Adding colour in secondary mesh    Physical Surface(Secondary[10]) = surf_Secondary210[];  //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐      pnt211[] += newp;   Point(newp) = {      Sp ‐ Ts*10,  ‐ls/2,  0, NM};   pnt211[] += newp;   Point(newp) = {      Sp ‐ Ts*10,   ls/2,  0, NM};   pnt211[] += newp;   Point(newp) = { Sp ‐ bs ‐ Ts*10,   ls/2,  0, NM};   pnt211[] += newp;   Point(newp) = { Sp ‐ bs ‐ Ts*10,  ‐ls/2,  0, NM};    For r In {#pnt211[]‐4:#pnt211[]‐1}     ln211[]+=newl; Line(newl) = {pnt211[r], pnt211[(r==#pnt211[]‐1)?r‐3:r+1]};   EndFor    lnl211[] += newll;   Line Loop(newll) = {ln211[]};    surf_Secondary211[] += news;   Plane Surface(news) = {newll‐1};    Color Black {Surface{surf_Secondary211[]};}  //Adding colour in secondary mesh    Physical Surface(Secondary[11]) = surf_Secondary211[];  

- 23 -

Page 128: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐      pnt212[] += newp;   Point(newp) = {      Sp ‐ Ts*11,  ‐ls/2,  0, NM};   pnt212[] += newp;   Point(newp) = {      Sp ‐ Ts*11,   ls/2,  0, NM};   pnt212[] += newp;   Point(newp) = { Sp ‐ bs ‐ Ts*11,   ls/2,  0, NM};   pnt212[] += newp;   Point(newp) = { Sp ‐ bs ‐ Ts*11,  ‐ls/2,  0, NM};    For r In {#pnt212[]‐4:#pnt212[]‐1}     ln212[]+=newl; Line(newl) = {pnt212[r], pnt212[(r==#pnt212[]‐1)?r‐3:r+1]};   EndFor    lnl212[] += newll;   Line Loop(newll) = {ln212[]};    surf_Secondary212[] += news;   Plane Surface(news) = {newll‐1};    Color Black {Surface{surf_Secondary212[]};}  //Adding colour in secondary mesh    Physical Surface(Secondary[12]) = surf_Secondary212[];  //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐    EndIf   //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐    If(m>4)   //Secondary poles for stators of 5 phases  //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐      pnt213[] += newp;   Point(newp) = {      Sp ‐ Ts*12,  ‐ls/2,  0, NM};   pnt213[] += newp;   Point(newp) = {      Sp ‐ Ts*12,   ls/2,  0, NM};   pnt213[] += newp;   Point(newp) = { Sp ‐ bs ‐ Ts*12,   ls/2,  0, NM};   pnt213[] += newp;   Point(newp) = { Sp ‐ bs ‐ Ts*12,  ‐ls/2,  0, NM};    For r In {#pnt213[]‐4:#pnt213[]‐1}     ln213[]+=newl; Line(newl) = {pnt213[r], pnt213[(r==#pnt213[]‐1)?r‐3:r+1]};   EndFor    lnl213[] += newll;   Line Loop(newll) = {ln213[]};    surf_Secondary213[] += news;   Plane Surface(news) = {newll‐1};    Color Black {Surface{surf_Secondary213[]};}  //Adding colour in secondary mesh    Physical Surface(Secondary[13]) = surf_Secondary213[];  //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐      pnt214[] += newp;   Point(newp) = {      Sp ‐ Ts*13,  ‐ls/2,  0, NM};   pnt214[] += newp;   Point(newp) = {      Sp ‐ Ts*13,   ls/2,  0, NM};   pnt214[] += newp;   Point(newp) = { Sp ‐ bs ‐ Ts*13,   ls/2,  0, NM};   pnt214[] += newp;   Point(newp) = { Sp ‐ bs ‐ Ts*13,  ‐ls/2,  0, NM};    For r In {#pnt214[]‐4:#pnt214[]‐1}     ln214[]+=newl; Line(newl) = {pnt214[r], pnt214[(r==#pnt214[]‐1)?r‐3:r+1]};   EndFor  

- 24 -

Page 129: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE   lnl214[] += newll;   Line Loop(newll) = {ln214[]};    surf_Secondary214[] += news;   Plane Surface(news) = {newll‐1};    Color Black {Surface{surf_Secondary214[]};}  //Adding colour in secondary mesh    Physical Surface(Secondary[14]) = surf_Secondary214[];  //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐      pnt215[] += newp;   Point(newp) = {      Sp ‐ Ts*14,  ‐ls/2,  0, NM};   pnt215[] += newp;   Point(newp) = {      Sp ‐ Ts*14,   ls/2,  0, NM};   pnt215[] += newp;   Point(newp) = { Sp ‐ bs ‐ Ts*14,   ls/2,  0, NM};   pnt215[] += newp;   Point(newp) = { Sp ‐ bs ‐ Ts*14,  ‐ls/2,  0, NM};    For r In {#pnt215[]‐4:#pnt215[]‐1}     ln215[]+=newl; Line(newl) = {pnt215[r], pnt215[(r==#pnt215[]‐1)?r‐3:r+1]};   EndFor    lnl215[] += newll;   Line Loop(newll) = {ln215[]};    surf_Secondary215[] += news;   Plane Surface(news) = {newll‐1};    Color Black {Surface{surf_Secondary215[]};}  //Adding colour in secondary mesh    Physical Surface(Secondary[15]) = surf_Secondary215[];  //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐    EndIf   

- 25 -

Page 130: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

Coils Code   //‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐  //Coil A:  //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐   // A + //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐    pnt311[] += newp; Point(newp) = { (‐L/2) ‐ cp/2 + wr, ‐H + lp + hy ‐ ws, 0, NM}; pnt311[] += newp; Point(newp) = { (‐L/2) ‐ cp/2 + wr,    ‐H + hy + wi, 0, NM}; pnt311[] += newp; Point(newp) = {      (‐L/2) ‐ wr,   ‐H + hy + wi, 0, NM}; pnt311[] += newp; Point(newp) = {      (‐L/2) ‐ wr, ‐H + lp + hy ‐ ws, 0, NM};  For a In {#pnt311[]‐4:#pnt311[]‐1}   ln311[]+=newl; Line(newl) = {pnt311[a], pnt311[(a==#pnt311[]‐1)?a‐3:a+1]}; EndFor  lnl311[] += newll; Line Loop(newll) = {ln311[]};  surf_CoilA11[] += news; Plane Surface(news) = {newll‐1};  Color Red {Surface{surf_CoilA11[]};}    //Adding colour in coil mesh  Physical Surface(CoilAp1) = surf_CoilA11[];  //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐    pnt312[] += newp; Point(newp) = { (‐L/2) ‐ cp/2 + wr,  H ‐ lp ‐ hy + ws, 0, NM}; pnt312[] += newp; Point(newp) = { (‐L/2) ‐ cp/2 + wr,     H ‐ hy ‐ wi, 0, NM}; pnt312[] += newp; Point(newp) = {      (‐L/2) ‐ wr,    H ‐ hy ‐ wi, 0, NM}; pnt312[] += newp; Point(newp) = {      (‐L/2) ‐ wr,  H ‐ lp ‐ hy + ws, 0, NM};  For a In {#pnt312[]‐4:#pnt312[]‐1}   ln312[]+=newl; Line(newl) = {pnt312[a], pnt312[(a==#pnt312[]‐1)?a‐3:a+1]}; EndFor  lnl312[] += newll; Line Loop(newll) = {ln312[]};  surf_CoilA12[] += news; Plane Surface(news) = {newll‐1};  Color Red {Surface{surf_CoilA12[]};}    //Adding colour in coil mesh  Physical Surface(CoilAp2) = surf_CoilA12[];  //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐    pnt313[] += newp; Point(newp) = { (‐L/2) + cp/2 ‐ wr + bp + m*Tp, ‐H + lp + hy ‐ ws, 0, NM}; pnt313[] += newp; Point(newp) = { (‐L/2) + cp/2 ‐ wr + bp + m*Tp,   ‐H + hy + wi, 0, NM}; pnt313[] += newp; Point(newp) = {      (‐L/2) + wr + bp + m*Tp,    ‐H + hy + wi, 0, NM}; pnt313[] += newp; Point(newp) = {      (‐L/2) + wr + bp + m*Tp, ‐H + lp + hy ‐ ws, 0, NM};  For a In {#pnt313[]‐4:#pnt313[]‐1}   ln313[]+=newl; Line(newl) = {pnt313[a], pnt313[(a==#pnt313[]‐1)?a‐3:a+1]}; 

- 26 -

Page 131: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE EndFor  lnl313[] += newll; Line Loop(newll) = {ln313[]};  surf_CoilA13[] += news; Plane Surface(news) = {newll‐1};  Color Red {Surface{surf_CoilA13[]};}    //Adding colour in coil mesh  Physical Surface(CoilAp3) = surf_CoilA13[];  //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐    pnt314[] += newp; Point(newp) = { (‐L/2) + cp/2 ‐ wr + bp + m*Tp,  H ‐ lp ‐ hy + ws, 0, NM}; pnt314[] += newp; Point(newp) = { (‐L/2) + cp/2 ‐ wr + bp + m*Tp,    H ‐ hy ‐ wi, 0, NM}; pnt314[] += newp; Point(newp) = {      (‐L/2) + wr + bp + m*Tp,     H ‐ hy ‐ wi, 0, NM}; pnt314[] += newp; Point(newp) = {      (‐L/2) + wr + bp + m*Tp,  H ‐ lp ‐ hy + ws, 0, NM};  For a In {#pnt314[]‐4:#pnt314[]‐1}   ln314[]+=newl; Line(newl) = {pnt314[a], pnt314[(a==#pnt314[]‐1)?a‐3:a+1]}; EndFor  lnl314[] += newll; Line Loop(newll) = {ln314[]};  surf_CoilA14[] += news; Plane Surface(news) = {newll‐1};  Color Red {Surface{surf_CoilA14[]};}    //Adding colour in coil mesh  Physical Surface(CoilAp4) = surf_CoilA14[];  //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐   // A ‐ //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐    pnt321[] += newp; Point(newp) = { (‐L/2) + cp/2 ‐ wr + bp, ‐H + lp + hy ‐ ws, 0, NM}; pnt321[] += newp; Point(newp) = { (‐L/2) + cp/2 ‐ wr + bp,     ‐H + hy + wi, 0, NM}; pnt321[] += newp; Point(newp) = {      (‐L/2) + wr + bp,     ‐H + hy + wi, 0, NM}; pnt321[] += newp; Point(newp) = {      (‐L/2) + wr + bp, ‐H + lp + hy ‐ ws, 0, NM};  For a In {#pnt321[]‐4:#pnt321[]‐1}   ln321[]+=newl; Line(newl) = {pnt321[a], pnt321[(a==#pnt321[]‐1)?a‐3:a+1]}; EndFor  lnl321[] += newll; Line Loop(newll) = {ln321[]};  surf_CoilA21[] += news; Plane Surface(news) = {newll‐1};  Color DarkRed {Surface{surf_CoilA21[]};}   //Adding colour in coil mesh  Physical Surface(CoilAn1) = surf_CoilA21[];  //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐    pnt322[] += newp; Point(newp) = { (‐L/2) + cp/2 ‐ wr + bp,  H ‐ lp ‐ hy + ws, 0, NM}; pnt322[] += newp; Point(newp) = { (‐L/2) + cp/2 ‐ wr + bp,     H ‐ hy ‐ wi, 0, NM}; pnt322[] += newp; Point(newp) = {      (‐L/2) + wr + bp,     H ‐ hy ‐ wi, 0, NM}; pnt322[] += newp; Point(newp) = {      (‐L/2) + wr + bp,  H ‐ lp ‐ hy + ws, 0, NM}; 

- 27 -

Page 132: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE  For a In {#pnt322[]‐4:#pnt322[]‐1}   ln322[]+=newl; Line(newl) = {pnt322[a], pnt322[(a==#pnt322[]‐1)?a‐3:a+1]}; EndFor  lnl322[] += newll; Line Loop(newll) = {ln322[]};  surf_CoilA22[] += news; Plane Surface(news) = {newll‐1};  Color DarkRed {Surface{surf_CoilA22[]};}   //Adding colour in coil mesh  Physical Surface(CoilAn2) = surf_CoilA22[];   //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐    pnt323[] += newp; Point(newp) = { (‐L/2) ‐ cp/2 + wr + m*Tp, ‐H + lp + hy ‐ ws, 0, NM}; pnt323[] += newp; Point(newp) = { (‐L/2) ‐ cp/2 + wr + m*Tp,      ‐H + hy + wi, 0, NM}; pnt323[] += newp; Point(newp) = {      (‐L/2) ‐ wr + m*Tp,     ‐H + hy + wi, 0, NM}; pnt323[] += newp; Point(newp) = {      (‐L/2) ‐ wr + m*Tp, ‐H + lp + hy ‐ ws, 0, NM};  For a In {#pnt323[]‐4:#pnt323[]‐1}   ln323[]+=newl; Line(newl) = {pnt323[a], pnt323[(a==#pnt323[]‐1)?a‐3:a+1]}; EndFor  lnl323[] += newll; Line Loop(newll) = {ln323[]};  surf_CoilA23[] += news; Plane Surface(news) = {newll‐1};  Color DarkRed {Surface{surf_CoilA23[]};}   //Adding colour in coil mesh  Physical Surface(CoilAn3) = surf_CoilA23[];  //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐    pnt324[] += newp; Point(newp) = { (‐L/2) ‐ cp/2 + wr + m*Tp,  H ‐ lp ‐ hy + ws, 0, NM}; pnt324[] += newp; Point(newp) = { (‐L/2) ‐ cp/2 + wr + m*Tp,       H ‐ hy ‐ wi, 0, NM}; pnt324[] += newp; Point(newp) = {      (‐L/2) ‐ wr + m*Tp,      H ‐ hy ‐ wi, 0, NM}; pnt324[] += newp; Point(newp) = {      (‐L/2) ‐ wr + m*Tp,  H ‐ lp ‐ hy + ws, 0, NM};  For a In {#pnt324[]‐4:#pnt324[]‐1}   ln324[]+=newl; Line(newl) = {pnt324[a], pnt324[(a==#pnt324[]‐1)?a‐3:a+1]}; EndFor  lnl324[] += newll; Line Loop(newll) = {ln324[]};  surf_CoilA24[] += news; Plane Surface(news) = {newll‐1};  Color DarkRed {Surface{surf_CoilA24[]};}   //Adding colour in coil mesh  Physical Surface(CoilAn4) = surf_CoilA24[];   //‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐  //Coil B:  //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐   // B + //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐   

- 28 -

Page 133: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE  pnt331[] += newp; Point(newp) = { (‐L/2) ‐ cp/2 + wr + Tp, ‐H + lp + hy ‐ ws, 0, NM}; pnt331[] += newp; Point(newp) = { (‐L/2) ‐ cp/2 + wr + Tp,    ‐H + hy + wi, 0, NM}; pnt331[] += newp; Point(newp) = {      (‐L/2) ‐ wr + Tp,    ‐H + hy + wi, 0, NM}; pnt331[] += newp; Point(newp) = {      (‐L/2) ‐ wr + Tp, ‐H + lp + hy ‐ ws, 0, NM};  For b In {#pnt331[]‐4:#pnt331[]‐1}   ln331[]+=newl; Line(newl) = {pnt331[b], pnt331[(b==#pnt331[]‐1)?b‐3:b+1]}; EndFor  lnl331[] += newll; Line Loop(newll) = {ln331[]};  surf_CoilB31[] += news; Plane Surface(news) = {newll‐1};  Color Green {Surface{surf_CoilB31[]};}    //Adding colour in coil mesh  Physical Surface(CoilBp1) = surf_CoilB31[];  //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐    pnt332[] += newp; Point(newp) = { (‐L/2) ‐ cp/2 + wr + Tp,  H ‐ lp ‐ hy + ws, 0, NM}; pnt332[] += newp; Point(newp) = { (‐L/2) ‐ cp/2 + wr + Tp,     H ‐ hy ‐ wi, 0, NM}; pnt332[] += newp; Point(newp) = {      (‐L/2) ‐ wr + Tp,     H ‐ hy ‐ wi, 0, NM}; pnt332[] += newp; Point(newp) = {      (‐L/2) ‐ wr + Tp,  H ‐ lp ‐ hy + ws, 0, NM};  For b In {#pnt332[]‐4:#pnt332[]‐1}   ln332[]+=newl; Line(newl) = {pnt332[b], pnt332[(b==#pnt332[]‐1)?b‐3:b+1]}; EndFor  lnl332[] += newll; Line Loop(newll) = {ln332[]};  surf_CoilB32[] += news; Plane Surface(news) = {newll‐1};  Color Green {Surface{surf_CoilB32[]};}    //Adding colour in coil mesh  Physical Surface(CoilBp2) = surf_CoilB32[];  //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐    pnt333[] += newp; Point(newp) = { (‐L/2) + cp/2 ‐ wr + bp + (m+1)*Tp, ‐H + lp + hy ‐ ws, 0, NM}; pnt333[] += newp; Point(newp) = { (‐L/2) + cp/2 ‐ wr + bp + (m+1)*Tp,    ‐H + hy + wi, 0, NM}; pnt333[] += newp; Point(newp) = {      (‐L/2) + wr + bp + (m+1)*Tp,   ‐H + hy + wi, 0, NM}; pnt333[] += newp; Point(newp) = {      (‐L/2) + wr + bp + (m+1)*Tp, ‐H + lp + hy ‐ ws, 0, NM};  For b In {#pnt333[]‐4:#pnt333[]‐1}   ln333[]+=newl; Line(newl) = {pnt333[b], pnt333[(b==#pnt333[]‐1)?b‐3:b+1]}; EndFor  lnl333[] += newll; Line Loop(newll) = {ln333[]};  surf_CoilB33[] += news; Plane Surface(news) = {newll‐1};  Color Green {Surface{surf_CoilB33[]};}    //Adding colour in coil mesh  Physical Surface(CoilBp3) = surf_CoilB33[];  

- 29 -

Page 134: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐    pnt334[] += newp; Point(newp) = { (‐L/2) + cp/2 ‐ wr + bp + (m+1)*Tp,  H ‐ lp ‐ hy + ws, 0, NM}; pnt334[] += newp; Point(newp) = { (‐L/2) + cp/2 ‐ wr + bp + (m+1)*Tp,     H ‐ hy ‐ wi, 0, NM}; pnt334[] += newp; Point(newp) = {      (‐L/2) + wr + bp + (m+1)*Tp,    H ‐ hy ‐ wi, 0, NM}; pnt334[] += newp; Point(newp) = {      (‐L/2) + wr + bp + (m+1)*Tp,  H ‐ lp ‐ hy + ws, 0, NM};  For b In {#pnt334[]‐4:#pnt334[]‐1}   ln334[]+=newl; Line(newl) = {pnt334[b], pnt334[(b==#pnt334[]‐1)?b‐3:b+1]}; EndFor  lnl334[] += newll; Line Loop(newll) = {ln334[]};  surf_CoilB34[] += news; Plane Surface(news) = {newll‐1};  Color Green {Surface{surf_CoilB34[]};}    //Adding colour in coil mesh  Physical Surface(CoilBp4) = surf_CoilB34[];  //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐   // B ‐ //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐    pnt341[] += newp; Point(newp) = { (‐L/2) + cp/2 ‐ wr + bp + Tp, ‐H + lp + hy ‐ ws, 0, NM}; pnt341[] += newp; Point(newp) = { (‐L/2) + cp/2 ‐ wr + bp + Tp,     ‐H + hy + wi, 0, NM}; pnt341[] += newp; Point(newp) = {      (‐L/2) + wr + bp + Tp,     ‐H + hy + wi, 0, NM}; pnt341[] += newp; Point(newp) = {      (‐L/2) + wr + bp + Tp, ‐H + lp + hy ‐ ws, 0, NM};  For b In {#pnt341[]‐4:#pnt341[]‐1}   ln341[]+=newl; Line(newl) = {pnt341[b], pnt341[(b==#pnt341[]‐1)?b‐3:b+1]}; EndFor  lnl341[] += newll; Line Loop(newll) = {ln341[]};  surf_CoilB41[] += news; Plane Surface(news) = {newll‐1};  Color DarkGreen {Surface{surf_CoilB41[]};}    //Adding colour in coil mesh  Physical Surface(CoilBn1) = surf_CoilB41[];  //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐    pnt342[] += newp; Point(newp) = { (‐L/2) + cp/2 ‐ wr + bp + Tp,  H ‐ lp ‐ hy + ws, 0, NM}; pnt342[] += newp; Point(newp) = { (‐L/2) + cp/2 ‐ wr + bp + Tp,     H ‐ hy ‐ wi, 0, NM}; pnt342[] += newp; Point(newp) = {      (‐L/2) + wr + bp + Tp,     H ‐ hy ‐ wi, 0, NM}; pnt342[] += newp; Point(newp) = {      (‐L/2) + wr + bp + Tp,  H ‐ lp ‐ hy + ws, 0, NM};  For b In {#pnt342[]‐4:#pnt342[]‐1}   ln342[]+=newl; Line(newl) = {pnt342[b], pnt342[(b==#pnt342[]‐1)?b‐3:b+1]}; EndFor  lnl342[] += newll; Line Loop(newll) = {ln342[]};  surf_CoilB42[] += news; Plane Surface(news) = {newll‐1};  Color DarkGreen {Surface{surf_CoilB42[]};}    //Adding colour in coil mesh 

- 30 -

Page 135: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE  Physical Surface(CoilBn2) = surf_CoilB42[];  //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐    pnt343[] += newp; Point(newp) = { (‐L/2) ‐ cp/2 + wr + (m+1)*Tp, ‐H + lp + hy ‐ ws, 0, NM}; pnt343[] += newp; Point(newp) = { (‐L/2) ‐ cp/2 + wr + (m+1)*Tp,     ‐H + hy + wi, 0, NM}; pnt343[] += newp; Point(newp) = {      (‐L/2) ‐ wr + (m+1)*Tp,      ‐H + hy + wi, 0, NM}; pnt343[] += newp; Point(newp) = {      (‐L/2) ‐ wr + (m+1)*Tp, ‐H + lp + hy ‐ ws, 0, NM};  For b In {#pnt342[]‐4:#pnt342[]‐1}   ln343[]+=newl; Line(newl) = {pnt343[b], pnt343[(b==#pnt343[]‐1)?b‐3:b+1]}; EndFor  lnl343[] += newll; Line Loop(newll) = {ln343[]};  surf_CoilB43[] += news; Plane Surface(news) = {newll‐1};  Color DarkGreen {Surface{surf_CoilB43[]};}    //Adding colour in coil mesh  Physical Surface(CoilBn3) = surf_CoilB43[];  //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐    pnt344[] += newp; Point(newp) = { (‐L/2) ‐ cp/2 + wr + (m+1)*Tp,  H ‐ lp ‐ hy + ws, 0, NM}; pnt344[] += newp; Point(newp) = { (‐L/2) ‐ cp/2 + wr + (m+1)*Tp,      H ‐ hy ‐ wi, 0, NM}; pnt344[] += newp; Point(newp) = {      (‐L/2) ‐ wr + (m+1)*Tp,       H ‐ hy ‐ wi, 0, NM}; pnt344[] += newp; Point(newp) = {      (‐L/2) ‐ wr + (m+1)*Tp,  H ‐ lp ‐ hy + ws, 0, NM};  For b In {#pnt344[]‐4:#pnt344[]‐1}   ln344[]+=newl; Line(newl) = {pnt344[b], pnt344[(b==#pnt344[]‐1)?b‐3:b+1]}; EndFor  lnl344[] += newll; Line Loop(newll) = {ln344[]};  surf_CoilB44[] += news; Plane Surface(news) = {newll‐1};  Color DarkGreen {Surface{surf_CoilB44[]};}    //Adding colour in coil mesh  Physical Surface(CoilBn4) = surf_CoilB44[];   //‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐  //Coil C:  If(m>2)    //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐     // C +   //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐      pnt351[] += newp;   Point(newp) = { (‐L/2) ‐ cp/2 + wr + 2*Tp, ‐H + lp + hy ‐ ws, 0, NM};   pnt351[] += newp;   Point(newp) = { (‐L/2) ‐ cp/2 + wr + 2*Tp,    ‐H + hy + wi, 0, NM};   pnt351[] += newp;   Point(newp) = {      (‐L/2) ‐ wr + 2*Tp,   ‐H + hy + wi, 0, NM};   pnt351[] += newp;   Point(newp) = {      (‐L/2) ‐ wr + 2*Tp, ‐H + lp + hy ‐ ws, 0, NM};    For c In {#pnt351[]‐4:#pnt351[]‐1} 

- 31 -

Page 136: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE     ln351[]+=newl; Line(newl) = {pnt351[c], pnt351[(c==#pnt351[]‐1)?c‐3:c+1]};   EndFor    lnl351[] += newll;   Line Loop(newll) = {ln351[]};    surf_CoilC51[] += news;   Plane Surface(news) = {newll‐1};    Color Yellow {Surface{surf_CoilC51[]};}   //Adding colour in coil mesh               Physical Surface(CoilCp1) = surf_CoilC51[];    //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐      pnt352[] += newp;   Point(newp) = { (‐L/2) ‐ cp/2 + wr + 2*Tp,  H ‐ lp ‐ hy + ws, 0, NM};   pnt352[] += newp;   Point(newp) = { (‐L/2) ‐ cp/2 + wr + 2*Tp,     H ‐ hy ‐ wi, 0, NM};   pnt352[] += newp;   Point(newp) = {      (‐L/2) ‐ wr + 2*Tp,    H ‐ hy ‐ wi, 0, NM};   pnt352[] += newp;   Point(newp) = {      (‐L/2) ‐ wr + 2*Tp,  H ‐ lp ‐ hy + ws, 0, NM};    For c In {#pnt352[]‐4:#pnt352[]‐1}     ln352[]+=newl; Line(newl) = {pnt352[c], pnt352[(c==#pnt352[]‐1)?c‐3:c+1]};   EndFor    lnl352[] += newll;   Line Loop(newll) = {ln352[]};    surf_CoilC52[] += news;   Plane Surface(news) = {newll‐1};    Color Yellow {Surface{surf_CoilC52[]};}   //Adding colour in coil mesh    Physical Surface(CoilCp2) = surf_CoilC52[];    //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐      pnt353[] += newp;   Point(newp) = { (‐L/2) + cp/2 ‐ wr + bp + (m+2)*Tp, ‐H + lp + hy ‐ ws, 0, NM};   pnt353[] += newp;   Point(newp) = { (‐L/2) + cp/2 ‐ wr + bp + (m+2)*Tp,    ‐H + hy + wi, 0, NM};   pnt353[] += newp;   Point(newp) = {      (‐L/2) + wr + bp + (m+2)*Tp,   ‐H + hy + wi, 0, NM};   pnt353[] += newp;   Point(newp) = {      (‐L/2) + wr + bp + (m+2)*Tp, ‐H + lp + hy ‐ ws, 0, NM};      For c In {#pnt353[]‐4:#pnt353[]‐1}     ln353[]+=newl; Line(newl) = {pnt353[c], pnt353[(c==#pnt353[]‐1)?c‐3:c+1]};   EndFor    lnl353[] += newll;   Line Loop(newll) = {ln353[]};    surf_CoilC53[] += news;   Plane Surface(news) = {newll‐1};    Color Yellow {Surface{surf_CoilC53[]};}   //Adding colour in coil mesh                   Physical Surface(CoilCp3) = surf_CoilC53[];    //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐      pnt354[] += newp;   Point(newp) = { (‐L/2) + cp/2 ‐ wr + bp + (m+2)*Tp,  H ‐ lp ‐ hy + ws, 0, NM};   pnt354[] += newp;   Point(newp) = { (‐L/2) + cp/2 ‐ wr + bp + (m+2)*Tp,       H ‐ hy ‐ wi, 0, NM};   pnt354[] += newp;   Point(newp) = {      (‐L/2) + wr + bp + (m+2)*Tp,      H ‐ hy ‐ wi, 0, NM};   pnt354[] += newp; 

- 32 -

Page 137: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE   Point(newp) = {      (‐L/2) + wr + bp + (m+2)*Tp,  H ‐ lp ‐ hy + ws, 0, NM};      For c In {#pnt354[]‐4:#pnt354[]‐1}     ln354[]+=newl; Line(newl) = {pnt354[c], pnt354[(c==#pnt354[]‐1)?c‐3:c+1]};   EndFor    lnl354[] += newll;   Line Loop(newll) = {ln354[]};    surf_CoilC54[] += news;   Plane Surface(news) = {newll‐1};    Color Yellow {Surface{surf_CoilC54[]};}   //Adding colour in coil mesh    Physical Surface(CoilCp4) = surf_CoilC54[];    //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐     // C ‐   //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐      pnt361[] += newp;   Point(newp) = { (‐L/2) + cp/2 ‐ wr + bp + 2*Tp, ‐H + lp + hy ‐ ws, 0, NM};   pnt361[] += newp;   Point(newp) = { (‐L/2) + cp/2 ‐ wr + bp + 2*Tp,    ‐H + hy + wi, 0, NM};   pnt361[] += newp;   Point(newp) = {      (‐L/2) + wr + bp + 2*Tp,     ‐H + hy + wi, 0, NM};   pnt361[] += newp;   Point(newp) = {      (‐L/2) + wr + bp + 2*Tp, ‐H + lp + hy ‐ ws, 0, NM};    For c In {#pnt361[]‐4:#pnt361[]‐1}     ln361[]+=newl; Line(newl) = {pnt361[c], pnt361[(c==#pnt361[]‐1)?c‐3:c+1]};   EndFor    lnl361[] += newll;   Line Loop(newll) = {ln361[]};    surf_CoilC61[] += news;   Plane Surface(news) = {newll‐1};    Color {186,177,35} {Surface{surf_CoilC61[]};}    //Adding colour in coil mesh                            //DarkYellow does not exist   Physical Surface(CoilCn1) = surf_CoilC61[];    //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐      pnt362[] += newp;   Point(newp) = { (‐L/2) + cp/2 ‐ wr + bp + 2*Tp,  H ‐ lp ‐ hy + ws, 0, NM};   pnt362[] += newp;   Point(newp) = { (‐L/2) + cp/2 ‐ wr + bp + 2*Tp,    H ‐ hy ‐ wi, 0, NM};   pnt362[] += newp;   Point(newp) = {      (‐L/2) + wr + bp + 2*Tp,     H ‐ hy ‐ wi, 0, NM};   pnt362[] += newp;   Point(newp) = {      (‐L/2) + wr + bp + 2*Tp,  H ‐ lp ‐ hy + ws, 0, NM};    For c In {#pnt362[]‐4:#pnt362[]‐1}     ln362[]+=newl; Line(newl) = {pnt362[c], pnt362[(c==#pnt362[]‐1)?c‐3:c+1]};   EndFor    lnl362[] += newll;   Line Loop(newll) = {ln362[]};    surf_CoilC62[] += news;   Plane Surface(news) = {newll‐1};    Color {186,177,35} {Surface{surf_CoilC62[]};}    //Adding colour in coil mesh                            //DarkYellow does not exist   Physical Surface(CoilCn2) = surf_CoilC62[];    //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐      pnt363[] += newp;   Point(newp) = { (‐L/2) ‐ cp/2 + wr + (m+2)*Tp, ‐H + lp + hy ‐ ws, 0, NM}; 

- 33 -

Page 138: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE   pnt363[] += newp;   Point(newp) = { (‐L/2) ‐ cp/2 + wr + (m+2)*Tp,     ‐H + hy + wi, 0, NM};   pnt363[] += newp;   Point(newp) = {      (‐L/2) ‐ wr + (m+2)*Tp,      ‐H + hy + wi, 0, NM};   pnt363[] += newp;   Point(newp) = {      (‐L/2) ‐ wr + (m+2)*Tp, ‐H + lp + hy ‐ ws, 0, NM};    For c In {#pnt362[]‐4:#pnt362[]‐1}     ln363[]+=newl; Line(newl) = {pnt363[c], pnt363[(c==#pnt363[]‐1)?c‐3:c+1]};   EndFor    lnl363[] += newll;   Line Loop(newll) = {ln363[]};    surf_CoilC63[] += news;   Plane Surface(news) = {newll‐1};    Color {186,177,35} {Surface{surf_CoilC63[]};}    //Adding colour in coil mesh                            //DarkYellow does not exist   Physical Surface(CoilCn3) = surf_CoilC63[];    //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐      pnt364[] += newp;   Point(newp) = { (‐L/2) ‐ cp/2 + wr + (m+2)*Tp,  H ‐ lp ‐ hy + ws, 0, NM};   pnt364[] += newp;   Point(newp) = { (‐L/2) ‐ cp/2 + wr + (m+2)*Tp,      H ‐ hy ‐ wi, 0, NM};   pnt364[] += newp;   Point(newp) = {      (‐L/2) ‐ wr + (m+2)*Tp,       H ‐ hy ‐ wi, 0, NM};   pnt364[] += newp;   Point(newp) = {      (‐L/2) ‐ wr + (m+2)*Tp,  H ‐ lp ‐ hy + ws, 0, NM};    For c In {#pnt364[]‐4:#pnt364[]‐1}     ln364[]+=newl; Line(newl) = {pnt364[c], pnt364[(c==#pnt364[]‐1)?c‐3:c+1]};   EndFor    lnl364[] += newll;   Line Loop(newll) = {ln364[]};    surf_CoilC64[] += news;   Plane Surface(news) = {newll‐1};    Color {186,177,35} {Surface{surf_CoilC64[]};}    //Adding colour in coil mesh                            //DarkYellow does not exist   Physical Surface(CoilCn4) = surf_CoilC64[];  EndIf   //‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐  //Coil D:  If(m>3)    //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐     // D +   //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐      pnt371[] += newp;   Point(newp) = { (‐L/2) ‐ cp/2 + wr + 3*Tp, ‐H + lp + hy ‐ ws, 0, NM};   pnt371[] += newp;   Point(newp) = { (‐L/2) ‐ cp/2 + wr + 3*Tp,    ‐H + hy + wi, 0, NM};   pnt371[] += newp;   Point(newp) = {      (‐L/2) ‐ wr + 3*Tp,   ‐H + hy + wi, 0, NM};   pnt371[] += newp;   Point(newp) = {      (‐L/2) ‐ wr + 3*Tp, ‐H + lp + hy ‐ ws, 0, NM};    For d In {#pnt371[]‐4:#pnt371[]‐1}     ln371[]+=newl; Line(newl) = {pnt371[d], pnt371[(d==#pnt371[]‐1)?d‐3:d+1]};   EndFor  

- 34 -

Page 139: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE   lnl371[] += newll;   Line Loop(newll) = {ln371[]};    surf_CoilD71[] += news;   Plane Surface(news) = {newll‐1};    Color Pink {Surface{surf_CoilD71[]};}    //Adding colour in coil mesh                   Physical Surface(CoilDp1) = surf_CoilD71[];    //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐      pnt372[] += newp;   Point(newp) = { (‐L/2) ‐ cp/2 + wr + 3*Tp,  H ‐ lp ‐ hy + ws, 0, NM};   pnt372[] += newp;   Point(newp) = { (‐L/2) ‐ cp/2 + wr + 3*Tp,        H ‐ hy ‐ wi, 0, NM};   pnt372[] += newp;   Point(newp) = {      (‐L/2) ‐ wr + 3*Tp,      H ‐ hy ‐ wi, 0, NM};   pnt372[] += newp;   Point(newp) = {      (‐L/2) ‐ wr + 3*Tp,  H ‐ lp ‐ hy + ws, 0, NM};    For d In {#pnt372[]‐4:#pnt372[]‐1}     ln372[]+=newl; Line(newl) = {pnt372[d], pnt372[(d==#pnt372[]‐1)?d‐3:d+1]};   EndFor    lnl372[] += newll;   Line Loop(newll) = {ln372[]};    surf_CoilD72[] += news;   Plane Surface(news) = {newll‐1};    Color Pink {Surface{surf_CoilD72[]};}    //Adding colour in coil mesh                   Physical Surface(CoilDp2) = surf_CoilD72[];    //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐      pnt373[] += newp;   Point(newp) = { (‐L/2) + cp/2 ‐ wr + bp + (m+3)*Tp, ‐H + lp + hy ‐ ws, 0, NM};   pnt373[] += newp;   Point(newp) = { (‐L/2) + cp/2 ‐ wr + bp + (m+3)*Tp,    ‐H + hy + wi, 0, NM};   pnt373[] += newp;   Point(newp) = {      (‐L/2) + wr + bp + (m+3)*Tp,   ‐H + hy + wi, 0, NM};   pnt373[] += newp;   Point(newp) = {      (‐L/2) + wr + bp + (m+3)*Tp, ‐H + lp + hy ‐ ws, 0, NM};      For d In {#pnt373[]‐4:#pnt373[]‐1}     ln373[]+=newl; Line(newl) = {pnt373[d], pnt373[(d==#pnt373[]‐1)?d‐3:d+1]};   EndFor    lnl373[] += newll;   Line Loop(newll) = {ln373[]};    surf_CoilD73[] += news;   Plane Surface(news) = {newll‐1};    Color Pink {Surface{surf_CoilD73[]};}    //Adding colour in coil mesh    Physical Surface(CoilDp3) = surf_CoilD73[];    //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐      pnt374[] += newp;   Point(newp) = { (‐L/2) + cp/2 ‐ wr + bp + (m+3)*Tp,  H ‐ lp ‐ hy + ws, 0, NM};   pnt374[] += newp;   Point(newp) = { (‐L/2) + cp/2 ‐ wr + bp + (m+3)*Tp,     H ‐ hy ‐ wi, 0, NM};   pnt374[] += newp;   Point(newp) = {      (‐L/2) + wr + bp + (m+3)*Tp,    H ‐ hy ‐ wi, 0, NM};   pnt374[] += newp;   Point(newp) = {      (‐L/2) + wr + bp + (m+3)*Tp,  H ‐ lp ‐ hy + ws, 0, NM};          For d In {#pnt374[]‐4:#pnt374[]‐1} 

- 35 -

Page 140: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE     ln374[]+=newl; Line(newl) = {pnt374[d], pnt374[(d==#pnt374[]‐1)?d‐3:d+1]};   EndFor    lnl374[] += newll;   Line Loop(newll) = {ln374[]};    surf_CoilD74[] += news;   Plane Surface(news) = {newll‐1};    Color Pink {Surface{surf_CoilD74[]};}    //Adding colour in coil mesh    Physical Surface(CoilDp4) = surf_CoilD74[];    //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐     // D ‐   //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐      pnt381[] += newp;   Point(newp) = { (‐L/2) + cp/2 ‐ wr + bp + 3*Tp, ‐H + lp + hy ‐ ws, 0, NM};   pnt381[] += newp;   Point(newp) = { (‐L/2) + cp/2 ‐ wr + bp + 3*Tp,   ‐H + hy + wi, 0, NM};   pnt381[] += newp;   Point(newp) = {      (‐L/2) + wr + bp + 3*Tp,    ‐H + hy + wi, 0, NM};   pnt381[] += newp;   Point(newp) = {      (‐L/2) + wr + bp + 3*Tp, ‐H + lp + hy ‐ ws, 0, NM};    For d In {#pnt381[]‐4:#pnt381[]‐1}     ln381[]+=newl; Line(newl) = {pnt381[d], pnt381[(d==#pnt381[]‐1)?d‐3:d+1]};   EndFor    lnl381[] += newll;   Line Loop(newll) = {ln381[]};    surf_CoilD81[] += news;   Plane Surface(news) = {newll‐1};    Color Purple {Surface{surf_CoilD81[]};}   //Adding colour in coil mesh                        //DarkPink does not exist     Physical Surface(CoilDn1) = surf_CoilD81[];    //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐      pnt382[] += newp;   Point(newp) = { (‐L/2) + cp/2 ‐ wr + bp + 3*Tp,  H ‐ lp ‐ hy + ws, 0, NM};   pnt382[] += newp;   Point(newp) = { (‐L/2) + cp/2 ‐ wr + bp + 3*Tp,    H ‐ hy ‐ wi, 0, NM};   pnt382[] += newp;   Point(newp) = {      (‐L/2) + wr + bp + 3*Tp,     H ‐ hy ‐ wi, 0, NM};   pnt382[] += newp;   Point(newp) = {      (‐L/2) + wr + bp + 3*Tp,  H ‐ lp ‐ hy + ws, 0, NM};    For d In {#pnt382[]‐4:#pnt382[]‐1}     ln382[]+=newl; Line(newl) = {pnt382[d], pnt382[(d==#pnt382[]‐1)?d‐3:d+1]};   EndFor    lnl382[] += newll;   Line Loop(newll) = {ln382[]};    surf_CoilD82[] += news;   Plane Surface(news) = {newll‐1};    Color Purple {Surface{surf_CoilD82[]};}   //Adding colour in coil mesh                        //DarkPink does not exist     Physical Surface(CoilDn2) = surf_CoilD82[];     //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐      pnt383[] += newp;   Point(newp) = { (‐L/2) ‐ cp/2 + wr + (m+3)*Tp, ‐H + lp + hy ‐ ws, 0, NM};   pnt383[] += newp;   Point(newp) = { (‐L/2) ‐ cp/2 + wr + (m+3)*Tp,     ‐H + hy + wi, 0, NM}; 

- 36 -

Page 141: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE   pnt383[] += newp;   Point(newp) = {      (‐L/2) ‐ wr + (m+3)*Tp,      ‐H + hy + wi, 0, NM};   pnt383[] += newp;   Point(newp) = {      (‐L/2) ‐ wr + (m+3)*Tp, ‐H + lp + hy ‐ ws, 0, NM};    For d In {#pnt383[]‐4:#pnt383[]‐1}     ln383[]+=newl; Line(newl) = {pnt383[d], pnt383[(d==#pnt383[]‐1)?d‐3:d+1]};   EndFor    lnl383[] += newll;   Line Loop(newll) = {ln383[]};    surf_CoilD83[] += news;   Plane Surface(news) = {newll‐1};    Color Purple {Surface{surf_CoilD83[]};}   //Adding colour in coil mesh                        //DarkPink does not exist     Physical Surface(CoilDn3) = surf_CoilD83[];    //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐      pnt384[] += newp;   Point(newp) = { (‐L/2) ‐ cp/2 + wr + (m+3)*Tp,  H ‐ lp ‐ hy + ws, 0, NM};   pnt384[] += newp;   Point(newp) = { (‐L/2) ‐ cp/2 + wr + (m+3)*Tp,      H ‐ hy ‐ wi, 0, NM};   pnt384[] += newp;   Point(newp) = {      (‐L/2) ‐ wr + (m+3)*Tp,       H ‐ hy ‐ wi, 0, NM};   pnt384[] += newp;   Point(newp) = {      (‐L/2) ‐ wr + (m+3)*Tp,  H ‐ lp ‐ hy + ws, 0, NM};    For d In {#pnt384[]‐4:#pnt384[]‐1}     ln384[]+=newl; Line(newl) = {pnt384[d], pnt384[(d==#pnt384[]‐1)?d‐3:d+1]};   EndFor    lnl384[] += newll;   Line Loop(newll) = {ln384[]};    surf_CoilD84[] += news;   Plane Surface(news) = {newll‐1};    Color Purple {Surface{surf_CoilD84[]};}   //Adding colour in coil mesh                        //DarkPink does not exist     Physical Surface(CoilDn4) = surf_CoilD84[];  EndIf   //‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐  //Coil E:  If(m>4)    //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐     // E +   //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐      pnt391[] += newp;   Point(newp) = { (‐L/2) ‐ cp/2 + wr + 4*Tp, ‐H + lp + hy ‐ ws, 0, NM};   pnt391[] += newp;   Point(newp) = { (‐L/2) ‐ cp/2 + wr + 4*Tp,    ‐H + hy + wi, 0, NM};   pnt391[] += newp;   Point(newp) = {      (‐L/2) ‐ wr + 4*Tp,   ‐H + hy + wi, 0, NM};   pnt391[] += newp;   Point(newp) = {      (‐L/2) ‐ wr + 4*Tp, ‐H + lp + hy ‐ ws, 0, NM};    For e In {#pnt391[]‐4:#pnt391[]‐1}     ln391[]+=newl; Line(newl) = {pnt391[e], pnt391[(e==#pnt391[]‐1)?e‐3:e+1]};   EndFor    lnl391[] += newll;   Line Loop(newll) = {ln391[]}; 

- 37 -

Page 142: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE    surf_CoilE91[] += news;   Plane Surface(news) = {newll‐1};    Color Orange {Surface{surf_CoilE91[]};}   //Adding colour in coil mesh    Physical Surface(CoilEp1) = surf_CoilE91[];    //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐      pnt392[] += newp;   Point(newp) = { (‐L/2) ‐ cp/2 + wr + 4*Tp,  H ‐ lp ‐ hy + ws, 0, NM};   pnt392[] += newp;   Point(newp) = { (‐L/2) ‐ cp/2 + wr + 4*Tp,        H ‐ hy ‐ wi, 0, NM};   pnt392[] += newp;   Point(newp) = {      (‐L/2) ‐ wr + 4*Tp,      H ‐ hy ‐ wi, 0, NM};   pnt392[] += newp;   Point(newp) = {      (‐L/2) ‐ wr + 4*Tp,  H ‐ lp ‐ hy + ws, 0, NM};    For e In {#pnt392[]‐4:#pnt392[]‐1}     ln392[]+=newl; Line(newl) = {pnt392[e], pnt392[(e==#pnt392[]‐1)?e‐3:e+1]};   EndFor    lnl392[] += newll;   Line Loop(newll) = {ln392[]};    surf_CoilE92[] += news;   Plane Surface(news) = {newll‐1};    Color Orange {Surface{surf_CoilE92[]};}   //Adding colour in coil mesh    Physical Surface(CoilEp2) = surf_CoilE92[];    //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐      pnt393[] += newp;   Point(newp) = { (‐L/2) + cp/2 ‐ wr + bp + (m+4)*Tp, ‐H + lp + hy ‐ ws, 0, NM};   pnt393[] += newp;   Point(newp) = { (‐L/2) + cp/2 ‐ wr + bp + (m+4)*Tp,    ‐H + hy + wi, 0, NM};   pnt393[] += newp;   Point(newp) = {      (‐L/2) + wr + bp + (m+4)*Tp,   ‐H + hy + wi, 0, NM};   pnt393[] += newp;   Point(newp) = {      (‐L/2) + wr + bp + (m+4)*Tp, ‐H + lp + hy ‐ ws, 0, NM};      For e In {#pnt393[]‐4:#pnt393[]‐1}     ln393[]+=newl; Line(newl) = {pnt393[e], pnt393[(e==#pnt393[]‐1)?e‐3:e+1]};   EndFor    lnl393[] += newll;   Line Loop(newll) = {ln393[]};    surf_CoilE93[] += news;   Plane Surface(news) = {newll‐1};    Color Orange {Surface{surf_CoilE93[]};}   //Adding colour in coil mesh    Physical Surface(CoilEp3) = surf_CoilE93[];    //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐      pnt394[] += newp;   Point(newp) = { (‐L/2) + cp/2 ‐ wr + bp + (m+4)*Tp,  H ‐ lp ‐ hy + ws, 0, NM};   pnt394[] += newp;   Point(newp) = { (‐L/2) + cp/2 ‐ wr + bp + (m+4)*Tp,     H ‐ hy ‐ wi, 0, NM};   pnt394[] += newp;   Point(newp) = {      (‐L/2) + wr + bp + (m+4)*Tp,    H ‐ hy ‐ wi, 0, NM};   pnt394[] += newp;   Point(newp) = {      (‐L/2) + wr + bp + (m+4)*Tp,  H ‐ lp ‐ hy + ws, 0, NM};          For e In {#pnt394[]‐4:#pnt394[]‐1}     ln394[]+=newl; Line(newl) = {pnt394[e], pnt394[(e==#pnt394[]‐1)?e‐3:e+1]};   EndFor    lnl394[] += newll; 

- 38 -

Page 143: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE   Line Loop(newll) = {ln394[]};    surf_CoilE94[] += news;   Plane Surface(news) = {newll‐1};    Color Orange {Surface{surf_CoilE94[]};}   //Adding colour in coil mesh    Physical Surface(CoilEp4) = surf_CoilE94[];    //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐     // E ‐   //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐      pnt301[] += newp;   Point(newp) = { (‐L/2) + cp/2 ‐ wr + bp + 4*Tp, ‐H + lp + hy ‐ ws, 0, NM};   pnt301[] += newp;   Point(newp) = { (‐L/2) + cp/2 ‐ wr + bp + 4*Tp,   ‐H + hy + wi, 0, NM};   pnt301[] += newp;   Point(newp) = {      (‐L/2) + wr + bp + 4*Tp,    ‐H + hy + wi, 0, NM};   pnt301[] += newp;   Point(newp) = {      (‐L/2) + wr + bp + 4*Tp, ‐H + lp + hy ‐ ws, 0, NM};    For e In {#pnt301[]‐4:#pnt301[]‐1}     ln301[]+=newl; Line(newl) = {pnt301[e], pnt301[(e==#pnt301[]‐1)?e‐3:e+1]};   EndFor    lnl301[] += newll;   Line Loop(newll) = {ln301[]};    surf_CoilE01[] += news;   Plane Surface(news) = {newll‐1};    Color {186,88,0} {Surface{surf_CoilE01[]};}    //Adding colour in coil mesh                          //Dark Orange is so light                 Physical Surface(CoilEn1) = surf_CoilE01[];    //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐      pnt302[] += newp;   Point(newp) = { (‐L/2) + cp/2 ‐ wr + bp + 4*Tp,  H ‐ lp ‐ hy + ws, 0, NM};   pnt302[] += newp;   Point(newp) = { (‐L/2) + cp/2 ‐ wr + bp + 4*Tp,    H ‐ hy ‐ wi, 0, NM};   pnt302[] += newp;   Point(newp) = {      (‐L/2) + wr + bp + 4*Tp,     H ‐ hy ‐ wi, 0, NM};   pnt302[] += newp;   Point(newp) = {      (‐L/2) + wr + bp + 4*Tp,  H ‐ lp ‐ hy + ws, 0, NM};    For e In {#pnt302[]‐4:#pnt302[]‐1}     ln302[]+=newl; Line(newl) = {pnt302[e], pnt302[(e==#pnt302[]‐1)?e‐3:e+1]};   EndFor    lnl302[] += newll;   Line Loop(newll) = {ln302[]};    surf_CoilE02[] += news;   Plane Surface(news) = {newll‐1};    Color {186,88,0} {Surface{surf_CoilE02[]};}    //Adding colour in coil mesh                                     //Dark Orange is so light   Physical Surface(CoilEn2) = surf_CoilE02[];     //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐      pnt303[] += newp;   Point(newp) = { (‐L/2) ‐ cp/2 + wr + (m+4)*Tp, ‐H + lp + hy ‐ ws, 0, NM};   pnt303[] += newp;   Point(newp) = { (‐L/2) ‐ cp/2 + wr + (m+4)*Tp,     ‐H + hy + wi, 0, NM};   pnt303[] += newp;   Point(newp) = {      (‐L/2) ‐ wr + (m+4)*Tp,      ‐H + hy + wi, 0, NM};   pnt303[] += newp; 

- 39 -

Page 144: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE   Point(newp) = {      (‐L/2) ‐ wr + (m+4)*Tp, ‐H + lp + hy ‐ ws, 0, NM};    For e In {#pnt303[]‐4:#pnt303[]‐1}     ln303[]+=newl; Line(newl) = {pnt303[e], pnt303[(e==#pnt303[]‐1)?e‐3:e+1]};   EndFor    lnl303[] += newll;   Line Loop(newll) = {ln303[]};    surf_CoilE03[] += news;   Plane Surface(news) = {newll‐1};    Color {186,88,0} {Surface{surf_CoilE03[]};}    //Adding colour in coil mesh                                       //Dark Orange is so light   Physical Surface(CoilEn3) = surf_CoilE03[];    //‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐  ‐      pnt304[] += newp;   Point(newp) = { (‐L/2) ‐ cp/2 + wr + (m+4)*Tp,  H ‐ lp ‐ hy + ws, 0, NM};   pnt304[] += newp;   Point(newp) = { (‐L/2) ‐ cp/2 + wr + (m+4)*Tp,      H ‐ hy ‐ wi, 0, NM};   pnt304[] += newp;   Point(newp) = {      (‐L/2) ‐ wr + (m+4)*Tp,       H ‐ hy ‐ wi, 0, NM};   pnt304[] += newp;   Point(newp) = {      (‐L/2) ‐ wr + (m+4)*Tp,  H ‐ lp ‐ hy + ws, 0, NM};    For e In {#pnt304[]‐4:#pnt304[]‐1}     ln304[]+=newl; Line(newl) = {pnt304[e], pnt304[(e==#pnt304[]‐1)?e‐3:e+1]};   EndFor    lnl304[] += newll;   Line Loop(newll) = {ln304[]};    surf_CoilE04[] += news;   Plane Surface(news) = {newll‐1};    Color {186,88,0} {Surface{surf_CoilE04[]};}    //Adding colour in coil mesh                          //Dark Orange is so light   Physical Surface(CoilEn4) = surf_CoilE04[];  EndIf   //‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐  

- 40 -

Page 145: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

Air and Infinity Codes   //‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐  //Air:  pnt4[] += newp; Point(newp) = {  Rin,   0,    0, NM}; pnt4[] += newp; Point(newp) = {    0,  Rin,    0, NM}; pnt4[] += newp; Point(newp) = { ‐Rin,   0,    0, NM}; pnt4[] += newp; Point(newp) = {    0, ‐Rin,    0, NM};  For t In {0:#pnt4[]‐1}   ln4[]+=newl; Circle(newl) = {pnt4[t], centre, pnt4[(t==#pnt4[]‐1)?0:t+1]}; EndFor  lnl4[] += newll; Line Loop(newll) = {ln4[]};  surf_Air[] += news;  If(m==2)   Plane Surface(news) = {lnl4[], lnl311[], lnl312[], lnl313[], lnl314[], lnl321[], lnl322[], lnl323[], lnl324[], lnl331[], lnl332[], lnl333[], lnl334[], lnl341[], lnl342[], lnl343[], lnl344[], lnl201[], lnl202[], lnl203[], lnl204[], lnl205[], lnl206[], lnl11[], lnl12[]}; EndIf  If(m==3)   Plane Surface(news) = {lnl4[], lnl311[], lnl312[], lnl313[], lnl314[], lnl321[], lnl322[], lnl323[], lnl324[], lnl331[], lnl332[], lnl333[], lnl334[], lnl341[], lnl342[], lnl343[], lnl344[], lnl351[], lnl352[], lnl353[], lnl354[], lnl361[], lnl362[], lnl363[], lnl364[], lnl201[], lnl202[], lnl203[], lnl204[], lnl205[], lnl206[], lnl207[], lnl208[], lnl209[], lnl11[], lnl12[]}; EndIf  If(m==4)   Plane Surface(news) = {lnl4[], lnl311[], lnl312[], lnl313[], lnl314[], lnl321[], lnl322[], lnl323[], lnl324[], lnl331[], lnl332[], lnl333[], lnl334[], lnl341[], lnl342[], lnl343[], lnl344[], lnl351[], lnl352[], lnl353[], lnl354[], lnl361[], lnl362[], lnl363[], lnl364[], lnl371[], lnl372[], lnl373[], lnl374[], lnl381[], lnl382[], lnl383[], lnl384[], lnl201[], lnl202[], lnl203[], lnl204[], lnl205[], lnl206[], lnl207[], lnl208[], lnl209[], lnl210[], lnl211[], lnl212[], lnl11[], lnl12[]}; EndIf  If(m==5)   Plane Surface(news) = {lnl4[], lnl311[], lnl312[], lnl313[], lnl314[], lnl321[], lnl322[], lnl323[], lnl324[], lnl331[], lnl332[], lnl333[], lnl334[], lnl341[], lnl342[], lnl343[], lnl344[], lnl351[], lnl352[], lnl353[], lnl354[], lnl361[], lnl362[], lnl363[], lnl364[], lnl371[], lnl372[], lnl373[], lnl374[], lnl381[], lnl382[], lnl383[], lnl384[], lnl391[], lnl392[], lnl393[], lnl394[], lnl301[], lnl302[], lnl303[], lnl304[],  lnl201[], lnl202[], lnl203[], lnl204[], lnl205[], lnl206[], lnl207[], lnl208[], lnl209[], lnl210[], lnl211[], lnl212[], lnl213[], lnl214[], lnl215[], lnl11[], lnl12[]}; EndIf  Color SkyBlue {Surface{surf_Air[]};}    //Adding colour in air mesh            Physical Surface(Air) = surf_Air[];   //‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐  //Air Inf:  pnt5[] += newp; Point(newp) = {  Rext,     0,    0, NM}; pnt5[] += newp; Point(newp) = {     0,  Rext,    0, NM}; 

- 41 -

Page 146: Pol Lahuerta Manauta FEM Modelization Using Gmsh and …deeea.urv.cat/public/PROPOSTES/pub/pdf/2337pub.pdf · FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV -

FEM Modelization using Gmsh and GetDP: Examples and Guidelines URV - ETSE

- 42 -

pnt5[] += newp; Point(newp) = { ‐Rext,     0,    0, NM}; pnt5[] += newp; Point(newp) = {     0, ‐Rext,    0, NM};  For tt In {0:#pnt4[]‐1}   ln5[]+=newl; Circle(newl) = {pnt5[tt], centre, pnt5[(tt==#pnt5[]‐1)?0:tt+1]}; EndFor  lnl5[] += newll; Line Loop(newll) = {ln5[]};  surf_AirInf[] += news; Plane Surface(news) = {lnl5[], lnl4[]};  Color Blue {Surface{surf_AirInf[]};}    //Adding colour in infinity mesh                Physical Surface(Inf) = surf_AirInf[];  Physical Line(Inf+1) = {ln5[]};      /* SurfaceGInf */   //‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐