Creating and modelling metallic supercells

In this section we will be concerned with modelling supercells of aluminium. When dealing with periodic problems there is no unique definition of the lattice: Clearly any duplication of the lattice along an axis is also a valid repetitive unit to describe exactly the same system. This is exactly what a supercell is: An $n$-fold repetition along one of the axes of the original lattice.

The following code achieves this for aluminium:

using DFTK
using LinearAlgebra

function aluminium_setup(repeat=1; Ecut=7.0, kgrid=[2, 2, 2])
    a = 7.65339
    lattice = a * Matrix(I, 3, 3)
    Al = ElementPsp(:Al, psp=load_psp("hgh/lda/al-q3"))
    atoms     = [Al, Al, Al, Al]
    positions = [[0.0, 0.0, 0.0], [0.0, 0.5, 0.5], [0.5, 0.0, 0.5], [0.5, 0.5, 0.0]]

    # Make supercell in ASE:
    # We convert our lattice to the conventions used in ASE
    # and then back ...
    supercell = ase_atoms(lattice, atoms, positions) * (repeat, 1, 1)
    lattice   = load_lattice(supercell)
    positions = load_positions(supercell)
    atoms = fill(Al, length(positions))

    # Construct an LDA model and discretise
    # Note: We disable symmetries explicitly here. Otherwise the problem sizes
    #       we are able to run on the CI are too simple to observe the numerical
    #       instabilities we want to trigger here.
    model = model_LDA(lattice, atoms, positions; temperature=1e-3, symmetries=false)
    PlaneWaveBasis(model; Ecut, kgrid)
end;

As part of the code we are using a routine inside the ASE, the atomistic simulation environment for creating the supercell and make use of the two-way interoperability of DFTK and ASE. For more details on this aspect see the documentation on Input and output formats.

Write an example supercell structure to a file to plot it:

setup = aluminium_setup(5)
ase_atoms(setup.model).write("al_supercell.png")

As we will see in this notebook the modelling of a system generally becomes harder if the system becomes larger.

  • This sounds like a trivial statement as per se the cost per SCF step increases as the system (and thus $N$) gets larger.
  • But there is more to it: If one is not careful also the number of SCF iterations increases as the system gets larger.
  • The aim of a proper computational treatment of such supercells is therefore to ensure that the number of SCF iterations remains constant when the system size increases.

For achieving the latter DFTK by default employs the LdosMixing preconditioner [HL2021] during the SCF iterations. This mixing approach is completely parameter free, but still automatically adapts to the treated system in order to efficiently prevent charge sloshing. As a result, modelling aluminium slabs indeed takes roughly the same number of SCF iterations irrespective of the supercell size:

M. F. Herbst and A. Levitt. Black-box inhomogeneous preconditioning for self-consistent field iterations in density functional theory. J. Phys. Cond. Matt 33 085503 (2021). ArXiv:2009.01665

is_converged = DFTK.ScfConvergenceDensity(1e-4)  # Flag convergence based on density
self_consistent_field(aluminium_setup(1); is_converged);
n     Energy            log10(ΔE)   log10(Δρ)   Diag
---   ---------------   ---------   ---------   ----
  1   -8.298435373218                   -0.85    5.4
  2   -8.300213544853       -2.75       -1.25    1.0
  3   -8.300449447081       -3.63       -1.89    3.0
  4   -8.300462766768       -4.88       -2.78    1.0
  5   -8.300464488352       -5.76       -3.12    4.2
  6   -8.300464564246       -7.12       -3.29    2.0
  7   -8.300464602188       -7.42       -3.43    1.0
  8   -8.300464623937       -7.66       -3.57    1.1
  9   -8.300464637557       -7.87       -3.73    1.0
 10   -8.300464641507       -8.40       -3.89    3.0
 11   -8.300464643805       -8.64       -4.26    1.0
self_consistent_field(aluminium_setup(2); is_converged);
n     Energy            log10(ΔE)   log10(Δρ)   Diag
---   ---------------   ---------   ---------   ----
  1   -16.64197953790                   -0.70    5.9
  2   -16.67835894790       -1.44       -1.14    1.4
  3   -16.67924080504       -3.05       -1.88    3.6
  4   -16.67928354583       -4.37       -2.77    3.8
  5   -16.67928616702       -5.58       -3.16    4.6
  6   -16.67928621423       -7.33       -3.54    1.8
  7   -16.67928622219       -8.10       -4.05    1.1
self_consistent_field(aluminium_setup(4); is_converged);
n     Energy            log10(ΔE)   log10(Δρ)   Diag
---   ---------------   ---------   ---------   ----
  1   -33.32549925064                   -0.56    6.5
  2   -33.33258345176       -2.15       -1.00    1.0
  3   -33.33413834248       -2.81       -1.74    5.0
  4   -33.33497923548       -3.08       -2.39    4.2
  5   -33.33690804082       -2.71       -2.50   12.2
  6   -33.33693306825       -4.60       -2.74    4.4
  7   -33.33694382437       -4.97       -3.64    2.2
  8   -33.33694388978       -7.18       -3.93    4.9
  9   -33.33694392564       -7.45       -4.52    1.8

When switching off explicitly the LdosMixing, by selecting mixing=SimpleMixing(), the performance of number of required SCF steps starts to increase as we increase the size of the modelled problem:

self_consistent_field(aluminium_setup(1); is_converged, mixing=SimpleMixing());
n     Energy            log10(ΔE)   log10(Δρ)   Diag
---   ---------------   ---------   ---------   ----
  1   -8.298573221858                   -0.85    5.1
  2   -8.300282347251       -2.77       -1.59    1.0
  3   -8.300462940495       -3.74       -2.71    4.8
  4   -8.300459372184   +   -5.45       -2.89    4.8
  5   -8.300464431088       -5.30       -3.57    1.4
  6   -8.300464634844       -6.69       -4.32    1.4
self_consistent_field(aluminium_setup(4); is_converged, mixing=SimpleMixing());
n     Energy            log10(ΔE)   log10(Δρ)   Diag
---   ---------------   ---------   ---------   ----
  1   -33.32715398783                   -0.56    6.6
  2   -33.33172523922       -2.34       -1.28    1.2
  3   -28.63975269828   +    0.67       -0.73    7.5
  4   -33.05758596493        0.65       -1.32    5.5
  5   -33.28206133805       -0.65       -1.37    3.9
  6   -33.20592861978   +   -1.12       -1.50    4.2
  7   -33.17518339152   +   -1.51       -1.45    4.9
  8   -33.33334444460       -0.80       -2.23    4.2
  9   -33.33462635566       -2.89       -2.32    2.6
 10   -33.33538664353       -3.12       -2.38    1.6
 11   -33.33592504105       -3.27       -2.50    1.5
 12   -33.33681580743       -3.05       -2.88    2.6
 13   -33.33691641034       -4.00       -3.17    3.5
 14   -33.33694230168       -4.59       -3.56    3.4
 15   -33.33694307210       -6.11       -3.96    3.1
 16   -33.33694377237       -6.15       -4.36    1.8

For completion let us note that the more traditional mixing=KerkerMixing() approach would also help in this particular setting to obtain a constant number of SCF iterations for an increasing system size (try it!). In contrast to LdosMixing, however, KerkerMixing is only suitable to model bulk metallic system (like the case we are considering here). When modelling metallic surfaces or mixtures of metals and insulators, KerkerMixing fails, while LdosMixing still works well. See the Modelling a gallium arsenide surface example or [HL2021] for details. Due to the general applicability of LdosMixing this method is the default mixing approach in DFTK.