Simulating Bar Magnet Fields

Simulating fields from bar magnets used for sensor applications is among the easiest electromagnetic simulation tasks.  

There are two main methods for doing this:

  • Finite-element analysis (FEA) software, and
  • Direct solutions of Maxwell's equations.

FEA software is a tested method for designing magnets.  It is capable of dealing with complicated geometries and challenging problems.  It is also quite expensive.  FEA software is well-known and documented.  There are many sources of good information about its capabilities and use.

Using direct solutions is not as well-known because there are not many applications where they are useful.  As it turns out,  many magnetic sensor applications are simple magnetic systems.  For applications with magnets (and with no magnetic material present), direct solutions to Maxwell's equations can be used.  Effective simulation tools can be built around these solutions at a fraction of the cost of FEA software.

This article focuses on the use of direct solutions.  The main reason is that few people know about or use this method.   Also, talking about direct solutions focuses attention on the magnetic characteristics of sensing applications.    


What is a direct solution to Maxwell's equations?

For well-designed bar magnets, there are formulas which give the magnetic field direction and strength around the magnet.  These formulas are derived from Maxwell's equations.  I've used them for hundreds of magnetic sensor projects in conjunction with FEA software.  I've found them to be a useful tool.  I found the accuracy comparable to FEA results for most simple bar magnet and sensor applications.

Physicists use Maxwell's equations to describe electricity and magnetism.  To an amazing degree of accuracy, these equations describe how electrical charges interact at a macroscopic level.  Mathematically speaking, they are a set of coupled partial differential equations.  If you put in boundary conditions and material equations, they can be used to accurately solve any electromagnetic problem.  In practice, they are too complicated to solve for most real-world applications.  FEA software implements numerical solutions to Maxwell's equations.  This allows people to simulate complicated magnetic systems.

In the case of simple magnet and sensor systems, we can get formulas for the magnetic fields from bar magnets.   The formulas for the field on the axis of simple bar magnet shapes are well-known.  There are a number of field calculators on the internet that implement them.  Formulas for the field anywhere around a bar magnet are less well-known and more complicated mathematically.  Rectangular magnet formulas have been known for a long time.  (I don't know the original source of those.)  They involve a combination of inverse tangent and logarithm functions.  I've seen a few of those implemented as field calculators in Excel and a few web sites.  Cylindrical and ring magnet formulas do not appear to be as well known.  They involve combinations of Elliptic integrals which are not trivially solved except in more advanced mathematical software.  I independently derived these a number of years ago for my own use and found some published a few years later in a different form.  I note too that I saw ring magnet formulas published which were incorrect. 

Note that a few assumptions are used when deriving the field formulas.

  • The magnet material must have an approximately square B-H curve.  Rare-earth and ferrite materials do.  Alnico materials do not.
  • The magnet design must not be too "flat".   The length to width ratio cannot be too small.  What is too small depends on the material, the magnet shape, and the temperature range of the application.  This is discussed in another article on magnet shape.

For most simple magnet and sensor applications, these assumptions are met.


How to Simulate Bar Magnet Fields

Accounting for tolerances is the most important part of bar magnet simulation for sensor applications.   This is very important so I will repeat it.  Accounting for tolerances is the most important part of bar magnet simulation for sensor applications.    Many people get hung up on the idea of simulation accuracy.  This is not the most important thing.  The most important thing is determining the potential range of field values that can occur for a given magnet design in an application.

A number of factors affect the tolerances for a given magnet design.

  • Material production variation
  • Magnet manufacturing variation
  • Temperature variation in the application
 

Let's step through a simulation example to illustrate this.   What is the expected field along the axis of a 6mm x 6mm Neo35H cylinder magnet?   We will solve this in 3 steps.

  1.    Solve the nominal case.
  2.   Look at the sources of variation.
  3.   Add up all of the sources of variation.
 

Nominal Field simulation Along Axis from North Pole

This plot used the formula for the field along the axis of a cylinder magnet.  The 0mm position is on the magnet face.

Note that many beginners would start and stop with this graph.  For sensor applications, it is necessary to understand how much variation can occur.  This graph is simply the starting point.

As a practical matter, this plot would not be far off from what your first prototypes would show.

 

The effect of different sources of field variation

There are four main sources of variation in the simulated field.  These will all likely occur for any design in production.

Material variation is how much the strength of the magnet varies due to production variation of the material.

Simulation uncertainty is the inherent error in using formulas or FEA software.  It's perhaps a few percent for most magnet work of this sort.

The temperature variation is how much the magnet strength varies with temperature.

The position variation is how much uncertainty there is in the mechanical mounting of the magnet in the application.

 

Effect of all tolerances on magnetic field

This plot shows the effect of adding together all of the tolerances.  In many applications, this is NOT negligible.

When designing magnets for use with sensors, you must take into account this type of variation.  It will show up in production runs for your application.  It is likely that you will often see +/-10% to +/-15% variations in field when all of the sources of variation are accounted for.

This variation can have a noticeable effect on the sensor performance.  It must be accounted for during the design phase.

 


Using either FEA software or field formulas for bar magnets will work.  The most important thing is running the appropriate variations of parameters to account for tolerances.  In any sensing application, the variations and tolerances will drive the sensor performance limits.

MagnetsDoc Stuve