Temperature and metallic systems

In this example we consider the modeling of a magnesium lattice as a simple example for a metallic system. For our treatment we will use the PBE exchange-correlation functional. First we import required packages and setup the lattice. Again notice that DFTK uses the convention that lattice vectors are specified column by column.

using DFTK
using Plots
using Unitful
using UnitfulAtomic

a = 3.01794  # bohr
b = 5.22722  # bohr
c = 9.77362  # bohr
lattice = [[-a -a  0]; [-b  b  0]; [0   0 -c]]
Mg = ElementPsp(:Mg, psp=load_psp("hgh/pbe/Mg-q2"))
atoms = [Mg => [[2/3, 1/3, 1/4], [1/3, 2/3, 3/4]]];

Next we build the PBE model and discretize it. Since magnesium is a metal we apply a small smearing temperature to ease convergence using the Fermi-Dirac smearing scheme. Note that both the Ecut is too small as well as the minimal $k$-point spacing kspacing far too large to give a converged result. These have been selected to obtain a fast execution time. By default PlaneWaveBasis chooses a kspacing of 2π * 0.022 inverse Bohrs, which is much more reasonable.

kspacing = 0.945 / u"angstrom"  # Minimal spacing of k-points,
#                                in units of wavevectors (inverse Bohrs)
Ecut = 5                        # kinetic energy cutoff in Hartree
temperature = 0.01              # Smearing temperature in Hartree

model = model_DFT(lattice, atoms, [:gga_x_pbe, :gga_c_pbe];
                  temperature=temperature,
                  smearing=DFTK.Smearing.FermiDirac())
kgrid = kgrid_from_minimal_spacing(lattice, kspacing)
basis = PlaneWaveBasis(model; Ecut, kgrid);

Finally we run the SCF. Two magnesium atoms in our pseudopotential model result in four valence electrons being explicitly treated. Nevertheless this SCF will solve for eight bands by default in order to capture partial occupations beyond the Fermi level due to the employed smearing scheme. In this example we use a damping of 0.8. The default LdosMixing should be suitable to converge metallic systems like the one we model here. For the sake of demonstration we still switch to Kerker mixing here.

scfres = self_consistent_field(basis, damping=0.8, mixing=KerkerMixing());
n     Free energy       Eₙ-Eₙ₋₁     ρout-ρin   α      Diag
---   ---------------   ---------   --------   ----   ----
  1   -1.761871589003         NaN   5.05e-02   0.80    4.3
  2   -1.762134180686   -2.63e-04   1.90e-02   0.80    1.0
  3   -1.762238826548   -1.05e-04   1.57e-03   0.80    4.0
  4   -1.762241597618   -2.77e-06   3.06e-04   0.80    2.7
  5   -1.762241619914   -2.23e-08   1.45e-05   0.80    2.7
scfres.occupation[1]
9-element Vector{Float64}:
 1.9999999999077938
 1.999997586274769
 0.004016880864924321
 3.000394444974501e-15
 1.1116033430590044e-18
 1.1115490087554245e-18
 7.978592750058253e-19
 7.977887718092079e-19
 3.3591851352821462e-22
scfres.energies
Energy breakdown (in Ha):
    Kinetic             0.7180601 
    AtomicLocal         0.3145390 
    AtomicNonlocal      0.3265800 
    Ewald               -2.1544222
    PspCorrection       -0.1026056
    Hartree             0.0055003 
    Xc                  -0.8610486
    Entropy             -0.0088446

    total               -1.762241619914

The fact that magnesium is a metal is confirmed by plotting the density of states around the Fermi level.

plot_dos(scfres)