Forces between cylindrical magnets

Deriving an equation to calculate the forces between cylindrical magnets is harder than for cuboid magnets (for which a closed form solution was first published in 1984).

Most recently, Ravaud et al. published (2010) an closed form expression for the force between coaxial magnetic cylinders, for which I’ve currently a paper in publication with a much simpler equation. You can download my code for implementing this in my repository of magnet code; the Matlab example is ‘examples/ravaud-cylmag.m’ and the Mathematica example has extension ‘.nb’ with the same name.

The force equation for coaxial magnets contains elliptic integrals, and when analysing the system for eccentric displacements in the radial direction the integral becomes, as far as I know, not possible to solve tractably. I’m aware of two different approaches for calculating the forces for these cases. The first is by Nagaraj in a somewhat-elusive paper from 1988 who simplifies the necessary integrals until only a double-integral that can be evaluated numerically. (A numerical evaluation of a nicely-behaved integral is typically around an order of magnitude slower than if a closed form solution is known.)

A more recent analysis of eccentric magnetic cylinder forces was published in 2009 by Vokoun et al., and to be honest their approach is a little alien to me; I haven’t looked into their maths very much and I don’t know if the implementation would be harder and/or more efficient than the approach used by Nagaraj.

Implementations of these latter two papers would be very useful for us at the moment but I don’t have time to do it myself right now; I have some honours students who might step up to the plate. If so, I’ll add their code to the magcode repository; a common theme with all this code is that a reference implementation saves people so much time when they need to use the theory publicised by these authors.

The DOIs for the papers mentioned above are:

  • Akoun & Yonnet 1984: 10.1109/TMAG.1984.1063554
  • Ravaud 2010: 10.1109/TMAG.2010.2049026
  • Nagaraj 1988: 10.1080/10402008808981815
  • Vokoun 2009: 10.1016/j.jmmm.2009.07.030

Obtaining less ugly printed Nichols plots

I’m unexpectedly teaching a course in system dynamics and PID control at the moment. In this course there is a somewhat complex display called a Nichols Plot, in which the log magnitude of an open loop transfer function (i.e., a complex function) is plotted against its phase, overlaid against contours of magnitude and phase of the closed loop dynamics. It’s these contours that cause some grief.

Using the in-built commands in both Matlab and Mathematica (resp. nichols and NicholsPlot) produces quite useable interactive plots which can be queried and manipulated on-screen. Information can be selected and extracted by clicking and pointing, which is largely the intention of using these sorts of techniques.

But for generating course material (slides, assignments, exams) neither Matlab nor Mathematica offer sufficient (user-accessible) features to produce print-quality output. Here’s the best I can do in Matlab:

Matlab nex

Actually, disregarding the clipping problem at the bottom of this plot, this is pretty close to what I’d like to get. All I want is a way to control those contour lines — solid light grey looks far better especially near that 6dB contour — but my brief investigation into trying to customise them didn’t get me very far.

And Mathematica is worse: (to be fair, Wolfram only recently added these plots to Mathematica so they’re still immature)

Mma nex

Frankly, the Mathematica output is largely unusable in print; contour labels are only visible on mouse-hover, which obviously is not suitable here; furthermore, these contour lines don’t have any customisation options, and digging into Mathematica’s internals for customising plots is even less fun than in Matlab. Finally, the tick labels need work so they snap to ±n 90°, which is yet something else that needs manual adjustment.

Here’s my first attempt at something a little better in Mathematica. I’m out of time now to keep playing with it, but I think I’m on the right track; all that’s missing is to omit the regions within the 6dB circle, etc. And then do the same thing in Matlab.

Better nex