Ab initio studies of defect concentrations and diffusion in metal oxides