Thermal evolution and magnetism of terrestrial planets.