The purification of the rare-earth metals: I. Solid state electrolysis of gadolinium