Using FEMM
Using FEMM
Introduction
Rules for the use of FEMM (Finite Element Method Magnetics) in the analysis of the
electrical machines.
The elements of the problem can be divided in:
1
Nicola Bianchi Using FEMM
Part I
Simple examples
1 A first example: the electromagnetic actuator
Let us consider the electromagnetic actuator of Fig. 1. It includes a fixed iron yoke
around which a coil is wound, and an iron plate. When the coil carries current, the
iron yoke attracts the iron plate, due to the magnetic pressure on its surface.
Neglecting the end effects, the simulation is carried out by assuming a planar
symmetry. This is that all the magnetic fields are repeated equal for each section of
the electromagnetic actuator. Then an unitary length is assumed, that is, Lstk =1 m.
1.2 Drawing
At first all the points of the structure are drawn, as shown in Fig. 2. The points can
be chosen by using the mouse (in this case it is suggested to use the snap to the grid)
or by using the keyboard (press TAB and insert the point coordinates).
2
Nicola Bianchi Using FEMM
After drawing the points, they have to be connected by segments. Select two
points at a time by the left bottom of the mouse, so that they are connected together.
Fig. 3 shows the segments that connect the points of Fig. 2.
3
Nicola Bianchi Using FEMM
along a segment. Thus, the flux lines results tangential to this segment. This
condition is used to confine the field lines into the domain.
Neumann: this condition imposed the flux density lines to be normal to the se-
lected segment. This condition is a natural condition. This means that it is
automatically satisfied, if other conditions are not assigned.
Periodic: this condition is assigned to two segments and imposes that the magnetic
vector potential behavior is the same along the two segments, i.e. Az,segment1 =
Az,segment2 .
Anti–periodic: this condition is assigned to two segments and imposes that the
magnetic vector potential behavior is the one opposite to the other along the
two segments, i.e. Az,segment1 = −Az,segment2 .
It is worth noticing that the boundary conditions are defined to confine the field
analysis to a given region, reducing the domain as minimum as possible.
In this specific problem, it will be assigned that no flux lines can cross this bound-
ary:
1. A boundary condition Az = 0 is defined in the problem.
2. The external lines, that is, the segments of the box are selected, using the right
bottom of the mouse.
3. The boundary condition is assigned.
1.4 Materials
The material of the objects that form the structure have to be defined. They can be
new materials, suitably defined for this analysis, or they can be selected from a given
Material Library. This includes the commonly used materials.
In the example, the materials that are used are Air, Iron and Copper.
A label is defined for each object. Then, the appropriate material is assigned to
the object: Iron is assigned to the two magnetic pieces, Copper is assigned to the two
coil sides, and Air is assigned to the remanent space.
Fig. 4 shows the label of the electromagnetic actuator.
1.5 Mesh
The subdivision of the structure in finite elements is automatic. This process is
commonly called ”to create the mesh”. Each object will be subdivided in small
elements (the finite element), which are triangles in FEMM.
It is possible to force the maximum mesh size in each object. The mesh size
refers to the area of the triangle used for this subdivision. The choice of the mesh
size depends on the problem to be analyzed. It is better to refine the parts of the
problem, in which the higher field gradients are expected.
Fig. 5 shows the final mesh of the electromagnetic actuator.
4
Nicola Bianchi Using FEMM
5
Nicola Bianchi Using FEMM
1.7 Groups
A group of objects can be defined to belong to the same group, defined by an identi-
fication number. The group can also contain one object only.
The group definition is useful when the automatic analysis is adopted, as will be
shown when the script files are dealt with.
In this example, we define the upper coil side as group 1001, the lower coil side as
group 1002 and the moving keeper as group 10.
1.8 Plot
Once all the steps above have been completed, the problem is ready to be solved. The
problem is analyzed. Then the results can be
At first the flux lines are plotted as shown in Fig. 7. This plot give us a rapid idea
if the problem has been correctly set.
A further visual analysis refers to the flux density map, shown in Fig. 8. This
gives an indication of the range of flux density values reached in the structure.
6
Nicola Bianchi Using FEMM
tation can be found in the chapter ”LUA Scripting Documentation” of the ”FEMM
User’s Manual” (Press key Help topics in the menu Help of the application.
7
Nicola Bianchi Using FEMM
\begin{verbatim}
%
where the text following \verb"--" is a comment.
\begin{verbatim}
N_sim = 10
for n = 1, (N_sim + 1), 1 do
I_coil = I_max * (n - 1) / N_sim
Once the value of the current is computed, the correspond circuits have to be
modified. The instructions that have to be used are
modifycircprop("CurrentPos", 1, I_coil)
modifycircprop("CurrentPos", 1, -I_coil)
3. to save in a temporary FEMM file, which becomes a copy of the original project
but with the modifications, and
openfemmfile("electromagnet.fem")
modifycircprop("CurrentPos", 1, I_coil)
modifycircprop("CurrentPos", 1, -I_coil)
savefemmfile("tempfile.fem ")
analyse()
8
Nicola Bianchi Using FEMM
2.3 Post–processing
The post–processing file contains the instructions that have to executed after the field
problem has been solved. This file can be called separately or can be launched by the
pre–processing, for instance when it is included within an analysis loop.
At first, the value of some parameters are assigned, e.g. the z–axis length and the
number of turns of the coil:
9
Nicola Bianchi Using FEMM
-- length (m)
L_z = 0.100
-- number of turns
N_t = 80
The first operation of the post–process is to read the data written in the temporary
file during the pre–processing.
Then, some operations are executed. The same conventions used in the pre–
processing have to be of course used. Some examples are reported hereafter.
Each operation is divided in two steps:
1. at first, an element (line, object, group) or a set of elements is selected,
2. an operation is executed referring to this element or this set of elements.
In the following example, the line on the top of the moving keeper is selected by
means of the two extremes of the line. Then the computation of the force along the
line is required. Fcx and Fcy are the constant component of the force along the x
and y directions respectively, while Fpx and Fpy are the pulsating force components
along the x and y directions respectively. The latter components are equal to zero in
magneto–static problems.
seteditmode(contour)
selectpoint(-60, -10)
selectpoint( 60, -10)
F_cx, F_px, F_cy, F_py = lineintegral(3)
Alternatively, the moving iron keeper could be selected by means of its group
number 10, and the force components are achieved from the Maxwell stress tensor:
groupselectblock(10)
F_cx = blockintegral(18)
F_cy = blockintegral(19)
F_px = blockintegral(20)
F_py = blockintegral(21)
In the following example, the flux linkage with the coil is computed. The two
coils can be selected by means their group number (1001 and 1002 for the upper
and the lower coil side respectively). The coil side surface is firstly computed. Then
the magnetic potential is integrated over the two surfaces, and the flux linkage is
computed from their difference.
10
Nicola Bianchi Using FEMM
-- surface
groupselectblock(1001)
Sup = blockintegral(5)
clearblock()
-- integral of Az
groupselectblock(1001)
intg_Are_1, intg_Aim_1 = blockintegral(1)
clearblock()
groupselectblock(1002)
intg_Are_2, intg_Aim_2 = blockintegral(1)
clearblock()
-- flux linkage
flux_re_1 = (intg_Are_1 / Sup) * L_z * N_t
flux_im_1 = (intg_Aim_1 / Sup) * L_z * N_t
flux_re_2 = (intg_Are_2 / Sup) * L_z * N_t
flux_im_2 = (intg_Aim_2 / Sup) * L_z * N_t
In order to compute the magnetic energy all the elements of the domain are se-
lected. No number is specified in the command groupselectblock() so as all blocks
are selected. Then, magnetic energy density, magnetic coenergy density and the prod-
uct A · J are integrated.
groupselectblock()
Energy = blockintegral(2)
Coenergy = blockintegral(17)
AJ_intgr = blockintegral(0)
Once the computation is finished, the results have to be stored into a file. The
file ”results.txt” is open to append (note the command ”a”) the results of the com-
putation. In the example hereafter the values are written on the same row, spaced by
some blank spaces, followed by a line end command (”\n”).
11
Nicola Bianchi Using FEMM
"\n")
closefile(handle)
exitpost()
Figure 9: Actuator
The pre–processing is
PRE_ATT.LUA
-- Current density is defined
jm=3
handle = openfile("result.txt", "a");
write(handle, jm, " ");
12
Nicola Bianchi Using FEMM
closefile(handle)
-- Loop of simulations varying the air--gap thickness
-- dz is the variation with respect to the initial position
for dz = 0,-0.6,-0.2 do
-- Its value is stored in the result file
handle = openfile("result.txt", "a");
write(handle, dz, " ");
closefile(handle)
-- The actuator structure is loaded
open_femm_file("actuator.fem")
-- The current density is assigned to the coil
modifymaterial("Copper", 4, jm)
-- Mover (group=1) is selected and moved
selectgroup(1)
move_translate(0, dz)
-- The changed structure is save in a temporary file
save_femm_file("temp.fem")
-- Solving the problem
analyse(1) -- (0) show window
-- (1) hide window
-- Post-processing
runpost("post_att.lua", "-windowhide")
end
The post–processing is
POST_ATT.LUA
-- selection of the line to integrate the flux density
seteditmode(contour)
selectpoint(0,10.5)
selectpoint(3,10.5)
Flux, B_avg = lineintegral(1)
-- unselection
clearcontour()
-- Data storage
handle = openfile("result.txt", "a");
write(handle, Flux, " ",
B_avg, "\n")
closefile(handle)
-- post-processing end
exitpost()
13
Nicola Bianchi Using FEMM
4 Useful functions
4.1 Mathematic functions
sin(x) Sine of x
cos(x) Cosine of x
tan(x) Tangent of x
asin(x) Inverse sine of x [−π/2, π/2], x ² [−1, 1]
acos(x) Inverse cosine of x [0, π], x ² [−1, 1]
atan(x) Inverse tangent of x [−π/2, π/2]
atan2(x, y) Inverse tangent of x/y [−π, π]
sinh(x) Hyperbolic sine of x
cosh(x) Hyperbolic cosine of x
tanh(x) Hyperbolic tangent of x
esp(x) Exponential ex
log(x) Natural logarithm of x, with x¿0
log10 (x) Common (base 10) logarithm of x, with x¿0
pow(x, y) Power xy √
sqrt(x) Square root x
ceil(x) Round towards plus infinity of x
f loor(x) Round towards minus infinity of x
abs(x) Absolute value of x
4.2 Vectors
When a vector of numbers has to be defined, we can use the curly brackets. For
instance, a vector of three number is
14
Nicola Bianchi Using FEMM
Acknowledgment
This report has been possible thanks to contribution of many students and PhD stu-
dents of the Electric Drive Laboratory of the Department of Electrical Engineering,
University of Padova, Italy. In particular, the big work of PhD. Eng. Fabio Luise,
PhD. Eng. Giorgio Grezzani, Eng. Diego Bon and Eng. Michele Dai Prè is acknowl-
edged.
Contacts
Prof. Nicola Bianchi, Prof. Silverio Bolognani, Electric Drive Laboratory, Depart-
ment of Electrical Engineering, University of Padova, Via Gradenigo 6 A Padova,
Italy. Phone: +39 049 827 7500, Fax: +39 049 827 7599, email: [bianchi] [bolognani]
@die.unipd.it.
15