Uranus and Neptune are a bit weird, although in fairness that may be because we don’t really know much about them. Our information is restricted to what we can see in telescopes (not a lot) and the Voyager fly-bys, which, of course, also devoted a lot of attention to the Moons, since a lot of effort was devoted to images. The planets are rather large featureless balls of gas and cloud and you can only do so much on a “zoom-past”. One of the odd things is the magnetic fields. On Earth, the magnetic field axis corresponds with the axis of rotation, more or less, but not so much there. Earth’s magnetic field is believed to be due to a molten iron core, but that could not occur there. That probably needs explaining. The iron in the dust that is accreted to form planets is a fine powder; the particles are in the micron size. The Earth’s core arises because the iron formed lumps, melted, and flowed to the core because it is denser. In my ebook “Planetary Formation and Biogenesis” I argue that the iron actually formed lumps in the accretion disk. While the star was accreting, the region around where Earth is reached something like 1600 degrees C, above the melting point of iron, so it formed globs. We see the residues of that in the iron-cored meteorites that sometimes fall to Earth. However, Mars does not appear to have an iron core. Within that model, the explanation is simple. While on Earth the large lumps of iron flowed towards the centre, on Mars, since the disk temperature falls off with distance from the star, at 1.5 AU the large lumps did not form. As a consequence, the fine iron particles could not move through the highly viscous silicates, and instead reacted with water and oxidised, or, if you prefer, rusted.
If the lumps that formed for Earth could not form at Mars because it was too far away from the star, the situation was worse for Uranus. As with Mars, the iron would be accreted as a fine dust and as the ice giants started to warm up from gravitational collapse, the iron, once it got to about 500 degrees Centigrade, would rapidly react with the water and oxidise to form iron oxides and hydrogen. Why did that not happen in the accretion disk? Maybe it did, and maybe at Mars it was always accreted as iron oxides, but by the time it got to where Earth is, there would be at least ten thousand times more hydrogen than iron, and hot hydrogen reduces iron oxide to iron. Anyway, Uranus and Neptune will not have an iron core, so what could generate the magnetic fields? Basically, you need moving electric charge. The planets are moving (rotating) so where does the charge come from?
The answer recently proposed is superionic ice. You will think that ice melts at 0 degrees Centigrade, and yes, it does, but only at atmospheric pressure. Increase the pressure and it melts at a lower temperature, which is how you make snowballs. But ice is weird. You may think ice is ice, but that is not exactly correct. There appear to be about twenty ices possible from water, although there are controversial aspects because high pressure work is very difficult and while you get information, it is not always clear about what it refers to. You may think that irrespective of that, ice will be liquid at the centre of these planets because it will be too hot for a solid. Maybe.
In a recent publication (Nature Physics, 17, 1233-1238 November 2021) authors studied ice in a diamond anvil cell at pressures up to 150 GPa (which is about 1.5 million times greater than our atmospheric pressure) and about 6,500 degrees K (near enough to Centigrade at this temperature). They interpret their observations as there being superionic ice there. The use of “about” is because there will be uncertainty due to the laser heating, and the relatively short times up there. (Recall diamond will also melt.)
A superionic ice is proposed wherein because of the pressure, the hydrogen nuclei can move about the lattice of oxygen atoms, and they are the cause of the electrical conduction. These conditions are what are expected deep in the interior but not at the centre of these two planets. There will presumably be zones where there is an equilibrium between the ice and liquid, and convection of the liquid coupled with the rotation will generate the movement of charge necessary to make the magnetism. At least, that is one theory. It may or may not be correct.