You are perhaps confusing work (energy e.g. in joules) with power (e.g. in watts).
This is a necessary aspect of the example, as given: it contains energy and power sinks -- the inductance and resistance, respectively.
We must separate these two elements, if we are to determine where the energy goes, and where the work goes.
We can assume a ZeroResistance coil for arguments sake. (Convenient, eh?
) This must be supplied from a current limited source, so that when turned on, its inductance charges up to some current, and eventually has zero voltage drop (because dI/dt = 0 and nothing is changing magnetically or mechanically). And when turned off, its current (and motion) goes to zero, and eventually its voltage as well.
In particular, the voltage drop is only the EMF (electromotive force, induced voltage) of the coil and magnetic circuit.
(In practice, we can separate these by knowing the coil resistance, sensing the coil current, and constructing the voltage drop due to resistance as Vr = I*R. Subtracting this out, we are left with the EMF of the coil -- and residual errors, which are not to be underestimated in such a situation. In a real coil, the coil temperature will be varying, and its resistance varies with frequency as well. A fairly complicated equivalent circuit would be needed to null this; in short, better not to try, but to understand it from a theoretical basis instead.)
So: coil, some air gap, the relay armature, and the pole piece wrapping around the coil. When off, the initial inductance is modest, due to the air gap. We can calculate this, given some approximations, and typical geometry. (For most relays, the geometry is close to a 'U' or 'E' core, with the armature being an 'I' piece, gapped away from the 'U'/'E' piece by the air gap. The core is soft iron, mu_r large enough that we can ignore its length.)
As current is applied, voltage is developed, according to: V = L * dI/dt. Gradually, the magnetic field increases, which puts a force across the air gap, according to: p = B^2 / (2*mu_0), the Maxwell strain.
This gives us a pressure. Integrated over the cross-section of the air gap, it gives us the force pulling the relay closed! A pressure also has units of energy density. integrated over the air gap volume, this gives the total energy stored in the air gap. Neat, huh?
Eventually, the force exceeds the spring force holding the armature back, and it begins to move. As it closes, the gap shortens, which causes the inductance to increase. We refer back to the inductor equation, V = L * dI/dt. If dI/dt is constant, then V will tick up when the armature begins to move -- in fact, V will be nearly proportional to the velocity of the armature. But V is already proportional to dI/dt, so how can we tell which is which?
Well, since we know we are performing real
work here, there is an energy loss due to something other than the magnetic field itself (namely, something moving).
We can perform the same decomposition, splitting the voltage into the component due to inductance, and the component due to work performed.
Actually, I don't think it can be the same decomposition, because we are varying a parameter, not simply adding components together. Well, welcome to the realities of nonlinear analysis.
Suffice it to say, the fact that V is higher than our initial level, while dI/dt is ramping steadily up, is necessarily performing work, and the integral V*I dt during that ramp, gives us the total energy stored.
When the relay fully closes, the air gap goes approximately to zero, and the voltage generated by a given dI/dt will be very large (i.e., the inductance is very high). That means the energy stored in the magnetic field is very small. (That's kind of a counterintuitive way to put it; maybe it helps to say that, for a given applied voltage, the dI/dt, or Irms at a given frequency, is small, therefore the reactive power is small, and so too, the energy stored per unit time is small.) With little energy in the magnetic field, we know that the energy we did deliver, must've gone into mechanical work!
For a lossless armature, that work will have gone into the spring, so we expect to get it back when we reverse this process. The waveform will be identical to what we started with, just played back in reverse. (Well, assuming a zero mass armature, too. It will accelerate differently this time, just because it's starting from a different position, and different spring force, and fringing around the air gap and all that. To a first approximation, and various other ideal constructions, it can be the same. In any case, the total area under the curve (as flux, integral V dt, and as energy, integral V I dt) will be the same.)
In practice, again there are losses -- the armature accelerates, then stops suddenly as it slams into the contacts and coil, bouncing several times in the process. The bounces dissipate mechanical energy as friction, and maybe acoustic and viscous energy in the air too. So the kinetic energy of the armature is lost, and more energy will be required to pull it in, than is returned (by the spring) on the way out (which again loses energy when it slams into the other stop).
In general, these are called
reluctance machines. The attractive force of magnetized, permeable cores is varied to affect mechanical work. Stepper motors are a continuous (rotating) application of this; relays and solenoids are a single-acting linear application.
Now that this has been covered -- we can consider an interesting riddle. Back in the mid 2000s, there was a heavily promoted overunity motor, Stoern Orbo I think it was? It had a rotor of permanent magnets, a stator of saturable cores, and nothing else (see-through acrylic structure). The claim was that the saturable cores attract the magnets, then are driven into saturation (no more attraction), and that the energy used to saturate the cores is zero, because they are simple inductors and that energy is returned when they are discharged before the next magnet approaches. Can you see what's wrong with this claim?
Tim