First principles calculation of residual resistivity