# Isotropic and anisotropic hyperfine coupling paramters¶

## Python API and CLI¶

Use the hyperfine_parameters() function or the CLI tool:

\$ python3 -m gpaw.hyperfine <gpw-file>

gpaw.hyperfine.hyperfine_parameters(calc: gpaw.calculator.GPAW, exclude_core=False) [source]

Calculate isotropic and anisotropic hyperfine coupling paramters.

One tensor ($$A_{ij}$$) per atom is returned in eV units. In Hartree atomic units, we have the isotropic part $$a = \text{Tr}(\mathbf{A}) / 3$$:

$a = \frac{2 \alpha^2 g_e m_e}{3 m_p} \int \delta_T(\mathbf{r}) \rho_s(\mathbf{r}) d\mathbf{r},$

and the anisotropic part $$\mathbf{A} - a$$:

$\frac{\alpha^2 g_e m_e}{4 \pi m_p} \int \frac{3 r_i r_j - \delta_{ij} r^2}{r^5} \rho_s(\mathbf{r}) d\mathbf{r}.$

Remember to multiply each tensor by the g-factors of the nuclei and divide by the total electron spin.

Use exclude_core=True to exclude contribution from “frozen” core.

For details, see Peter E. Blöchl and Oleg V. Yazyev et al..

## G-factors¶

Here is a list of g-factors (from Wikipedia):

 Nucleus g-factor $$^{1}$$H 5.586 $$^{3}$$He -4.255 $$^{7}$$Li 2.171 $$^{13}$$C 1.405 $$^{14}$$N 0.404 $$^{17}$$O -0.757 $$^{19}$$F 5.254 $$^{23}$$Na 1.477 $$^{27}$$Al 1.457 $$^{29}$$Si -1.111 $$^{31}$$P 2.261 $$^{57}$$Fe 0.181 $$^{63}$$Cu 1.485 $$^{67}$$Zn 0.350 $$^{129}$$Xe -1.545

## Hydrogen 21 cm line¶

Here is how to calculate the famous hydrogen spectral line of 21 cm:

import numpy as np
from ase import Atoms
import ase.units as units
from gpaw import GPAW, PW
from gpaw.hyperfine import hyperfine_parameters

h = Atoms('H', magmoms=[1])
h.center(vacuum=3)
h.calc = GPAW(mode=PW(400), txt=None)
e = h.get_potential_energy()
A = hyperfine_parameters(h.calc)[0] * 5.586
a = np.trace(A) / 3
frequency = a * units._e / units._hplanck  # Hz
wavelength = units._c / frequency  # meters
print(f'{wavelength * 100:.1f} cm')


The output will be 23.2 cm. It’s slightly off because the LDA spin-density at the position of the hydrogen nucleus is a bit too low (should be $$1/\pi$$ in atomic units).