Finite Element Method Magnetics : FAQ

FAQ


If you are a first-time user, the best way to start is by completing the FEMM tutorial. You can get to the tutorial via the FEMM entry of your Windows start menu or at the MagneticsTutorial page. Some users prefer the old tutorial instead.

Several frequently asked questions about FEMM are addressed below. The answers to many other FEMM-related questions can often be answered by searching the old FEMM Mailing List Archives.

There is also an active FEMM user's group at http://groups.yahoo.com/group/femm/.


Questions


1 Do I need a special license to use FEMM analyze problems on a commercial job?
2 For AC problems, does FEMM use Peak or RMS currents/fluxes?
3 FEMM returned unexpectedly high flux densities for my problem. What's going on?
4 Does FEMM take saturation into account?
5 Why aren't there any eddy currents in my AC problem?
6 Why is H pointing the wrong way inside my permanent magnet?
7 Why does the field due permanent magnets disappear in AC problems?
8 Does FEMM simulate problems with motion-induced eddy currents?
9 The solver doesn't finish running. What's going on?
10 Why do the reported losses go down rather than up when I increase the frequency?
11 The eddy current distribution in my device doesn't look right. What's going on?
12 Can I drive coils with a specified voltage rather than a specified current?
13 Which version of Lua does FEMM use?
14 How do I put a comment in a Lua script?
15 How do I run a Lua script from the command line?
16 The forces predicted by FEMM are different than I expected. What's going on?
17 The torques predicted by FEMM are different than I expected. What's going on?
18 How do I simulate an induction motor?
19 There are weird errors and/or crashes when I try to run FEMM. How do I fix this?
20 Is there a 3D version of FEMM?
21 What are some good reference books about finite elements?
22 Why does the Triangle mesh generator fail on some geometries?
23 Is there a native Linux version of FEMM?
24 How do I reference FEMM in an academic publication?
25 Why is the AC force for my problem about half of the force reported in a DC simulation?
26 Why are are DC and 2X frequency force results reported when I compute force on an AC problem?
27 Why isnít the flux in phase with the current in an AC analysis and/or why is the inductance complex-valued?
28 How do I separate the real and imaginary parts of a complex number in Lua?
29 How do I build FEMM with Visual Studio Express Edition?
30 How do I minimize the FEMM window and/or solver during Matlab script execution?

1 Do I need a special license to use FEMM analyze problems on a commercial job?


There's no fee or special license required for simply using the results of the codes that are up on the website as part of an analysis done for some commercial purpose. Like it says in the license:

(b) Activities other than copying, distribution and modification of the
Program are not subject to this License and they are outside its scope.
Functional use (running) of the Program is not restricted, and any
output produced through the use of the Program is subject to this
license only if its contents constitute a work based on the Program
(independent of having been made by running the Program).

In other words, you can use the results of the program for pretty much any purpose. However, you do need a special license to resell the program itself or to include pieces of the source in a commercial product.


2 For AC problems, does FEMM use Peak or RMS currents/fluxes?


In FEMM, everthing is Peak, not RMS. More specifically, for AC problems, all quantities (currents, fluxes, etc.) are represent as complex numbers where the absolute value of the number represents the amplitude, and the argument of the numbers represent phase shift. For example, if a was a complex number representing the magnetic vector potential at some point, we could explicitly represent vector potential as a function of time, A(t), using the equation:

A(t) = Re[a (cos ωt + j sin ωt) ] = Re(a) cos ωt - Im(a) sin ωt = Re [a ejωt]


3 FEMM returned unexpectedly high flux densities for my problem. What's going on?


FEMM will only give reasonable results if you are interpolating between defined points on the B-H curve for the material. Depending on your particular problem, you may need to add points to your B-H curves so that you are always interpolating rather than extrapolating.

For nonlinear AC problems, there is also another factor at play. In this type of problem, FEMM is solving for the amplitude of the fundamental part of the field, which allows bigger values of flux density to appear than would be possible in a magnetostatic solution. For example, consider a material that saturates at about 2 Tesla. Imagine that at some point in the material, the flux density is traversing a a square wave versus time, varying between -2 Tesla and 2 Tesla. This would be analogous to an AC problem in which the material was subjected to a high degree of saturation. In this case, the amplitude of the fundamental is 2 Tesla * (4/π ), or 2.54648 Tesla. Although the peak value considering all harmonics is 2 Tesla, it is reasonable for significantly higher flux densities to appear when just the fundamental is considered. Although the amplitude values produced by the nonlinear time harmonic simulation seem intuitively odd, the forces and losses resulting by these calculations are typically reasonable.


4 Does FEMM take saturation into account?


Yes. See Question 3.


5 Why aren't there any eddy currents in my AC problem?


Make sure that the materials that you are using have reasonable values for conductivity (i.e. not zero).


6 Why is H pointing the wrong way inside my permanent magnet?


By default, FEMM takes the view that permanent magnets are essentially the same as solenoids. That is, the magnet is modeled as a chunk of low-permeability material. The "source" of the PM's flux is a current sheet of density Hc*(mn) on the edges of the permanent magnet, where Hc is the magnet's coercivity, m is a unit vector in the direction of magnetization, and n is an outward unit normal to the edge of the PM. This is a fairly typical way to model permanent magnets in the context of a finite element formulation (because it is any easy way to include PMs), and it is also equivalent to a magnetic charge-based formulation. This issue is also discussed in one of the appendices of the FEMM manual.

By changing a preference, it is possible to make FEMM display the demagnetizing field intensity instead of the equivalent coil field intensity. Just select the "Demag. H in PMs" selection on the "Magnetics Output" preferences tab. This selection shifts the magnet's operating point back to the second quadrant for display and computation purposes.


7 Why does the field due permanent magnets disappear in AC problems?


The AC simulations in FEMM simulate only one frequency at a time. Since permanent magnets produce a DC flux, their contribution to the field is only visible in DC simulations. At frequencies other than DC, permanent magnets look like "plain" low permeability (and possibly conductive) materials.


8 Does FEMM simulate problems with motion-induced eddy currents?


No. FEMM does not model eddy currents induced by motion.


9 The solver doesn't finish running. What's going on?


You probably didn't apply any boundary conditions to the problem. Although the solver will sometimes find a solution in cases in which boundary conditions haven't been specified (e.g. in cases with only permanent magnets), it's not guaranteed to finish unless you have defined boundary conditions on the edges of your problem.

The easiest type of boundary condition is the "Prescribed A" boundary condition type. Set all of the parameters to zero. Apply this boundary condition to all the outside edges of your solution region.


10 Why do the reported losses go down rather than up when I increase the frequency?


This seemingly odd behavior can happen in AC problems in which you specify the currents by imposing a "source current density" (J) via the definition of a material, rather than creating a "circuit" to supply the current. The source current density that is being specified as part of the material properties is the current density that would be there in the absence of induced currents. Setting the source current is, in some sense, like setting the applied voltage. When the problem is evaluated at a non-zero frequency, there is non-negligible inductive impedance so that extra voltage is required to get the same net current as would be obtained at DC. Since the current is attenuated by inductance, the total losses are less.

You can "correct" this problem either by setting the conductivity of the region to zero, or by imposing the current on the region via a "circuit" property.


11 The eddy current distribution in my device doesn't look right. What's going on?


In 2D planar problems, all parts of the problem are, by default "shorted together at infinity." If there is a specific connectivity of the regions in your problem, you have to impose that connectivity by the way that you define the problem. This is usually done by defining a parallel-type circuit in which the total current is zero. This circuit property is then applied to all regions that are supposed to be connected together (that is, all the regions over which the current is to be conserved).

In addition, always make sure that the mesh has been defined to be adequately fine in blocks in which a small skin depth is expected. This can be done either by defining a small mesh size for entire regions that are subject to eddy currents, or by defining a fine mesh density on the lines or arcs that form the surface of the region. For small skin depth problems, defining a fine surface mesh is the more efficient way to go.


12 Can I drive coils with a specified voltage rather than a specified current?


No. In FEMM, you can only specify the current in a coil. The post-processor does, however, report the voltage across a coil in which the current in the coil has been defined via "circuit properties."


13 Which version of Lua does FEMM use?


FEMM has the Lua 4.0 scripting language embedded within it. The reference manual for Lua 4.0 is here.


14 How do I put a comment in a Lua script?


Precede the comment by two hypens, e.g.:

-- This is a comment


15 How do I start a Lua script from the command line?


You can specify the Lua script that you want to run via the syntax:

femm.exe -lua-script=yourscript.lua -windowhide

The addition of -windowhide makes femm run with the window minimized.

In addition to the name of a lua script, lua variable definitions can be passed over the command line using the lua-var flag, e.g.:

-lua-var=goldenratio=1.61803399


16 The forces predicted by FEMM are different than I expected. What's going on?


It's possible to get bad force results if you don't set up your problems carefully and if you don't compute the force in the right way.

* Only use the "weighted stress tensor" volume integral to obtain forces. This method tends to have a lot less error than integrating Maxwell's stress tensor on a contour. Also refer to Section 2.3.11 in the FEMM Manual.

* For 2D problems, make sure that the correct depth in the into-the-page direction has been specified via the Problem Definition dialog.

* Make sure to use a fine mesh density when you are computing force, especially in the air air the part of interest. In applications like motors, it's usually desirable to have several rows of elements in the gap between the rotor and stator. When in doubt, re-run the problem with a finer mesh. You can double or halve the mesh prescribed mesh density in all blocks simultaneously by pressing F3 and F4 respectively.

* Be careful on 2D problems. Is 2D really a good approximation for your case, or will end effects lead to significant errors in force (and impedance)?

* Force can also be nontrivial to measure experimentally. Mechanisms that can introduce error into experimental measurements include friction in the experimental setup, load cell calibration, accurate control of current, accurate control of air gaps, and so on.


17 The torques predicted by FEMM are different than I expected. What's going on?


See above Question 16 - the same issues that influence force calculation also apply to torque calculation. Also remember that the torque computed by FEMM is typically the torque about the point (0,0). Misleading results can often occur if you are attempting to compute the torque on a rotor that is not centered at (0,0).


18 How do I simulate an induction motor?


Look here for an example analysis of an induction motor.


19 There are weird errors and/or crashes when I try to run FEMM. How do I fix this?


You may need the VC++ 2008 (x86) Redistributable Package or the VC++ 2008 (x64) Redistributable Package, depending on whether you have installed a 32- or 64-bit version of FEMM.

If you are trying to install an old version (prior to 01Oct2011), you probably have "bad" versions of mfc42.dll and msvcrt.dll on your machine. You can download versions of these files that are compatible with FEMM from here. Put the dlls in the same directory as the FEMM executables (typically c:\progra~1\femm42\bin for FEMM prior to 01Oct2011).


20 Is there a 3D version of FEMM?


No. For intrinsically 3D magnetostatic problems, I sometimes use Radia.


21 What are some good reference books about finite elements?


P. R. Silvester and R. L. Ferrari, Finite elements for electrical engineers, third edition, Cambridge University Press, 1996.
S. R. H. Hoole, Computer-aided analysis and design of electromagnetic devices, Elsevier, 1989.
N. Ida and J. Bastos, Electromagnetics and calculation of fields, Springer-Verlag, 1997.
N. Bianchi, Electrical machine analysis using finite elements, CRC Press, 2005.


22 Why does the Triangle mesh generator fail on some geometries?


If your geometry contains intersecting lines that form very small angles, triangle can run into problems meshing in the region of the intersection. The same issue can occur if you have a geometry with a line tangent to an arc, because very small angles can occur at the point of tangency. Sometimes, it is sufficient to change the Min Angle parameter in the Problem Definition dialog (reached by the Problem main menu selection in the preprocessor) so that it is a smaller value than the default 30 degrees (e.g. 20 degrees). In other cases, it may be necessary to redraw the geometry to get it to mesh correctly, e.g. put a small radius instead of a sharp corner; put a small gap between a tangent circle and line, etc.


23 Is there a native Linux version of FEMM?


No. However, FEMM has been tuned so that it runs properly on Linux machines via Wine. See the LinuxSupport page for more details.


24 How do I reference FEMM in an academic publication?


Reasonable ways to reference computer programs in journal articles, dissertations, etc., are described on the web, e.g.:
http://www.columbia.edu/cu/cup/cgos/basic.html
http://www.public.iastate.edu/~donpayne/310/chicelec.html

I'd probably pick something like:

D. C. Meeker, Finite Element Method Magnetics, Version 4.0.1 (03Dec2006 Build), http://www.femm.info


25 Why is the AC force for my problem about half of the force reported in a DC simulation?


Although this behavior might seem strange, it is actually correct. The trick here is that in a harmonic problem, the field varies sinusoidally, but the force is related to the square of the field, producing a DC component, and a 2-times frequency component, but no force at the drive frequency.

To see this effect, consider for example a simple c-core electromagnet acting on a slab of iron. The instantaneous force on one pole of the c-core can be obtained via Maxwell's stress tensor:

F = B2*area/(2*μo)

Now, imagine that the problem is harmonic, and the gap flux density, B, is defined as:

B = Bo*cos ωt

Substituting in the force gives:

F = Bo2 * cos2 ωt * area / (2*μo)

Now, using the trigonometric identity cos2 ωt= (1/2)*(1+cos 2ωt) gives:

F= area*Bo2/(4*μo) + (area*Bo2*cos 2ωt)/(4*μo)

So there are 2 components of the force: a DC part of the force, and a part at twice the drive frequency. Now, the DC part is 1/2 of what it would be if the problem were evaluated at 0 Hz, so that the peak force is the same as in the DC case (e.g. when t=0, π/ω, etc.) when the cosine part adds to the DC component. Conversely, the minimum force is zero when the cosine part cancels the DC part (at the instants where the current driving the fields passes through zero).


26 Why are are DC and 2X frequency force results reported when I compute force on an AC problem?


See Question 25.


27 Why isnít the flux in phase with the current in an AC analysis and/or why is the inductance complex-valued?


Eddy currents and hysteresis make the flux lag the current and make the inductance complex-valued. The imaginary part of the resulting inductance is associated with eddy current and hysteresis losses.

Consider an inductance, L, that is complex-valued. The inductance could be decomposed as: L = Lr - j Li where Lr and Li are the real and imaginary components of L respectively. Now, consider the impedance that is implied: Z = j ω L, where ω represents the frequency in radians per second. Expanding this out, we get:

Z= j ω Lr + ω Li

The imaginary part of the inductance contributes a real part to the impedance, associated with losses. You could interpret the (ω Li) term as the frequency-dependent part of the circuit's resistance. The real part of the inductance the forms the imaginary part of the impedance, associated with inductive energy storage.


28 How do I separate the real and imaginary parts of a complex number in Lua?


If x represents some complex-valued number in Lua, you can get the real and imaginary parts with the built-in functions re(x) and im(x), respectively. Other useful built-in functions for manipulating complex numbers are:

abs(x) Returns the magnitude of complex number x
arg(x) Returns the argument of complex number x in radians (essentially the same as atan2(im(x),re(x)))
conj(x) Returns the complex conjugate of complex number x.

All built-in math functions should give the correct results for complex-valued arguments.

It is also important to note that in FEMM's implementation of Lua, sqrt(-1) is represented by the uppercase I. When representing complex numbers, always multiply by I. For example, the complex number 100*I is valid, but 100I would give an error. If you ask Lua to print out a complex number, that number will follow the same convention. For example, if the command:

print(tanh(1+I))

would return the answer:

1.083923327338695+I*0.2717525853195117


29 How do I build FEMM with Visual Studio Express Edition?


FEMM uses MFC code, but MFC code isn't really supported by Visual C++ Express. There is a "How to compile MFC code in Visual C++ Express" page on Code Project -- mileage may vary. Alternatively, free trial versions of Visual Studio Professional are available that support compiling MFC code.


30 How do I minimize the FEMM window and/or solver during Matlab script execution?


You can use the main_minimize function at the beginning of your Matlab script to hide the FEMM window. When you run an analysis, you can call it with mi_analyze(1) to hide the solver window that pops up when you do an analysis.

For Mathematica, the syntax is MainMinimize[] and MIAnalyze[1].

Some people have also run FEMM in a virtual machine (via VirtualBox or Virtual PC). Then, they can minimize the entire virtual machine.