You might get a hint of how magnetic fields are macroscopically modeled looking at the solar dynamo
The solar dynamo is the physical process that generates the Sun's magnetic field. The Sun is permeated by an overall dipole magnetic field, as are many other celestial bodies such as the Earth. The dipole field is produced by a circular electric current flowing deep within the star, following Ampère's law. The current is produced by shear (stretching of material) between different parts of the Sun that rotate at different rates, and the fact that the Sun itself is a very good electrical conductor (and therefore governed by the laws of magnetohydrodynamics).
The earth's magnetic field is modeled
Walter M. Elsasser, considered a "father" of the presently accepted dynamo theory as an explanation of the Earth's magnetism, proposed that this magnetic field resulted from electric currents induced in the fluid outer core of the Earth. He revealed the history of the Earth's magnetic field through pioneering the study of the magnetic orientation of minerals in rocks.
However, unlike the field of a bar magnet, Earth's field changes over time because it is generated by the motion of molten iron alloys in the Earth's outer core .
So , because the magnetic fields depend on fluid dynamics earth's field is time dependent, and the geological studies experimentally support the dynamo model.
If the fluid congeals, not currents will flowing in the interior and there will be no magnetic field in the planet.