Ab initio method for electromigration analysis