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.
First we setup BCC iron without spin polarization using a single iron atom inside the unit cell.
using DFTK
a = 5.42352 # Bohr
lattice = a / 2 * [[-1 1 1];
[ 1 -1 1];
[ 1 1 -1]]
atoms = [ElementPsp(:Fe, load_psp("hgh/lda/Fe-q8.hgh"))]
positions = [zeros(3)];
To get the ground-state energy we use an LDA model and rather moderate discretisation parameters.
kgrid = [3, 3, 3] # k-point grid (Regular Monkhorst-Pack grid)
Ecut = 15 # kinetic energy cutoff in Hartree
model_nospin = model_DFT(lattice, atoms, positions; 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.65007675686 -0.48 5.2 108ms
2 -16.65071112646 -3.20 -1.01 1.0 186ms
3 -16.65081052303 -4.00 -2.32 1.8 15.3ms
4 -16.65082409485 -4.87 -2.83 2.2 18.1ms
5 -16.65082459166 -6.30 -3.27 1.2 14.4ms
6 -16.65082467695 -7.07 -3.76 1.5 15.5ms
7 -16.65082469709 -7.70 -4.26 2.0 17.5ms
scfres_nospin.energies
Energy breakdown (in Ha):
Kinetic 15.9208786
AtomicLocal -5.0693434
AtomicNonlocal -5.2202493
Ewald -21.4723040
PspCorrection 1.8758831
Hartree 0.7793502
Xc -3.4467520
Entropy -0.0182879
total -16.650824697092
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];
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(lattice, atoms, positions; functionals=LDA(),
magnetic_moments, temperature=0.01)
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.66168543820 -0.51 2.618 5.0 54.8ms
2 -16.66825372683 -2.18 -1.09 2.445 1.5 31.7ms
3 -16.66905010624 -3.10 -2.07 2.341 2.0 34.9ms
4 -16.66909873407 -4.31 -2.68 2.304 1.5 73.3ms
5 -16.66910297709 -5.37 -3.01 2.296 1.8 32.5ms
6 -16.66910414445 -5.93 -3.47 2.286 1.9 33.5ms
7 -16.66910416920 -7.61 -3.77 2.286 1.8 32.4ms
8 -16.66910417370 -8.35 -4.29 2.285 1.5 31.1ms
9 -16.66910417503 -8.88 -4.91 2.286 1.5 31.3ms
10 -16.66910417505 -10.69 -5.18 2.286 1.5 31.2ms
11 -16.66910417509 -10.44 -5.65 2.286 1.4 52.6ms
12 -16.66910417508 + -11.51 -6.31 2.286 1.8 34.1ms
scfres.energies
Energy breakdown (in Ha):
Kinetic 16.2947177
AtomicLocal -5.2227252
AtomicNonlocal -5.4100272
Ewald -21.4723040
PspCorrection 1.8758831
Hartree 0.8191959
Xc -3.5406833
Entropy -0.0131612
total -16.669104175082
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.65082469709217
Magnetic case: -16.669104175082072
Difference: -0.01827947798990337
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.9999987814402859, 0.9999987814402859, 0.9999987814402859, 0.9582252633609609, 0.9582252633609524, 1.1266437566773338e-29]
(scfres.occupation[idown])[1:7] = [1.0, 0.8438946529300559, 0.8438946529304134, 0.8438946529303009, 8.140959801577863e-6, 8.1409598015775e-6, 1.5791971363970304e-32]
Similarly the eigenvalues differ
@show scfres.eigenvalues[iup][1:7]
@show scfres.eigenvalues[idown][1:7];
(scfres.eigenvalues[iup])[1:7] = [-0.06935855112749573, 0.35688569322336533, 0.3568856932233658, 0.35688569322338437, 0.4617361794319932, 0.4617361794319953, 1.1596213367306465]
(scfres.eigenvalues[idown])[1:7] = [-0.031257475680584776, 0.47618912475611486, 0.4761891247560877, 0.47618912475609626, 0.6102500339471352, 0.6102500339471356, 1.2253221546198645]
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)
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)