Collinear spin and magnetic systems

In this example we consider iron in the BCC phase. To show that this material is ferromagnetic we will model it once allowing collinear spin polarization and once without and compare the resulting SCF energies. In particular the ground state can only be found if collinear spins are allowed.

The bulk(:Fe) function from AtomsBuilder returns a BCC iron setup with a single iron atom inside the unit cell.

using AtomsBuilder
using PseudoPotentialData
using DFTK

bulk(:Fe)
FlexibleSystem(Fe, periodicity = TTT):
    cell_vectors      : [  -1.435    1.435    1.435;
                            1.435   -1.435    1.435;
                            1.435    1.435   -1.435]u"Å"

    Atom(Fe, [       0,        0,        0]u"Å")

First we consider a setup without spin polarization. To get the ground-state energy of this system we use an LDA model and rather moderate discretisation parameters.

Ecut  = 15         # kinetic energy cutoff in Hartree
kgrid = [3, 3, 3]  # k-point grid (Regular Monkhorst-Pack grid)
pseudopotentials = PseudoFamily("cp2k.nc.sr.lda.v0_1.largecore.gth")

model_nospin  = model_DFT(bulk(:Fe); pseudopotentials, functionals=LDA(), temperature=0.01)
basis_nospin  = PlaneWaveBasis(model_nospin; kgrid, Ecut)
scfres_nospin = self_consistent_field(basis_nospin; tol=1e-4, mixing=KerkerDosMixing());
n     Energy            log10(ΔE)   log10(Δρ)   Diag   Δtime
---   ---------------   ---------   ---------   ----   ------
  1   -16.64988378810                   -0.48    6.0    106ms
  2   -16.65068213392       -3.10       -1.02    1.0    180ms
  3   -16.65081854017       -3.87       -2.30    1.8   16.0ms
  4   -16.65083397857       -4.81       -2.84    2.0   17.0ms
  5   -16.65083457467       -6.22       -3.40    1.5   14.9ms
  6   -16.65083463341       -7.23       -3.95    2.0   16.8ms
  7   -16.65083463713       -8.43       -4.33    1.5   15.6ms
scfres_nospin.energies
Energy breakdown (in Ha):
    Kinetic             15.9209327
    AtomicLocal         -5.0693507
    AtomicNonlocal      -5.2202869
    Ewald               -21.4723279
    PspCorrection       1.8758893 
    Hartree             0.7793525 
    Xc                  -3.4467559
    Entropy             -0.0182879

    total               -16.650834637135

Since we did not specify any initial magnetic moment on the iron atom, DFTK will automatically assume that a calculation with only spin-paired electrons should be performed. As a result the obtained ground state features no spin-polarization.

Now we repeat the calculation, but give the iron atom an initial magnetic moment. For specifying the magnetic moment pass the desired excess of spin-up over spin-down electrons at each centre to the Model and the guess density functions. In this case we seek the state with as many spin-parallel $d$-electrons as possible. In our pseudopotential model the 8 valence electrons are 1 pair of $s$-electrons, 1 pair of $d$-electrons and 4 unpaired $d$-electrons giving a desired magnetic moment of 4 at the iron centre. The structure (i.e. pair mapping and order) of the magnetic_moments array needs to agree with the atoms array and 0 magnetic moments need to be specified as well.

magnetic_moments = [4];
Units of the magnetisation and magnetic moments in DFTK

Unlike all other quantities magnetisation and magnetic moments in DFTK are given in units of the Bohr magneton $μ_B$, which in atomic units has the value $\frac{1}{2}$. Since $μ_B$ is (roughly) the magnetic moment of a single electron the advantage is that one can directly think of these quantities as the excess of spin-up electrons or spin-up electron density.

We repeat the calculation using the same model as before. DFTK now detects the non-zero moment and switches to a collinear calculation.

model = model_DFT(bulk(:Fe); pseudopotentials, functionals=LDA(),
                  temperature=0.01, magnetic_moments)
basis = PlaneWaveBasis(model; Ecut, kgrid)
ρ0 = guess_density(basis, magnetic_moments)
scfres = self_consistent_field(basis, tol=1e-6; ρ=ρ0, mixing=KerkerDosMixing());
n     Energy            log10(ΔE)   log10(Δρ)   Magnet   Diag   Δtime
---   ---------------   ---------   ---------   ------   ----   ------
  1   -16.66151388527                   -0.51    2.617    5.8   52.2ms
  2   -16.66821219554       -2.17       -1.10    2.443    1.5   55.8ms
  3   -16.66906348432       -3.07       -2.08    2.340    2.1   34.7ms
  4   -16.66910894160       -4.34       -2.60    2.305    1.5   29.6ms
  5   -16.66911251003       -5.45       -2.88    2.297    1.6   30.1ms
  6   -16.66911415388       -5.78       -3.52    2.287    1.6   37.9ms
  7   -16.66911419752       -7.36       -3.88    2.285    2.0   43.4ms
  8   -16.66911420251       -8.30       -4.30    2.286    1.4   29.8ms
  9   -16.66911420355       -8.98       -5.01    2.286    1.8   32.4ms
 10   -16.66911420358      -10.60       -5.41    2.286    2.0   51.8ms
 11   -16.66911420358      -11.30       -5.88    2.286    1.0   27.5ms
 12   -16.66911420358   +  -11.42       -6.25    2.286    1.9   33.6ms
scfres.energies
Energy breakdown (in Ha):
    Kinetic             16.2947694
    AtomicLocal         -5.2227286
    AtomicNonlocal      -5.4100653
    Ewald               -21.4723279
    PspCorrection       1.8758893 
    Hartree             0.8191976 
    Xc                  -3.5406876
    Entropy             -0.0131612

    total               -16.669114203578
Model and magnetic moments

DFTK does not store the magnetic_moments inside the Model, but only uses them to determine the lattice symmetries. This step was taken to keep Model (which contains the physical model) independent of the details of the numerical details such as the initial guess for the spin density.

In direct comparison we notice the first, spin-paired calculation to be a little higher in energy

println("No magnetization: ", scfres_nospin.energies.total)
println("Magnetic case:    ", scfres.energies.total)
println("Difference:       ", scfres.energies.total - scfres_nospin.energies.total);
No magnetization: -16.6508346371347
Magnetic case:    -16.669114203577564
Difference:       -0.01827956644286388

Notice that with the small cutoffs we use to generate the online documentation the calculation is far from converged. With more realistic parameters a larger energy difference of about 0.1 Hartree is obtained.

The spin polarization in the magnetic case is visible if we consider the occupation of the spin-up and spin-down Kohn-Sham orbitals. Especially for the $d$-orbitals these differ rather drastically. For example for the first $k$-point:

iup   = 1
idown = iup + length(scfres.basis.kpoints) ÷ 2
@show scfres.occupation[iup][1:7]
@show scfres.occupation[idown][1:7];
(scfres.occupation[iup])[1:7] = [1.0, 0.9999987814917173, 0.9999987814917173, 0.9999987814917173, 0.9582260340852072, 0.958226034085207, 1.1262937411619377e-29]
(scfres.occupation[idown])[1:7] = [1.0, 0.8438932589725868, 0.8438932589724303, 0.843893258972513, 8.14065081876577e-6, 8.140650818762878e-6, 1.6185727550219243e-32]

Similarly the eigenvalues differ

@show scfres.eigenvalues[iup][1:7]
@show scfres.eigenvalues[idown][1:7];
(scfres.eigenvalues[iup])[1:7] = [-0.06935782700514458, 0.35688632608509, 0.35688632608508297, 0.35688632608508447, 0.4617370418293072, 0.46173704182930725, 1.1596254988606451]
(scfres.eigenvalues[idown])[1:7] = [-0.03125672245907143, 0.47619028550737885, 0.47619028550739073, 0.47619028550738446, 0.6102514684359969, 0.6102514684360004, 1.2250769278660898]
``k``-points in collinear calculations

For collinear calculations the kpoints field of the PlaneWaveBasis object contains each $k$-point coordinate twice, once associated with spin-up and once with down-down. The list first contains all spin-up $k$-points and then all spin-down $k$-points, such that iup and idown index the same $k$-point, but differing spins.

We can observe the spin-polarization by looking at the density of states (DOS) around the Fermi level, where the spin-up and spin-down DOS differ.

using Plots
bands_666 = compute_bands(scfres, MonkhorstPack(6, 6, 6))  # Increase kgrid to get nicer DOS.
plot_dos(bands_666)
Example block output

Note that if same k-grid as SCF should be employed, a simple plot_dos(scfres) is sufficient.

Similarly the band structure shows clear differences between both spin components.

using Unitful
using UnitfulAtomic
bands_kpath = compute_bands(scfres; kline_density=6)
plot_bandstructure(bands_kpath)
Example block output