Finite Element Method Magnetics: User's Manual
Finite Element Method Magnetics: User's Manual
Version 4.2
Users Manual
October 25, 2015
David Meeker
[email protected]
Contents
1 Introduction
1.1 Overview . . . . . . . . . . . . . . . . . .
1.2 Relevant Partial Differential Equations . . .
1.2.1 Magnetostatic Problems . . . . . .
1.2.2 Time-Harmonic Magnetic Problems
1.2.3 Electrostatic Problems . . . . . . .
1.2.4 Heat Flow Problems . . . . . . . .
1.2.5 Current Flow Problems . . . . . . .
1.3 Boundary Conditions . . . . . . . . . . . .
1.3.1 Magnetic and Electrostatic BCs . .
1.3.2 Heat Flow BCs . . . . . . . . . . .
1.4 Finite Element Analysis . . . . . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
2 Interactive Shell
2.1 DXF Import/Export . . . . . . . . . . . . . . .
2.2 Magnetics Preprocessor . . . . . . . . . . . . .
2.2.1 Preprocessor Drawing Modes . . . . .
2.2.2 Keyboard and Mouse Commands . . .
2.2.3 View Manipulation . . . . . . . . . . .
2.2.4 Grid Manipulation . . . . . . . . . . .
2.2.5 Edit . . . . . . . . . . . . . . . . . . .
2.2.6 Problem Definition . . . . . . . . . . .
2.2.7 Definition of Properties . . . . . . . . .
2.2.8 Exterior Region . . . . . . . . . . . . .
2.2.9 Analysis Tasks . . . . . . . . . . . . .
2.3 Magnetics Postprocessor . . . . . . . . . . . .
2.3.1 Postprocessor modes . . . . . . . . . .
2.3.2 View and Grid Manipulation . . . . . .
2.3.3 Keyboard Commands . . . . . . . . . .
2.3.4 Mouse Actions . . . . . . . . . . . . .
2.3.5 Miscellaneous Useful View Commands
2.3.6 Contour Plot . . . . . . . . . . . . . .
2.3.7 Density Plot . . . . . . . . . . . . . . .
2.3.8 Vector Plots . . . . . . . . . . . . . . .
2.3.9 Line Plots . . . . . . . . . . . . . . . .
2
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.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
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
40
41
44
46
46
47
48
53
54
54
54
55
55
56
57
58
59
60
60
61
66
67
67
67
67
68
69
70
70
70
71
72
76
77
77
78
78
78
79
80
80
81
3 Lua Scripting
3.1 What Lua Scripting? . . . . . . . . . . . . .
3.2 Common Lua Command Set . . . . . . . . .
3.3 Magnetics Preprocessor Lua Command Set .
3.3.1 Object Add/Remove Commands . . .
3.3.2 Geometry Selection Commands . . .
3.3.3 Object Labeling Commands . . . . .
3.3.4 Problem Commands . . . . . . . . .
3.3.5 Mesh Commands . . . . . . . . . . .
3.3.6 Editing Commands . . . . . . . . . .
3.3.7 Zoom Commands . . . . . . . . . . .
3.3.8 View Commands . . . . . . . . . . .
3.3.9 Object Properties . . . . . . . . . . .
3.3.10 Miscellaneous . . . . . . . . . . . .
3.4 Magnetics Post Processor Command Set . . .
3.4.1 Data Extraction Commands . . . . .
3.4.2 Selection Commands . . . . . . . . .
3.4.3 Zoom Commands . . . . . . . . . . .
3.4.4 View Commands . . . . . . . . . . .
3.4.5 Miscellaneous . . . . . . . . . . . .
3.5 Electrostatics Preprocessor Lua Command Set
3.5.1 Object Add/Remove Commands . . .
3.5.2 Geometry Selection Commands . . .
3.5.3 Object Labeling Commands . . . . .
3.5.4 Problem Commands . . . . . . . . .
3.5.5 Mesh Commands . . . . . . . . . . .
3.5.6 Editing Commands . . . . . . . . . .
3.5.7 Zoom Commands . . . . . . . . . . .
3.5.8 View Commands . . . . . . . . . . .
3.5.9 Object Properties . . . . . . . . . . .
3.5.10 Miscellaneous . . . . . . . . . . . .
3.6 Electrostatics Post Processor Command Set .
3.6.1 Data Extraction Commands . . . . .
3.6.2 Selection Commands . . . . . . . . .
3.6.3 Zoom Commands . . . . . . . . . . .
3.6.4 View Commands . . . . . . . . . . .
3.6.5 Miscellaneous . . . . . . . . . . . .
3.7 Heat Flow Preprocessor Lua Command Set .
3.7.1 Object Add/Remove Commands . . .
3.7.2 Geometry Selection Commands . . .
3.7.3 Object Labeling Commands . . . . .
3.7.4 Problem Commands . . . . . . . . .
3.7.5 Mesh Commands . . . . . . . . . . .
3.7.6 Editing Commands . . . . . . . . . .
3.7.7 Zoom Commands . . . . . . . . . . .
4
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
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.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
117
117
119
120
121
122
123
123
125
125
126
126
127
128
128
128
130
130
130
132
133
134
136
137
137
139
4 Mathematica Interface
141
5 ActiveX Interface
143
6 Numerical Methods
6.1 Finite Element Formulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6.2 Linear Solvers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6.3 Field Smoothing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
144
144
144
145
A Appendix
A.1 Modeling Permanent Magnets . . . . . .
A.2 Bulk Lamination Modeling . . . . . . . .
A.3 Open Boundary Problems . . . . . . . . .
A.3.1 Truncation of Outer Boundaries .
A.3.2 Asymptotic Boundary Conditions
A.3.3 Kelvin Transformation . . . . . .
A.4 Nonlinear Time Harmonic Formulation .
149
149
152
155
155
155
158
160
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Chapter 1
Introduction
FEMM is a suite of programs for solving low frequency electromagnetic problems on two-dimensional
planar and axisymmetric domains. The program currently addresses linear/nonlinear magnetostatic problems, linear/nonlinear time harmonic magnetic problems, linear electrostatic problems,
and steady-state heat flow problems.
FEMM is divided into three parts:
Interactive shell (femm.exe). This program is a Multiple Document Interface pre-processor
and a post-processor for the various types of problems solved by FEMM. It contains a CADlike interface for laying out the geometry of the problem to be solved and for defining material properties and boundary conditions. Autocad DXF files can be imported to facilitate
the analysis of existing geometries. Field solutions can be displayed in the form of contour
and density plots. The program also allows the user to inspect the field at arbitrary points, as
well as evaluate a number of different integrals and plot various quantities of interest along
user-defined contours.
triangle.exe. Triangle breaks down the solution region into a large number of triangles,
a vital part of the finite element process. This program was written by Jonathan Shewchuk
and is available at www.cs.cmu.edu/ quake/triangle.html
Solvers (fkern.exe for magnetics; belasolv for electrostatics); hsolv for heat flow problems; and csolv for current flow problems.. Each solver takes a set of data files that describe
problem and solves the relevant partial differential equations to obtain values for the desired
field throughout the solution domain.
The Lua scripting language is integrated into the interactive shell. Unlike previous versions of
FEMM (i.e. v3.4 and lower), only one instance of Lua is running at any one time. This single
instance of Lua can both build and analyze a geometry and evaluate the post-processing results,
simplifying the creation of various sorts of batch runs.
In addition, all edit boxes in the user interface are parsed by Lua, allowing equations or mathematical expressions to be entered into any edit box in lieu of a numerical value. In any edit box in
FEMM, a selected piece of text can be evaluated by Lua via a selection on the right mouse button
menu.
The purpose of this document is to give a brief explanation of the kind of problems solved by
FEMM and to provide a fairly detailed documentation of the programs use.
6
1.1 Overview
The goal of this section is to give the user a brief description of the problems that FEMM solves.
This information is not really crucial if you are not particularly interested in the approach that
FEMM takes to formulating the problems. You can skip most of Overview, but take a look at
Section 1.3. This section contains some important pointers about assigning enough boundary
conditions to get a solvable problem.
Some familiarity with electromagnetism and Maxwells equations is assumed, since a review of
this material is beyond the scope of this manual. However, the author has found several references
that have proved useful in understanding the derivation and solution of Maxwells equations in
various situations. A very good introductory-level text for magnetic and electrostatic problems is
Plonuss Applied electromagnetics [1]. A good intermediate-level review of Maxwells equations,
as well as a useful analogy of magnetism to similar problems in other disciplines is contained
in Hooles Computer-aided analysis and design of electromagnetic devices [2]. For an advanced
treatment, the reader has no recourse but to refer to Jacksons Classical electrodynamics [3]. For
thermal problems, the author has found Whites Heat and mass tranfer [4] and Habermans Elementary applied partial differential equations [5] to be useful in understanding the derivation and
solution of steady-state temperature problems.
(1.1)
B = 0
(1.2)
(1.3)
If a material is nonlinear (e.g. saturating iron or alnico magnets), the permeability, is actually a
function of B:
B
(1.4)
=
H(B)
7
FEMM goes about finding a field that satisfies (1.1)-(1.3) via a magnetic vector potential approach. Flux density is written in terms of the vector potential, A, as:
B = A
Now, this definition of B always satisfies (1.2). Then, (1.1) can be rewritten as:
1
A = J
(B)
(1.5)
(1.6)
For a linear isotropic material (and assuming the Coulomb gauge, A = 0), eq. (1.6) reduces to:
1
2 A = J
(1.7)
FEMM retains the form of (1.6), so that magnetostatic problems with a nonlinear B-H relationship
can be solved.
In the general 3-D case, A is a vector with three components. However, in the 2-D planar and
axisymmetric cases, two of these three components are zero, leaving just the component in the out
of the page direction.
The advantage of using the vector potential formulation is that all the conditions to be satisfied have been combined into a single equation. If A is found, B and H can then be deduced by
differentiating A. The form of (1.6), an elliptic partial differential equation, arises in the study of
many different types of engineering phenomenon. There are a large number of tools that have been
developed over the years to solve this particular problem.
B
t
(1.9)
(1.10)
(1.11)
(1.12)
(B)
(1.13)
where Jsrc represents the applied currents sources. The V term is an additional voltage gradient
that, in 2-D problems, is constant over a conducting body. FEMM uses this voltage gradient in
some harmonic problems to enforce constraints on the current carried by conductive regions.
FEMM considers (1.13) for the case in which the field is oscillating at one fixed frequency. For
this case, a phasor transformation [2] yields a steady-state equation that is solved for the amplitude
and phase of A. This transformation is:
A = Re [a(cos t + j sint) =] = Re ae jwt
(1.14)
in which a is a complex number. Substituting into (1.13) and dividing out the complex exponential
term yields the equation that FEMM actually solves for harmonic magnetic problems:
1
a = ja + Jsrc V
(1.15)
e f f (B)
in which Jsrc represents the phasor transform of the applied current sources.
Strictly speaking, the permeability should be constant for harmonic problems. However,
FEMM retains a nonlinear relationship in the harmonic formulation, allowing the program to approximate the effects of saturation on the phase and amplitude of the fundamental of the field
distribution. The form of the BH curve is not exactly the same as in the DC case. Instead, effective permeability e f f is selected to give the correct amplitude of the fundamental component of
the waveform under sinusoidal excitation. There are a number of subtleties to the nonlinear time
harmonic formulationthis formulation is addressed in more detail in Appendix A.4.
FEMM also allows for the inclusion of complex and frequency-dependent permeability in time
harmonic problems. These features allow the program to model materials with thin laminations
and approximately model hysteresis effects.
(1.16)
E = 0
(1.17)
where represents charge density. The second is the differential form of Amperes loop law:
Displacement and field intensity are also related to one another via the constitutive relationship:
D = E
9
(1.18)
where is the electrical permittivity. Although some electrostatics problems might have a nonlinear
constitutive relationship between D and E, the program only considers linear problems.
To simplify the computation of fields which satisfy these conditions, the program employs the
electric scalar potential, V , defined by its relation to E as:
E = V
(1.19)
2V =
(1.20)
Because of the vector identity = 0 for any scalar , Amperes loop law is automatically
satisfied. Substituting into Gauss Law and applying the constitutive relationship yields the secondorder partial differential equation:
which applies over regions of homogeneous . The program solves (1.20) for voltage V over a
user-defined domain with user-defined sources and boundary conditions.
(1.21)
(1.22)
where k is the thermal conductivity. Thermal conductivity is often a weak function of temperature.
FEMM allows for the variation of conductivity as an arbitrary function of temperature.
Ultimately, one is generally interested in discerning the temperature, T , rather than the heat
flux density or temperature gradient. Temperature is related to the temperature gradient, G, by:
G = T
(1.23)
Substituting (1.23) into Gauss Law and applying the constitutive relationship yields the secondorder partial differential equation:
(kT ) = q
(1.24)
FEMM solves (1.24) for temperature T over a user-defined domain with user-defined heat sources
and boundary conditions.
10
(1.25)
B = 0
(1.26)
E = B
subject to the constitutive relations:
(1.27)
D =
(1.28)
J = E
(1.29)
D = E
(1.30)
(1.31)
By application of a standard vector identity, the left-hand side of (1.31) is zero, leading to:
J + D = 0
(1.32)
As before, we can assume an electric potential, V , that is related to field intensity, E, by:
E = V
(1.33)
Because the flux density, B, is assumed to be negligibly small, (1.26) and (1.27) are suitably satisfied by this choice of potential.
If a phasor transformation is again assumed, wherein differentiation with respect to time is
replaced by multiplication by j, the definition of voltage can be substituted into (1.32) to yield:
(( + j) V ) = 0
(1.34)
If it is assumed that the material properties are piece-wise continuous, things can be simplified
slightly to:
( + j) 2V = 0
(1.35)
FEMM solves (1.35) to analyze current flow problems.
Eq. (1.35) also applies for the solution of DC current flow problems. At zero frequency, the
term associated with electrical permittivity vanishes, leaving:
2V = 0
(1.36)
By simply specifing a zero frequency, this formulation solves DC current flow problems in a consistent fashion.
11
T
+ h (T To ) = 0
n
(1.38)
where h is the heat transfer coefficient and To is the ambient cooling fluid temperature.
Radiation Heat flux via radiation can be described mathematically as:
k
T
+ ksb T 4 To4 = 0
n
(1.39)
where beta is the emissivity of the surface (a dimensionless value between 0 and 1) and ksb
is the Stefan-Boltzmann constant.
Periodic A periodic boundary conditions joins two boundaries together. In this type of
boundary condition, the boundary values on corresponding points of the two boundaries
are set equal to one another.
Antiperiodic The antiperiodic boundary condition also joins to gether two boundaries. However, the boundary values are made to be of equal magnitude but opposite sign.
If no boundary conditions are explicitly defined, each boundary defaults an insulated condition
(i.e. no heat flux across the boundary). However, a non-derivative boundary condition must be
defined somewhere (or the potential must be defined at one reference point in the domain) so that
the problem has a unique solution.
13
14
Chapter 2
Interactive Shell
The FEMM Interactive Shell is currently broken into six major sections:
Magnetics Preprocessor
Electrostatics Preprocessor
Heat Flow Preprocessor
Magnetics Postprocessor
Electrostatics Postprocessor
Heat Flow Postprocessor
This section of the manual explains the functionality of each section in detail.
performed to turn the dxf file into a valid finite element geometry. For example, large dxf files
might take up to a minute or two to import.
The current femm geometry can be exported in dxf format by selecting the Export DXF option
off of the File menu in any preprocessor window. The dxf files generated from femm can then be
imported into CAD programs to aid in the mechanical detailing of a finalized design, or imported
into other finite element or boundary element programs.
Function
Edit the properties of selected point(s)
Display dialog for the numerical entry of coordinates for a new point
Unselect all points
Delete selected points
Key
Space
Escape
Delete
Key
Space
Tab
Escape
Delete
Function
Edit the properties of selected block labels(s)
Display dialog for the numerical entry of coordinates for a new label
Unselect all block labels
Delete selected block label(s)
Key
Space
Escape
Delete
18
Point Mode
Action
Left Button Click
Right Button Click
Right Button DblClick
Function
Create a new point at the current mouse pointer location
Select the nearest point
Display coordinates of the nearest point
Function
Create a new block label at the current mouse pointer location
Select the nearest block label
Display coordinates of the nearest block label
Group Mode
Action
Function
Right Button Click Select the group associated with the nearest object
Table 2.2: Magnetics Preprocessor Mouse button actions
The Status Bar selection can be used to hide or show the one-line status bar at the bottom
of the femm window. Generally, it is desirable for the toolbar to be displayed, since the current
location of the mouse pointer is displayed on the status line.
The Toolbar selection can be used to hide or show the toolbar buttons. The toolbar is not
fundamentally necessary to running femm, because any selection on the toolbar is also available
via selections off of the main menu. If more space on the screen is desired, this option can be
chosen to hide the toolbar. Selecting it a second time will show the toolbar again. It may be useful
to note that the toolbar can be undocked from the main screen and made to float at a user-defined
location on screen. This is done by pushing the left mouse button down on an area of the toolbar
that is not actually a button, and then dragging the toolbar to its desired location. The toolbar can
be docked again by moving it back to its original position.
buttons. These buttons are pictured in Figure 2.3. The left-most button in Figure 2.3 shows and
2.2.5 Edit
Several useful tasks can be performed via the Edit menu off of the main menu.
Perhaps the most frequently used is the Undo command. Choosing this selection undoes the
last addition or deletion that the user has made to the models geometry.
For selecting many objects quickly, the Select Group command is useful. This command
allows the user to select objects of the current type located in an arbitrary rectangular box. When
this command is selected, move the mouse pointer to one corner of the region that is to be selected.
Press and hold the left mouse button. Then, drag the mouse pointer to the opposite diagonal
corner of the region. A red box will appear, outlining the region to be selected. When the desired
region has been specified, release the left mouse button. All objects of the current type completely
contained within the box will become selected.
Any objects that are currently selected can be moved, copied, or pasted. To move or copy
selected objects, simply choose the corresponding selection off of the main menus Edit menu. A
dialog will appear prompting for an amount of displacement or rotation.
20
21
The third edit box is the Solver Precision edit box. The number in this edit box specifies
the stopping criteria for the linear solver. The linear algebra problem could be represented by:
Mx = b
where M is a square matrix, b is a vector, and x is a vector of unknowns to be determined. The
solver precision value determines the maximum allowable value for ||b Mx||/||b||. The default
value is 108 .
The fourth edit box is labeled Min Angle. The entry in this box is used as a constraint in
the Triangle meshing program. Triangle adds points to the mesh to ensure that no angles smaller
than the specified angle occur. If the minimum angle is 20.7 degrees or smaller, the triangulation
algorithm is theoretically guaranteed to terminate (assuming infinite precision arithmetic Triangle
may fail to terminate if you run out of precision). In practice, the algorithm often succeeds for
minimum angles up to 33.8 degrees. For highly refined meshes, however, it may be necessary
to reduce the minimum angle to well below 20 to avoid problems associated with insufficient
floating-point precision. The edit box will accept values between 1 and 33.8 degrees.
Lastly, there is an optional Comment edit box. The user can enter in a few lines of text that give
a brief description of the problem that is being solved. This is useful if the user is running several
small variations on a given geometry. The comment can then be used to identify the relevant
features for a particular geometry.
yet been defined. Pushing the Add Property button allows the user to define a new property
type. The Delete Property button removes the definition of the property currently in view in the
Property Name box. The Modify Property button allows the user to view and edit the property
currently selected in the Property Name box. Specifics for defining the various property types are
addressed in the following subsections.
In general, a number of these edit boxes prompt the user for both real and imaginary components for entered values. If the problem you are defining is magnetostatic (zero frequency), enter
the desired value in the box for the real component, and leave a zero in the box for the imaginary
component. The reason that femm uses this formalism is to obtain a relatively smooth transition
from static to time-harmonic problems. Consider the definition of the Phasor transformation in
Eq. 1.14. The phasor transformation assumes that all field values oscillate in time at a frequence
of . The phasor transformation takes the cosine part of the field value and represents it as the real
part of a complex number. The imaginary part represents the magnitude of the sine component,
90o out of phase. Note what happens as the frequency goes to zero:
lim (are cos t aim sin t) = are
(2.1)
Therefore, the magnetostatic ( = 0) values are just described by the real part the specified complex
number.
Point Properties
If a new point property is added or an existing point property modified, the Nodal Property
dialog box appears. This dialog box is pictured in Figure 2.7
The first selection is the Name edit box. The default name is New Point Property, but this
name should be changed to something that describes the property that you are defining.
Next are edit boxes for defining the vector potential, A, at a given point, or prescribing a point
current, J, at a given point. The two definitions are mutually exclusive. Therefore, if there is a
nonzero value the J box, the program assumes that a point current is being defined. Otherwise, it
is assumed that a point vector potential is being defined.
There is an edit box for vector point vector potential, A. A can be defined as a complex value,
if desired. The units of A are Weber/Meter. Typically, A needs to be defined as some particular
values (usually zero) at some point in the solution domain for problems with derivative boundary
conditions on all sides. This is the typical use of defining a point vector potential.
Lastly, there is an edit box for the definition of a point current, J. The units for the point current
are in Amperes. The value of J can be defined as complex, if desired.
Boundary Properties
The Boundary Property dialog box is used to specify the properties of line segments or arc
segments that are to be boundaries of the solution domain. When a new boundary property is
added or an existing property modified, the Boundary Property dialog pictured in Figure 2.8
appears.
The first selection in the dialog is the Name of the property. The default name is New Boundary, but you should change this name to something more descriptive of the boundary that is being
defined.
23
(2.3)
Small Skin Depth This boundary condition denotes an interface with a material subject
to eddy currents at high enough frequencies such that the skin depth in the material is very
small. A good discussion of the derivation of this type of boundary condition is contained in
[2]. The result is a Robin boundary condition with complex coefficients of the form:
1+ j
A
A=0
(2.4)
+
n
24
(2.6)
The parameters for this class of boundary condition are specified in the Mixed BC parameters
box in the dialog. By the choice of coefficients, this boundary condition can either be a Robin
or a Neumann boundary condition. There are two main uses of this boundary condition:
1. By carefully selecting the c0 coefficient and specifying c1 = 0, this boundary condition can be applied to the outer boundary of your geometry to approximate an upbounded solution region. For more information on open boundary problems, refer to
Appendix A.3.
25
2. The Mixed boundary condition can used to set the field intensity, H, that flows parallel
to a boundary. This is done by setting c0 to zero, and c1 to the desired value of H in
units of Amp/Meter. Note that this boundary condition can also be used to prescribe
A/n = 0 at the boundary. However, this is unnecessarythe 1st order triangle finite
elements give a A/n = 0 boundary condition by default.
Strategic Dual Image This is sort of an experimental boundary condition that I have
found useful for my own purposes from time to time. This boundary condition mimics
an open boundary by solving the problem twice: once with a homogeneous Dirichlet
boundary condition on the SDI boundary, and once with a homogeneous Neumann condition
on the SDI boundary. The results from each run are then averaged to get the open boundary
result. This boundary condition should only be applied to the outer boundary of a circular
domain in 2-D planar problems. Through a method-of-images argument, it can be shown
that this approach yields the correct open-boundary result for problems with no iron (i.e just
currents or linear magnets with unit permeability in the solution region).
Periodic This type of boundary condition is applied to either two segments or two arcs to
force the magnetic vector potential to be identical along each boundary. This sort of boundary is useful in exploiting the symmetry inherent in some problems to reduce the size of
the domain which must be modeled. The domain merely needs to be periodic, as opposed to
obeying more restrictive A = 0 or A/n = 0 line of symmetry conditions. Another useful application of periodic boundary conditions is for the modeling of open boundary problems,
as discussed in Appendix A.3.3. Often, a periodic boundary is made up of several different
line or arc segments. A different periodic condition must be defined for each section of the
boundary, since each periodic BC can only be applied to a line or arc and a corresponding
line or arc on the remote periodic boundary.
Antiperiodic The antiperiodic boundary condition is applied in a similar way as the periodic boundary condition, but its effect is to force two boundaries to be the negative of one
another. This type of boundary is also typically used to reduce the domain which must be
modeled, e.g. so that an electric machine might be modeled for the purposes of a finite
element analysis with just one pole.
Materials Properties
The Block Property dialog box is used to specify the properties to be associated with block labels. The properties specified in this dialog have to do with the material that the block is composed
of, as well as some attributes about how the material is put together (laminated). When a new
material property is added or an existing property modified, the Block Property dialog pictured
in Figure 2.9 appears.
As with Point and Boundary properties, the first step is to choose a descriptive name for the
material that is being described. Enter it in the Name edit box in lieu of New Material.
Next decide whether the material will have a linear or nonlinear B-H curve by selecting the
appropriate entry in the B-H Curve drop list.
If Linear B-H Relationship was selected from the drop list, the next group of Linear
Material Properties parameters will become enabled. FEMM allows you to specify different
26
27
relative permeabilities in the vertical and horizontal directions (x for the x- or horizontal direction,
and y for the y- or vertical direction).
There are also boxes for hx and hy , which denote the hysteresis lag angle corresponding to
each direction, to be used in cases in which linear material properties have been specified. A
simple, but surprisingly effective, model for hysteresis in harmonic problems is to assume that
hysteresis creates a constant phase lag between B and H that is independent of frequency. This is
exactly the same as assuming that hysteresis loop has an elliptical shape. Since the hysteresis loop
is not exactly elliptical, the perceived hysteresis angle will vary somewhat for different amplitudes
of excitation. The hysteresis angle is typically not a parameter that appears on manufacturers
data sheets; you have to identify it yourself from a frequency sweep on a toroidal coil with a core
composed of the material of interest. For most laminated steels, the hysteresis angle lies between 0o
and 20o [6]. This same reference also has a very good discussion of the derivation and application
of the fixed phase lag model of hysteresis.
If Nonlinear B-H Curve was selected from the drop list, the Nonlinear Material Properties
parameter group becomes enabled. To enter in points on your B-H curve, hit the Edit B-H Curve
button. When the button is pushed a dialog appears that allows you to enter in B-H data (see Figure 2.10. The information to be entered in these dialogs is usually obtained by picking points off of
B (flux density) column as in the H (field intensity) column. To define a nonlinear material,
you must enter at least three points, and you should enter ten or fifteen to get a good fit.
After you are done entering in your B-H data points, it is a good idea to view the B-H curve to
see that it looks like it is supposed to. This is done by pressing the Plot B-H Curve button or
the Log Plot B-H Curve button on the B-H data dialog. You should see a B-H curve that looks
something like the curve pictured in Figure 2.11. The boxes in the plot represent the locations of
30
conductor of interest and achieve similar results. For eddy current problems, however, the circuit
properties are much more usefulthey allow the user to define the current directly, and they allow
the user to assign a particular connectivity to various regions of the geometry. This information is
used to obtain impedance, flux linkage, etc., in a relatively painless way in the postprocessor.
By applying circuit properties, one can also enforce connectivity in eddy current problems.
By default, all objects in eddy current problems are shorted together at infinitythat is, there
is nothing to stop induced currents from returning in other sections of the domain that might not
be intended to be physically connected. By applying a parallel-connected circuit with a zero net
current density constraint to each physical part in the geometry, the connectivity of each part is
enforced and all is forced to be conserved inside the part of interest.
The dialog for entering circuit properties is pictured in Figure 2.14.
Specifically, there are three parametes that are collected in the dialog that appears when the
user selects the External Region properties. These are:
Center of Exterior Region The location along the z-axis of the axisymmetric problem
where the center of the block representing the external region is located.
Radius of Exterior Region Radius of the sphere representing the exterior region.
Radius of Interior Region Radious of the spehre representing the interior region (i.e.
the region in which the items of interest are located).
To finish defining the axisymmetric external region, the Block located in an external
region check box must be selected in any block labels that are located in the region that is desired
to be the axisymmetric external region.
as compared to a magnetostatic problem with the same mesh. The slowest problems to analyze
are nonlinear time-harmonic problems, since multiple successive approximation iterations must be
used to converge on the final solution. However, nonlinear problems almost never take more than
10 iterations. Later iterations in nonlinear problems are usually are quite fast compared to the first
iteration or two because the later iterations can be initialized with an approximate solution that is
very close to the actual solution.
For users who have a technical interest in what is under the hood in fkern, some details are
provided in the Appendix (Section 6).
The big magnifying glass icon is used to display the results in a postprocessing window
once the analysis is finished. A detailed description of the magnetics postprocessor addressed in
Section 2.3.
appears as a green line on the postprocessor screen. When the ends of the contour meet, the block
is defined. All elements enclosed by the contour (all elements that form the block) then turn green
in the postprocessor window.
A Left Button Click attempts to add the nearest Point in the input geometry to the Blocks contour. However, a block can only be defined along line and arc segments from the input geometry.
Each node on the boundary of the block must be selected in order to form the Block boundary. In
Block mode, the Right mouse button has no function.
Figure 2.20: Line Plot, Integration, and Circuit Results toolbar buttons
In the contour plot dialog, a check box is also present titled Show stress tensor mask. If this
box is checked, the contour lines associated with the last Weighted Stress Tensor integration are
also displayed, by default as orange flux lines.
39
Figure 2.22: When in doubt plots and integrals taken on this side of a contour.
Force from stress tensor. This integral totals the force produced on the contour derived from Maxwells stress tensor. Deriving meaningful force results requires some care in
the choice of integration path; refer to Section 2.3.12 for a detailed discussion of force and
torque calculation.
Torque from stress tensor. This selection integrates the torque about the point (0,0)
inferred from Maxwells stress tensor. Again, some guidelines must be followed to get
accurate torque results (see Section 2.3.12).
B.n2. This selection evaluates the integral of the square of the normal flux along the line.
This integral is not so commonly used, but it has been useful in the past for some specialized
purposes, like determining the RMS amplitude of a periodic flux distribution.
A.J This integral is the evaluation of A JdV that is usually used evaluate inductance for
linear problems. Generally, the self-inductance of a coil is:
Lsel f =
A JdV
i2
(2.8)
A This integral, the evaluation of AdV , can be used to evaluate mutual inductances between
coils. Similar to the formula for self inductance, mutual inductance is:
Lmutual =
A1 J2 dV2
i1 i2
(2.9)
where A1 is the component of A produced by the first coil, J2 is the current in the second
coil, and i1 and i2 are the current in the first and second coils, respectively. dV2 is meant to
denote that the integral is taken over the volume of the second coil. We can rearrange (2.9)
into a somewhat simpler form by noting that n2 i2 = J2 a2 . That is, the total amps times
turns for the second coil equals the current density in the second coil times the second coils
cross-section area. Substituting for J2 in (2.9) yields:
Z
Z
n2
Lmutual =
A1 dV2
A1 dV2
(2.10)
i1 a2 J2+
J2
41
where the first bracketed term in (2.10) is the contribution from the turns of coil 2 that are
pointed out of the page and the second term is the contribution from the turns of coil 2 that
are pointed into the page. To evaluate mutual inductance with FEMM, one substitutes values
into (2.10). First, run the model with only coil 1 turned on. Then, integrate A over the
volume in which the second coil lies (although the second coil is not turned on). For planar
problems, you will typically have to make two separate integrationsone over the region
where the turns in coil 2 are pointed out of the page (i.e. that part of the coil in which
a positive current results in current flowing in the out-of-the-page direction), and one over
the region in which the turns in coil 2 are pointed into the page. Add these two results
together to get the total A1 dV2 integral. Lastly, multiply the integral result times n2 /(i1a2 ) to
get mutual inductance.
Magnetic field energy This selection calculates the energy stored in the magnetic field
in the specified region. This integral can be used as an alternate method of getting inductance
for problems that are linear (at least not heavily saturated). Denoting E as the energy stored
in the magnetic field, inductance can be obtained by solving the formula:
E=
Li2
2
W =
H(B )dB dV
(2.11)
(2.12)
(2.13)
Wc =
B(H )dH dV
0
Coenergy can be used in an alternative method of force and torque computation. To compute
force via coenergy, currents are held constant, and the position of the object upon which the
force is desired is perturbed slightly. The force can then be estimated by:
F=
Wc (p + ) Wc (p)
(2.14)
where p denotes the initial position, p + denotes the perturbed position, and is the magnitude of the perturbation. The component of force determined in this way acts along the
direction of the perturbationone has to perform two such operations to get both horizontal
and vertical components of the force.
Hyst. and/or Laminated eddy current losses. This selection is typically used to
obtain the core losses produced in laminated iron sections in harmonic problems.
Resistive losses This selection integrates the i2 R losses due to currents flowing in the
z direction (or direction, if you are evaluating an axisymmetric problem).
42
43
(2.16)
where n denotes the direction normal to the surface at the point of interest. The net force on an
object is obtained by creating a surface totally enclosing the object of interest and integrating the
magnetic stress over that surface.
44
While an integration of (2.16) theoretically gives the magnetic force on an object, numerical
problems arise when trying to evaluate this integral on a finite element mesh made of first-order
triangles. Though the solution for vector potential A is relatively accurate, the distributions of B
and H are an order less accurate, since these quantities are obtained by differentiating the trial
functions for A. That is, A is described by a linear function over each element, but B and H are
piece-wise constant over each element. Errors in B and H can be particularly large in elements in
which the exact solution for B and H changes rapidlythese areas are just not well approximated
by a piece-wise approximation. Specifically, large errors can arise in the tangential components
of B and H in elements adjacent to boundaries between materials of different permeabilites. The
worst errors arise on this sort of interface at corners, where the exact solution for B is nearly a
singularity.
If the stress tensor integral is evaluated on the interface between two different materials, the
results will be particularly erroneous. However, the stress tensor has the property that, for an
exact solution, the same result is obtained regardless of the path of integration, as long as that path
encircles the body of interest and passes only through air (or at least, every point in the contour
is in a region with a constant permeability). This implies that the stress tensor can be evaluated
over a contour a few elements away from the surface of an objectwhere the solution for B and
H is much more accurate. Much more accurate force results will be obtained by integrating along
the contour a few elements removed from any boundary or interface. The above discussion is the
rationale for the first guideline for obtaining forces via stress tensor:
Never integrate stress stress tensor along an interface between materials. Always define the integration contour as a closed path around the object of interest with the
contour displaced several elements (at least two elements) away from any interfaces
or boundaries.
As an example of a properly defined contour, consider Figure 2.23. This figure represents a
horseshoe magnet acting on a block of iron. The objective is to obtain the magnetic forces acting
upon the iron block. The red line in the figure represents the contour defined for the integration.
The contour was defined running clockwise around the block, so that the normal to the contour
points outward. Always define your contour in a clockwise direction to get the correct sign. Note
that the contour is well removed from the surface of the block, and the contour only passes through
air. To aid in the definition of a closed contour, grid and the snap to grid were turned on, and the
corners of the contour are grid points that were specified by right mouse button clicks.
The second rule of getting good force results is:
Always use as fine a mesh as possible in problems where force results are desired.
Even though an integration path has been chosen properly (away from boundaries and interfaces),
some significant error can still arise if a coarse mesh is used. Note that (2.16) is composed of B2
terms this means that stress tensor is one order worse in accuracy than B. The only way to get
that accuracy back is to use a fine mesh density. A good way to proceed in finding a mesh that is
dense enough is to solve the problem on progressively finer meshes, evaluating the force on each
mesh. By comparing the results from different mesh densities, you can get and idea of the level
of accuracy (by looking at what digits in the answer that change between various mesh densities).
You then pick the smallest mesh density that gives convergence to the desired digit of accuracy.
45
Figure 2.23: Properly defined contour for integration of Maxwells Stress Tensor
For torque computations, all the same rules apply as for force computations (i.e. define integration contours away from boundaries and interfaces, and use a dense mesh).
46
(2.17)
47
Next are edit boxes for defining the voltage at a given point, or prescribing a point charge
density at a given point. The type of point property is chosen via the radio buttons, and the value
is entered in the enabled edit box.
Boundary Properties
The Boundary Property dialog box is used to specify the properties of line segments or arc
segments that are to be boundaries of the solution domain. When a new boundary property is
added or an existing property modified, the Boundary Property dialog pictured in Figure 2.28
appears.
50
an unbounded solution region. For more information on open boundary problems, refer to the
Appendix.
Surface Charge Density This selection is used to apply distributions of line charge to segments or arc segments in the problem. Unlike all of the other boundary conditions, this BC type is
often used on internal boundaries between materials or on isolated segments. Typically, other BCs
are only used on exterior boundaries.
Periodic This type of boundary condition is applied to either two segments or two arcs to force
the potential to be identical along each boundary. This sort of boundary is useful in exploiting the
symmetry inherent in some problems to reduce the size of the domain which must be modeled. The
domain merely needs to be periodic, as opposed to obeying more restrictive V = 0 or V /n = 0
line of symmetry conditions. Another useful application of periodic boundary conditions is for the
modeling of open boundary problems, as discussed in Appendix 3. Often, a periodic boundary
is made up of several different line or arc segments. A different periodic condition must be defined
for each section of the boundary, since each periodic BC can only be applied to a line or arc and a
corresponding line or arc on the remote periodic boundary.
Antiperiodic The antiperiodic boundary condition is applied in a similar way as the periodic
boundary condition, but its effect is to force two boundaries to be the negative of one another. This
type of boundary is also typically used to reduce the domain which must be modeled, e.g. so that
an electric machine might be modeled for the purposes of a finite element analysis with just one
pole.
Materials Properties
The Block Property dialog box is used to specify the properties to be associated with block
labels. The properties specified in this dialog have to do with the material of which the block is
composed. When a new material property is added or an existing property modified, the Block
Property dialog pictured in Figure 2.29 appears.
Next, permittivity for the material needs to be specified. FEMM allows you to specify different
relative permittivities in the vertical and horizontal directions (x for the x- or horizontal direction,
and y for the y- or vertical .
A volume charge density () can also be prescribed by filling in the appropriate box in the
material properties dialog.
Materials Library
Since one kind of material might be needed in several different models, FEMM has a built-in library of electrostatic Block Property definitions. The user can access and maintain this library
through the Properties | Materials Library selection off of the main menu. When this option is selected, the Materials Library dialog pictured in Figure 2.30 appears.
For fixed voltages, one could alternatively apply a Fixed Voltage boundary condition. However, applying a fixed voltage as a conductor allows the user to group together several physically
disjoint surfaces into one conductor upon which the total net charge is automatically computed.
The dialog for entering conductor properties is pictured in Figure 2.31.
finished analyzing your problem, the console window will disappear. The time that Belasolve
requires is highly dependent on the problem being solved. Solution times are typically on the
order of 1 to 10 seconds, depending upon the size and complexity of the problem and the speed of
the machine analyzing the problem.
The big magnifying glass icon is used to run the postprocessor once the analysis is finished.
54
Figure 2.34: Line Plot, Integration, and Conductor Results toolbar buttons.
When this button is pressed, the X-Y Plot dialog (see Figure 2.35) appears with a drop list
containing the types of line plots available. Choose the desired type of plot and press OK.
data is written in two-column text format. If Write data to text file is selected, a femmplot
window will not appear.
Currently, the type of line plots supported are: Potential along the contour; Magnitude of the
flux density along the contour; Component of flux density normal to the contour; Component of
flux density tangential to the contour; Magnitude of the field intensity along the contour; Component of field intensity normal to the contour; Component of field intensity tangential to the contour;
In all of these plots, the direction of the normal is understood to be as shown in Figure 2.36.
The tangential direction is understood to be the direction in which the contour was defined.
Figure 2.36: When in doubt plots and integrals taken on this side of a contour.
In certain cases, the quantity to be plotted can be ambiguous. This can occur, for example, if a
plot of the tangential field intensity is requested on a contour running along an interface between
two materials of differing permittivity. In this case, there is a discontinuity in the tangential field
intensity, and the value of this quantity is different on each side of the interface. The postprocessor
resolves the conflict by always evaluating the plots at a differentially small distance to the normal
side of the line. Therefore, by defining the same contour but reversing the order in which the points
are specified, plots of the quantity of interest on each side of a boundary can be obtained.
some types of integrals; however, some types may require several seconds to evaluate. When the
evaluation of the integral is completed, the answer appears on the screen in a pop-up box.
The line integrals currently supported are:
E.t This integral returns the voltage drop along the defined contour
D.n. This integral returns the total electrix flux passing through a volume defined by extruding or sweeping the defined contour. If this integral is performed over a closed contour, the
resulting quantity is equal to the charge contained inside the contour.
Contour Length/Area. This integral returns the length of the defined contour in meters, as
well as the area of the extruded or swept volume associated with the defined contour.
Force from stress tensor. This integral totals the force produced on the contour derived from Maxwells stress tensor. Deriving meaningful force results requires some care in
the choice of integration path; refer to Section 2.5.7 for a detailed discussion of force and
torque calculation.
Torque from stress tensor. This selection integrates the torque about the point (0,0)
inferred from Maxwells stress tensor. Again, some guidelines must be followed to get
accurate torque results.
Force via Weighted Stress Tensor The Weighted Stress Tensor block integrals automatically compute a weighting function over the finite element mesh that allows all possible
air elements to contribute to the stress tensor integration. This approach is similar to the
weighted stress tensor approach described in [7] and/or [8]. To compute the force on a region or set of regions, the user selects the blocks upon which force result is desired and
selects the Force via Weighted Stress Tensor integral. The program then computes
the weighting function by solving an additional Laplace equation over the air surrounding
the blocks upon which the force is to be computed. It may take a few seconds to compute
the weighting functionprogress is be indicated by a progress bar that is displayed while
the weighting function is being computed. The stress tensor is then evaluated as a volume
integration, and the results are displayed. The results are typically more accurate than the
Maxwell Stress Tensor line integral, since in some sense, all possible contours have been
averaged to yield the Weighted Stress Tensor force result.
If the user is interested in the contours along which the integral was performed, the stress
tensor mask box can be checked in the contour plot dialog. A set of orange (by default)
lines will be displayed that.
Torque via Weighted Stress Tensor This integral is torque version of the Force via
Weighted Stress Tensor integral. Instead of force, torque about (0,0) is computed using
the same weighting function approach.
1
(D (E n) + E (D n) (D E) n)
(2.19)
2
where n denotes the direction normal to the surface at the point of interest. The net force on an
object is obtained by creating a surface totally enclosing the object of interest and integrating the
stress over that surface.
For best results, never integrate the stress tensor along an interface between materials. Always define the integration contour as a closed path around the object of interest with the contour
displaced several elements (at least two elements) away from any interfaces or boundaries.
Always use as fine a mesh as possible in problems where force results are desired. A good
way to proceed in finding a mesh that is dense enough is to solve the problem on progressively
finer meshes, evaluating the force on each mesh. By comparing the results from different mesh
densities, you can get and idea of the level of accuracy (by looking at what digits in the answer
that change between various mesh densities). You then pick the smallest mesh density that gives
convergence to the desired digit of accuracy.
For torque computations, all the same rules apply as for force computations (i.e. define integration contours away from boundaries and interfaces, and use a dense mesh).
dF =
59
The second edit box is the Solver Precision edit box. The number in this edit box specifies
the stopping criteria for the linear solver. The linear algebra problem could be represented by:
Mx = b
(2.20)
61
This dialog is the manager for a particular type of properties. All currently defined properties
are displayed in the Property Name drop list at the top of the dialog. At the beginning of a new
model definition, the box will be blank, since no properties have yet been defined. Pushing the Add
Property button allows the user to define a new property type. The Delete Property button
removes the definition of the property currently in view in the Property Name box. The Modify
Property button allows the user to view and edit the property currently selected in the Property
Name box. Specifics for defining the various property types are addressed in the following subsections.
Point Properties
If a new point property is added or an existing point property modified, the Nodal Property
dialog box appears. This dialog box is pictured in Figure 2.40.
62
63
65
66
67
Figure 2.47: Line Plot, Integration, and Conductor Results toolbar buttons.
When this button is pressed, the X-Y Plot dialog (see Figure 2.48) appears with a drop list
containing the types of line plots available. Choose the desired type of plot and press OK.
Figure 2.49: When in doubt plots and integrals taken on this side of a contour.
In certain cases, the quantity to be plotted can be ambiguous. This can occur, for example, if a
plot of the tangential field intensity is requested on a contour running along an interface between
two materials of differing permittivity. In this case, there is a discontinuity in the tangential field
intensity, and the value of this quantity is different on each side of the interface. The postprocessor
resolves the conflict by always evaluating the plots at a differentially small distance to the normal
side of the line. Therefore, by defining the same contour but reversing the order in which the points
are specified, plots of the quantity of interest on each side of a boundary can be obtained.
Contour length & area. The length of the contour, and the area formed by extruding the
contour.
Average temperature. The average temperature along the line.
70
(2.21)
72
Materials Properties
The Block Property dialog box is used to specify the properties to be associated with block
labels. The properties specified in this dialog have to do with the material of which the block is
composed. When a new material property is added or an existing property modified, the Block
Property dialog pictured in Figure 2.55 appears.
loss tangent =
75
sin
cos
(2.23)
For material that are also conductive, FEMM combines the defined conductivity, permittivity,
and loss tangent to obtain the complex-valued effective electrical conductivities:
x,e f f = x + jo x e j
(2.24)
y,e f f = y + jo y e
which takes into account resistive losses and addition dielectric losses due to the definition of a
non-zero loss tangent.
Conductor Properties
The purpose of the conductor properties is mainly to allow the user to apply constraints on the total
amount of current flowing in and out of a surface. Alternatively, conductors with a fixed voltage
can be defined, and the program will compute the total current flow through the during the solution
process.
For fixed voltages, one could alternatively apply a Fixed Voltage boundary condition. However, applying a fixed voltage as a conductor allows the user to group together several physically
disjoint surfaces into one conductor upon which the total current flow is automatically computed.
The dialog for entering conductor properties is pictured in Figure 2.56.
never have to call the mesher from within FEMM. However, it is almost always important to get
a look at the mesh and see that it looks right. When the mesh generation button is pressed,
the mesher is called. While the mesher is running, an entry labeled triangle will appear on
the Windows taskbar. After the geometry is triangulated, the finite element mesh is loaded into
memory and displayed underneath the defined nodes, segments, and block labels as a set of yellow
lines.
If you have a very large model, just keeping all of the mesh information in core can take up a
significant amount of memory. If you are about to analyze a very large problem, it might be a good
idea to choose the Mesh | Purge Mesh option off of the main menu. When this option is selected,
the mesh is removed from memory, and the memory that it occupied is freed for other uses.
The second button, with the hand-crank icon, executes the solver, csolv.exe. Before csolv
is actually run, the Triangle is called to make sure the mesh is up to date. Then, csolv is called.
When csolv runs, it opens up a console window to display status information to the user. However, csolv requires no user interaction while it is running. When csolv is finished analyzing your
problem, the console window will disappear. The time that csolv requires is highly dependent on
the problem being solved. Solution times are typically on the order of 1 to 10 seconds, depending
upon the size and complexity of the problem and the speed of the machine analyzing the problem.
The big magnifying glass icon is used to run the postprocessor once the analysis is finished.
77
Figure 2.59: Line Plot, Integration, and Conductor Results toolbar buttons.
When this button is pressed, the X-Y Plot dialog (see Figure 2.60) appears with a drop list
containing the types of line plots available. Choose the desired type of plot and press OK.
After OK is pressed, the program computes the desired values along the defined contour.
When computation of the values is finished, a plot window will appear with a graph of the selected
quantity. the plot.
By default, the Write data to text file box is not checked. If the user selects this option,
the file selection dialog will appear and prompt for a filename to which to write the data. The data
is written in two-column text format. If Write data to text file is selected, a plot window
will not appear.
Currently, the type of line plots supported are:
V Voltage
|J| Magnitude of current density
J.n Normal current density
78
80
81
Chapter 3
Lua Scripting
3.1 What Lua Scripting?
The Lua extension language has been used to add scripting/batch processing facilities to FEMM.
The Interactive Shell can run Lua scripts through the Open Lua Script selection on the Files
menu, or Lua commands can be entered in directly to the Lua Console Window.
Lua is a complete, open-source scripting language. Source code for Lua, in addition to detailed documentation about programming in Lua, can be obtained from the Lua homepage at
http://www.lua.org. Because the scripting files are text, they can be edited with any text editor
(e.g. notepad). As of this writing, the latest release of Lua is version 5.0. However, the version of
Lua incorporated into FEMM is Lua 4.0.
In addition to the standard Lua command set described in [9], a number of FEMM-specific
functions have been added for manipulating files in both the pre- and post-processor. These commands are described in the following sections.
mi
mi
mi
mi
mo
mo
addpointprop
modifypointprop
addcircprop
modifycircprop
getpointvalues
lineintegral
mo blockintegral
mo getcircuitproperties
showconsole() Displays the floating Lua console window.
showpointprops() Displays the floating FEMM Properties display window.
smartmesh(state) Calling with a state of 0 turns off smart mesh functionality for the
present session; calling with a state of 1 turns smarth meshing on. The setting os not
permanentusing the Preferences setting to permanently turn on or off.
84
87
88
To obtain a Mixed type boundary condition, set C1 and C0 as required and BdryFormat
to 2. Set all other parameters to zero.
For a Strategic dual image boundary, set BdryFormat to 3 and set all other parameters
to zero.
For a Periodic boundary condition, set BdryFormat to 4 and set all other parameters
to zero.
For an Anti-Perodic boundary condition, set BdryFormat to 5 set all other parameters
to zero.
mi addcircprop("circuitname", i, circuittype)
adds a new circuit property with name "circuitname" with a prescribed current, i. The
circuittype parameter is 0 for a parallel-connected circuit and 1 for a series-connected
circuit.
mi deletematerial("materialname") deletes the material named "materialname".
mi deleteboundprop("propname") deletes the boundary property named "propname".
mi deletecircuit("circuitname") deletes the circuit named circuitname.
mi deletepointprop("pointpropname") deletes the point property named "pointpropname"
mi_modifymaterial("BlockName",propnum,value) This function allows for modification of a materials properties without redefining the entire material (e.g. so that current can
be modified from run to run). The material to be modified is specified by "BlockName".
The next parameter is the number of the property to be set. The last number is the value to
be applied to the specified property. The various properties that can be modified are listed
below:
propnum
0
1
2
3
4
5
6
7
8
9
10
11
Symbol
BlockName
x
y
Hc
Jr
dlam
hmax
LamFill
LamType
hx
hy
Description
Name of the material
x (or r) direction relative permeability
y (or z) direction relative permeability
Coercivity, Amps/Meter
Source current density, MA/m2
Electrical conductivity, MS/m
Lamination thickness, mm
Hysteresis lag angle for nonlinear problems, degrees
Iron fill fraction
0 = None/In plane, 1 = parallel to x, 2=parallel to y
Hysteresis lag in x-direction for linear problems, degrees
Hysteresis lag in y-direction for linear problems, degrees
mi_modifyboundprop("BdryName",propnum,value) This function allows for modification of a boundary property. The BC to be modified is specified by "BdryName". The next
parameter is the number of the property to be set. The last number is the value to be applied
to the specified property. The various properties that can be modified are listed below:
90
propnum
0
1
2
3
4
5
6
7
8
9
Symbol
BdryName
A0
A1
A2
c0
c1
BdryFormat
Description
Name of boundary property
Prescribed A parameter
Prescribed A parameter
Prescribed A parameter
Prescribed A phase
Small skin depth relative permeability
Small skin depth conductivity, MS/m
Mixed BC parameter
Mixed BC parameter
Type of boundary condition:
0 = Prescribed A
1 = Small skin depth
2 = Mixed
3 = Strategic Dual Image
4 = Periodic
5 = Antiperiodic
mi_modifypointprop("PointName",propnum,value) This function allows for modification of a point property. The point property to be modified is specified by "PointName".
The next parameter is the number of the property to be set. The last number is the value to
be applied to the specified property. The various properties that can be modified are listed
below:
propnum
0
1
2
Symbol
PointName
A
J
Description
Name of the point property
Nodal potential, Weber/Meter
Nodal current, Amps
mi_modifycircprop("CircName",propnum,value) This function allows for modification of a circuit property. The circuit property to be modified is specified by "CircName".
The next parameter is the number of the property to be set. The last number is the value to
be applied to the specified property. The various properties that can be modified are listed
below:
propnum
0
1
2
Symbol
CircName
i
CircType
Description
Name of the circuit property
Total current
0 = Parallel, 1 = Series
3.3.10 Miscellaneous
mi savebitmap("filename") saves a bitmapped screenshot of the current view to the file
specified by "filename", subject to the printf-type formatting explained previously for
the savefemmfile command.
91
92
name
B.n
H.t
Contour length
Stress Tensor Force
Stress Tensor Torque
(B.n)2
values 1
total B.n
total H.t
surface area
DC r/x force
DC torque
total (B.n)2
values 2
avg B.n
avg H.t
DC y/z force
2 torque
avg (B.n)2
values 3
2 r/x force
-
values 4
2 y/z force
-
Returns typically two (possibly complex) values as results. For force and torque results, the
2 results are only relevant for problems where 6= 0. The 1 results are only relevant
for incremental permeability AC problems. The 1 results represent the force and torque
interactions between the steady-state and the incremental AC solution.
mo blockintegral(type) Calculate a block integral for the selected blocks
93
Type
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
Definition
AJ
A
Magnetic field energy
Hysteresis and/or lamination losses
Resistive losses
Block cross-section area
Total losses
Total current
Integral of Bx (or Br ) over block
Integral of By (or Bz ) over block
Block volume
x (or r) part of steady-state Lorentz force
y (or z) part of steady-state Lorentz force
x (or r) part of 2 Lorentz force
y (or z) part of 2 Lorentz force
Steady-state Lorentz torque
2 component of Lorentz torque
Magnetic field coenergy
x (or r) part of steady-state weighted stress tensor force
y (or z) part of steady-state weighted stress tensor force
x (or r) part of 2 weighted stress tensor force
y (or z) part of 2 weighted stress tensor force
Steady-state weighted stress tensor torque
2 component of weighted stress tensor torque
R2 (i.e. moment of inertia / density)
x (or r) part of 1 weighted stress tensor force
y (or z) part of 1 weighted stress tensor force
1 component of weighted stress tensor torque
x (or r) part of 1 Lorentz force
y (or z) part of 1 Lorentz force
1 component of Lorentz torque
This function returns one (possibly complex) value, e.g.: volume = mo blockintegral(10)
mo getpointvalues(X,Y) Get the values associated with the point at x,y RETURN values
in order
94
Symbol
A
B1
B2
Sig
E
H1
H2
Je
Js
Mu1
Mu2
Pe
Ph
Definition
vector potential A or flux
flux density Bx if planar, Br if axisymmetric
flux density By if planar, Bz if axisymmetric
electrical conductivity
stored energy density
field intensity Hx if planar, Hr if axisymmetric
field intensity Hy if planar, Hz if axisymmetric
eddy current density
source current density
relative permeability x if planar, r if axisymmetric
relative permeability y if planar, z if axisymmetric
Power density dissipated through ohmic losses
Power density dissipated by hysteresis
Definition
Potential
|B|
Bn
Bt
|H|
H n
H t
Jeddy
Jsource + Jeddy
Definition
Multi-column text with legend
Multi-column text with no legend
Mathematica-style formatting
95
For example, if one wanted to plot B n to the screen with 200 points evaluated to make the
graph, the command would be:
mo makeplot(2,200)
If this plot were to be written to disk as a metafile, the command would be:
mo_makeplot(2,200,"c:\\temp\myfile.emf")
To write data instead of a plot to disk, the command would be of the form:
mo_makeplot(2,200,"c:\\temp\myfile.txt",0)
mo_getprobleminfo() Returns info on problem description. Returns four values:
Return value
1
2
3
4
Definition
problem type
frequency in Hz
depth assumed for planar problems in meters
length unit used to draw the problem in meters
mo selectpoint(x,y) Adds a contour point at the closest input point to (x,y). If the selected point and a previous selected points lie at the ends of an arcsegment, a contour is added
that traces along the arcsegment. The mo selectpoint command has the same functionality as the left-button-click contour point selection when the program is running in interactive
mode.
mo clearcontour() Clear a prevously defined contour
mo clearblock() Clear block selection
legend Set to 0 to hide the plot legend or 1 to show the plot legend.
gscale Set to 0 for a colour density plot or 1 for a grey scale density plot.
upper_B Sets the upper display limit for the density plot.
lower_B Sets the lower display limit for the density plot.
type Type of density plot to display. Valid entries are "bmag", "breal", and "bimag"
for magnitude, real component, and imaginary component of flux density (B), respectively; "hmag", "hreal", and "himag" for magnitude, real component, and imaginary
component of field intensity (H); and "jmag", "jreal", and "jimag" for magnitude,
real component, and imaginary component of current density (J).
if legend is set to -1 all parameters are ignored and default values are used e.g.:
mo_showdensityplot(-1)
mo_hidecontourplot() Hides the contour plot.
mo_showcontourplot(numcontours,lower_A,upper_A,type) shows the A contour plot
with options:
numcontours Number of A equipotential lines to be plotted.
upper_A Upper limit for A contours.
lower_A Lower limit for A contours.
type Choice of "real", "imag", or "both" to show either the real, imaginary of both
real and imaginary components of A.
If numcontours is -1 all parameters are ignored and default values are used, e.g.:
mo_showcontourplot(-1)
mo showvectorplot(type,scalefactor) controls the display of vectors denoting the field
strength and direction. The parameters taken are the type of plot, which should be set to 0
for no vector plot, 1 for the real part of flux density B; 2 for the real part of field intensity H;
3 for the imaginary part of B; 4 for the imaginary part of H; 5 for both the real and imaginary
parts of B; and 6 for both the real and imaginary parts of H. The scalefactor determines
the relative length of the vectors. If the scale is set to 1, the length of the vectors are chosen
so that the highest flux density corresponds to a vector that is the same length as the current
grid size setting.
mo minimize minimizes the active magnetics output view.
mo maximize maximizes the active magnetics output view.
mo restore restores the active magnetics output view from a minimized or maximized state.
mo resize(width,height) resizes the active magnetics output window client area to width
height.
98
3.4.5 Miscellaneous
mo close() Closes the current post-processor instance.
mo refreshview() Redraws the current view.
mo reload() Reloads the solution from disk.
mo savebitmap("filename") saves a bitmapped screen shot of the current view to the file
specified by "filename". Note that if you use a path you must use two backslashes (e.g.
"c:\\temp\\myfemmfile.fem"). If the file name contains a space (e.g. file names like
c:\program files\stuff) you must enclose the file name in (extra) quotes by using a \"
sequence. For example:
mo_save_bitmap("\"c:\\temp\\screenshot.bmp\"")
mo savemetafile("filename") saves a metafile screenshot of the current view to the file
specified by "filename", subject to the printf-type formatting explained previously for
the savebitmap command.
mo shownames(flag) This function allow the user to display or hide the block label names
on screen. To hide the block label names, flag should be 0. To display the names, the
parameter should be set to 1.
mo numnodes() Returns the number of nodes in the in focus magnetics output mesh.
mo numelements() Returns the number of elements in the in focus magnets output mesh.
mo getnode(n) Returns the (x,y) or (r,z) position of the nth mesh node.
mo getelement(n) MOGetElement[n] returns the following proprerties for the nth element:
1. Index of first element node
2. Index of second element node
3. Index of third element node
4. x (or r) coordinate of the element centroid
5. y (or z) coordinate of the element centroid
6. element area using the length unit defined for the problem
7. group number associated with the element
100
101
angle angle by which the selected objects are incrementally shifted to make each copy.
angle is measured in degrees.
copies number of copies to be produced from the selected objects.
editaction 0 nodes, 1 lines (segments), 2 block labels, 3 arc segments, 4- group
102
scalefactor a multiplier that determines how much the selected objects are scaled
editaction 0 nodes, 1 lines (segments), 2 block labels, 3 arc segments, 4- group
ei mirror(x1,y1,x2,y2,(editaction)) mirror the selected objects about a line passing
through the points (x1,y1) and (x2,y2). Valid editaction entries are 0 for nodes, 1 for
lines (segments), 2 for block labels, 3 for arc segments, and 4 for groups.
ei seteditmode(editmode) Sets the current editmode to:
"nodes" nodes
For a Periodic boundary condition, set BdryFormat to 3 and set all other parameters to
zero.
For an Anti-Perodic boundary condition, set BdryFormat to 4 set all other parameters to
zero.
ei addconductorprop("conductorname", Vc, qc, conductortype) adds a new conductor property with name "conductorname" with either a prescribed voltage or a prescribed total charge. Set the unused property to zero. The conductortype parameter is 0
for prescribed charge and 1 for prescribed voltage.
ei deletematerial("materialname") deletes the material named "materialname".
ei deleteboundprop("boundpropname") deletes the boundary property named "boundpropname".
ei deleteconductor("conductorname") deletes the conductor named conductorname.
ei deletepointprop("pointpropname") deletes the point property named "pointpropname"
ei modifymaterial("BlockName",propnum,value) This function allows for modification of a materials properties without redefining the entire material (e.g. so that current can
be modified from run to run). The material to be modified is specified by "BlockName".
The next parameter is the number of the property to be set. The last number is the value to
be applied to the specified property. The various properties that can be modified are listed
below:
propnum Symbol
Description
0
BlockName Name of the material
ex
x (or r) direction relative permittivity
1
2
ey
y (or z) direction relative permittivity
3
qs
Volume charge
ei modifyboundprop("BdryName",propnum,value) This function allows for modification of a boundary property. The BC to be modified is specified by "BdryName". The next
parameter is the number of the property to be set. The last number is the value to be applied
to the specified property. The various properties that can be modified are listed below:
propnum
0
1
2
3
4
5
Symbol
BdryName
Vs
qs
c0
c1
BdryFormat
Description
Name of boundary property
Fixed Voltage
Prescribed charge density
Mixed BC parameter
Mixed BC parameter
Type of boundary condition:
0 = Prescribed V
1 = Mixed
2 = Surface charge density
3 = Periodic
4 = Antiperiodic
105
ei modifypointprop("PointName",propnum,value) This function allows for modification of a point property. The point property to be modified is specified by "PointName".
The next parameter is the number of the property to be set. The last number is the value to
be applied to the specified property. The various properties that can be modified are listed
below:
propnum Symbol
Description
0
PointName Name of the point property
1
Vp
Prescribed nodal voltage
2
qp
Point charge density in C/m
ei modifyconductorprop("ConductorName",propnum,value) This function allows for
modification of a conductor property. The conductor property to be modified is specified by
"ConductorName". The next parameter is the number of the property to be set. The last
number is the value to be applied to the specified property. The various properties that can
be modified are listed below:
propnum Symbol
Description
0
ConductorName Name of the conductor property
1
Vc
Conductor voltage
2
qc
Total conductor charge
3
ConductorType 0 = Prescribed charge, 1 = Prescribed voltage
3.5.10 Miscellaneous
ei savebitmap("filename") saves a bitmapped screenshot of the current view to the file
specified by "filename", subject to the printf-type formatting explained previously for
the ei saveas command.
ei savemetafile("filename") saves a metafile screenshot of the current view to the file
specified by "filename", subject to the printf-type formatting explained previously for
the ei saveas command.
ei refreshview() Redraws the current view.
ei close() closes the preprocessor window and destroys the current document.
ei shownames(flag) This function allow the user to display or hide the block label names
on screen. To hide the block label names, flag should be 0. To display the names, the
parameter should be set to 1.
ei readdxf("filename") This function imports a dxf file specified by "filename".
ei savedxf("filename") This function saves geometry informatoin in a dxf file specified
by "filename".
ei defineouterspace(Zo,Ro,Ri) defines an axisymmetric external region to be used in
conjuction with the Kelvin Transformation method of modeling unbounded problems. The
Zo parameter is the z-location of the origin of the outer region, the Ro parameter is the radius
106
of the outer region, and the Ri parameter is the radius of the inner region (i.e. the region
of interest). In the exterior region, the permeability varies as a function of distance from
the origin of the external region. These parameters are necessary to define the permeability
variation in the external region.
ei attachouterspace() marks all selected block labels as members of the external region
used for modeling unbounded axisymmetric problems via the Kelvin Transformation.
ei detachouterspace() undefines all selected block labels as members of the external
region used for modeling unbounded axisymmetric problems via the Kelvin Transformation.
ei attachdefault() marks the selected block label as the default block label. This block
label is applied to any region that has not been explicitly labeled.
ei detachdefault() undefines the default attribute for the selected block labels.
ei makeABC(n,R,x,y,bc) creates a series of circular shells that emulate the impedance of
an unbounded domain (i.e. an Inprovised Asymptotic Boundary Condition). The n parameter contains the number of shells to be used (should be between 1 and 10), R is the radius of
the solution domain, and (x,y) denotes the center of the solution domain. The bc parameter
should be specified as 0 for a Dirichlet outer edge or 1 for a Neumann outer edge. If the
function is called without all the parameters, the function makes up reasonablevaluesforthemissingparameters.
Integral
E t
Dn
Contour length
Force from stress tensor
Torque from stress tensor
This integral returns either 1 or 2 values, depending on the integral type, e.g. :
Fx, Fy = eo lineintegral(3)
eo blockintegral(type) Calculate a block integral for the selected blocks
107
type
0
1
2
3
4
5
6
Integral
Stored Energy
Block Cross-section
Block Volume
Average D over the block
Average E over the block
Weighted Stress Tensor Force
Weighted Stress Tensor Torque
Definition
V (Voltage)
|D| (Magnitude of flux density)
D . n (Normal flux density)
D . t (Tangential flux density)
|E| (Magnitude of field intensity)
E . n (Normal field intensity)
E . t (Tangential field intensity)
108
FileFormat
0
1
2
Definition
Multi-column text with legend
Multi-column text with no legend
Mathematica-style formatting
For example, if one wanted to plot V to the screen with 200 points evaluated to make the
graph, the command would be:
eo makeplot(0,200)
If this plot were to be written to disk as a metafile, the command would be:
eo makeplot(0,200,"c:temp.emf")
To write data instead of a plot to disk, the command would be of the form:
eo makeplot(0,200,"c:temp.txt",0)
eo getprobleminfo() Returns info on problem description. Returns three values: the
Problem type (0 for planar and 1 for axisymmetric); the depth assumed for planar problems
in units of meters; and the length unit used to draw the geometry represented in units of
meters.
eo getconductorproperties("conductor") Properties are returned for the conductor
property named conductor. Two values are returned: The voltage of the specified conductor, and the charge carried on the specified conductor.
109
The angle parameter can take on values from -180 to 180 degrees. The anglestep parameter must be greater than zero. If there are less than two points defined in the contour, this
command is ignored.
eo selectpoint(x,y) Adds a contour point at the closest input point to (x,y). If the selected point and a previous selected points lie at the ends of an arcsegment, a contour is added
that traces along the arcsegment. The selectpoint command has the same functionality as
the left-button-click contour point selection when the program is running in interactive mode.
eo clearcontour() Clear a prevously defined contour
eo clearblock() Clear block selection
eo gridsnap("flag") Setting flag to on turns on snap to grid, setting flag to off turns
off snap to grid.
3.6.5 Miscellaneous
eo close() close the current postprocessor window.
eo refreshview() Redraws the current view.
eo reload() Reloads the solution from disk.
111
112
113
114
angle angle by which the selected objects are incrementally shifted to make each copy.
angle is measured in degrees.
copies number of copies to be produced from the selected objects.
editaction 0 nodes, 1 lines (segments), 2 block labels, 3 arc segments, 4- group
115
scalefactor a multiplier that determines how much the selected objects are scaled
editaction 0 nodes, 1 lines (segments), 2 block labels, 3 arc segments, 4- group
hi mirror(x1,y1,x2,y2,(editaction)) mirror the selected objects about a line passing
through the points (x1,y1) and (x2,y2). Valid editaction entries are 0 for nodes, 1 for
lines (segments), 2 for block labels, 3 for arc segments, and 4 for groups.
hi seteditmode(editmode) Sets the current editmode to:
"nodes" nodes
117
To obtain a convection boundary condition, set h to the desired heat transfer coefficient
and Tinf to the desired external temperature and set BdryFormat to 2.
For a Radiation boundary condition, set beta equal to the desired emissivity and Tinf
to the desired external temperature and set BdryFormat to 3.
For a Periodic boundary condition, set BdryFormat to 4 and set all other parameters
to zero.
For an Anti-Perodic boundary condition, set BdryFormat to 5 set all other parameters
to zero.
hi addconductorprop("conductorname", Tc, qc, conductortype) adds a new conductor property with name "conductorname" with either a prescribed temperature or a prescribed total heat flux. Set the unused property to zero. The conductortype parameter is 0
for prescribed heat flux and 1 for prescribed temperature.
hi deletematerial("materialname") deletes the material named "materialname".
hi deleteboundprop("boundpropname") deletes the boundary property named "boundpropname".
hi deleteconductor("conductorname") deletes the conductor named conductorname.
hi deletepointprop("pointpropname") deletes the point property named "pointpropname"
hi modifymaterial("BlockName",propnum,value) This function allows for modification of a materials properties without redefining the entire material (e.g. so that current can
be modified from run to run). The material to be modified is specified by "BlockName".
The next parameter is the number of the property to be set. The last number is the value to
be applied to the specified property. The various properties that can be modified are listed
below:
propnum Symbol
Description
0
BlockName Name of the material
1
kx
x (or r) direction thermal conductivity
2
ky
y (or z) direction thermal conductivity
3
qs
Volume heat generation
kt
Volumetric heat capacity
4
hi modifyboundprop("BdryName",propnum,value) This function allows for modification of a boundary property. The BC to be modified is specified by "BdryName". The next
parameter is the number of the property to be set. The last number is the value to be applied
to the specified property. The various properties that can be modified are listed below:
118
propnum Symbol
Description
0
BdryName
Name of boundary property
1
BdryFormat Type of boundary condition:
0 = Prescribed temperature
1 = Heat Flux
2 = Convection
3 = Radiation
4 = Periodic
5 = Antiperiodic
Tset
Fixed Temperature
2
3
qs
Prescribed heat flux density
4
Tinf
External temperature
5
h
Heat transfer coefficient
6
beta
Emissivity
hi modifypointprop("PointName",propnum,value) This function allows for modification of a point property. The point property to be modified is specified by "PointName".
The next parameter is the number of the property to be set. The last number is the value to
be applied to the specified property. The various properties that can be modified are listed
below:
propnum Symbol
Description
0
PointName Name of the point property
1
Tp
Prescribed nodal temperature
qp
Point heat generation in W/m
2
hi modifyconductorprop("ConductorName",propnum,value) This function allows for
modification of a conductor property. The conductor property to be modified is specified by
"ConductorName". The next parameter is the number of the property to be set. The last
number is the value to be applied to the specified property. The various properties that can
be modified are listed below:
propnum Symbol
Description
0
ConductorName Name of the conductor property
1
Tc
Conductor temperature
2
qc
Total conductor heat flux
3
ConductorType 0 = Prescribed heat flow, 1 = Prescribed temperature
hi addtkpoint("materialname",T,k) adds the point (T,k) to the thermal conductivity
vs. temperature curve for the material specified by "materialname".
hi cleartkpoints("materialname") erases all of the thermal conductivity points that
have been defined for the material named "materialname".
3.7.10 Miscellaneous
hi savebitmap("filename") saves a bitmapped screenshot of the current view to the file
specified by "filename", subject to the printf-type formatting explained previously for
the hi saveas command.
119
Integral
Temperature difference (G t)
Heat flux through the contour (F n)
Contour length
Average Temperature
This integral returns either 1 or 2 values, depending on the integral type, e.g. :
Ftot, Favg = ho lineintegral(2)
ho blockintegral(type) Calculate a block integral for the selected blocks
type
0
1
2
3
4
Integral
Average T over the block
Block Cross-section
Block Volume
Average F over the block
Average G over the block
121
PlotType
0
1
2
3
4
5
6
Definition
V (Temperature)
|D| (Magnitude of heat flux density)
D . n (Normal heat flux density)
D . t (Tangential heat flux density)
|E| (Magnitude of field intensity)
E . n (Normal field intensity)
E . t (Tangential field intensity)
ho addcontour(x,y) Adds a contour point at (x,y). If this is the first point then it
starts a contour, if there are existing points the contour runs from the previous point to this
point. The ho addcontour command has the same functionality as a right-button-click
contour point addition when the program is running in interactive mode.
ho bendcontour(angle,anglestep) Replaces the straight line formed by the last two
points in the contour by an arc that spans angle degrees. The arc is actually composed
of many straight lines, each of which is constrained to span no more than anglestep degrees.
The angle parameter can take on values from -180 to 180 degrees. The anglestep parameter must be greater than zero. If there are less than two points defined in the contour, this
command is ignored.
ho selectpoint(x,y) Adds a contour point at the closest input point to (x,y). If the selected point and a previous selected points lie at the ends of an arcsegment, a contour is added
that traces along the arcsegment. The selectpoint command has the same functionality as
the left-button-click contour point selection when the program is running in interactive mode.
ho clearcontour() Clear a prevously defined contour
ho clearblock() Clear block selection
123
ho gridsnap("flag") Setting flag to on turns on snap to grid, setting flag to off turns
off snap to grid.
3.8.5 Miscellaneous
ho close() close the current postprocessor window.
ho refreshview() Redraws the current view.
ho reload() Reloads the solution from disk.
ho savebitmap("filename") saves a bitmapped screen shot of the current view to the
file specified by "filename". Note that if you use a path you must use two backslashes
(e.g. "c:\\temp\\myfile.bmp"). If the file name contains a space (e.g. file names like
c:\program files\stuff) you must enclose the file name in (extra) quotes by using a \" sequence. For example:
ho savebitmap("\"c:\\temp\\screenshot.bmp\"")
ho savemetafile("filename") saves a metafile screenshot of the current view to the file
specified by "filename", subject to the printf-type formatting explained previously for the
savebitmap command.
ho shownames(flag) This function allow the user to display or hide the block label names
on screen. To hide the block label names, flag should be 0. To display the names, the
parameter should be set to 1.
ho numnodes() Returns the number of nodes in the in focus heat flow output mesh.
ho numelements() Returns the number of elements in the in focus heat flow output mesh.
ho getnode(n) Returns the (x,y) or (r,z) position of the nth mesh node.
ho getelement(n) MOGetElement[n] returns the following proprerties for the nth element:
1. Index of first element node
2. Index of second element node
3. Index of third element node
4. x (or r) coordinate of the element centroid
5. y (or z) coordinate of the element centroid
6. element area using the length unit defined for the problem
7. group number associated with the element
126
127
angle angle by which the selected objects are incrementally shifted to make each copy.
angle is measured in degrees.
copies number of copies to be produced from the selected objects.
128
scalefactor a multiplier that determines how much the selected objects are scaled
editaction 0 nodes, 1 lines (segments), 2 block labels, 3 arc segments, 4- group
ci mirror(x1,y1,x2,y2,(editaction)) mirror the selected objects about a line passing
through the points (x1,y1) and (x2,y2). Valid editaction entries are 0 for nodes, 1 for
lines (segments), 2 for block labels, 3 for arc segments, and 4 for groups.
ci seteditmode(editmode) Sets the current editmode to:
"nodes" nodes
129
130
ci modifyboundprop("BdryName",propnum,value) This function allows for modification of a boundary property. The BC to be modified is specified by "BdryName". The next
parameter is the number of the property to be set. The last number is the value to be applied
to the specified property. The various properties that can be modified are listed below:
propnum
0
1
2
3
4
5
Symbol
BdryName
Vs
qs
c0
c1
BdryFormat
Description
Name of boundary property
Fixed Voltage
Prescribed current density
Mixed BC parameter
Mixed BC parameter
Type of boundary condition:
0 = Prescribed V
1 = Mixed
2 = Surface current density
3 = Periodic
4 = Antiperiodic
ci modifypointprop("PointName",propnum,value) This function allows for modification of a point property. The point property to be modified is specified by "PointName".
The next parameter is the number of the property to be set. The last number is the value to
be applied to the specified property. The various properties that can be modified are listed
below:
propnum Symbol
Description
0
PointName Name of the point property
1
Vp
Prescribed nodal voltage
2
qp
Point current density in A/m
ci modifyconductorprop("ConductorName",propnum,value) This function allows for
modification of a conductor property. The conductor property to be modified is specified by
"ConductorName". The next parameter is the number of the property to be set. The last
number is the value to be applied to the specified property. The various properties that can
be modified are listed below:
propnum Symbol
Description
0
ConductorName Name of the conductor property
1
Vc
Conductor voltage
2
qc
Total conductor current
3
ConductorType 0 = Prescribed current, 1 = Prescribed voltage
3.9.10 Miscellaneous
ci savebitmap("filename") saves a bitmapped screenshot of the current view to the file
specified by "filename", subject to the printf-type formatting explained previously for
the ci saveas command.
ci savemetafile("filename") saves a metafile screenshot of the current view to the file
132
Integral
E t
Jn
Contour length
Average voltage over contour
Force from stress tensor
Torque from stress tensor
This integral returns either 1 or 2 values, depending on the integral type, e.g. :
Fx, Fy = co lineintegral(4)
co blockintegral(type) Calculate a block integral for the selected blocks
type
0
1
2
3
4
5
6
7
8
9
10
11
Integral
Real Power
Reactive Power
Apparent Power
Time-Average Stored Energy
Block cross-section area
Block volume
x (or r) direction Weighted Stress Tensor force, DC component
y (or z) direction Weighted Stress Tensor force, DC component
x (or r) direction Weighted Stress Tensor force, 2x frequency component
y (or z) direction Weighted Stress Tensor force, 2x frequency component
Weighted Stress Tensor torque, DC component
Weighted Stress Tensor torque, 2x frequency component
134
Symbol
V
Jx
Jy
Kx
Ky
Ex
Ey
ex
ey
Jdx
Jdy
ox
oy
Jcx
Jcy
Definition
Voltage
x- or r- direction component of current density
y- or z- direction component of current density
x- or r- direction component of AC conductivity
y- or z- direction component of AC conductivity
x- or r- direction component of electric field intensity
y- or z- direction component of electric field intensity
x- or r- direction component of permittivity
y- or z- direction component of permittivity
x- or r- direction component of displacement current density
y- or z- direction component of displacement current density
x- or r- direction component of permittivity
y- or z- direction component of permittivity
x- or r- direction component of conduction current density
y- or z- direction component of conduction current density
Definition
V (Voltage)
|J| (Magnitude of current density)
J . n (Normal current density)
J . t (Tangential current density)
|E| (Magnitude of field intensity)
E . n (Normal field intensity)
E . t (Tangential field intensity)
|Jc| (Magnitude of conduction current density)
Jc . n (Normal conduction current density)
Jc . t (Tangential conduction current density)
|Jd| (Magnitude of displacement current density)
Jd . n (Normal displacement current density)
Jd . t (Tangential displacement current density)
Definition
problem type
frequency in Hz
depth assumed for planar problems in meters.
length unit used to draw the problem, represented in meters
136
co selectpoint(x,y) Adds a contour point at the closest input point to (x,y). If the selected point and a previous selected points lie at the ends of an arcsegment, a contour is added
that traces along the arcsegment. The selectpoint command has the same functionality as
the left-button-click contour point selection when the program is running in interactive mode.
co clearcontour() Clear a prevously defined contour
co clearblock() Clear block selection
co gridsnap("flag") Setting flag to on turns on snap to grid, setting flag to off turns
off snap to grid.
137
Description
|V |
|Re(V )|
|Im(V )|
|J|
|Re(J)|
|Im(J)|
|E|
|Re(E)|
|Im(E)|
Description
No vector plot
Re(J)
Re(E)
The scalefactor determines the relative length of the vectors.
Im(J)
Im(E)
Re(J) and Im(J)
Re(E) and Im(E)
138
If the scale is set to 1, the length of the vectors are chosen so that the highest field magnitude
corresponds to a vector that is the same length as the current grid size setting.
co minimize() minimizes the active magnetics input view.
co maximize() maximizes the active magnetics input view.
co restore() restores the active magnetics input view from a minimized or maximized
state.
co resize(width,height) resizes the active magnetics input window client area to width
height.
3.10.5 Miscellaneous
co close() close the current postprocessor window.
co refreshview() Redraws the current view.
co reload() Reloads the solution from disk.
co savebitmap("filename") saves a bitmapped screen shot of the current view to the
file specified by "filename". Note that if you use a path you must use two backslashes
(e.g. "c:\\temp\\myfile.bmp"). If the file name contains a space (e.g. file names like
c:\program files\stuff) you must enclose the file name in (extra) quotes by using a \" sequence. For example:
co savebitmap("\"c:\\temp\\screenshot.bmp\"")
co savemetafile("filename") saves a metafile screenshot of the current view to the file
specified by "filename", subject to the printf-type formatting explained previously for the
savebitmap command.
co shownames(flag) This function allow the user to display or hide the block label names
on screen. To hide the block label names, flag should be 0. To display the names, the
parameter should be set to 1.
co numnodes() Returns the number of nodes in the in focus current flow output mesh.
co numelements() Returns the number of elements in the in focus current flow output
mesh.
co getnode(n) Returns the (x,y) or (r,z) position of the nth mesh node.
co getelement(n) MOGetElement[n] returns the following proprerties for the nth element:
1. Index of first element node
2. Index of second element node
3. Index of third element node
139
140
Chapter 4
Mathematica Interface
FEMM can interact with Mathematica via Mathematicas MathLink API. Once Mathematica and
FEMM are connected, any any string sent by Mathematica is automatically collected and interpreted as a command to FEMMs Lua interpreter. Results can be returned across the link by a
special Lua print command that sends the results to Mathematica as a list, rather than to the Lua
console screen.
The MathLink connection to FEMM can be initialized in two ways. The link can either be
established automatically on startup, or during a session via commands in the Lua console. To
establish the connection on startup, just use the LinkLaunch function in Mathematica, e.g.:
mlink = LinkLaunch["c:\\progra1\\femm42\\bin\\femm.exe"];
To initialize the link, some string must first be sent over the link from the Mathematica side,
e.g.:
LinkWrite[mlink, "print(0)"]
All strings sent to FEMM are then sent using the same sort of LinkWrite command. When it is
time to close the link, the link can be closed using the LinkClose command, e.g.:
LinkClose[mlink]
To start a link during a session, the Lua command mlopen() can be used. A dialog will then
appear, prompting for a name for the link. Choose any name that you want, e.g. portname. On the
Mathematica side, one connects to the newly formed link via the Mathematica command:
mlink = LinkConnect["portname"]
After this point, the link is used and closed in the same way as the link that is automatically
created on startup.
As previously noted, LinkWrite is used on the mathematica side to send a string to FEMM.
FEMM automatically monitors the link and interprets the string with no further user action required. To send results back to Mathematica, one uses the mlput command in Lua. This function
works exactly like the print command in lua, except that the result gets pushed back across the
link as a list of mixed reals and strings, as appropriate. To retrieve this information on the Mathematica side, one uses the LinkRead command, e.g.:
result = LinkRead[mlink]
To automate the interaction between FEMM and Mathematica, a Mathematica package called
MathFEMM is available. This package implements a set of Mathematica functions similar to those
implemented in Lua. With MathFEMM, the the user does not have to deal with the specifics of
creating the Mathlink connection and manually transferring information across it. All MathLink
141
details are taken care of automatically by the package, and the Mathematica front-end can then be
used to directly control FEMM via a set of Mathematica function calls.
142
Chapter 5
ActiveX Interface
FEMM also allows for interprocess communication via ActiveX. FEMM is set up to act as an
ActiveX Automation Server so that other programs can connect to FEMM as clients and command
FEMM to perform various actions and analyses in a programmatic way.
FEMM registers itself as an ActiveX server under the name femm.ActiveFEMM42. An explanation of how to connect to and manipulate an ActiveX server are beyond the treatment of this
manual, in part because the specifics depend upon what client platform is being used (e.g. VB,
VC++, Matlab, etc.)
The interface to FEMM contains no properties and only two methods:
BSTR call2femm(BSTR luacmd);
BSTR mlab2femm(BSTR luacmd);
In each case, a string is passed to the method, and a string is returned as a result. The incoming
string is sent to the Lua interpreter. Any results from the Lua command are returned as a string.
The difference between the two methods is that call2femm returns a string with each returned item
separated by a newline character, whereas mlab2femm returns the result formatted as a Matlab
array, with the total package enclosed by square brackets and the individual items separated by
spaces. FEMM assumes that it is the clients responsibility to free the memory allocated for both
the input and output strings.
One program that can connect to FEMM as a client via Active X is Matlab. From Matlab,
one can send commands to the FEMM Lua interpreter and receive the results of the command.
To aid in the use of FEMM from Matlab, a toolbox called OctaveFEMM is available. This toolbox implements Matlab commands that subsume the functionality of Lua using equivalent Matlab
commands, in a similar way to the fashion that MathFEMM works with Mathematica. Using the
toolbox, all details of the ActiveX interface are taken care of in a way that is completely transparent
to the user.
143
Chapter 6
Numerical Methods
For those of you interested in whats going on behind the scenes in the solvers, this section is
meant as a brief description of the methods and techniques used by FEMM. References are cited
as applicable.
preconditioner must also be stored. Instead, the Symmetric Successive Over-Relaxation (SSOR)
preconditioner, as described in [13], is used. The advantage of this preconditioner is that it is built
on the fly in a simple way using only the matrix elements that are already in storage. In general,
the speed of PCG using SSOR is said to be comparable to the speed of PCG with Incomplete
Cholesky.
For harmonic problems, the regular PCG algorithm cannot be used; the matrix that arises in
the formulation of harmonic problems is Complex Symmetric (i.e. A = AT ), rather than Hermitian
(i.e. A = A ). Curiously, there is not much literature available on iterative solvers for complex
symmetric problems, given the number of diverse applications in which these problems arise.
However, there is a very good paper on the solution of linear problems with complex symmetric
matrices via various flavors of Conjugate Gradient by Freund [14]. The techniques discussed
by Freund allow one to operate directly on the complex symmetric matrix and take advantage
of the symmetric structure to minimize the number of computations that must be performed per
iteration. Although Freund supports Quasi-Minimum Residual approach, FEMM uses the complex
symmetric version of biconjugate gradient also described in [14]. After coding and comparing the
the speed of both BCG and QMR, it was found that BCG is somewhat faster due to a relatively
smaller number of computations that must be performed per iteration (even though QMR has better
convergence properties than BCG).
However, using the algorithms as described by [14], solution times were unacceptably long.
To decrease solution times, the complex symmetric BCG algorithm was modified to include the
SSOR preconditioner (built in exactly the same way as for magnetostatic problems). Including the
SSOR preconditioner in complex symmetric BCG problems usually yields an order of magnitude
improvement in speed over no preconditioner.
In all problems, a node renumbering scheme is used. Although the conjugate gradient schemes
work well without renumbering, the renumbering seems to roughly halve the solution time. There
is an overall advantage to using the renumbering, because the of time required to perform the
renumbering is small compared to the time required to run CG or BCG. Although there are many
possible approaches to renumbering, FEMM uses the Cuthill-McKee method as described in [2].
Although there are newer schemes that yield a tighter profile, Cuthill-McKee does a relatively good
job and requires very little to execute. The renumbering code is a hold-over from an early version
of FEMM that employed a banded Gauss Elimination solver in which a good node numbering is
essential to good performance. The renumbering speeds up CG and BCG by reducing the error
between the SSOR approximation of A1 and the exact A1 . An interesting paper on the effect of
the ordering of the unknowns on convergence in conjugate gradient methods is [15].
its Gauss Point). One desires a continuous profile of B that can be interpolated from nodal values,
in the same way that vector potential A can be represented. The problem is, the raw solution of
B is multivalued at any node point, those values being the different constant values of B in each
element surrounding the node point. The general approach to estimating the true value of B at
any node point is to fit a least-squares plane through the values of B at the Gauss points of all
elements that surround a node of interest, and to take the value of the plane at the node points
location as its smoothed value of B [16].
However, this approach to patch recovery has a lot of shortcomings. For the rather irregular
meshes that can arise in finite elements, the least-squares fit problem can be ill-condition, or even
singular, at some nodes in the finite element mesh. Furthermore, the superconvergence solution can
actually be less accurate than the piece-wise constant solution in the neighborhood of boundaries
and interfaces.
One can note that the patch recovery method is merely a weighted average of the flux densities in all of the elements surrounding a given node. Instead of a least-squares fit, FEMM simply
weights the values of flux density in each adjacent elements Gauss point with a value inversely
proportional to the distance from the Gauss point to the node point of interest. Away from boundaries, the results seem to be nearly as good as a least-squares fit. At boundaries and interfaces, the
smoothed solution is no worse than the unsmoothed solution.
A related approach is used for smoothing D and E in electrostatics problems. In electrostatics
problems, however, nodal values of D are found by taking the gradient of a best-fit plane through
the voltage of the neighboring nodes. A number of special cases must be caught so that reasonable
results are obtained at various boundaries and surfaces.
146
Bibliography
[1] M. Plonus, Applied electromagnetics. McGraw-Hill, 1978.
[2] S. R. Hoole, Computer-aided analysis and design of electromagnetic devices, Elsevier, 1989.
[3] J. D. Jackson, Classical electrodynamics, 2nd ed, Wiley, 1975.
[4] F. M. White, Heat and mass transfer, Addison-Wesley, 1988.
[5] R. Haberman, Elementary applied partial differential equations, Prentice-Hall, 1987.
[6] R. L. Stoll, The analysis of eddy currents, Oxford University Press, 1974.
[7] S. McFee, J. P. Webb, and D. A. Lowther, A tunable volume integration formulation for
force calculation in finite-element based computational magnetostatics, IEEE Transactions
on Magnetics, 24(1):439-442, January 1988.
[8] F. Henrotte, G. Deliege, and K. Hameyer, The eggshell method for the computation of electromagnetic forces on rigid bodies in 2D and 3D, CEFC 2002, Perugia, Italy, April 16-18,
2002. (pdf version)
[9] R. Ierusalimschy, L. H. de Figueiredo, and W. Celes, Reference Manual of the Programming
Language Lua 4.0 http://www.lua.org/manual/4.0/
[10] P. E. Allaire, Basics of the finite element method, 1985.
[11] P. P. Silvester, Finite elements for electrical engineers, Cambridge University Press, 1990.
[12] F. Henrotte et al, A new method for axisymmetric linear and nonlinear problems, IEEE
Transactions on Magnetics, MAG-29(2):1352-1355, March 1993.
[13] C. A. Fletcher, Computational techniques for fluid dynamics, Springer-Verlag, 1988.
[14] R. W. Freund, Conjugate gradient-type methods for linear systems with complex symmetric
coefficient matrices, SIAM Journal of Scientific and Statistical Computing, 13(1):425-448,
January 1992.
[15] E. F. DAzevedo, P. A. Forsyth, and W. Tang, Ordering methods for preconditioned conjugate gradient methods applied to unstructured grid problems, SIAM J. Matrix Anal. Appl.,
12(4), July 1992.
147
[16] O. C. Zienkiewicz and J. Z. Zhu, The superconvergent patch recovery and a posteriori
estimates, part 1: the recovery technique, International Journal for Numerical Methods in
Engineering, 33:1331-1364, 1992.
[17] Q. Chen and A. Konrad, A review of finite element open boundary techniques for static and
quasistatic electromagnetic field problems, IEEE Transactions on Magnetics, 33(1):663676, January 1997.
[18] E. M. Freeman and D. A. Lowther, A novel mapping technique for open boundary finite
element solutions to Poissons equation, IEEE Transactions on Magnetics, 24(6):2934-2936,
November 1988.
[19] D. A. Lowther, E. M. Freeman, and B. Forghani, A sparse matrix open boundary method for
finite element analysis, IEEE Transactions on Magnetics, 25(4)2810-2812, July 1989.
[20] E. M. Freeman and D. A. Lowther, An open boundary technique for axisymmetric and
three dimensional magnetic and electric field problems, IEEE Transactions on Magnetics,
25(5):4135-4137, September 1989.
[21] A. G. Jack and B. C. Mecrow, Methods for magnetically nonlinear problems involving
significant hysteresis and eddy currents, IEEE Transactions on Magnetics, 26(2):424-429,
March 1990.
[22] D. OKelly, Hysteresis and eddy current losses in steel plates with nonlinear magnetization
characteristics, Proceedings of the IEE, 119(11):1675-1676, November 1972.
148
Appendix A
Appendix
A.1 Modeling Permanent Magnets
FEMM accommodates permanent magnets, but there are some special rules associated with properly modeling them. This appendix will explain how to distill enough information from a manufacturers literature to properly define the material in FEMM.
The manufacturer provides information about their material in the form of a demagnetization
curve. A sample curve for Alnico 5 is pictured in Figure A.1. The task is to get the appropriate
information out of the curve put in a FEMM Block Property model.
Magnets can be modeled from several different, but equally valid, points of view. From the
perspective finite element analysis, the most useful model is to think of the magnet as a volume of
ferromagnetic material surrounded by a thin sheet of current, as shown in Figure A.2. From this
5(105) E
Hc =
(A.1)
where E is the energy product in MGOe and the resulting Hc is in units of A/m (e.g. 40 MGOe
106 A/m).
With alnico magnets, great care must be taken in interpreting the finite element results. Unlike
rare-earth magnets, these magnets exhibit a great degree of hysteresis when they are demagnetized. That is, when the flux density is pushed below the knee in the demagnetization curve, the
flux level does not recover to the previous magnitude when the opposing MMF is removed. This
hysteresis is illustrated in Figure A.4. This sort of demagntization and recoil can occur when the
150
151
magnets are being handled prior to assembly into a device. In a motor, the magnets will demagnetize somewhat when the motor is first started. They will eventually end up running back and
forth along a recoil line that is below the virgin demagnetization curve. The point is that the
modeler cannot be sure exactly where the magnets are operatingan analysis that takes this sort
of hysteresis into account is beyond the scope of FEMM. Note, however, that this caution applies
only for nonlinear magnets; for practical purposes, rare-earth magnets generally do not exhibit this
sort of hysteresis behavior.
L
r o cW
(A.2)
and another reluctance for flux that flows through the air between laminations:
Rez,air =
L
o (1 c)W
(A.3)
where L and W are the length and width of the path traversed, and c is the fraction of the path filled
with iron. Adding these two reluctances in parallel yields:
Rez =
L
((1 c) + cr )oW
(A.4)
Since L and W are arbitrarily chosen, the bulk permeability of the section is:
ez = ((1 c) + cr )o
152
(A.5)
(A.7)
(1 c)L
oW
(A.8)
Rhard, f e =
Rhard,air =
(A.9)
r o
c + (1 c)r
(A.10)
If the material is laminated in-plane, all flux is flowing in the easy direction, and (A.6) is
used as the permeability for each element. In problems that are laminated parallel to x or y,
(A.6) and (A.10) are used as permeabilities in the standard fashion for elements with an anisotropic
permeability.
For harmonic problems, eddy currents flow in the laminations, and hysteresis causes additional
loss. If the laminations are thin compared to the other dimensions of the geometry, the effects
of eddy currents and hysteresis can be encapsulated in a frequency-dependent permeability [6].
In this case, the magnetostatic permeability, r is simply replaced by the frequency-dependent
permeability f d in (A.6) and (A.10):
h j
i
jh
h
d
2
2
tanh e
r e
jr o 2
fd =
(A.11)
jr o d2
In (A.11), h represents a constant phase lag between B and H due to hysteresis, is the conductivity of the lamination material, d is the thickness of the iron part of the lamination, and is the
frequency of excitation in rad/s. Note that the concept of hysteresis-induced lag can be applied to
154
am
cos(m + m )
m
m=1 r
(A.12)
where the am and m parameters are chosen so that the solution matches the prescribed potential
on the surface of the circle.
155
One could think of this solution as describing the solution exterior to a finite element problem
with a circular outer boundary. The solution is described inside the circle via a finite element
solution. The trick is to knit together the analytical solution outside the circle to the finite element
solution inside the circle.
From inspecting (A.12), one can see that the higher-numbered harmonic, the faster the magnitude of the harmonic decays with respect to increasing r. After only a short distance, the highernumbered harmonics decay to the extent that almost all of the open-space solution is described by
only the leading harmonic. If n is the number of the leading harmonic, the open-field solution for
large, but not infinite, r is closely described by:
an
cos(n + n)
rn
(A.13)
A
nan
= n+1 cos(n + n )
r
r
(A.14)
A(r, )
Differentiating with respect to r yields:
If (A.14) is solved for an and substituted into (A.13), the result is:
A n
A=0
+
r
r
(A.15)
Now, (A.15) is a very useful result. This is the same form as the mixed boundary condition
supported by FEMM. If the outer edge of the solution domain is circular, and the outer finite element boundary is somewhat removed from the area of primary interest, the open domain solution
can be closely approximated by applying (A.15) the circular boundary.
To apply the Asymptotic Boundary Condition, define a new, mixed-type boundary condition.
Then, pick the parameters so that:
n
o r o
= 0
c0 =
(A.16)
c1
(A.17)
where ro is the outer radius of the region in meters (regardless of the working length units), and
o = 4(107).
Although the above derivation was specifically for 2-D problems, it turns out that when the
same derivation is done for the axisymmetric case, the definition of the mixed boundary condition
coefficients are exactly the same as (A.16).
To apply the Asymptotic Boundary Condition to electrostatics problems, pick the parameters
so that:
o n
ro
c1 = 0
c0 =
(A.18)
where ro is the outer radius of the region in meters (regardless of the working length units), and
o = 8.85418781762e-012. Note that o is defined in the Lua implementation in both the preand post-processors as the global variable eo, which can be used in any script or edit box in the
program.
156
A quick note on computational efficiency: applying the absorbing boundary condition imposes no additional computing cost on the problem. The ABC is computationally no more timeconsuming to apply than enforcing A = 0 at the outer boundary. Solution times for the PCG solver
are equivalent in either case. It can also readily be derived that the ABC works exactly the same
for harmonics problems. (To see this, just assume that the am in (A.12) can be complex valued,
and follow the same derivation).
(A.19)
(A.20)
Assume that the near field region of the problem can be contained in a circle of radius ro centered
at the origin. The far-field region is then everything outside the circle.
One approach to unbounded problems is to attempt to map the unbounded region onto a
bounded region, wherein problems can more easilby be solved. Specifically, we desire a way
to transform the unbounded region outside the circle into a bounded region. One simple way to
make such a mapping is to define another variable, R, that is related to r by:
ro2
R=
r
(A.21)
By inspecting (A.21), it can be seen that this relationship maps the exterior region onto a circle of
radius ro .
158
The next step is to transform (A.19), the differential equation that the field must satisfy, into
the mapped space. That is, (A.19) must be written in terms of R and rather than r and . We can
evaluate derivatives in terms of R instead of r by employing the chain rule:
=
r R
dR
dr
=
R
R
ro
2
(A.22)
A
A
=
r
R
and we can substitute (A.22) into (A.19) to yield, after some algebraic manipulation:
A
1 2 A
1
R
+ 2 2 =0
R R
R
R
(A.23)
(A.24)
Eq. (A.24), the transformed equation for the outer region, has exactly the same form as inner
region, only in terms of R rather than r. The implication is that for the 2-D planar problem, the
exterior can be modeled simply by creating a problem domain consisting of two circular regions:
on circular region containing the items of interest, and an additional circular region to represent
the far field. Then, periodic boundary conditions must be applied to corresponding edges of the
circle to enforce the continuity of A at the edges of the two regions. The is continuity of A at the
boundary between the exterior and interior regions. For a finite element formulation consisting
of first-order triangles, (A.23) is enforced automatically at the boundaries of the two regions. The
second circular region exactly models the infinite space solution, but does it on a bounded domain
one could always back out the field for any point in space by applying the inverse of (A.21).
Kelvin Transformation Example open1.fem
As an example, consider an E-core lamination stack with a winding around it. Suppose that the
objective is to determine the field around the E-core in the absence of any flux return path (i.e.
when the magnetic circuit is open). In this case, the flux is not constrained to flow in a path that is
a priori well defined, because the laminations that complete the flux path have been removed.
The geometry was chosen arbitrarily, the purpose here being more the procedure than the actual
problem. The E-core was chosen to have a 0.5 thick center leg, 0.25 thick outer legs, and a slot
depth of 0.75. The material for the core is linear with a relative permeability of 2500. The coil
carries a bulk current density of 2 MA/m2. The input geometry is picture in Figure A.8.
In Figure A.8, the core is placed within a circular region, and a second circular region is drawn
next to the region containing the core. Periodic boundary conditions are applied to the arcs that
define the boundaries as shown in Figure A.8. The way that periodic boundary conditions are
implemented in FEMM, each periodic boundary condition defined for the problem is to be applied
to two and only two corresponding entities. In this case, each boundary circle is composed of two
arcs, so two periodic boundary conditions must be defined to link together each arc with in the
domain with the core to its corresponding arc in the domain representing the exterior region.
Also notice that a point has been drawn in the center of the exterior region. A point property
has been applied to this point that specifies that A = 0 at this reference point. The center of the
circle maps to infinity in the analogous open problem, so it makes sense to define, in effect, A = 0
159
161