A general set of methods is presented for calculating chemical potentials in
solid and liquid mixtures using {\em ab initio} techniques based on density
functional theory (DFT). The methods are designed to give an {\em ab initio}
approach to treating chemical equilibrium between coexisting solid and liquid
solutions, and particularly the partitioning ratio of solutes between such
solutions. For the liquid phase, the methods are based on the general technique
of thermodynamic integration, applied to calculate the change of free energy
associated with the continuous interconversion of solvent and solute atoms, the
required thermal averages being computed by DFT molecular dynamics simulation.
For the solid phase, free energies and hence chemical potentials are obtained
using DFT calculation of vibrational frequencies of systems containing
substitutional solute atoms, with anharmonic contributions calculated, where
needed, by thermodynamic integration. The practical use of the methods is
illustrated by applying them to study chemical equilibrium between the outer
liquid and inner solid parts of the Earth's core, modelled as solutions of S,
Si and O in Fe. The calculations place strong constraints on the chemical
composition of the core, and allow an estimate of the temperature at the
inner-core/outer-core boundary.Comment: 19 pages, two figure