29/06/2017
Easy simulation of magnetic stray fields using freeware and open source tools.
Sometimes you need to calculate the magnetic stray field from a permanent magnet, or a current distribution. Since the sources (“magnetic charges, currents”) are known, you can obtain the magnetic field by integration over sources (e.g. Biot-Savart method). Programs like Sage (freeware) or Matlab, Maple and Mathematica (all commercial) are helpfull. If you need to illustrate the field distribution, you need to do this integration over a wide range of points. In that case a finite element method is handy, even though you do no actually solve a differential equation. Finite elements also provide you with a control to check whether you did your intergration correctly. Many people use Comsol. A good open source alternative is FreeFEM++ (opensource). Examples on how to deal with (magnetic) charge distributions can be found in the manual, including the weak formulation of the differential equation. Unfortunately, for current distributions the weak formulation is not given. For current distributions in a cylindrical coordinate system, you can download an example for cylindrical coordinate system here.