Why do electromagnets consume energy? If they do, aren't permanent magnets free energy? I understand that a permanent magnet by itself doesn't produce any energy without external work. But electromagnets which need electricity consume energy, isn't this energy "freely" available in a permanent magnet.
Yes, I understand that there is zero resistance and VI=0 and hence zero energy, but isn't the battery drained as it is a short circuit? And isn't this draining of the battery energy consumption?
 A: all electromagnets (except those made of superconductive wire and operating at cryogenic temperatures) do actually possess electrical resistance. This means that electrical power is being dissipated in their wires whenever they are turned on and producing a magnetic field. this means that the battery connected to the electromagnet coil will indeed go dead after a while. 
in a permanent magnet, the work necessary to get all its individual atomic magnets aligned and pointing in the same direction was performed on it during its manufacture, and then frozen into its microstructure so it would persist- which means that even in a permanent magnet, the net field it produces did not come "for free". 
A: Suppose you find a strong permanent magnet laying on the ground. Here's something you can do with it: You can mount it to a tiny gantry, and you can lower it into position over a piece of ferrous metal, and the piece of metal will jump up off the table and stick to the magnet.
Woo Hoo! Free energy! It took energy to raise that bit of metal against the Earth's gravity, and the magnet did it for you.
Now what? Can you do it again?
The answer is, No. You can't. You can't lift the piece of metal a second time until you separate it from the magnet and lower it back to the table top. Separating the metal bit from the magnet takes just as much energy (from you) as the magnet provided in the first place.
It's no different from finding a fully charged battery laying on the ground. Woo Hoo! Free energy!... Until you use it up, and then want to re-charge it.
To stretch the analogy, perhaps to the breaking point, you can interpret the second paragraph of niels nielsen's answer as an explanation of where the initial "charge" on the magnet came from.
