Relativistic calculations with X2C

In this tutorial

Electrons near a heavy nucleus move fast enough that relativity matters for chemistry. You compute the hydrogen halides HF, HCl, HBr and HI three ways: nonrelativistic, with the spin-free (scalar) exact two-component Hamiltonian X2C, and with two-component X2C including spin–orbit coupling. You see the scalar correction grow roughly as \(Z^4\), and the spin–orbit splitting of the HOMO, which you compare with photoelectron spectra. Every number is checked against PySCF. Time: below 1.5 s per run; 12 runs in about 10 s (16 cores). Files: hbr_nr.yaml, hbr_sf.yaml, hbr_so.yaml, hbr_so.out (reference output), pyscf_hx.py (PySCF check), run.sh.

Why relativity

The 1s electrons of iodine (\(Z=53\)) move at about \(Z/c \approx 0.39\) of the speed of light. Two effects follow:

  • Scalar effects. The relativistic mass increase contracts and stabilizes the s and p shells. The d and f shells then see a better-screened nucleus and expand. The core energy changes by a large amount, roughly in proportion to \(Z^4\), and the valence shells change through the core.

  • Spin–orbit coupling. The orbital and spin angular momenta couple. A p shell splits into \(p_{1/2}\) and \(p_{3/2}\), and a molecular \(\pi\) level into \(\Omega = 1/2\) and \(\Omega = 3/2\).

The exact two-component (X2C) method decouples the electronic and positronic parts of the one-electron Dirac Hamiltonian exactly, in the basis set, and keeps the electronic part. DFTSW27 offers it in two flavours:

spin-free X2C

two-component X2C

input

relativity: method: x2c

plus scf: mode: noncollinear, spin_orbit: true

orbitals

real, collinear spin

complex two-component spinors

includes

scalar effects

scalar effects and spin–orbit coupling

cost

as nonrelativistic

about 2–3 times (a \(2n\times2n\) complex problem)

The input files

Three files differ only in a few lines. The two-component one:

system:
  charge: 0
  unpaired_electrons: 0
  units: angstrom

functional:
  backend: libxc
  exchange: GGA_X_PBE
  correlation: GGA_C_PBE

basis:
  name: 6-31G**
  file: basis/631Gss.nw

scf:
  mode: noncollinear       # two-component spinors
  spin_orbit: true
  max_iter: 200
  conv_tol: 1.0e-7

relativity:
  method: x2c

mesh:
  prune: none                # the pruned H mesh misses part of the halogen density

coulomb:
  method: eri

atoms:
  - element: H
    position: [0.0, 0.0, 0.0]
  - element: Br
    position: [0.0, 0.0, 1.4144]
    uncontract: true         # core functions free to contract relativistically

hbr_sf.yaml drops the two scf lines (mode, spin_orbit); hbr_nr.yaml also drops the relativity section.

relativity: method: x2c

The one-electron Hamiltonian \(T+V\) becomes the X2C one (point nucleus). This needs the libcint build (build_run_dft_libcint.sh).

scf: mode: noncollinear and spin_orbit: true

Two-component spinors. With x2c the decoupling is done in the spin-orbital basis, and the spin–orbit operator comes from the bare nucleus. The two-electron spin–orbit terms are not included, so the spin–orbit coupling of light elements is overestimated (see below).

functional: backend: libxc

The noncollinear SCF takes GGAs through libxc only.

uncontract: true on the halogen

A nonrelativistic contracted basis fixes the shape of the core orbitals. Relativity contracts them, so the core functions must be free. Exercise 1 shows what goes wrong otherwise.

mesh: prune: none

The default SCF grid is pruned: it uses fewer angular points close to and far from each nucleus. For the small hydrogen atom bonded to iodine, the pruned region holds a lot of iodine density. With pruning, HI integrates 54 electrons with an error of \(1.2\times10^{-4}\), and its energy is 0.13 mHa off. Without it the error is \(8\times10^{-6}\). The run prints a warning when the grid integrates the density with a relative error above \(10^{-6}\).

conv_tol: 1.0e-7

For heavy elements the SCF convergence floor is about \(10^{-7}\).

Running

$ ./build_run_dft_libcint.sh           # once: run_dft with libcint
$ tutorials/14_x2c/run.sh ./run_dft    # 12 runs and the figure

run.sh makes the HF, HCl and HI inputs from the HBr files by changing the element and the bond length (experimental: 0.917, 1.2746, 1.4144 and 1.6092 Å).

Reading the output

The two-component run announces the Hamiltonian, then iterates with complex DIIS:

  two-component X2C1e one-electron Hamiltonian (c =   137.036000)
  non-collinear SCF: backend=libxc, exchange=GGA_X_PBE, correlation=GGA_C_PBE, GGA=T
  two-component one-electron operator (spin-orbit included)
  complex DIIS on (8 vectors)
 ...
   e_spin_orbit (Ha) =      -0.2471772137
   spinor orbital energies around HOMO-LUMO (n_electrons_total = 36):
       #   31  HOMO-5   =      -0.4104396667 Ha   -11.16863 eV   occ= 1.0000
       #   32  HOMO-4   =      -0.4104396667 Ha   -11.16863 eV   occ= 1.0000
       #   33  HOMO-3   =      -0.2757421268 Ha    -7.50333 eV   occ= 1.0000
       #   34  HOMO-2   =      -0.2757421268 Ha    -7.50333 eV   occ= 1.0000
       #   35  HOMO-1   =      -0.2635661332 Ha    -7.17200 eV   occ= 1.0000
       #   36  HOMO     =      -0.2635661332 Ha    -7.17200 eV   occ= 1.0000
       #   37  LUMO     =      -0.0437210483 Ha    -1.18971 eV   occ= 0.0000
 ...
  TOTAL ENERGY =     -2606.5649787355 Ha
  • Every spinor level is doubly degenerate. These are Kramers pairs: for a closed shell, time-reversal symmetry pairs each spinor with a partner of the same energy.

  • The \(\pi\) lone pair is split. In the spin-free run, the HOMO is a fourfold-degenerate \(\pi\) level at \(-7.337\) eV (two orbitals, two spins). With spin–orbit coupling it splits into \(\pi_{3/2}\) (HOMO, \(-7.172\) eV) and \(\pi_{1/2}\) (\(-7.503\) eV), 0.331 eV apart.

  • e_spin_orbit is \(\mathrm{Re\,tr}(h_{\rm SO}P)\), the expectation value of the spin–orbit part of the one-electron operator. It is not the energy lowering: that is the total-energy difference to the spin-free run, \(-0.0853\) Ha.

The four halides

../../_images/hx_relativity.png

Fig. 36 Left: energy lowering by the scalar relativistic correction and by spin–orbit coupling, against the halogen’s atomic number. Right: the HOMO \(\pi\) level without relativity, with scalar relativity, and split by spin–orbit coupling.

\(E_{\rm nr}\) (Ha)

\(E_{\rm sf}-E_{\rm nr}\) (Ha)

\(E_{\rm 2c}-E_{\rm sf}\) (Ha)

\(\pi\) splitting (eV)

expt. (eV)

HF

\(-100.37181\)

\(-0.0884\)

\(-0.00001\)

0.047

≈ 0.04

HCl

\(-460.62987\)

\(-1.424\)

\(-0.0008\)

0.088

≈ 0.08

HBr

\(-2574.35647\)

\(-32.12\)

\(-0.085\)

0.331

≈ 0.33

HI

\(-6920.00814\)

\(-193.98\)

\(-1.123\)

0.635

0.63

  • The scalar correction grows steeply with \(Z\): from 0.09 Ha for HF to 194 Ha for HI. A fit gives \(Z^{4.3}\), close to the \(Z^4\) of hydrogen-like ions. Almost all of it comes from the 1s and 2s shells of the halogen. Bond energies change far less, but for iodine they change too.

  • The spin–orbit energy grows even faster and reaches 1.1 Ha for HI.

  • Scalar relativity barely moves the \(\pi\) level. It moves up by 0.01 eV (HF) to 0.07 eV (HI), because the contracted core screens the nucleus better. Spin–orbit coupling dominates the valence region.

How good is it?

Against PySCF. files/pyscf_hx.py runs the same calculations: RKS, sfx2c1e and GKS x2c1e, the same Cartesian basis with the halogen uncontracted. All twelve total energies agree within 6 µHa, and the spinor energies within \(10^{-5}\) eV. PySCF 2.x removes overlap eigenvalues below \(10^{-6}\) by default. The uncontracted iodine basis has one at \(1.8\times10^{-7}\), so the script switches this off (pyscf.scf.hf.remove_overlap_zero_eigenvalue = False). Otherwise PySCF’s HI energy is up to 0.2 mHa higher (5 mHa for the contracted basis).

Against experiment. Photoelectron spectra show the \(\Omega=3/2\) and \(1/2\) components of the first ionization: 10.42 and 11.05 eV for HI (Frost, McDowell et al. 1967), a splitting of 0.63 eV. For HBr, HCl and HF the splittings are about 0.33, 0.08 and 0.04 eV. The orbital-energy splitting of the neutral molecule is a good estimate of the splitting of the ion. For HBr and HI it agrees within 0.01 eV. For HCl and HF it is 10% and 30% too large, because the two-electron terms that screen the nuclear spin–orbit field are missing. Their relative weight is largest for light atoms.

Things to try

1. A contracted basis

run.sh --exercises repeats HI with the iodine basis contracted (no uncontract).

What you should find

HI

uncontracted

contracted

\(E_{\rm sf}-E_{\rm nr}\) (Ha)

\(-193.98\)

\(-160.70\)

\(E_{\rm 2c}-E_{\rm sf}\) (Ha)

\(-1.123\)

\(+0.069\)

\(\pi\) splitting (eV)

0.635

0.591

The contracted core functions have the nonrelativistic shape and cannot contract. A sixth of the scalar correction is lost, and the spin–orbit energy even comes out positive: a \(p_{1/2}\) spinor needs a tighter radial function than a contracted nonrelativistic p function can give. Use uncontracted or relativistically contracted bases (e.g. the x2c- or DKH-contracted families) for heavy atoms.

2. ZORA

relativity: method: zora with scaled: true is the zeroth-order regular approximation.

What you should find

For HI, unscaled ZORA gives \(-7223.66\) Ha, 110 Ha below spin-free X2C (\(-7113.99\)). Unscaled ZORA total energies overshoot, and they depend on the potential used to build the operator. Scaled ZORA (\(E_{\rm sc}=-7115.54\) Ha) is within 1.6 Ha of X2C. That is still a large error for total energies, though it largely cancels in energy differences. X2C is exact for the one-electron problem in the given basis, so prefer it when the libcint build is available.

3. Check against PySCF

$ python3 tutorials/14_x2c/files/pyscf_hx.py F Cl Br I
What you should find

For each molecule PySCF prints the three energies and the four highest occupied orbital energies (eV). For example, HI 2c: \(E=-7115.10986\), with \(\pi_{1/2}\) at \(-7.05881\) and \(\pi_{3/2}\) at \(-6.42357\) eV, the same as DFTSW27.

Troubleshooting

  • relativity=x2c needs libcint. Build with build_run_dft_libcint.sh.

  • noncollinear XC: in-house functionals are LDA only. Use functional: backend: libxc for GGAs in two-component runs.

  • Energies only. Forces need gradient: method: numerical. X2C is all-electron (ECPs are refused). The g-tensor and NMR analyses need a nonrelativistic reference.

  • WARNING: the SCF grid integrates the density with relative error … For a light atom next to a heavy one, set mesh: prune: none.

Next: Noncollinear magnetism: a frustrated triangle.