Clampere's law

15 min read Original article ↗

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:

  1. Off - the magnet is rotated such that the magnetic field lines don't penetrate the metallic table, so there is no attraction force.
  2. 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?

Switchable magnetic clamp in off and on statesA two-panel diagram of a switchable magnetic clamp. The off panel shows flux closing inside the clamp body, while the on panel shows flux crossing the air gap and steel table.
The direction of the magnet relative to the clamp and table determines the attraction force.

Let's cut right to the chase - here's an interactive simulation of the clamp setup in 2D, where you can play with:

  • θ\theta - the rotation angle of the magnet (0 degrees means 'on')
  • RmR_m - the radius of the magnet
  • μr,sep\mu_{r,sep} - the relative permeability of the spacer material
  • μr,table\mu_{r,table} - the relative permeability of the table
  • μr,iron\mu_{r,iron} - the relative permeability of the iron blocks
  • BrB_r - 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:

  • B\mathbf{B} - the real magnetic field that exerts forces on moving charges
  • H\mathbf{H} - just the part of the field due to free currents
  • M\mathbf{M} - just the part of the field due to intrinsic magnetisation

which are related as

B=μ0(H+M)\mathbf{B} = \mu_0(\mathbf{H} + \mathbf{M})

where μ0=4π×107 H/m\mu_0 = 4\pi\times10^{-7}\text{ H/m} is a constant.

For materials without any intrinsic magnetisation, they can become magnetised in response to a field, e.g. an H\mathbf{H}-field produced by a current. In simple situations this response is linear: M=χmH\mathbf{M} = \chi_m \mathbf{H} for some material-related constant χm\chi_m, and therefore B=μ0(1+χm)H=μ0μrH\mathbf{B} = \mu_0(1 + \chi_m)\mathbf{H} = \mu_0 \mu_r \mathbf{H} - the magnetic field inside materials is boosted by a factor μr\mu_r - the relative permeability of the material.

Permanent magnets are handled in this model by adding a so-called remanent magnetic field3 Br\mathbf{B}_r to the total (e.g. one which persists in the absence of free currents), so B=μ0μrH+Br\mathbf{B} = \mu_0\mu_r\mathbf{H} + \mathbf{B}_r. 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:

B=0\nabla \cdot \mathbf{B} = 0

i.e. there are no magnetic monopoles - magnetic field lines are closed loops, and

×H=J\nabla \times \mathbf{H} = \mathbf{J}

where J\mathbf{J} 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 (VV) push a current (II) through a resistance (RR), permanent magnets (F\mathcal{F}) push a magnetic flux (Φ\Phi) through a reluctance (R\mathcal{R}):

Φ=FR\Phi = \frac{\mathcal{F}}{\mathcal{R}}

a relation known as Hopkinson's law4. If you want to build a good magnetic clamp, you'll want to maximise the Φ\Phi flowing through the steel table: the flux is just the area integral of the magnetic field Bds\int\mathbf{B}\cdot\text{d}\mathbf{s}.

Let's see how this relation comes about in our magnetic circuit. Given there are no free currents about, we have that ×H=0\nabla \times \mathbf{H} = 0 and therefore

Hdl=0\oint\mathbf{H}\cdot \text{d}\mathbf{l} = 0

i.e. the integral of H\mathbf{H} 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:

magnetHmdl+returnHdl=0\int_\text{magnet}\mathbf{H}_m\cdot \text{d}\mathbf{l} + \int_\text{return}\mathbf{H}\cdot \text{d}\mathbf{l} = 0

Inside the magnet, from the relation above we know that

H=BBrμm\mathbf{H} = \frac{\mathbf{B} - \mathbf{B}_r}{\mu_m}

where μm\mu_m is the relative permeability of the magnet. Let's also say:

  • The flux is constant throughout - Φ=B/A\Phi = B/A where AA is the cross-sectional area of the flux
  • The magnet has length m\ell_m and area AmA_m
  • The return path has length r\ell_r, area ArA_r and permeability μr\mu_r

then

magnetHmdlΦmμmAmBrmμmandreturnHdlΦrμrAr\int_\text{magnet}\mathbf{H}_m\cdot \text{d}\mathbf{l} \approx \frac{\Phi\ell_m}{\mu_mA_m} - \frac{B_r\ell_m}{\mu_m} \qquad \text{and} \qquad \int_\text{return}\mathbf{H}\cdot \text{d}\mathbf{l} \approx \frac{\Phi\ell_r}{\mu_rA_r}

so

Brmμm=Φ(mμmAm+rμrAr)\frac{B_r\ell_m}{\mu_m} = \Phi\left( \frac{\ell_m}{\mu_mA_m} + \frac{\ell_r}{\mu_rA_r} \right)

The left term looks like the 'forcing' term pushing the flux - it goes up for a stronger, longer magnet, i.e. F=Brm/μm\mathcal{F} = B_r\ell_m/\mu_m. The terms on the right act like resistances - if they go up, the flux goes down, making it more difficult for F\mathcal{F} to drive the flux. We therefore associate them with magnetic reluctances R=/μA\mathcal{R} = \ell / \mu A.

The final solution for the flux in this setup is therefore:

Φ=FRm+Rr\Phi = \frac{\mathcal{F}}{\mathcal{R_m}+\mathcal{R_r}}

This is a simple equation, but it tells us a few important things:

  • Stronger magnets (higher F\mathcal{F}) mean more flux (admittedly we could have figured that one out ourselves)
  • Higher μr\mu_r means lower Rr\mathcal{R}_r, 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:

  1. Off - the field lines flow up out of the magnet and really want to avoid the high-R\mathcal{R} spacer material. They flow straight into the low-R\mathcal{R} 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.
  2. 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-R\mathcal{R} table just there, so they can dip into the table and circumvent the spacer, before flowing back into the magnet.

Once you have a B\mathbf{B}-field crossing from the clamp into the table, you can think of the (tiny) gap in-between supporting a magnetic energy density U=B2/2μ0U = B^2/2\mu_0. 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 B2\propto B^2. 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 B=0\nabla\cdot\mathbf{B}=0, we can write B\mathbf{B} as the curl of a magnetic vector potential A\mathbf{A}

B=×A\mathbf{B} = \nabla \times \mathbf{A}

and so substituting H=B/μ\mathbf{H}=\mathbf{B}/\mu gives

×(1μ×A)=J\nabla \times \left(\frac{1}{\mu}\nabla \times \mathbf{A}\right) = \mathbf{J}

(The current density J\mathbf{J} 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. B\mathbf{B} only has components in the xx-yy plane. Therefore A\mathbf{A} (and J\mathbf{J}) must only have a zz-component, and

Bx=Azy,By=AzxB_x = \frac{\partial A_z}{\partial y}, \qquad B_y = -\frac{\partial A_z}{\partial x}

Substituting for A\mathbf{A} in the equation above, we end up with a 2D PDE for the single zz-component:

x(1μAzx)+y(1μAzy)=Jz\frac{\partial}{\partial x} \left( \frac{1}{\mu}\frac{\partial A_z}{\partial x} \right) + \frac{\partial}{\partial y} \left( \frac{1}{\mu}\frac{\partial A_z}{\partial y} \right) = -J_z

Finally, the source term JzJ_z needs to be constructed from the magnet magnetisation vector Vm\mathbf{V}_m. Given that

J=×Vm\mathbf{J} = \nabla \times \mathbf{V}_m

and the magnet is pointing in the θ\theta direction, we have

Vm=Mcosθx^+Msinθy^\mathbf{V}_m = M\cos\theta\hat{\mathbf{x}} + M\sin\theta\hat{\mathbf{y}}

so

Jz=MxsinθMycosθJ_z = \frac{\partial M}{\partial x}\sin\theta - \frac{\partial M}{\partial y}\cos\theta

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 (MM, μ\mu, θ\theta) and things we don't (AA) - 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 (i,j)(i, j) and the size of the grid cells is hh, the equation to solve on each grid cell looks like:

1h2[Ai+1,jAi,jμi+12,jAi,jAi1,jμi12,j+Ai,j+1Ai,jμi,j+12Ai,jAi,j1μi,j12]=[Mi+1,jMi1,j2hsinθMi,j+1Mi,j12hcosθ]\begin{aligned} &\frac{1}{h^2} \left[ \frac{A_{i+1,j}-A_{i,j}}{\mu_{i+\frac12,j}} - \frac{A_{i,j}-A_{i-1,j}}{\mu_{i-\frac12,j}} + \frac{A_{i,j+1}-A_{i,j}}{\mu_{i,j+\frac12}} - \frac{A_{i,j}-A_{i,j-1}}{\mu_{i,j-\frac12}} \right] \\ &= -\left[ \frac{M_{i+1,j}-M_{i-1,j}}{2h}\sin\theta - \frac{M_{i,j+1}-M_{i,j-1}}{2h}\cos\theta \right] \end{aligned}

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 Ai,jA_{i,j} in terms of its neighbours.

Ai,jnew=Ai+1,jμi+12,j+Ai1,jμi12,j+Ai,j+1μi,j+12+Ai,j1μi,j12+h2(Mi+1,jMi1,j2hsinθMi,j+1Mi,j12hcosθ)1μi+12,j+1μi12,j+1μi,j+12+1μi,j12A_{i,j}^{\text{new}} = \frac{ \frac{A_{i+1,j}}{\mu_{i+\frac12,j}} + \frac{A_{i-1,j}}{\mu_{i-\frac12,j}} + \frac{A_{i,j+1}}{\mu_{i,j+\frac12}} + \frac{A_{i,j-1}}{\mu_{i,j-\frac12}} + h^2 \left( \frac{M_{i+1,j}-M_{i-1,j}}{2h}\sin\theta - \frac{M_{i,j+1}-M_{i,j-1}}{2h}\cos\theta \right) }{ \frac{1}{\mu_{i+\frac12,j}} + \frac{1}{\mu_{i-\frac12,j}} + \frac{1}{\mu_{i,j+\frac12}} + \frac{1}{\mu_{i,j-\frac12}} }

Do this for all grid cells, and we have a new solution for AA 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:

  1. Update the uniform buffer with the current control values.
struct Uniforms {
  angle: f32,
  magnetRadius: f32,
  separatorMu: f32,
  tableMu: f32,
  ironMu: f32,
  magnetStrength: f32,
}
  1. Run many relaxation steps, alternating between two storage buffers.
  2. 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]));
  }
}
  1. Find the min/max values of AzA_z for computing contours (this again benefits from parallelisation).
  2. Estimate the pulling force by computing the magnetic pressure in the air gap.
  3. Compute the contour lines using marching squares7.
  4. Render the materials and contours.
  5. 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.

15°30°45°60°75°90°0kg20kg40kg60kg80kg

θ\theta

Pull force
Clamp force vs. rotation angle.

Another interesting question is to ask: how much do the non-magnetic spacer components matter? Running the same simulations again for different values of μr,sep\mu_{r,sep}, we see that increasing the spacer permeability rapidly lowers the force on the table:

15°30°45°60°75°90°0kg20kg40kg60kg80kg

θ\theta

Pull force

120

Clamp force as a function of θ\theta for different μr,sep\mu_{r,sep}.

though the drop levels off fairly quickly:

0204060801000kg20kg40kg60kg80kg

μr,sep\mu_{r,sep}

Pull force
Clamp force vs. separator relative permeability.

Let's see if we can understand this falloff using a rough circuit model. The magnet 'force' F\mathcal{F} is pushing useful flux Φt\Phi_t through the table with reluctance Rt\mathcal{R}_t, and wasted flux Φsep\Phi_{\text{sep}} through the separator with reluctance Rsep\mathcal{R}_{\text{sep}}:

Φ=Φt+Φsep\Phi = \Phi_t + \Phi_{sep}

where

Rsep1μr,sep.\mathcal{R}_{\text{sep}} \propto \frac{1}{\mu_{r,sep}}.
A toy magnetic-circuit model for understanding how the separator affects the force on the table.

In an ideal case, the flux through the table would be simply Φt=F/Rt\Phi_t=\mathcal{F}/\mathcal{R}_t, independent of the separator. Nothing is ever ideal though, so let's assume the magnet, air, table. etc. contribute their own reluctance R0\mathcal{R}_0, so the magnetic 'force' across the table/separator is a lower effective value Feff\mathcal{F}_{\text{eff}}.

We then have

Φt=FeffRt,Φsep=FeffRsepΦ=Feff(1Rt+1Rsep).\Phi_t = \frac{\mathcal{F}_{\text{eff}}}{\mathcal{R}_t}, \qquad \Phi_{sep} = \frac{\mathcal{F}_{\text{eff}}}{\mathcal{R}_{\text{sep}}} \Rightarrow \Phi = \mathcal{F}_{\text{eff}} \left( \frac{1}{\mathcal{R}_t} + \frac{1}{\mathcal{R}_{\text{sep}}} \right).

If we define the combined reluctance Reff\mathcal{R}_{\text{eff}} by Φ=Feff/Reff\Phi=\mathcal{F}_{\text{eff}}/\mathcal{R}_{\text{eff}}, then

Reff=(1Rt+1Rsep)1=RtRsepRt+Rsep.\mathcal{R}_{\text{eff}} = \left( \frac{1}{\mathcal{R}_t} + \frac{1}{\mathcal{R}_{\text{sep}}} \right)^{-1} = \frac{\mathcal{R}_t\mathcal{R}_{\text{sep}}} {\mathcal{R}_t+\mathcal{R}_{\text{sep}}}.

Now the relation for the total circuit, including the non-ideal reluctance R0\mathcal{R}_0, is

Φ=FR0+Reff.\Phi = \frac{\mathcal{F}}{\mathcal{R}_0+\mathcal{R}_{\text{eff}}}.

Substituting this value for Φ\Phi into the definition of Feff\mathcal{F}_{\text{eff}} we get:

Feff=ΦReff=FReffR0+Reff.\mathcal{F}_{\text{eff}} = \Phi\mathcal{R}_{\text{eff}} = \mathcal{F} \frac{\mathcal{R}_{\text{eff}}}{\mathcal{R}_0+\mathcal{R}_{\text{eff}}}.

The useful table flux is the part driven through Rt\mathcal{R}_t, so now we know Feff\mathcal{F}_{\text{eff}} we can calculate Φt\Phi_t as follows, substituting for Reff\mathcal{R}_{\text{eff}} from above:

Φt=FeffRt=FReffRt(R0+Reff)=FRsepR0(Rt+Rsep)+RtRsep.\Phi_t = \frac{\mathcal{F}_{\text{eff}}}{\mathcal{R}_t} = \mathcal{F} \frac{\mathcal{R}_{\text{eff}}} {\mathcal{R}_t\left(\mathcal{R}_0+\mathcal{R}_{\text{eff}}\right)} = \mathcal{F} \frac{\mathcal{R}_{\text{sep}}} {\mathcal{R}_0\left(\mathcal{R}_t+\mathcal{R}_{\text{sep}}\right) +\mathcal{R}_t\mathcal{R}_{\text{sep}}}.

Finally, to get the dependence on μr,sep\mu_{r,sep} write

Rsep=kμr,sep\mathcal{R}_{\text{sep}} = \frac{k}{\mu_{r,sep}}

for some constant kk, then

Φt=Fk/μr,sepR0(Rt+k/μr,sep)+Rtk/μr,sep=FR0+Rt+(R0Rt/k)μr,sep.\begin{aligned} \Phi_t &= \mathcal{F} \frac{k/\mu_{r,sep}} {\mathcal{R}_0\left(\mathcal{R}_t+k/\mu_{r,sep}\right) +\mathcal{R}_t k/\mu_{r,sep}} \\ &= \frac{\mathcal{F}} {\mathcal{R}_0+\mathcal{R}_t+ \left(\mathcal{R}_0\mathcal{R}_t/k\right)\mu_{r,sep}}. \end{aligned}

Phew! This model circuit gives us a flux through the table that looks like (furiously waves hands)

Φt11+cμr,sep\Phi_t \propto \frac{1}{1 + c\,\mu_{r,sep}}

for some constant cc. We know that the pull force scales like B2B^2, or

FpullΦt21(1+cμr,sep)2.F_{\text{pull}} \propto \Phi_t^2 \propto \frac{1}{\left(1 + c\,\mu_{r,sep}\right)^2}.

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

  1. 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
  2. https://youtu.be/-qUu8kIliy8?t=697
  3. https://en.wikipedia.org/wiki/Remanence
  4. https://en.wikipedia.org/wiki/Magnetic_circuit
  5. https://en.wikipedia.org/wiki/Relaxation_(iterative_method)
  6. https://www.ethanepperly.com/index.php/blog/
  7. https://en.wikipedia.org/wiki/Marching_squares