I have a magnetic disk (Radius R, height h) that creates magnetic field lines (axisymmetrical). I simulated the field lines, exported the data and am now trying to fit a function into the data to have a analytical solution for the magnetic flux density of my specific magnet. For several r's fixed I have the magnetic flux Density $B_z(z)$ as well as $B_r(z)$

I need functions of the following form: $B_z(r,z)$ and $B_r(r,z)$ since I think $B_\phi (r,z)$ is $0$. So I am wondering how I need to start. I found the following equation online but I think its only for the absolute value, not $B_z$ and $B_r$ how I need it:

$$B(r,z) = \frac{\mu_0 m}{4\pi (z^2+r^2)^{\frac{3}{2}}}\sqrt{1+\frac{3z^2}{z^2+r^2}}$$

Can someone help me how my function needs to look? I was thinking something like: $$B_z(r,z) = \frac{a}{b+((z+c)^2+(r+d)^2)^{\frac{3}{2}}}\sqrt{1+\frac{3z^2}{z^2+r^2}}$$ or am I completely off now? And furthermore, how would I change to cartesian coordinates then?

Many thanks for your help!


1 Answer 1


My answer will probably be a little off topic, but why do you need this kind of analytical function ? Since you have the magnetic flux density (FEM simulation I guess), you can use any interpolation to get the B value anywhere... Unless you have a very specific need, if you only want to get the value of B anywhere, that is probably the easiest solution. I would use, for instance, scipy.interpolate.griddata or even interp2d if your mesh is regular.

From an academic point of view, the analytical solution of the induced magnetic field of a coil/magnet does not exist without the use of simplifications (ex. being far for the magnet (your equation), near the axe...).

  • $\begingroup$ Hey.. Yes its a FEM Simulation (Comsol to be specific) but in the end I want to have a Matlab function giving me the position depending on the magnetic flux density in z and r direction (or x,y,z). I am also near the magnet since everything is just around 1mm big. I want the whole thing not depending on the simulation if I can get a good approximation as a analytical function... Do you get what I mean? I am quite bad in explaining myself :) $\endgroup$
    – Kathiieee
    Commented Oct 17, 2014 at 14:27
  • 1
    $\begingroup$ In this case, the solution that is both the most accurate and the easiest is, I believe, loading the table in matlab and use interpolation. It is possible to assume an analytical equation and perform an optimization, but unless you have a very good guess, it won't be as accurate. Be careful, I doubt that the equation you mentioned will give you accurate results close to the magnet. Moreover, if there are other ferromagnetic pieces near the magnet, please remember that the magnetic field will be totally different. $\endgroup$
    – TZDZ
    Commented Oct 17, 2014 at 15:13
  • $\begingroup$ Isn't it possible to fit my data in a good guess function? Something with r and z to the power of 3? Or do you think that is too inaccurate? $\endgroup$
    – Kathiieee
    Commented Oct 17, 2014 at 15:29
  • $\begingroup$ I see two options. 1) you have a good guess, find a good analytical function that will more or less fit the data (it will be hard close to the magnet because of its geometry) 2) you use some piecewise interpolation that will use a systematic method, no luck/guess needed, with a better accuracy (because of its construction). Basically, the piecewise interpolated function is exactly the function you need, the only difference is the absence of simple analytical representation (for matlab, no difference). $\endgroup$
    – TZDZ
    Commented Oct 17, 2014 at 16:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.