Electronic structure of transition metal compounds by variational cluster approximation