  First-principles calculations enable accurate predictions of electronic
interactions and dynamics. However, computing the electron spin dynamics
remains challenging. The spin-orbit interaction causes various dynamical
phenomena that couple with phonons, such as spin precession and spin-flip e-ph
scattering, which are difficult to describe with current first-principles
calculations. In this work, we show a rigorous framework to study
phonon-induced spin relaxation and decoherence, by computing the spin-spin
correlation function and its vertex corrections due to e-ph interactions. We
apply this approach to a model system and develop corresponding
first-principles calculations of spin relaxation in GaAs. Our vertex-correction
formalism is shown to capture the Elliott-Yafet, Dyakonov-Perel, and
strong-precession mechanisms - three independent spin decoherence regimes with
distinct physical origins - thereby unifying their theoretical treatment and
calculation. Our method is general and enables quantitative studies of spin
relaxation, decoherence, and transport in a wide range of materials and
devices.
