# Magnetic anisotropy and zero-field splitting :::{admonition} Video :class: tip [Watch the narrated video of this tutorial on YouTube](https://www.youtube.com/watch?v=TjPAryt2wwU). ::: :::{admonition} In this tutorial :class: tip In a molecule with more than one unpaired electron, spin–orbit coupling and the dipolar interaction between the spins make some magnetization directions cheaper than others. This zero-field splitting is what makes single-molecule magnets possible. You compute it for triplet O$_2$: the spin–orbit part in second-order perturbation theory and by the force theorem, plus the spin–spin part. You check it against PySCF and experiment, and see how the answer depends on the spin–orbit operator and on the element. **Time:** about 2 s per run (8 cores). **Files:** {download}`o2_mae.yaml `, {download}`o2_mae.out ` (reference output), exercise inputs `files/o2_mae_nuclear.yaml`, `files/s2_mae.yaml`, `files/o2_mae_tilted.yaml`, {download}`run.sh `. ::: ## The spin Hamiltonian For a spin $S\ge1$ the lowest-order anisotropy is the zero-field-splitting Hamiltonian $$ \hat H_{\rm ZFS} = D\left[\hat S_z^2 - \tfrac13 S(S+1)\right] + E\left(\hat S_x^2-\hat S_y^2\right), \qquad 0\le E/D\le \tfrac13 . $$ - **$D>0$ (easy plane):** the magnetization prefers the plane perpendicular to the $z$ axis. - **$D<0$ (easy axis):** the magnetization prefers the $z$ axis itself, and the barrier $|D|S^2$ to reversing it is what a single-molecule magnet needs. $D$ has two sources: - **Spin–orbit coupling (SOC).** DFTSW27 evaluates it in second order over the Kohn–Sham orbitals (Pederson and Khanna, 1999). - **Direct dipolar spin–spin interaction (SS).** It is computed from the spin density. ## The input file ```yaml system: charge: 0 unpaired_electrons: 2 units: angstrom functional: exchange: pbe correlation: pbe basis: name: def2-TZVP file: basis/def2-TZVP.nw scf: conv_tol: 1.0e-10 analysis: magnetic_anisotropy: true anisotropy_method: both soc_potential: coulomb zfs_spin_spin: true atoms: - element: O position: [0.0, 0.0, -0.60375] - element: O position: [0.0, 0.0, 0.60375] ``` `unpaired_electrons: 2` : O$_2$ is a triplet ($^3\Sigma_g^-$, $S=1$). The SCF is collinear unrestricted. The anisotropy is evaluated afterwards, so it costs almost nothing. `analysis: magnetic_anisotropy: true` : The spin–orbit anisotropy tensor $\boldsymbol\gamma$, with $E_2(\mathbf n) = \mathbf n\cdot\boldsymbol\gamma\cdot\mathbf n + E_2^{\rm iso}$ for magnetization along $\mathbf n$, and from it $D_{\rm SOC}$ and $E_{\rm SOC}$. `anisotropy_method: both` : Also the force theorem: a one-shot two-component calculation with the full spin–orbit operator for six directions. It agrees with the perturbative result to second order. `soc_potential: coulomb` : The potential in $h_{\rm SO} = \frac{1}{4c^2}\boldsymbol\sigma\cdot(\nabla V\times\mathbf p)$. `coulomb` (nuclear plus Hartree, the default) includes the screening of the nucleus by the electrons; `nuclear` is the bare one-electron Breit–Pauli operator (exercise 1). `zfs_spin_spin: true` : The spin–spin term $D_{\rm SS}$, and the total $D=D_{\rm SOC}+D_{\rm SS}$. ## Running ```bash $ OMP_NUM_THREADS=8 ./run_dft tutorials/10_mae/files/o2_mae.yaml > o2_mae.out ``` ## Reading the output **Spin–spin.** ```text Zero-field splitting: spin-spin (direct dipolar) contribution D_SS = 1.892055 cm^-1 E_SS = 0.000000 cm^-1 D_SS z axis: 0.000000 0.000000 1.000000 ``` **Spin–orbit, second order.** ```text Magnetic anisotropy: 2nd-order spin-orbit (Pederson-Khanna) anisotropy tensor gamma (cm^-1), lab frame; E2(n) = n.gamma.n + E2_iso -0.00858031 0.00000000 0.00000000 0.00000000 -0.00858031 -0.00000000 0.00000000 -0.00000000 1.15125964 easy axis: 0.189173 -0.981944 -0.000000 hard-easy energy difference = 1.159840 cm^-1 ( 1.6688 K) ... D_total = D_SOC + D_SS tensor (cm^-1), lab frame: D = 3.051895 E = 0.000000 cm^-1 E/D = 0.00000 z axis: 0.00000 0.00000 1.00000 D = 1.159840 cm^-1 ( 1.6688 K) [D = 3/2 d_zz / S^2] ``` - **The $z$ axis is the hard axis.** Its tensor element is the largest, and it is the bond direction. - **Any direction in the $xy$ plane is easy.** The printed "easy axis" is one arbitrary choice within that plane. - $D_{\rm SOC} = 1.160$ cm$^{-1}$ and $D_{\rm total} = 3.05$ cm$^{-1}$, both positive: O$_2$ has an easy plane perpendicular to its bond. - $E=0$ by the cylindrical symmetry of a linear molecule. **Spin–orbit, force theorem.** ```text Magnetic anisotropy: force theorem (one-shot 2c, full SOC) direction n E_FT(n) (Ha) E2_PK(n) (Ha) .n || 1.0000 0.0000 0.0000 -1.11941394E-05 -1.11981479E-05 0.00300 0.00300 0.0000 0.0000 1.0000 -5.91833431E-06 -5.91352826E-06 0.00000 0.00000 ... D = 1.157905 cm^-1 E = 0.000000 cm^-1 ``` The two-component energies agree with the perturbative ones to about 0.1 %, and $D$ to 0.002 cm$^{-1}$. The induced orbital moment $\langle L\rangle$ is zero along the bond and small perpendicular to it. ```{figure} figures/mae_angle.png :width: 80% Spin–orbit anisotropy energy as the magnetization turns from the bond axis (0°) into the perpendicular plane (90°), from $\boldsymbol\gamma$ (`dftsw27plot.py mae o2_mae.out ...`). The minimum at 90° is the easy plane. The three curves are the main run and exercises 1 and 2. ``` ## How good are the numbers? - **Against PySCF.** An independent PySCF implementation of the same formula (the script in `examples/magnetic_anisotropy/`, run with PBE and def2-TZVP) gives $D_{\rm SOC}=1.159840$ cm$^{-1}$ with the screened potential and 1.966730 cm$^{-1}$ with the bare one. Both are identical to DFTSW27 to all printed digits. - **Against experiment.** The experimental $D$ of O$_2$ is 3.96 cm$^{-1}$. PBE gives $1.16 + 1.89 = 3.05$ cm$^{-1}$. Uncoupled second-order spin–orbit coupling with a semilocal functional is known to underestimate the SOC part. - **Sign conventions.** DFTSW27 uses the Pederson–Khanna convention (`zfs_soc_convention: pk`; `neese` and `vanwullen` are available). PySCF's `prop.zfs` reports the opposite sign. ## Things to try ### 1. The spin–orbit operator `files/o2_mae_nuclear.yaml`: `soc_potential: nuclear`. :::{dropdown} What you should find $D_{\rm SOC} = 1.967$ cm$^{-1}$, 1.7 times the screened value, and $D_{\rm total}=3.86$ cm$^{-1}$. That is closer to experiment, but for the wrong reason: the bare one-electron operator ignores the screening of the nucleus by the other electrons and overestimates spin–orbit coupling. The spin–spin part does not depend on this choice. ::: ### 2. A heavier element `files/s2_mae.yaml`: S$_2$, also a $^3\Sigma_g^-$ triplet. :::{dropdown} What you should find | | $D_{\rm SOC}$ | $D_{\rm SS}$ | $D$ (cm$^{-1}$) | |---|---|---|---| | O$_2$ | 1.16 | 1.89 | 3.05 | | S$_2$ | 11.08 | 0.37 | 11.45 | Spin–orbit coupling grows steeply with the nuclear charge, while the spin–spin term shrinks, because the spin density is more spread out. For S$_2$ spin–orbit dominates; for O$_2$ the two are comparable. ::: ### 3. The tensor follows the molecule `files/o2_mae_tilted.yaml` tilts the bond by 30° in the $xz$ plane. :::{dropdown} What you should find Same $D$ (1.159839 against 1.159840 cm$^{-1}$), with the tensor $z$ axis at (0.500, 0, 0.866), exactly along the tilted bond. The tensor is computed in the laboratory frame and diagonalized, so the orientation of the input does not matter. ::: ## Scope and troubleshooting - **Larger magnetic molecules.** Transition-metal complexes work the same way. `examples/sim_co_sph4/` is a 49-atom Co(II) single-ion magnet with the perturbative, force-theorem and self-consistent spin–orbit results compared. - **Not available.** Noncollinear runs, ECP atoms and SIC references are skipped with a message. - **Small gaps.** A warning is printed when an occupied–virtual gap is below $10^{-3}$ Ha, where second-order perturbation theory breaks down. Use the self-consistent spin–orbit SCF (`scf: spin_orbit`, tutorial 15) instead. **Next:** {doc}`../11_pdscf/index`.