Magnetic Field Energy Increase while magnetic field does work on a current carrying loop - Where does the energy come from?

Imagine you have an external magnetic Field $$\vec{B}_{\text{ext}}$$(for the sake of simplicity, it should be constant throughout the entire space), which is not generated by any current density (imagine that it's simply a solution to the setup of no current density, with apropriately choosen boundary conditions).

Now we place a current ($$\vec{j}$$) carrying loop somewhere, which generates a field $$\vec{B}$$. Initially the Field $$\vec{B}$$ should be antiparalell to $$\vec{B}_{\text{ext}}$$. For the sake of simplicity I assume that the loop has no resistance, so the current inside just flows freely.

What now happens is that the Lorentz-force will act on the charges in the loop, generating torque that will turn the loop until $$\vec{B}$$ and $$\vec{B}_{\text{ext}}$$ are paralell. Since the Lorentz-force doesn't change the energy of the charges, every bit of Energy that went into moving the loop stems from the current inside the loop: While the charges are accelerated perpendicular to the direction of the conductor (moving the loop), they are decellerated along the direction of the conductor (reducing the current).

In terms of energy conservation - so far so good, everything is fine.

My problem now is: The more both magnetic fields do align, their field energy (which is the squared sum of them, $$(\vec{B}_{\text{ext}} + \vec{B})^2$$ increases. Where does the energy come from, that leads to this increase of energy?

You are forgetting the field in the loop plane far from the loop, which initially points in the same direction as the external field $$\vec{B}_{ext}$$. This contributes positive field energy initially, but negative energy after the flip.
• I wouldn't have thought the calculation Needs to be that complicated. Can't I just calculate $\int \vec{B}_{\text{ext}}(\Theta) \vec{B}$ with $\vec{B}$ being an abitrary magnetic field generated by a spatially confined, sourcefree current density, and \vec{B}_{\text{ext}}(\Theta) being a constant magnetic field with strengh, pointing into the direction of $\hat{e}_{\theta}$, and then (without further specifying the current density) "somehow" Show that the result doesn't depend on $\Theta$? – Quantumwhisp May 21 at 5:48
• The complicated calculation is needed to derive the energy conservation theorem for the whole system, in particular the expression for field energy. An expression such as $\int \mathbf B\cdot\mathbf B_{ext},dV$ is a natural first guess but not obvious it is exactly accurate in this case. Exchange of energy between EM field and mechanical energy of the wire due to constraint forces is taking place and some energy may be stored in the field or charges, which is not accounted for by this expression. – Ján Lalinský May 21 at 15:58