## Introduction

The manipulation of electron spins is of increasing interest in a wide-range of emerging technologies. The rapidly growing field of spintronics seeks to control spin as the unit of information instead of charge in devices such as spin transistors1. Quantum information technologies seek to utilize localized spin states in materials both as single-photon emitters2,3,4 and as spin-qubits for future integrated quantum computers5. Both spintronics and quantum information applications therefore demand a quantitative understanding of spin dynamics and transport in metals and semiconductors. Recent advances in circularly polarized pump-probe spectroscopy6, spin injection, and detection techniques7 have enabled increasingly detailed experimental measurement of spin dynamics in solid-state systems8,9. However, a universal first-principles theoretical approach to predict spin dynamics, quantitatively interpret these experiments and design new materials has remained out of reach.

A key metric of useful spin dynamics is the spin relaxation time τs1. For example, spin-based quantum information applications require τs exceeding milliseconds for reliable qubit operation. Consequently, accurate prediction of τs in general materials is an important milestone for first-principles design of quantum materials. Spin–spin10, spin–phonon11, and spin-impurity scatterings, all contribute to spin relaxation, but spin–phonon scattering sets the intrinsic material limitation and is typically the dominant mechanism at room temperature1. Further, spin–phonon relaxation arises from a combination of spin–orbit coupling (SOC) and electron–phonon scattering, and is traditionally described by two mechanisms. First, the Elliott–Yafet (EY) mechanism involves spin–flip transitions between pairs of Kramers-degenerate states due to SOC-based spin-mixing of these states12,13. Second, the D’yakonov–Perel’ (DP) mechanism in systems with broken inversion symmetry involves electron spins precessing between scattering events due to the SOC-induced internal effective magnetic field14.

Previous theoretical approaches have extensively investigated these two distinct mechanisms of intrinsic spin–phonon relaxation using model Hamiltonians in various materials15. These methods require parametrization for each specific material, which needs extensive prior information about the material and specialized computational techniques, and often only studies one mechanism at a time. Furthermore, most of these approaches require the use of simplified formulae12,14 and make approximations to the electronic structure (e.g. low spin-mixing) or electron–phonon matrix elements15. This limits the generality and reliability of these approaches for complex materials, particularly for the DP mechanism, where various empirical relations are widely employed to estimate τs1. Sophisticated methods based on spin susceptibility16 and time evolution of density matrix17 also rely on suitably chosen model Hamiltonians with empirical scattering matrix elements. Therefore, while these methods provide some mechanistic insight, they do not serve as predictive tools of spin relaxation time for the design of new materials.

A general first-principles technique to predict spin–phonon relaxation in arbitrary materials is therefore urgently needed. Previous first-principles studies have addressed the EY mechanism in centrosymmetric semiconductors18,19 and metals20. These methods18,20 rely on defining a pseudospin that allows the use of Fermi’s golden rule (FGR) with only spin–flip transitions13. However, this is only well-defined for cases with weak spin-mixing such that eigenstates within each Kramers-degenerate pair can be chosen to have small spin-minority components, precluding the study of spin relaxation of states with strong spin-mixing, e.g. holes in silicon and noble metals. First-principles calculations have not yet addressed systems with such complex degeneracy structures, where the simple picture of spin–flip matrix elements in a FGR breaks down, or systems without inversion symmetry that do not exhibit Kramers degeneracy. Therefore, a more general first-principles technique without the material-specific simplifying assumptions of these previous approaches is now necessary.

In this work, we establish a new, accurate and unified first-principles technique for predicting spin relaxation time based on perturbative treatment of the Lindbladian dynamics of density matrices21. Importantly, by covering previously disparate mechanisms (e.g. EY and DP) in a unified framework, this technique is applicable to all materials regardless of dimensionality, symmetry (especially inversion) and strength of spin-mixing, which is critical for new material design. All SOC effects are included self-consistently (and non-perturbatively) in the ground-state eigensystem at the density functional theory (DFT) level, and we predict τs through a universal rate expression without the need to invoke real-time dynamics. In this article, we first introduce our theoretical framework based on first-principles density-matrix dynamics, and then show prototypical examples of τs for the broad range of systems, including three with inversion symmetry—silicon, iron, and graphene, and three without inversion symmetry—monolayer MoS2, monolayer MoSe2, and bulk GaN, in excellent agreement with available experimental data. By doing so, we establish the foundation for quantum dynamics of open systems from first-principles to facilitate the design of quantum materials.

## Results

### Theory

The key to treating arbitrary state degeneracy and spin-mixing for spin relaxation is to switch to an ab initio density-matrix formalism, which goes beyond specific cases such as Kramers degeneracy or Rashba-split model Hamiltonians. Specifically, we seek to work with density matrices of electrons alone, treating its interactions with an environment consisting of a thermal bath of phonons. In general, tracing out the environmental degrees of freedom in a full quantum Liouville equation of the density-matrix results in a quantum Lindblad equation. Specifically, for electron–phonon coupling21 based on the standard Born–Markov approximation22 that neglects memory effects in the environment, the Lindbladian dynamics in interaction picture reduces to

$$\frac{\partial {\rho }_{{\alpha }_{1}{\alpha }_{2}}}{\partial t}=\frac{2\pi }{\hslash {N}_{q}}{\rm{Re}}{\mathop{\sum }\limits_{q\lambda \!{\pm} \alpha ^{\prime} {\alpha }_{1}^{\prime}{\alpha }_{2}^{\prime}}}\left[\begin{array}{c}{\left(I-\rho \right)}_{{\alpha }_{1}\alpha ^{\prime} }{\left({G}^{q\lambda \!{\pm} }\right)}_{\alpha ^{\prime} {\alpha }_{1}^{\prime}}{\rho }_{{\alpha }_{1}^{\prime}{\alpha }_{2}^{\prime}}{\left({G}^{q\lambda {\mp} }\right)}_{{\alpha }_{2}^{\prime}{\alpha }_{2}}\\ -\,{\left({G}^{q\lambda \mp }\right)}_{{\alpha }_{1}\alpha ^{\prime} }{\left(I-\rho \right)}_{\alpha ^{\prime} {\alpha }_{1}^{\prime}}{\left({G}^{q\lambda \!{\pm} }\right)}_{{\alpha }_{1}^{\prime}{\alpha }_{2}^{\prime}}{\rho }_{{\alpha }_{2}^{\prime}{\alpha }_{2}}\end{array}\right]{n}_{q\lambda }^{\pm },$$
(1)

where α is a combined index labeling electron wavevector k and band index n, λ is mode index and ± corresponds to $$q=\mp \left(k-k^{\prime} \right)$$. $${n}_{q\lambda }^{\pm }\equiv {n}_{q\lambda }+0.5\pm 0.5$$ and nqλ is phonon occupation. $${G}_{\alpha \alpha ^{\prime} }^{q\lambda \!{\pm} }={g}_{\alpha \alpha ^{\prime} }^{q\lambda \!{\pm} }{\delta }^{1/2}({\varepsilon }_{\alpha }-{\varepsilon }_{\alpha }^{\prime}\pm {\omega }_{q\lambda })$$ is the electron–phonon matrix element including energy conservation, where ωqλ is the phonon frequency.

This specific form of the Lindbladian dynamics preserves positive definiteness of the density matrix which is critical for numerical stability21. In addition, the energy-conserving δ-function above is regularized by a Gaussian with a width γ, which corresponds physically to the collision time. In some cases, the results depend on γ and γ → 0 is not the relevant limit23. Here, the Lindblad master equation with finite smearing parameters corresponding to the collision time can be regarded as the best Markovian approximation to the exact dynamics23. In the case of spin relaxation, this is particularly important for systems that exhibit the DP mechanism, as we show below. Consequently, we consistently determine the smearing parameters from ab initio electron–phonon linewidth calculations throughout24,25.

The density-matrix formalism allows the computation of any observable such as number and spin density of carriers, and the inclusion of different relaxation mechanisms at time scales spanning femtoseconds to microseconds, which forms the foundation of the general relaxation time approach we discuss below. Given an exponentially relaxing measured quantity $$O={\rm{Tr}}(o\rho )$$, where o and ρ are the observable operator and the density matrix, respectively, we can define the relaxation rate Γo and relaxation time $${\tau }_{\mathrm{o}}={\Gamma }_{\mathrm{o}}^{-1}$$ of quantity O as

$$\frac{\partial \left(O-{O}^{{\rm{eq}}}\right)}{\partial t}=-{\Gamma }_{\mathrm{o}}(O-{O}^{{\rm{eq}}}),$$
(2)

where eq corresponds to the final equilibrium state. We note that even when the observables have additional $$\cos (\omega t)$$ oscillation factors, such as due to spin precession with periodicity of ω, the above equation remains an appropriate definition of the overall relaxation rate. For example, for a precessing and relaxing spin system with $$S(t)={S}_{0}\exp (-t/\tau )\cos (\omega t)$$, the initial relaxation rate is $$\dot{S}(0)=-{S}_{0}/\tau$$, which is exactly the same as that of a pure exponential relaxation.

The equilibrium density matrix in band space is $${({\rho }^{{\rm{eq}}})}_{nn^{\prime} }^{k}={f}_{kn}{\delta }_{nn^{\prime} }$$, where fkn are the Fermi occupation factors of electrons in equilibrium. Writing the initial density matrix ρ = ρeq + δρ, assuming a small perturbation δρρeq and k-diagonal o and δρ, the Lindblad dynamics expression (Eq. (1)) and the definition (Eq. (2)) yield

$${\Gamma }_{\mathrm{o}}= \, \frac{2\pi }{\hslash {N}_{q}Tr\left(o\delta \rho \right)}{{\rm{Tr}}}_{n}{\rm{Re}}{\mathop{\sum }\limits_{kk^{\prime} \lambda }}{\left[o,{G}^{q\lambda -}\right]}_{kk^{\prime} }\\ \times {\left[\begin{array}{c}{\left(\delta \rho \right)}_{k}{G}_{kk^{\prime} }^{q\lambda -}{({n}_{q\lambda }+I-{f}_{k^{\prime} })}\\ -\,({n}_{q\lambda }+{f}_{k}){G}_{kk^{\prime} }^{q\lambda -}{\left(\delta \rho \right)}_{k^{\prime} }\end{array}\right]}^{{\dagger }_{n}}.$$
(3)

Here, the G is exactly as defined above in Eq. (1), but separating the wavevector indices (k, $$k^{\prime}$$) and writing it as a matrix in the space of band indices (n, $$n^{\prime}$$) alone. Similarly, o and δρ are also matrices in the band space, Trn and †n are trace and Hermitian conjugate in band space, and $${[o,G]}_{kk^{\prime} }\equiv {o}_{k}{G}_{kk^{\prime} }-{G}_{kk^{\prime} }{o}_{k^{\prime} }$$, written using matrices in band space.

Given an initial perturbation δρ and an observable o, Eq. (3) can now compute the relaxation of expectation value O from its initial value. Even for a specific observable like spin, several choices are possible for the initial perturbation corresponding directly to the experimental measurement scheme. Specifically for spin relaxation rate Γs,i, the observable is the spin matrix Si labeled by Cartesian directions i = x, y, z, and the initial perturbed state should contain a deviation of spin expectation value from equilibrium. The most general (experiment-agnostic) choice for preparing a spin polarization is to assume that all other degrees of freedom are in thermal equilibrium, which can be implemented using a test magnetic field Bi as a Lagrange multiplier for implementing a spin polarization constraint. With a corresponding initial perturbation Hamiltonian of H1 = −2μBBiSi/, where μB is the Bohr magneton, perturbation theory yields

$$\delta {\rho }_{k,mn}=-\frac{2{\mu }_{{\rm{B}}}{B}_{i}}{\hslash }\frac{{f}_{km}-{f}_{kn}}{{\epsilon }_{km}-{\epsilon }_{kn}}{S}_{i,k,mn}.$$
(4)

In some cases, Si,k,mn ≈ 0 when ϵkm ≠ ϵkn. For these cases, $$\delta \rho \approx -(2{\mu }_{\mathrm{B}}{B}_{i}/\hslash )(\partial f/\partial \epsilon ){S}_{i}^{\mathrm{deg} }$$, where $${({S}_{i}^{\mathrm{deg} })}_{knn^{\prime} }\equiv {\left({S}_{i}\right)}_{knn^{\prime} }{\delta }_{{\varepsilon }_{kn}{\varepsilon }_{kn^{\prime} }}$$ is the degenerate-subspace projection of Si. In such cases, we can further simplify Eq. (3) to the Fermi Golden rule-like expression,

$${\Gamma }_{s,i}= \frac{2\pi }{\hslash {N}_{k}{N}_{q}{k}_{{\rm{B}}}T{\chi }_{s,i}}\mathop{\sum}\limits_{kk^{\prime} \lambda \!{\pm} \!nn^{\prime} }\left\{| {\left[{S}_{i}^{\mathrm{deg} },{g}^{q\lambda -}\right]}_{knk^{\prime} n^{\prime} }{| }^{2}\right.\\ \left.\delta ({\epsilon }_{kn}-{\epsilon }_{k^{\prime} n^{\prime} }-{\omega }_{q\lambda }){f}_{k^{\prime} n^{\prime} }(1-{f}_{kn}){n}_{q\lambda }\right\},$$
(5)

where $${\chi }_{s,i}=T{r}_{n}[{S}_{i}(-\partial f/\partial \epsilon ){S}_{i}^{\mathrm{deg} }]/{N}_{k}$$. Note that the test field Bi etc. drops out of the final expression and only serves to select the direction of the perturbation in the high-dimensional space of density matrices.

Without SOC, $${S}_{i}^{\mathrm{deg} }={S}_{i}$$ commutes with g, leading to Γs,i = 0 as expected. If $${S}_{i}^{\mathrm{deg} }$$ is diagonal, $${[{S}_{i}^{\mathrm{deg} },{g}^{q\lambda -}]}_{knk^{\prime} n^{\prime} }$$ reduces to $$\Delta {s}_{i,knk^{\prime} n^{\prime} }{g}_{knk^{\prime} n^{\prime} }^{q\lambda -}$$, where $$\Delta {s}_{i,knk^{\prime} n^{\prime} }\equiv {s}_{i,kn}-{s}_{i,k^{\prime} n^{\prime} }$$ is the change in (diagonal) spin expectation value for a pair of states. Therefore, in this limit, Eq. (5) reduces to transitions between pairs of states, each contributing proportionally to the square of the corresponding spin change.

See Supplementary Note 1 and 2 for detailed derivations of the above equations. As we show in Supplementary Note 1 and 2, the above equations can be reduced to previous formulae with spin–flip matrix elements in Kramers-degenerate subspaces for systems with inversion symmetry and weak spin-mixing, such as conduction electron spin relaxation in bulk Si, similar to ref. 18. However, Eq. (3) is much more general, applicable for systems with arbitrary degeneracy and crystal symmetry, and we therefore use it throughout for all results presented below. In addition, the overall framework can also be extended to other observables and can be made to correspond to specific measurement techniques that prepare a different initial density matrix e.g. a circularly polarized pump pulse.

Finally, note that in our first-principles method, all SOC-induced effects (such as the Rashba/Dresselhaus effects) are self-consistently included in the ground-state eigensystem or the unperturbed Hamiltonian H0. This is essential to allow us to simulate τs by a single rate calculation when there is broken inversion symmetry. On the other hand, if SOC does not enter into H0, as in previous work with model Hamiltonians, it must be treated as a separate term that provides an internal effective magnetic field. Consequently, those approaches require a coherent part of the time evolution to describe the fast spin precession induced by this effective magnetic field, which require explicit real-time dynamics simulations even to capture spin relaxation, going beyond a simple exponential decay as in Eq. (2). Using fully self-consistent SOC in a first-principles method is therefore critical to avoid this system-specific complexity and arrive at the universal approach outlined above.

### Systems with inversion symmetry: Si and Fe

We first present results for systems with inversion symmetry traditionally described by a Elliot–Yafet spin–flip mechanism. Figure 1a shows that our predictions of electron spin relaxation time (τs) of Si as a function of temperature are in excellent agreement with experimental measurements26,27. Note that previous first-principles calculations18 approximated spin–flip electron–phonon matrix elements from pseudospin wavefunction overlap and spin-conserving electron–phonon matrix element, effectively assuming that the scattering potential varies slowly on the scale of a unit cell; we make no such approximation in our direct first-principles approach. Importantly, this allows us to go beyond the doubly degenerate Kramers-degenerate case of conduction electrons in Si. In contrast, holes in Si exhibit strong spin-mixing with spin-2/3 character and spin expectation values no longer close to /2. Figure 1b shows our predictions for the hole–spin relaxation time, which is much shorter than the electron case as a result of the strong mixing (450 fs for holes compared to 7 ns for electrons at 300 K) and is much closer to the momentum relaxation time. In addition, Fig. 1d shows that the change in spin expectation values (Δs) per scattering event (evaluated using Eq. (5)) has a broad distribution for holes in Si, indicating that they cannot be described purely by spin–flip transitions, while conduction electrons in Si predominantly exhibit spin–flip transitions with Δs = 1.

We next consider an example of a ferromagnetic metal, iron, which exhibits a complex band structure not amenable for model Hamiltonian approaches. Previous first-principles calculations for ferromagnets employ empirical Elliott relation28 or FGR formulae with spin–flip matrix elements specifically developed for metals or ferromagnets20. Here, we apply exactly the same technique used for the silicon calculations above and predict spin relaxation times in iron in good agreement with experimental measurements (Fig. 1c)29,30,31. Our Wannier interpolation also enables systematic and efficient Brillouin zone convergence of these predictions which were not possible previously. Similar to holes in Si, the Δs of Fe also exhibits a broad distribution extending from 0 to in the contribution to the total spin relaxation rate (Fig. 1d). Therefore, spin relaxation in transition metals are not purely spin–flip transitions, and we expect this effect to be even more pronounced in 4d and 5d metals with stronger SOC than the 3d magnetic metal considered here. Finally, Fig. 1a–c shows that τs is approximately proportional to momentum relaxation time τm for both Si and bcc Fe, which is expected for spin relaxation in systems with EY mechanisms1.

### Systems with inversion symmetry: graphene

Graphene is of significant interest for spin-based technologies, and significant recent work with model Hamiltonians seeks to identify the fundamental limits of spin coherence in graphene32. Estimates vary widely from theoretical estimates on the order of microseconds to experiments ranging from picoseconds to nanoseconds33,34,35,36, with the discrepancies hypothesized to arise from faster extrinsic relaxation in experiments. However, previous model Hamiltonian studies required parametrization of approximate matrix elements, and focus on specific phonon modes (e.g. flexural modes) for spin–phonon relaxation. Here we predict intrinsic electron–phonon spin relaxation time for free-standing graphene to firmly establish the intrinsic spin–phonon relaxation limit free of specific model choices or parameters.

Figure 2 shows the predicted spin–phonon relaxation times as a function of temperature and Fermi level position. At room temperature, our calculated lifetimes are of the same magnitude (in microseconds) as previous predictions33 indicating that faster relaxation is likely extrinsic in experiments. However, in addition to the flexural phonon mode33,35, in-plane acoustic (A) phonon modes have a strong and non-negligible contribution, while optical modes (O) have an overall smaller effect (Fig. 2b). We also find that the ratio between in-plane and out-of-plane spin relaxation times range from 0.5 to 0.7 (Fig. 2a, c), consistent with experimental measurements34. As evident from Fig. 2c, longer spin relaxation time of up to microseconds is achievable at low temperatures in pristine and free-standing graphene. However, at low temperatures, competing effects from substrates and disorder can make overall measured spin relaxation faster than theoretical predictions35.

Finally note that while the ratio between in-plane and out-of-plane spin relaxation times is nearly 1/2, which is often considered to be a signature of the DP mechanism, free-standing graphene is inversion symmetric and does not exhibit the DP mechanism. Figure 2d shows that the spin relaxation time is mostly insensitive to the extrinsic scattering rates, instead of the linear relation (inverse relation with scattering time) expected for the DP mechanism, as discussed below in further detail. The spin relaxation of graphene may be switched to the DP regime by adding substrates or external electric fields to break inversion symmetry36,37, which will be investigated in detail using this theoretical framework in future work.

### Systems without inversion symmetry: out-of-plane τs of MoS2 and MoSe2

The two-dimensional transition metal dichalcogenides (TMDs) exhibit extremely long-lived spin/valley polarization (over nanoseconds)38, with long valley-state persistence attributed to spin-valley locking effects. A fundamental understanding of spin/valley relaxation mechanisms is now required to utilize this degree of freedom for valleytronic computing39. Next we investigate spin relaxation τs of systems without inversion symmetry from first-principles, starting with two TMD systems—monolayer MoS2 and MoSe2 as prototypical examples. (Unless specified, τs represents out-of-plane spin relaxation time τs,zz for TMDs.)

In both systems, valence and conduction band edges at K and K′ valleys exhibit relatively large SOC band splitting, with nearly perfect out-of-plane spin polarization. Time-reversal symmetry further enforces opposite spin directions for the band-edge states at K and K′. Previous studies using model Hamiltonians consider the DP mechanism to dominate spin relaxation in these materials17, but in our first-principles approach, we do not need to a priori restrict our calculations to EY or DP limits.

In Fig. 3, we show the out-of-plane spin (τs) and momentum (τm) relaxation time of conduction electrons in two monolayer TMDs as a function of temperature, along with their intervalley/intravalley contributions and experimental values. First, the overall agreement between our calculations and previous experiments by ultrafast pump-probe spectroscopy is excellent38,40,41. Note that ultrafast measurements of TMDs obtain coupled dynamics of spin and valley polarizations according to the selection rules with circularly polarized light, necessitating additional analysis to extract τs, e.g., a phenomenological model fit to experimental curves in ref. 38. On the other hand, our first-principles method simulates τs directly without model or input parameters. This provides additional confidence in the experimental procedures of extracting τs, and lends further insights into different scattering contributions in the dynamical processes as we show below. Moreover, special care is necessary when comparing with certain low temperature measurements with lightly doped samples, which access spin relaxation of excitons rather than individual free carriers, as discussed in refs. 42,43; we focus here on spin relaxation of free carriers.

Next, comparing the relative contributions of intervalley and intravalley scattering for spin relaxation time, we find that the intravalley process dominates spin relaxation of conduction electrons in both TMDs: the intravalley only spin relaxation time (black squares) in Fig. 3 is nearly identical with the net spin relaxation time (red circles), while the intervalley contribution alone (blue triangles) is consistently more than an order of magnitude higher in relaxation time (lower in rate). Furthermore, with decreasing temperature, the relative contribution of the intervalley process decreases because the minimum phonon energies for wave vectors connecting the two valleys exceed 20 meV, and the corresponding phonon occupations become negligible at temperatures far below 300 K.

Previous theoretical studies of MoS2 with model Hamiltonians17 obtained (out-of-plane) τs two orders of magnitude higher than our predictions, which agree with experimental data38. Such significant deviations are possibly because of the approximate treatments of electronic structure and electron–phonon coupling in their theoretical model. In addition, our first-principle calculations treat all phonon modes on an equal footing. Table 1 shows that the relative contributions of each phonon mode to τs varies strongly with temperature. Full electron and phonon band structure is therefore vital to correctly describe spin–phonon relaxation with varying temperature, while model Hamiltonians that select specific phonon modes have limited range of validity17.

Hole–spin relaxation in MoS2 and MoSe2 has not been previously investigated in detail theoretically. Figure 4 presents our predictions of hole τs and τm in the two TMDs, indicating that hole τs is much longer than that for electrons at all temperatures, exceeding 1 ns below 100 K. In contrast to the electron case, the intervalley process is relatively much more important and dominates spin relaxation at low temperature in MoS2 and at all temperatures in MoSe2. This is because large SOC splitting at the valence band maximum makes the intravalley transition between two valence bands nearly impossible based on energy conservation in the electron–phonon scattering process. Experimental measurements also observe long spin relaxation times dominated by intervalley scattering in tungsten dichalcogenides44, which may facilitate applications in spintronic and valleytronic devices.

External magnetic fields can serve as tools tuning material properties45 and are an inherent component of spin dynamics measurements38,44. Systems with broken inversion symmetry in particular may strongly respond to magnetic fields. We therefore investigate the effects of an external field B on τs by introducing a Zeeman term (gsμB/)BS to the electronic Hamiltonian interpolated using Wannier functions (approximating gs ≈ 2), just prior to computing τs with Eq. (3). Figure 5 shows that the out-of-plane τs of conduction electrons of MoS2 decreases with increasing in-plane magnetic field Bx, in agreement with experimental work on MoS238 and in general consistency with previous theoretical studies of τs for systems with broken inversion symmetry17,46.

This strong magnetic field response has a simple intuitive explanation: in TMDs, the spin splitting of bands can be considered as the result of the internal effective magnetic field $${B}_{{\mathrm{so}}}\hat{{\bf{z}}}$$ due to broken inversion symmetry. Applying a finite Bx perpendicular to $${B}_{{\mathrm{so}}}\hat{{\bf{z}}}$$ will cause additional spin-mixing and increase the spin–flip transition probability, thereby reducing the spin relaxation time. The degree of reduction depends on the detailed electronic structure of MoS2 and MoSe2 as shown in Supplementary Figs. 2 and 3: MoSe2 exhibits a larger spin splitting of conduction bands and a higher internal magnetic field, and is therefore less affected by external Bx. Similarly, hole–spin relaxation in both MoS2 and MoSe2 (not shown) exhibit very weak dependence on Bx because of the large spin splitting and high internal effective magnetic field Bso for valence band-edge states compared to those near the conduction band minimum. This insensitivity of hole τs to magnetic fields is also consistent with experimental studies of hole τs in WS244 and WSe247.

Finally, out-of-plane magnetic field Bz has a negligible effect on spin relaxation for TMDs (not shown), unlike the in-plane magnetic field Bx or By. This is because electronic states around band edges are already polarized along the out-of-plane direction under a strong internal $${B}_{{\mathrm{so}}}\hat{{\bf{z}}}$$. High experimental external magnetic fields  ~1 Tesla are relatively weak in contrast and only slightly change the spin polarization of the states, rather than introducing a spin-mixing that leads to spin relaxation.

### Systems without inversion symmetry: in-plane τs of MoS2

In all cases, the spin–phonon relaxation time decreases with increasing temperature, approximately proportional to the momentum relaxation time τm. This is expected because both scattering rates, $${\tau }_{{\mathrm{s}}}^{-1}$$ and $${\tau }_{{\mathrm{m}}}^{-1}$$, are proportional to phonon occupation factors which increase with temperature. The intrinsic in-plane spin relaxation time (τs,xx) in MoS2 also shows the same trend with temperature (Fig. 6a), but exhibits a fundamental difference from the previous cases when considering additional extrinsic scattering.

Specifically, Fig. 6b shows the dependence of spin relaxation times in MoS2 conduction electrons as a function of extrinsic scattering rates, which enter Eq. (3) through an additional contribution to the smearing width γ of the energy-conserving δ-functions (in addition to the intrinsic electron–phonon contributions computed from first-principles). This additional smearing physically corresponds to the reduced lifetime and increased broadening of the electronic states in the material due to scattering against defects, impurities etc37. Importantly, the in-plane spin relaxation time τs,xx increases linearly with extrinsic scattering rate, or inversely with extrinsic scattering time, which is a hallmark of the DP mechanism of spin relaxation48.

Note that this inverse relation competes with the phonon occupation factors in determining the overall temperature dependence of spin relaxation time. At higher temperature, increased phonon occupation factors lower the intrinsic relaxation times of both carrier and spin, as stated above. The lowered intrinsic carrier relaxation time increases the finite smearing width in Eq. (3), which contributes towards increasing the spin relaxation time within the DP mechanism (inverse relation). However, the direct contribution of phonon occupation factors in the spin relaxation rate in Eq. (3) overwhelms this secondary change and results in a net decrease of spin relaxation time, consistent with all calculations above and experiments49,50.

In contrast with the in-plane case, the out-of-plane spin relaxation τs,zz is mostly insensitive to the extrinsic scattering rate (and broadening γ), as all previous spin relaxation results in Kramers-degenerate materials discussed above (e.g. for graphene in Fig. 2d). Note that τs,xx is also overall much shorter than τs,zz, because the strong internal magnetic field in TMDs stabilizes spins in the z direction as discussed above. Large anisotropy in spin lifetimes due to a similar spin-valley locking effect has been theoretically predicted51 and experimentally measured52 previously in graphene–TMD interfaces as well.

### Systems without inversion symmetry: GaN

Finally, we show spin relaxation in GaN as an archetypal example of the DP mechanism. Fig. 7 shows that both in-plane (τs,xx) and out-of-plane (τs,zz) spin lifetime of GaN are proportional to extrinsic scattering rates, or inversely proportional to extrinsic scattering time. Most importantly, the ratio between τs,zz and τs,xx is exactly 1/2 for this material, which is an additional feature of the conventional DP mechanism1. Note that, in contrast, the 2D TMDs are more complex due to strong SOC splitting and anisotropy, did not exhibit this 1/2 ratio, and exhibited the extrinsic scattering dependence only for in-plane spin relaxation. Overall, these results indicate that the general density-matrix formalism presented here elegantly captures the characteristic DP and EY mechanism limits, as well as complex cases that do not fit these limits, all on the same footing in a unified framework.

## Discussion

In summary, we have demonstrated an accurate and universal first-principles method for predicting spin relaxation time of arbitrary materials, regardless of electronic structure, strength of spin-mixing and crystal symmetry (especially with/without inversion symmetry). Our work goes far beyond previous first-principles techniques based on a specialized Fermi’s golden rule with spin–flip transitions and provides a pathway to an intuitive understanding of spin relaxation with arbitrary spin-mixing. In TMD monolayer materials, we clarify the roles of intravalley and intervalley processes, which are additionally resolved by phonon modes, in electron and hole–spin relaxation. We predict long-lived spin polarization from resident carriers of MoS2 and MoSe2 and show their strong sensitivity of electron spin relaxation to in-plane magnetic fields.

The predictive power of first-principles calculations is crucial for providing fundamental understanding of spin relaxation in new materials. The same technique can be applied to predict spin relaxation in realistic materials with or without defects useful for quantum technologies, wherever spin relaxation is dominated by electron–phonon scattering. We have already considered the general impact of disorder and electron-impurity scattering on spin–phonon relaxation through carrier broadening, but impurities can contribute an additional channel for spin relaxation, especially in the Kramers-degenerate case and at lower temperatures18. The extension of this technique to directly predict electron-impurity scattering for specific defects is relatively straightforward using supercell calculations, but computationally more demanding, while predicting the impact of electron–hole interaction53,54,55 and electron–electron scattering56,57 is additionally challenging. Finally, a robust understanding of ultrafast experiments may require simulation of real-time dynamics to capture initial state effects, probe wavelength effects and beyond-single-exponential decay dynamics, which is a natural next step within the general Lindbladian density-matrix formalism presented here.

## Methods

### Computational details

All simulations are performed by the open-source plane-wave code - JDFTx58 using pseudopotential method, except that the Born effective charges and dielectric constants are obtained from open-source code QuantumESPRESSO59. We firstly carry out electron structure, phonon and electron–phonon matrix element calculations in DFT using Perdew–Burke–Ernzerhof exchange-correlation functional60 with relatively coarse k and q meshes. The phonon calculations are done using the supercell method. We have used supercells of size 7 × 7 × 7, 4 × 4 × 4, 6 × 6 × 1, 6 × 6 × 1, 6 × 6 × 1, 4 × 4 × 4 for silicon, BCC iron, graphene, monolayer MoS2, monolayer MoSe2 and GaN, respectively, which have shown reasonable convergence for each system (<20% error bar in the final spin relaxation estimates). SOC is included through the use of the fully relativistic pseudopotentials61. For monolayer MoS2 and MoSe2, the Coulomb truncation technique is employed to accelerate convergence with vacuum sizes62.

We then transform all quantities from plane wave to maximally localized Wannier function basis63 and interpolate them24,25,64,65 to substantially finer k and q meshes (with  >3 × 105 total points) for lifetime calculations. Statistical errors of lifetime computed using different random samplings of k-points are found to be negligible (<1%). This Wannier interpolation approach fully accounts for polar terms in the electron–phonon matrix elements and phonon dispersion relations using the approaches of Verdi and Giustino66 and Sohier et al.67 for the 3D and 2D systems.