Back in the before times, I worked in labs full of metal optical tables. We'd often clamp bits and pieces to the tables using these kinds of magnetic clamps1:

This image alone brings back the smell of a freshly-opened vaccum chamber...
These clamps were pretty magic to me - they required no power source, could be easily turned 'on' or 'off' by rotating a switch, and the clamping force went from very strong to nothing at all. Whenever anything in physics feels magic, magnets are almost always to blame! I had to understand how they worked.
The prompt to actually investigate the inner workings of these clamps came from the excellent video by Works By Design on YouTube - head to the 11:302 mark in the video below to see their explanation of the clamping physics:
A very brief summary of the above is (don't worry - we'll get to the gory details soon!) that the clamp contains a permanent magnet which rotates:
- Off - the magnet is rotated such that the magnetic field lines don't penetrate the metallic table, so there is no attraction force.
- On - the magnet is rotated so the field penetrates the table, and there is a large attraction force.
The clamp consists of two different materials with different magnetic properties, which magically allows you to turn the clamp on and off - a 'spacer' material separating two iron blocks. But how?
Let's cut right to the chase - here's an interactive simulation of the clamp setup in 2D, where you can play with:
- - the rotation angle of the magnet (0 degrees means 'on')
- - the radius of the magnet
- - the relative permeability of the spacer material
- - the relative permeability of the table
- - the relative permeability of the iron blocks
- - the strength of the magnet
After solving for the magnetic field (shown by the lines, and colour-coded by strength), we also calculate a rough approximation of the pulling force on the table. This comes to ~74kg, which is actually a surprisingly good match to the quoted value of 70kg for this clamp (see the link above to the data sheet).
WebGPU simulation of a magnetic clamp. The contours are constant vector-potential lines, colored by magnetic flux density.
While you are quite within your rights to read no further now you've been given your toy to play with, you'd be missing out on a diversion into one of the less-sexy areas of electromagnetism - magnetostatics! With all of the fun of time-dependence and electricity stripped out, do Maxwell's equations have any fight left in them? Let's see.
Magnetic magic physics
There are a couple of different fields to keep in mind when thinking about magnetism in the presence of magnetic materials:
- - the real magnetic field that exerts forces on moving charges
- - just the part of the field due to free currents
- - just the part of the field due to intrinsic magnetisation
which are related as
where is a constant.
For materials without any intrinsic magnetisation, they can become magnetised in response to a field, e.g. an -field produced by a current. In simple situations this response is linear: for some material-related constant , and therefore - the magnetic field inside materials is boosted by a factor - the relative permeability of the material.
Permanent magnets are handled in this model by adding a so-called remanent magnetic field3 to the total (e.g. one which persists in the absence of free currents), so . As we'll see later, this remanent field acts much like a free current in that it can induce magnetisation in other materials.
Definitions complete, we can now add to the mix the physics that tells us how these fields vary in space:
i.e. there are no magnetic monopoles - magnetic field lines are closed loops, and
where is the current density i.e. free currents create magnetic fields as noted above.
Magnetic circuits
Because magnetic field lines flow in loops, it's often useful to think of building a magnetic circuit analagously to an electrical circuit - like voltages () push a current () through a resistance (), permanent magnets () push a magnetic flux () through a reluctance ():
a relation known as Hopkinson's law4. If you want to build a good magnetic clamp, you'll want to maximise the flowing through the steel table: the flux is just the area integral of the magnetic field .
Let's see how this relation comes about in our magnetic circuit. Given there are no free currents about, we have that and therefore
i.e. the integral of around a closed loop vanishes. The loop we want to consider proceeds through the magnet, through some other materials, and back into the magnet again:
Inside the magnet, from the relation above we know that
where is the relative permeability of the magnet. Let's also say:
- The flux is constant throughout - where is the cross-sectional area of the flux
- The magnet has length and area
- The return path has length , area and permeability
then
so
The left term looks like the 'forcing' term pushing the flux - it goes up for a stronger, longer magnet, i.e. . The terms on the right act like resistances - if they go up, the flux goes down, making it more difficult for to drive the flux. We therefore associate them with magnetic reluctances .
The final solution for the flux in this setup is therefore:
This is a simple equation, but it tells us a few important things:
- Stronger magnets (higher ) mean more flux (admittedly we could have figured that one out ourselves)
- Higher means lower , means more flux
- The intrinsic reluctance of the magnet is baked in to the circuit in series with the return path - this makes sense, as it is made of some kind of material after all!
Available flux is conserved, so if given a choice between low and high reluctance materials, Maxwell's equations tell us that it will settle in the low-reluctance material - the field strength becomes amplified and concentrated there.
Well that's all well and good, but what does it have to do with this clamp?
Ah, thanks for getting me back on track there. Now we know that magnetic fields will seek out a path with the lowest possible reluctance, we can compare the two configurations for the clamp:
- Off - the field lines flow up out of the magnet and really want to avoid the high- spacer material. They flow straight into the low- iron blocks, and stay trapped inside while looping around back to the bottom of the magnet. There's no need to ever flow into the table, so there is very little force exerted on it.
- On - the field lines flow sideways out of the magnet, straight into the iron. Great! Then they try to loop back round under the magnet, and encounter the spacer. Bad! Fortunately there is a lovely low- table just there, so they can dip into the table and circumvent the spacer, before flowing back into the magnet.
Once you have a -field crossing from the clamp into the table, you can think of the (tiny) gap in-between supporting a magnetic energy density . Moving the clamp from the table would require adding energy to this volume (to maintain the energy density), which implies pushing on the clamp with a force . It doesn't take a big change in magnetic field to create a strong force! Notice in the simulation above how few field lines actually head into the table, compared to staying within the iron.
Oh yes, the simulation?
We've covered most of the physics we need to understand the mighty table clamp, but there's a bit more required to actually simulate this setup - let's cover those pieces.
Because , we can write as the curl of a magnetic vector potential
and so substituting gives
(The current density here includes both free and bound currents - only the latter is present in the permanent magnet).
We're only interested in a 2D simulation here, e.g. only has components in the - plane. Therefore (and ) must only have a -component, and
Substituting for in the equation above, we end up with a 2D PDE for the single -component:
Finally, the source term needs to be constructed from the magnet magnetisation vector . Given that
and the magnet is pointing in the direction, we have
so
The magnet strength is actually constant across the magnet in this simulation, so you can think of the bound magnetisation current as running in a thin strip around the edge of the magnet, directed out of the plane.
Solving the 2D case
OK, we've finally got an equation just in terms of things we know (, , ) and things we don't () - let's get to solving it. We'll use our favourite approach of finite differences, where we set up a uniform 2D grid and solve for values in each grid cell.
Assuming the grid is indexed like and the size of the grid cells is , the equation to solve on each grid cell looks like:
Aargh, this is much worse! Fortunately there is a numerical trick we can play that works well in this situation - we first rearrange this equation and solve for the current grid cell in terms of its neighbours.
Do this for all grid cells, and we have a new solution for across the whole grid. Then repeat! Use the new values on the RHS of the equation, and compute some newer ones - rinse and repeat until the values stop changing (or their changes reduce below some threshold). You can see this happening visually in the simulation above - after changing a parameter, the solver resets and starts computing new values until convergence.
This approach is known as relaxation5, which is an appropriate name as it's indeed quite relaxing to not have to worry about any more complicated maths. (The interested reader can see Ethan Epperley's6 blog for some real computational methods.)
Making it interactive
Now this was all working well - the field configurations looked reasonable, and the computed forces were even in the right ballpark. (As an ex-experimental physicist, I'll take anything within 2 orders of magnitude as a success.)
However running in the browser on the CPU, a 128x128 grid was taking several seconds to converge and render. This is fine if you're writing a paper and being all serious, but I just wanted a fun simulation to play with (and on a serious note, real-time interactivity really does help with gaining an intuitive understanding of a physical situation). This of course means dumping everything on the GPU (my favourite pastime) which sped things up a lot. The benefit of this relaxation algorithm is that all cells can be updated independently, and so benefits hugely from the massive parallelisation you get for free on the GPU.
The approach goes roughly as follows, with everything staying in buffers on the GPU:
- Update the uniform buffer with the current control values.
struct Uniforms {
angle: f32,
magnetRadius: f32,
separatorMu: f32,
tableMu: f32,
ironMu: f32,
magnetStrength: f32,
}
- Run many relaxation steps, alternating between two storage buffers.
- Compute the residual between the last two buffers.
@compute @workgroup_size(256)
fn main(@builtin(local_invocation_id) local_id : vec3<u32>) {
let lid = local_id.x;
var local_delta = 0.0;
let total_nodes = u32(uniforms.nx) * u32(uniforms.ny);
for (var idx = lid; idx < total_nodes; idx += 256u) {
local_delta = max(local_delta, abs(A_latest.data[idx] - A_previous.data[idx]));
}
}
- Find the min/max values of for computing contours (this again benefits from parallelisation).
- Estimate the pulling force by computing the magnetic pressure in the air gap.
- Compute the contour lines using marching squares7.
- Render the materials and contours.
- Copy the residual and force buffers back to the CPU, to render to the screen or decide to stop solving.
Simulation results
Blimey, it's taken a lot of physics and code to get to this point. Let's relax with the scientist's favourite pastime - plotting things changing in response to other things.
First and foremost: the pulling force as a function of the rotation angle. As expected, this smoothly rolls off to zero as the clamp is switched off.
Another interesting question is to ask: how much do the non-magnetic spacer components matter? Running the same simulations again for different values of , we see that increasing the spacer permeability rapidly lowers the force on the table:
120
though the drop levels off fairly quickly:
Let's see if we can understand this falloff using a rough circuit model. The magnet 'force' is pushing useful flux through the table with reluctance , and wasted flux through the separator with reluctance :
where
In an ideal case, the flux through the table would be simply , independent of the separator. Nothing is ever ideal though, so let's assume the magnet, air, table. etc. contribute their own reluctance , so the magnetic 'force' across the table/separator is a lower effective value .
We then have
If we define the combined reluctance by , then
Now the relation for the total circuit, including the non-ideal reluctance , is
Substituting this value for into the definition of we get:
The useful table flux is the part driven through , so now we know we can calculate as follows, substituting for from above:
Finally, to get the dependence on write
for some constant , then
Phew! This model circuit gives us a flux through the table that looks like (furiously waves hands)
for some constant . We know that the pull force scales like , or
Now this is only a sketch, but it does capture some of the qualitative behaviour - a small change in separator permeability will have a big impact on pulling force, which drops of more slowly as it grows. We don't capture here the fact that there seems to be a floor in the pulling force, but that's likely due to fringe fields leaking into the table regardless of the separator.
I'm glad we finally found the time to give the humble table clamp the appreciation it deserves. A simple invention, but one that's backed by actual honest-to-god proper physics. Who wouldn't like that?
References
- https://www.first4magnets.com/product/63-x-50-x-55mm-high-switchable-magnetic-base-with-m8-mounting-hole-70kg-pull-19206?variant=1144&gad_source=1&gad_campaignid=23681945015&gbraid=0AAAAAD2d-osLm-u4gZPqs32j-WTLSKCTk&gclid=Cj0KCQjwlerQBhDMARIsAB16H-Ui5J5g9w3IRSbNf762U9hc-dkvDM3DdD7KHulRarqyqdYltki1M2QaAkw6EALw_wcB
- https://youtu.be/-qUu8kIliy8?t=697
- https://en.wikipedia.org/wiki/Remanence
- https://en.wikipedia.org/wiki/Magnetic_circuit
- https://en.wikipedia.org/wiki/Relaxation_(iterative_method)
- https://www.ethanepperly.com/index.php/blog/
- https://en.wikipedia.org/wiki/Marching_squares