2
$\begingroup$

I want to produce publication-quality drawings of the field of a bar magnet, in both the field line representation and as a "sea of arrows." I've found some open-source software that looks like it will do this (matplotlib, with the quiver and streamplot functions), but it would be convenient to have some closed-form equation that would produce a good enough expression for the field.

In principle I guess there is a physically well-defined statement to the problem with a well-defined solution. You would have a cylinder or rectangular box made of a uniformly magnetized, highly permeable material. However, I don't really care if it's the right solution to some idealized version of the problem, as long as it looks reasonable (compared to photos of iron filings) and is physically admissible (e.g., it would be bad if it had a nonvanishing divergence).

Any suggestions on how to cook up a reasonable analytic expression that will look sort of right? It would probably have two different forms on the interior and exterior, with discontinuities in the field at the surface.

Maybe the thing to do is to start from a magnetic potential $\textbf{A}$, then distort it somehow, then take its curl. That way we would be guaranteed to get a $\textbf{B}$ with a vanishing divergence. I don't really care if the calculus is a little messy, as long as it's closed form. I can crank out an ugly curl using a computer algebra system.

Maybe another possibility would be just to add up a multipole expansion up to some order, and fiddle with the coefficients, but it seems like this could take a lot of trial and error, and the abrupt kinks in the field lines at the surfaces would seem impossible to reproduce with a finite number of terms.

$\endgroup$
1
$\begingroup$

I was working on simulating magnetic fields recently and also came across some Python source code which does FEA on current distributions and space to draw vectors everywhere. I'm sure it could be extended to use streamplot though I haven't worked with that.

Regarding an analytic solution. It depends what you're looking for. If you want an expression for the field everywhere the solutions are not going to be very nice. Perhaps you've come across this formula for the magnetic field of a loop of current off axis? You could model your bar magnet as a number of loops stacked on top of each other and use this formula to get the field most everywhere (it will be a bad approximation close to the magnet itself). This is if you're ok with working out many many elliptic integrals functions.

Honestly a more straightforward analytic solution to probably sum up the field of many magnetic dipoles filling the volume of your bar magnet. Or, if you truly truly want to stay analytic you should imagine the bar magnet as being a volume filled with a uniform (or otherwise) dipole magnetization density. You can then use the formula for the field due to a particular dipole element and then integrate (rather than sum) over the volume. Likely this can be "written down" analytically. I don't know how nasty it will be.

For my application it ended up being much simpler and faster computationally to just go ahead and go numeric and use the FEA.

$\endgroup$
  • $\begingroup$ Thanks, this is interesting. I don't think the realistic field for a bar magnet really is a sum of dipoles, is it? I think the permeability also matters. If it was a sum of dipole fields, then it would be formally equivalent to the electric field of a capacitor. The actual field should have kinks in it at the surface (but should not blow up there as the field of a current loop would). $\endgroup$ – Ben Crowell Nov 15 '18 at 19:32
  • $\begingroup$ You should be able to treat it as a medium with a uniform permeability and fixed magnetization. You can then calculate the $\textbf{H}$ field everywhere, which should be continuous. When you calculate the $\textbf{B}$ field you will get the kink at the surface which you are looking for. $\endgroup$ – jgerber Nov 15 '18 at 23:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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