When two magnets attract and move each other, what is the energy flow?

When magnets attract each other, the two objects move on their own, even though they have mass, and this motion can* be calculated as the energy that would be spent to move two objects with similar mass but without any substantial macroscopic magnetic interaction. *Not saying this is how energy has to be calculated but instead saying that the calculation can be done, whether one says it is meaningful or not.

Another way to calculate an energy here, is to say we now use two electromagnets of the same mass as our magnets, make sure to obtain the same motion from them using an external power supply and, well, see how much electrical energy was used. I am speaking in terms of an experimental setup but of course there are existing formulas that will do well.

One way to imagine where an energy could come from to move the two "autonomous" magnets is to say the energy was waiting somewhere, stored after or even when the magnets were set apart, then was released, like a spring, to bring them back together.

Obviously this picture is less intellectually satisfying for magnets that were never stuck together before, and could lead to even more dubious suggestions like saying all magnets were initially stuck together when the universe was created and will spend their entire existence looking for their soul mate. However I do not exclude the possibility that today's magnets are a sort of perturbation of the initial conditions that would recover when such spontaneous movement occurs. I just do not know.

So as far as I know (e.g. Wikipedia), in the case of simple magnets, the magnetic attraction is due to electrons spin ordered in a certain way in the materials involved. In this description, there is no energy used in the sense of the energy expenditure described above, not even, to my knowledge, a transduction of some sort. But I am unaware of the adequate description of the system at work, thus my question.

So where is the energy in the system? Where is it before, during and after the magnets moved and joined together? Please answer in terms of energy, and not work or force, and in plain English as I am trying to understand the physical process involved at a molecular and electronic level, not at a thermodynamic or macroscopic one. If someone can provide an exact description instead of an approximation, that would be perfect.

As a side note, I am aware, or at least I remember reading that somewhere, that a composite object such as an atom with a nucleus and electrons has less energy than its constituents if they were spatially separated. There is an analogy here (and maybe more), the two magnets having less energy once they reach each other, requiring extra energy to set them apart. In the case of electrons joining the nucleus, there might be radiation released, which is energy, so the same question applies there too. As if some energy that favored the independence of the electron or magnet was lost after they were bound. But my question centers on magnets only.

Energy is stored in the magnetic field. Specifically, for a magnetic field $$\vec{B}$$, the energy $$E$$ stored in it is calculated by:

$$E=\int \frac{B^2}{2\mu} dV$$

where the integral is taken over all space and $$\mu$$ is the permeability (either of the vacuum or of whatever material the field is measured in).

When you change the magnetic field configuration in some way, you also change the amount of energy stored in the magnetic field. For example, when you push two repelling permanent magnets together, the energy stored in the magnetic field increases, and you supply that energy by doing work pushing them together. The same applies when pulling attracting permanent magnets apart. In contrast, when you allow two repelling magnets to accelerate away from each other (or two attracting magnets to accelerate towards each other), the energy stored in the magnetic field decreases, and is transferred to the kinetic energy of the magnets.

Now, to address the various things that are going on in your first five paragraphs:

When magnets attract each other, the two objects move on their own, even though they have mass, and this motion can* be calculated as the energy that would be spent to move two objects with similar mass but without any substantial macroscopic magnetic interaction. *Not saying this is how energy has to be calculated but instead saying that the calculation can be done, whether one says it is meaningful or not.

I don't really know what you're trying to say here, but it's likely incorrect. The magnetic field is an integral part of the energy budget of two interacting permanent magnets.

Another way to calculate an energy here, is to say we now use two electromagnets of the same mass as our magnets, make sure to obtain the same motion from them using an external power supply and, well, see how much electrical energy was used. I am speaking in terms of an experimental setup but of course there are existing formulas that will do well.

This won't tell you the energy required to move them. Instead, it'll mostly tell you how much heat is dissipated through the wires due to their nonzero resistance. If you want to do an experimental setup, you have to measure how much work is done in moving the magnets, so you need to measure the force that the thing pushing the magnets is exerting, not the thing supplying the current to the magnets.

One way to imagine where an energy could come from to move the two "autonomous" magnets is to say the energy was waiting somewhere, stored after or even when the magnets were set apart, then was released, like a spring, to bring them back together.

"Somewhere" means "in the magnetic field".

Obviously this picture is less intellectually satisfying for magnets that were never stuck together before, and could lead to even more dubious suggestions like saying all magnets were initially stuck together when the universe was created and will spend their entire existence looking for their soul mate.

Again, I have no idea what you're trying to say. Magnets still interact, regardless of their being "stuck together before", and permanent magnets were not all created at the Big Bang. You can create one now by placing a unmagnetized iron core in an electromagnet and then turning off the electromagnet.

However I do not exclude the possibility that today's magnets are a sort of perturbation of the initial conditions that would recover when such spontaneous movement occurs. I just do not know.

Again, not all permanent magnets were created in the Big Bang.

So as far as I know (e.g. Wikipedia), in the case of simple magnets, the magnetic attraction is due to electrons spin ordered in a certain way in the materials involved. In this description, there is no energy used in the sense of the energy expenditure described above, not even, to my knowledge, a transduction of some sort. But I am unaware of the adequate description of the system at work, thus my question.

The energy is stored in the magnetic field. There is also an interaction energy between the electron spins, but this mainly acts to keep the magnet from spontaneously demagnetizing rather than contributing to the energy density of the magnetic field.

• If energy is stored in the magnetic field, where does it originate from though? Is it not generated by charge carriers in the first place? – Exocytosis May 10 at 14:59
• @Exocytosis There are two components to the stored field energy: the energy that comes from the relative positions of the two permanent magnets (which is zero when the magnets are infinitely far apart), and the energy that comes from the assembly of each individual magnet (which is independent of the magnets' positions). Unless you're demagnetizing or magnetizing the permanent magnets, the second term doesn't change; rather, it describes the energy required to generate the magnetic field associated with one permanent magnet. – probably_someone May 10 at 16:32
• Thanks but still this is not what I am looking for. You are talking about fields and magnets, but I want a description of the energy evolution at a molecular level. What is minimum number of metal atoms necessary to make a magnet with two poles, similar to a macroscopic one? After you answered this, I will ask about the rest. If you prefer not to answer this, I will simply ask a new question. In any case, thank you for your contribution. – Exocytosis May 10 at 17:50
• @Exocytosis Given that most of your question was about macroscopic permanent magnets, it didn't occur to me that what you actually wanted was a microscopic description (the two situations are easiest explained by quite different theories). In any case, it only takes one atom to make a magnet with two poles (atoms can have a magnetic dipole moment, after all). As to whether that single atom is "similar to a macroscopic magnet," that depends on what you mean by "similar". – probably_someone May 10 at 19:59
• I see. Your answer about an atom that can be a dipole is great. Having those two dipoles, what happens sequentially (timeline) to the energy? Clearly before there is any energy in a field between those particles, it must have started at the dipoles themselves. Although we are talking about magnetism, if I talked about EM waves, first there is a charge carrier motion, and then, there is radiation. What is the complete sequence of events for two dipoles to approach each other? – Exocytosis May 10 at 20:07