Excited magnetic states possess longitudinal and transverse perturbations of magnetic moments that deviate from ground-state magnetic configurations. They are crucial for understanding magnetic ordering, magnetic phase transitions, and other magnetic phenomena. Further, magnetic excited states are prevalent in frustrated magnets [14], multiferroics [58], superconductors [919], topological magnets [20], etc, and are of crucial importance to phenomena such as superconductivity [919], quantum critical point [2124], quantum phase transition [25], and the quantum anomalous Hall effect [26]. The above exotic phenomena stems from the delicate interaction between spin and other degree of freedoms (DoF) such as charge, orbital, and lattice. The elucidation of the microscopic mechanism of these coupling effects need to evaluate the second or higher order derivatives of the energy with respect to the magnetic moment and other DoFs. In order to do so, the magnetic moment must be considered as a variable that can be altered independently from the other DoFs. And the manifestation of its variation, i.e. the excited magnetic states, is hence critical to understand the mutual interactions, and is significantly challenging to simulate despite its ubiquity.

However, the commonly used density functional theory (DFT) [27] was originally developed to describe ground states. In their seminal works, Dederichs et al. [28] and Dudarev et al. [29, 30] introduced a Lagrange multiplier λ to constrain the magnetic moments when solving the Kohn-Sham equation as \(\nabla _{\phi _{i}} L=0\) [28, 29, 3134]. However, it is difficult to simultaneously reach the global minimum of Lagrangian and meet the constraint, and thus it is not guaranteed that the magnetic moment M gets to its constrained target. This situation is particularly severe in itinerant metallic magnetic materials [35]. Therefore, the magnetic moment is difficult to control and to be considered as a completely independent DoF, and the energy of corresponding system is difficult to identify. These uncertainties escalate when the energy is differentiated by an infinitesimal variation of magnetic moment or other DoF, to evaluate the coupling strength, such as the magnetoelectrical coupling constant.

Another unfavorable fact is that these methods require the user to be highly proficient at interactively adjusting the optimization strategy [30, 34], which makes these methods highly prone to numerical error. This is because that the optimization is conducted only in the electronic energy functional minimization, where the constraining parameter λ is set as a pre-defined constant. λ, when improperly chosen, leads the system to a local minimum (λ too small) or to divergence (λ too big). In additional, this fixed λ is difficult to adapt to actual spin fluctuations where different magnetic components exhibit different deviations from the original ground state, which also makes the Hamiltonian numerically unstable to be diagonalized. Recently, Hegde et al. [36] developed a self-consistent method to impose spin constraints and sped up the convergence significantly. However, this method only deals with collinear magnetic orders, which hinder the study of complex noncollinear spin fluctuations.

To address these deficiencies, in this letter, we proposed a self-adaptive spin-constrained DFT scheme, where Kohn-Sham orbitals and the constraining vectors are updated iteratively to reach the global optimum of the Lagrangian and the target magnetic moments. In this scheme, the on-site adaptable constraint \(\{\boldsymbol{\lambda}_{I} \}\) are imposed in the form of a local vector field. The amplitude and orientation of the constraining vector field \(\{\boldsymbol{\lambda}_{I} \}\) depend on the local magnetic environment of atom I and vary from component to component. Equipped with this strategy, the magnetic moment can be altered independently from the other DoFs in our non-collinear first-principles scheme. Our approach now paves the way for the investigation of spin fluctuation and its influence on other DoF. To exemplify this method, we then apply it to two scenarios. The first is a spin configuration with confined rotation, using ferromagnetic materials Fe and layered magnetic materials CrI3 as examples. To simulate real-world fluctuations, it is later generalized to study the electronic band structure of CrI3 with random magnetic orientations.

1 Results

Self-adaptive spin-constraining algorithm. Our scheme is sketched in Fig. 1. It is based on the optimization of the Lagrangian function L under the constraint that the magnetic moment of atom I, that is, \(\mathbf{M}_{I} ( \{\phi _{i} \} )\), is the same as the target value denoted by \(\mathbf{M}_{I}^{*}\). To implement this, we design two nested loops updating the Kohn-Sham orbitals \(\{\phi _{i} \}\) and the Lagrangian multiplier \(\{\boldsymbol{\lambda}_{I} \}\) respectively.

Figure 1
figure 1

Scheme of self-adaptive spin-constrained DFT method DeltaSpin. The outer electronic loop updates electron density ρ, while inner λ-loop updates constraining multiplier λ. (Subscripts for indexing atoms and orbitals are omitted for clarity)

(i) Electronic loop: For a particular \(\boldsymbol{\lambda}_{I}\), we can solve

$$ \frac{\delta E_{\mathrm{KS}}}{\delta \langle \phi _{i}|}-\sum_{I} \boldsymbol{ \lambda}_{I} \cdot \frac{\delta \mathbf{M}_{I}}{\delta \langle \phi _{i}|} =\epsilon _{i} |\phi _{i}\rangle $$
(1)

to obtain a self-consistent solution \(\{\phi _{i} (\boldsymbol{\lambda}_{I} ) \}\) and the magnetic moment \(\mathbf{M} ( \{\phi _{i} (\boldsymbol{\lambda}_{I} ) \} )\). The atomic magnetic moment \(\mathbf{M}_{I}\) is generally defined as \(\mathbf{M}_{I} ( \{\phi _{i} \} ) = \mathrm{Tr}({\rho} {\sigma}\hat{\mathcal{W}}_{I})\), where ρ is the density matrix, σ is the Pauli matrix, \(\hat{\mathcal{W}}_{I}\) is a pre-defined weight operator for atom I. Thus, Eq. (1) is obtained as

$$ \hat{\mathcal{H}}_{\mathrm{KS}} \vert \phi _{i}\rangle -\sum _{I}\boldsymbol{\lambda}_{I} \cdot \mathrm{ \sigma}\hat{\mathcal{W}}_{I} \vert \phi _{i}\rangle= \epsilon _{i} |\phi _{i}\rangle. $$
(2)

Note that \(\boldsymbol{\lambda}_{I}\) acts as a constraining field [28].

(ii) λ-loop: We can progressively update \(\{\boldsymbol{\lambda}_{I} \}\) by optimizing

$$ \min_{\boldsymbol{\lambda}_{I}} \bigl\vert \mathbf{M} \bigl( \bigl\{ \phi _{i} (\boldsymbol{\lambda}_{I} ) \bigr\} \bigr)- \mathbf{M}^{*} \bigr\vert ^{2}, $$
(3)

that is, the error ΔM between the current magnetization and the target, using the nonlinear conjugate gradient (NCG) method. For an updated \(\boldsymbol{\lambda}_{I}^{*}\), we can solve Eq. (2) via diagonalization in the subspace spanned by the old orbitals \(\{\phi _{i} (\boldsymbol{\lambda}_{I} ) \}\) to obtain a new set of orbitals \(\{\phi _{i} (\boldsymbol{\lambda}_{I}^{*} ) \}\), and thus, the moment \(\mathbf{M}(\boldsymbol{\lambda}_{I}^{*})\). In this way, the optimization can continue until a minimum is achieved. A perturbation-like scheme similar to that in Ref. [36] was chosen, which significantly reduced the computational cost compared to diagonalization in the entire basis set. In addition, the λ-loop converged rapidly because the function \(\mathbf{M} ( \{\phi _{i} (\boldsymbol{\lambda}_{I} ) \} ) = \partial ^{2} L/{\partial \boldsymbol{\lambda}_{I}^{2}}\) is proved to be almost monotonous according to the first-order perturbation theory (\(L (\phi _{i}, \boldsymbol{\lambda}_{I}, \epsilon _{i} )\) is a concave function of \(\boldsymbol{\lambda}_{I}\) at \(0~\mathrm{K}\) [33]).

Certain details of the scheme deserve further discussion. In the λ-loop, the gradient of the object function can be approximated as \(2 (\mathbf{M}_{I} - \mathbf{M}_{I}^{*}) \frac{\partial \mathbf{M}_{I}}{\partial \boldsymbol{\lambda}_{I}} \), based on the assumption that \(\partial{\mathbf{M}_{I^{\prime }\neq I}}/\partial{\boldsymbol{\lambda}_{I}}\), which is the non-local response to the on-site constraining field, is negligible. \({\partial \mathbf{M}_{I}}/{\partial \boldsymbol{\lambda}_{I}}\) can be then obtained by lower-complexity estimation strategies for the NCG iteration. To provide better convergence, we control both \(\Delta \mathbf{M} = \sqrt{|\mathbf{M} ( \{\phi _{i} ( \boldsymbol{\lambda}_{I} ) \} )-\mathbf{M}^{*}|^{2}}\) and the main diagonal of the gradients \(\partial{\mathbf{M}_{I}}/\partial{\boldsymbol{\lambda}_{I}}\) in the λ-loop. We first introduce a gradually tightened criterion \(\varepsilon _{\mathbf{M}}\) for the former, preventing the constraining field from reaching an early stage local minimum. In case of the latter, the loop is programmed to stop when the local response was smaller than an empirical value \(\varepsilon _{\mathrm{loc}}\) (\(\varepsilon _{ \mathrm{loc}} \approx 1~\mu _{B}^{2}/\mathrm{eV}\) works well across our limited tests). This criterion, which is based on the aforementioned localization assumption, is of particular importance. Additionally, the weight operator in Eq. (2) is often an integral in a real-space ball of radius \(r_{\mathrm{cut}}\) with a smoothed boundary as \(\hat{\mathcal{W}}_{I} = \int \mathrm{d}\mathbf{r} f(r_{\mathrm{cut}}- \vert \mathbf{r}-\mathbf{r}_{I} \vert )|\mathbf{r}\rangle \langle\mathbf{r}|\). It may take a different form such as the Mulliken partitioning in atomic orbital basis DFT [37].

Upon convergence, the magnetic effective field can be obtained efficiently based on the Hellmann–Feynman theorem as

$$ \mathbf{B}^{\mathrm{eff}}_{I} = - \frac{\delta L(\mathbf{M}_{I}^{*})}{\delta \mathbf{M}_{I}^{*}} = - \boldsymbol{\lambda}_{I}. $$
(4)

This suggests that by continuously updating the constraining field, ΔM is minimized and an increasingly accurate estimation of the magnetic effective field is obtained, which turns out to be the constraining field \(\boldsymbol{\lambda}_{I}\) itself. This estimation shows good correspondence with the true value, which is obtained via differentiation near the collinear limit, and a relative error of up to 4% through the entire path of non-collinear rotation (see Fig. S2 in the Additional file 1). This is because Eq. (4) is strictly correct only if \(\langle \phi _{i} | {\nabla _{\mathbf{M}_{I}} \hat{\mathcal{H}}_{\mathrm{KS}}} |\phi _{i}\rangle \) is negligible [38].

Potential energy surface. A fine-grid potential energy surface (PES) is of great significance, particularly the one considering the spin DoF. While the previous quadratic cDFT requires a predetermined multiplier λ and may collapse during the early stage of the electronic loop (an analysis is presented in the Additional file 1), the proposed method can self-adaptively update the multiplier and exhibits a much better precision and efficiency. We studied the magnetic PES of the bcc-Fe (Fig. 2). The two DoFs scanned were the magnitude of atomic moments \(|\mathbf{M}|\) and the included angle between the nearest neighbors’ moments θ. In the calculations using former quadratic constraints, the root-mean-square error (RMSE) between the obtained and desired spin configurations were stuck at approximately \(10^{-2} \mu _{B}\) (blue lines in Fig. 2(b)). In comparison, the DeltaSpin algorithm exhibited a much better convergence, where the RMSE decreased rapidly to nearly zero (\(10^{-8} \mu _{B}\)) for the same number of electronic iterations. We found that the energy-favored magnitude increased when the spins approached the ferromagnetic (FM) order and decreased when approaching anti-ferromagnetic (AFM) order. Moreover, the magnitude-optimized energy curve was the PES calculated using the former direction-only constraining method, which is a subset of our \(V(|\mathbf{M}|, \theta )\) PES.

Figure 2
figure 2

Potential energy surface (PES) study of bcc-Fe with magnetic excitation. (a) Structure of bcc-Fe and spin configuration with deviated included angle of two neighboring Fe magnetic moments \(\theta = \langle \mathbf{M}_{\mathrm{Fe_{1}}}, \mathbf{M}_{ \mathrm{Fe_{2}}}\rangle \) and magnitude \(|\mathbf{M}|\). (b) Comparison of convergence between DeltaSpin and former quadratic cDFT method with different λ. X axis: number of electronic iterations. Y axis: root-mean-square error (RMSE) between the obtained and the desired magnetization. (c) PES as a function of θ and \(|\mathbf{M}|\). Solid and dashed lines respectively denote single-variable PES and its projection. Blue line indicates the PES with \(|\mathbf{M}|\) fixed at ground-state value 1.54 \(\mu _{B}\) (using radial Bessel function as \(\hat{\mathcal{W}}_{I}\) in Eq. (2)). Red line indicates the PES with energy-minimized \(|\mathbf{M}|\). Dashed lines are their projections. (d) PES relative to such energy-minimized path

Effects on magnetic interactions. One of the advantages of this method is the ability to obtain the real on-site magnetic interaction around an arbitrary magnetic configuration through simple calculations of the first derivative of energy E with respect to M. This was not possible in previous studies as achieving precision for both E and δM was challenging. In Fig. 3, we show the calculated \(J_{ij}\) and \(K_{ij}\) as the bilinear exchange and biquadratic exchange parameters with variation in the magnetic configurations. The effective Hamiltonian used was \(H = -\sum_{i, j > i} J_{i j} (\mathbf{e}_{i} \cdot \mathbf{e}_{j} ) - \sum_{i, j > i} K_{i j} (\mathbf{e}_{i} \cdot \mathbf{e}_{j} )^{2} \), where i, j is the atom index. Both \(J_{1}\) and \(K_{1}\) exhibited strong dependency on the local magnetic configurations, as shown in Fig. 3. Further, \(J_{1}\) from the previous energy-mapping strategy, which is a constant at approximately 3 meV [39], was between the maximum and the minimum of the result obtained.

Figure 3
figure 3

Configuration dependency of bilinear and biquadratic exchange interaction in monolayer CrI3. X axis: canting angle θ, that is, the included angle of two neighboring Cr magnetic moments. Y axis: the intensity of different exchange interactions. \(J_{1}\), \(J_{2}\), and \(J_{3}\) represent the interaction between the first, second, and third nearest neighbors respectively (same with \(K_{1}\), \(K_{2}\), \(K_{3}\), indicated using different colors in the inset of (a)). (a) Bilinear parameter \(J_{ij}\). The inset figure is an illustration of honeycomb CrI3 and the exchange interaction where Cr atoms are denoted by grey balls and O atoms are omitted. (b) Biquadratic parameter \(K_{ij}\)

The magnetic effective fields \(\frac{\delta E}{\delta \mathbf{M}}\) and magnetic torques \(\frac{\delta E}{\delta \mathbf{e}}\) are generally considered as the indicators of magnetic interactions and could be employed as the driving forces in further dynamical simulations using real-time TDDFT or the Landau-Lifshitz-Gilbert(Bloch) method. There are two different strategies to calculate them: (i) Finite difference approximation directly using the definition, that is, taking derivatives of the total energy E with respect to \(\mathbf{M}_{I}^{*}\); (ii) Hellmann–Feynman approximation, that is, the constraining field, explained above.

We calculated such constraining-field-approximated magnetic torques and compared them to the finite-differentiated ones in bcc-Fe and monolayer CrI3 (see Fig. S2). The maximum relative error was about 4%, which was attributed to the non-collinear contribution in Kohn-Sham functional \(\langle \phi _{i} |{\nabla _{\mathbf{M}_{I}} \hat{\mathcal{H}}_{\mathrm{KS}}}|\phi _{i}\rangle\), and perfectly acceptable in some cases. Notice that the difference was negligible in the collinear limit, that is, in the neighborhood of FM and AFM order, both in Fe and in CrI3. It means that Hellmann–Feynman approximation is a efficient and reliable choice given that the complexity of explicit differentiation is at least \(\mathcal{O}(N)\) (N is the number of atoms) whereas to obtain constraining field only one calculation is needed. In addition, if a delicate description instead of a crude estimate of magnetic dynamics is needed, one can always apply an infinitesimal change to spin moments, recalculate the total energy, and take the derivatives. This procedure is also unachievable for λ-fixed constraining formalism wherein the inadequate precision of energy leads to poor precision of magnetic torques.

Effects on lattice dynamics. The variation in spin configuration has a non-trivial influence on phonon behaviors, and this study proposed a straightforward method to identify such couplings. This was performed by combining the frozen phonon method [40] with DeltaSpin. In particular, the system’s energy must be precisely calculated at the atomic and magnetic excitations. Simultaneously, the magnetic configuration must be prevented from “drifting away”. DeltaSpin can limit the energy and on-site moment error to \(10^{-9}~\mathrm{eV}\) and \(10^{-7}~\mu _{B}\), respectively, while maintaining efficiency with more than one hundred atoms; to the best of our knowledge, it is the only method that can access this type of phonon calculations. Four selected spin-fluctuating states were obtained for CrI3 (Fig. 4). Only the moments of chromium were constrained, while iodine atoms were fully relaxed, owing to the functionality of DeltaSpin to selectively constrain atoms or components. We found five modes that were significantly influenced by magnetic excitation, all of which appeared in the high-frequency branches where the Cr vibrations dominated (Fig. 4(a)). Regardless of spin-orbit coupling and anti-symmetric exchange, these frequency shifts can be roughly explained by the change in the “Heisenberg-only” force constant. \([\partial{J_{ij}}/\partial{\mathbf{r}} ] [\mathbf{e}_{i} \cdot \mathbf{e}_{j} ]\). The second term depends on the spin configuration explicitly. The first term, which is mainly contributed by the competition between the AFM \(t_{2g}\)-\(t_{2g}\) and FM \(t_{2g}\)-\(e_{g}\) interactions [41], also experiences considerable changes because of the different occupancies of \(e_{g}\) and \(t_{2g}\) orbitals across all four configurations. The existence of “collective-motion” modes, in which the distance between any two Cr atoms remains unchanged (Fig. 4(c), \({\Gamma _{2}^{-}+\Gamma _{3}^{-}}\)), indicates that the interaction between Cr and I atoms, that is, the metal-ligand interaction, is also strongly affected by only changing the on-site moments of metal atoms. Moreover, the moments of I relax from \(10^{-1} \mu _{B}\) to approximately zero as θ increases from 0 to 180, whose importance has been demonstrated by previous research [4245]. Using this algorithm, we can obtain the spin-lattice interaction information. Consequently, the process starts from the objective of obtaining a particular magnetic configuration to determine a feasible method of selective excitation via lattice vibrations. Thus, this can guide ultrafast THz experiments through resonant excitation of infrared (IR) [46] or Raman-active phonons [47].

Figure 4
figure 4

Phonon structure of monolayer CrI3’s different magnetic states. (a) Overall phonon spectrum at \(\theta =0^{\circ}, 60^{\circ}, 120^{\circ}, 180^{\circ}\). Dashed blocks indicate five modes (indexed by roman numerals) with significant frequency change owing to magnetic excitation. Physically-irreducible representations: I: \(\mathrm{M_{1}^{-}}\); II: \(\mathrm{M_{1}^{+}}\); III: \({\Gamma _{2}^{-}+\Gamma _{3}^{-}}\); IV: \(\mathrm{M_{1}^{+}}\); V: \(\mathrm{K_{1}}\). (b-e) Zoom image of mode I, II, III, IV, and V with the schematic atomic displacement on the bottom side. Azure and white balls denote Cr and I atoms, respectively. The arrows indicate the instant direction of their motion, where the green and orange ones represent two opposite directions

Effects on electronic structure. Spin fluctuations have a prominent effect on the electronic structure such as the band structure and orbital character of the Fermi surface [4850]. First-principles calculations of electronic structures with spin fluctuations are a critical input for further evaluating the many-body effect [51]. Here, we demonstrate that the band structure is profoundly affected by spin fluctuations using the constrained method (Fig. 5). We modeled several spin-fluctuating configurations near the ground state of monolayer CrI3, wherein magnetic moments were drawn at random from the uniform distribution within the FM order ±10. Their “excited” Kohn-Sham orbitals were then precisely calculated following the DFT routine, which distinguished our method from TDDFT utilizing the expansion of the ground state. Different branches from the obtained bands showed slightly different broadening behaviors with amplitudes varying in the range of 30-50 meV; consequently, the bandgap shifted. In addition, we obtained several electronic states with different canting angles θ in the transition from the FM to the Néel AFM phase of CrI3. These exhibited prominent variation in the band gap, Fermi surface, and topological features (see Fig. S4-5 in the Additional file 1). Thus, this method can be a potentially useful strategy to access a spin-renormalized band structure that fully considers the coupling between spin and electronic DoF [11], which is exceptionally useful for investigating fundamental low-energy physics or exploring rich functionalities in dynamic or optical properties.

Figure 5
figure 5

Band dispersion near conduction band minimum (CBM) and valence band maximum (VBM), resulting from randomly fluctuated spin configurations. (a) Schematic of monolayer CrI3 with randomly fluctuated spins. (b-c) Band dispersion for several selected branches. Solid curves represent ground-state bands while scatters represent corresponding fluctuated ones. Different colors are used to indicate different branches

The wave function is solved precisely via DeltaSpin for spin-fluctuating states. Thus, we are able to depict more detailed electronic structure. Strong interplay between magnetism and topology of electronic states was found, bringing forth rich functionalities in dynamical or optical properties. The topological sensibility to the magnetic configuration was observed for the first time using cDFT. We modeled ten excited states with different canting angles θ in the transition from FM to Néel AFM phase of monolayer CrI3. They exhibited significant variation in band structure, band gap, and Fermi surface as shown in Fig. 6. We noticed the splitting of every two-fold degenerate band when θ went from 180 to 0, following the parity-time (PT) symmetry breaking from AFM to FM phase. It could be further demonstrated in Fermi surface, where one hexagon-shape band in AFM phase split into two concentric circle-shaped valence bands in FM phase (Fig. 6(b)). This process happened on Γ-M path first, then on Γ-K. Simultaneously, the band gap went through a variation of about 50 meV. Moreover, we demonstrated the change in Berry curvature \(\mathbf{F}(\mathbf{k})\) and its sensitivity \(\partial \mathbf{F}(\mathbf{k})/\partial \theta \) throughout the process (see Fig. 6(d-e)), These were calculated using Fukui’s formalism, defined as \(\mathbf{F}(\mathbf{k}) \equiv \ln [ U_{1} (\mathbf{k} ) U_{2} (\mathbf{k}+\hat{1} ) U_{1} ( \mathbf{k}+\hat{2} )^{-1} U_{2} (\mathbf{k} )^{-1} ]\), where \(\hat{1}(\hat{2})\) denotes the reciprocal basis vector and \(U_{1(2)}\) represents a purposely defined U(1) link variable [52]. However, the Chern number [53], obtained by integrating the Berry curvature over the Brillouin zone, shows no dependence on the magnetic configuration because CrI3 is, as a whole, a trivial insulator.

Figure 6
figure 6

Electronic structure of monolayer CrI3 of different canting angles θ. (a) Band structure near Fermi level. Ten band structures are in the same figure, aligned according to their Fermi levels. The inset shows the two-fold splitting of VBM from FM phase (red, \(\theta = 0^{\circ}\)) to Néel AFM phase (blue, \(\theta = 180^{\circ}\)). (b) Fermi surface in two dimensions with \(E = E_{\mathrm{F}} - 0.31 \mathrm{eV} \). (c) Band gap as a function of θ. (d) Total Berry curvature and its gradient with respect to θ as a function of k in reciprocal primitive cell at \(\theta =0^{\circ}, 90^{\circ}, 180^{\circ}\). (e) The derivative of Berry curvature with respect to θ as a function of k in reciprocal primitive cell at \(\theta =0^{\circ}, 90^{\circ}, 180^{\circ}\)

2 Discussion

This study proposes a self-adaptive spin-constrained DFT method wherein the spin fluctuations or magnetic excitation were incorporated along with spin-orbit coupling and non-collinear magnetic configurations, capable of dealing with full degrees of freedom of the amplitude and rotation angle from both magnetic and ligand atoms [45]. This enabled us to gain further insight into spin fluctuations from the electron, lattice, and magnetic perspectives, and also get access to the wave function of magnetic excited states. Here we demonstrate the broading of band because of the random perturbations of magnetic moments, while this can be easily scaled to different temperature and the broading with k dependence can be an indicator to real coupling between spin and other DoFs such as electron and lattice. In addition, the obtained precise atomic forces and magnetic effective fields could be employed as the driving forces in further dynamical simulations such as Landau–Lifshitz–Gilbert (or Landau-Lifshitz-Bloch) or TDDFT [54, 55]. Moreover, the rapid calculation of energy and its corresponding derivatives indicate its ability as a systematic data generator for machine learning surrogate models [5660] and is expected to be revolutionary with its ability to obtain arbitrary spin-lattice configurations with first-principles precision and high efficiency.

3 Methods

Spin-constrained approach. The spin-constrained DFT calculations have been performed using the self-adaptive spin-constraining algorithm DeltaSpin, which has been implemented as a loadable module for Vienna Ab initio Simulation Package (VASP) [6163]. The tolerance \(\varepsilon _{\mathbf{M}}\) for all the constrained local magnetic moments was \(10^{-8}\mu _{B}\). In Fe bulk, the magnetic moments of all Fe atoms were constrained to required values. In CrI3, only the magnetic moments of Cr atoms were constrained and those of I atoms were set to be fully relaxed. For the finite difference calculations of magnetic effective fields, a 10−3 rad interval was used to approximate an infinitesimal variation when calculating \(\Delta E/\Delta \mathbf{e}\).

Density functional theory calculations. All the structural optimization and electronic structure calculations have been performed with VASP at the level of density functional theory with the Perdew-Burke-Ernzerhof (PBE) functional. The energy cut off was 600 eV for the plane-wave basis of the valence electrons in bulk Fe and 520 eV for monolayer CrI3. The DFT + U approach with \(U = 5.3~\mathrm{eV}\) is applied for Cr in CrI3. Total energy tolerance for electronic structure minimization was 10−8 eV and a Γ-centered mesh with k-spacing \(0.06\pi~\mathring{\mathrm{A}}^{-1}\) was applied for both two systems. The VASPBERRY code [64] was used to calculate Berry curvature and Chern number directly from the output of VASP. For the phonon calculations, Phonopy was used to create a \(3 \times 3 \times 1\) supercell structure for monolayer CrI3 and VASP was then employed to calculate the force constants.

Local mapping of the spin Hamiltonian. Inspired by the energy-mapping method [65], we defined “canting angle” θ in honeycomb-like MX3 as Fig. S3. We fit a “local” second-order polynomial around \(\theta ^{*}\) to the total energy of certain configurations with different θ as follows:

$$\begin{aligned} H&=-\sum_{i < j} J_{i j} (\hat{ \mathbf{e}}_{i} \cdot \hat{\mathbf{e}}_{j} ) - \sum _{i < j} K_{i j} ( \hat{\mathbf{e}}_{i} \cdot \hat{\mathbf{e}}_{j} )^{2} \end{aligned}$$
(5)
$$\begin{aligned} &= a_{0}\bigl(\theta ^{*}\bigr) + a_{1}\bigl( \theta ^{*}\bigr) \cdot \cos{\theta} + a_{2}\bigl( \theta ^{*}\bigr) \cdot \cos ^{2}{\theta}, \end{aligned}$$
(6)

where θ is in the neighborhood of \(\theta ^{*}\), that is, \(\theta \in (\theta ^{*} - \delta \theta , \theta ^{*} + \delta \theta )\). Notice that all coefficients of the polynomial implicitly depends on the centered \(\theta ^{*}\). After deduction, \(\theta ^{*}\)-centered pair-wise exchange parameters from the first nearest neighbor (1-NN) up to 3-NN can be solved via

$$ \begin{pmatrix} 6 & 0 & 6 \\ 2 & 8 & 6 \\ 4 & 8 & 0 \end{pmatrix} \begin{pmatrix} J_{1}, K_{1} \\ J_{2}, K_{2} \\ J_{3}, K_{3} \end{pmatrix} = - \begin{pmatrix} a_{1}^{\mathrm{N}}, a_{2}^{\mathrm{N}} \\ a_{1}^{\mathrm{Z}}, a_{2}^{\mathrm{Z}} \\ a_{1}^{\mathrm{S}}, a_{2}^{\mathrm{S}} \end{pmatrix}, $$
(7)

where the dependency of all quantities on \(\theta ^{*}\) are omitted. N for Néel, Z for Zigzag, S for Stripy. These exchange parameters can be treated as the local exchange parameters at \(\theta ^{*}\).