Modelling a gallium arsenide surface

This example shows how to use the atomistic simulation environment or ASE for short, to set up and run a particular calculation of a gallium arsenide surface. ASE is a Python package to simplify the process of setting up, running and analysing results from atomistic simulations across different simulation codes. For more details on the integration DFTK provides with ASE, see Atomistic simulation environment (ASE).

In this example we will consider modelling the (1, 1, 0) GaAs surface separated by vacuum.

Parameters of the calculation. Since this surface is far from easy to converge, we made the problem simpler by choosing a smaller Ecut and smaller values for n_GaAs and n_vacuum. More interesting settings are Ecut = 15 and n_GaAs = n_vacuum = 20.

miller = (1, 1, 0)   # Surface Miller indices
n_GaAs = 2           # Number of GaAs layers
n_vacuum = 4         # Number of vacuum layers
Ecut = 5             # Hartree
kgrid = (4, 4, 1);   # Monkhorst-Pack mesh

Use ASE to build the structure:

using ASEconvert
using PythonCall

a = 5.6537  # GaAs lattice parameter in Ångström (because ASE uses Å as length unit)
gaas = ase.build.bulk("GaAs", "zincblende"; a)
surface = ase.build.surface(gaas, miller, n_GaAs, 0, periodic=true);
    CondaPkg Found dependencies: /home/runner/.julia/packages/ASEconvert/pAQve/CondaPkg.toml
    CondaPkg Found dependencies: /home/runner/.julia/packages/CondaPkg/0UqYV/CondaPkg.toml
    CondaPkg Found dependencies: /home/runner/.julia/packages/PythonCall/83z4q/CondaPkg.toml
    CondaPkg Resolving changes
             + ase
             + libstdcxx
             + libstdcxx-ng
             + openssl
             + python
    CondaPkg Initialising pixi
             │ /home/runner/.julia/artifacts/cefba4912c2b400756d043a2563ef77a0088866b/bin/pixi
             │ init
             │ --format pixi
             └ /home/runner/work/DFTK.jl/DFTK.jl/docs/.CondaPkg
✔ Created /home/runner/work/DFTK.jl/DFTK.jl/docs/.CondaPkg/pixi.toml
    CondaPkg Wrote /home/runner/work/DFTK.jl/DFTK.jl/docs/.CondaPkg/pixi.toml
             │ [dependencies]
             │ openssl = ">=3, <3.6"
             │ libstdcxx = ">=3.4,<15.0"
             │ libstdcxx-ng = ">=3.4,<15.0"
             │ ase = ">=3.26,<3.27"
             │ 
             │     [dependencies.python]
             │     channel = "conda-forge"
             │     build = "*cp*"
             │     version = ">=3.10,!=3.14.0,!=3.14.1,<4"
             │ 
             │ [project]
             │ name = ".CondaPkg"
             │ platforms = ["linux-64"]
             │ channels = ["conda-forge"]
             │ channel-priority = "strict"
             └ description = "automatically generated by CondaPkg.jl"
    CondaPkg Installing packages
             │ /home/runner/.julia/artifacts/cefba4912c2b400756d043a2563ef77a0088866b/bin/pixi
             │ install
             └ --manifest-path /home/runner/work/DFTK.jl/DFTK.jl/docs/.CondaPkg/pixi.toml
✔ The default environment has been installed.

Get the amount of vacuum in Ångström we need to add

d_vacuum = maximum(maximum, surface.cell) / n_GaAs * n_vacuum
surface = ase.build.surface(gaas, miller, n_GaAs, d_vacuum, periodic=true);

Write an image of the surface and embed it as a nice illustration:

ase.io.write("surface.png", surface * pytuple((3, 3, 1)), rotation="-90x, 30y, -75z")
Python: None

Use the pyconvert function from PythonCall to convert the ASE atoms to an AtomsBase-compatible system. This can then be used in the same way as other AtomsBase systems (see AtomsBase integration for details) to construct a DFTK model:

using DFTK
using PseudoPotentialData

pseudopotentials = PseudoFamily("cp2k.nc.sr.pbe.v0_1.largecore.gth")
model = model_DFT(pyconvert(AbstractSystem, surface);
                  functionals=PBE(),
                  temperature=1e-3,
                  smearing=DFTK.Smearing.Gaussian(),
                  pseudopotentials)
Model(gga_x_pbe+gga_c_pbe, 3D):
    lattice (in Bohr)    : [7.55469   , 0         , 0         ]
                           [0         , 7.55469   , 0         ]
                           [0         , 0         , 40.0648   ]
    unit cell volume     : 2286.6 Bohr³

    atoms                : As₂Ga₂
    pseudopot. family    : PseudoFamily("cp2k.nc.sr.pbe.v0_1.largecore.gth")

    num. electrons       : 16
    spin polarization    : none
    temperature          : 0.001 Ha
    smearing             : DFTK.Smearing.Gaussian()

    terms                : Kinetic()
                           AtomicLocal()
                           AtomicNonlocal()
                           Ewald(nothing)
                           PspCorrection()
                           Hartree()
                           Xc(gga_x_pbe, gga_c_pbe)
                           Entropy()

In the above we use the pseudopotential keyword argument to assign the respective pseudopotentials to the imported model.atoms. Try lowering the SCF convergence tolerance (tol) or try mixing=KerkerMixing() to see the full challenge of this system.

basis  = PlaneWaveBasis(model; Ecut, kgrid)
scfres = self_consistent_field(basis; tol=1e-6, mixing=LdosMixing());
n     Energy            log10(ΔE)   log10(Δρ)   Diag   Δtime 
---   ---------------   ---------   ---------   ----   ------
  1   -16.58767106289                   -0.58    5.3    7.68s
  2   -16.72506687129       -0.86       -1.01    1.0    4.42s
  3   -16.73050422522       -2.26       -1.57    2.2    385ms
  4   -16.73121945699       -3.15       -2.16    1.0    241ms
  5   -16.73132325348       -3.98       -2.58    1.9    276ms
  6   -16.73133349269       -4.99       -2.82    2.0    285ms
  7   -16.73085450918   +   -3.32       -2.47    2.1    302ms
  8   -16.73124558522       -3.41       -2.73    2.6    289ms
  9   -16.73115952946   +   -4.07       -2.67    2.1    272ms
 10   -16.73133983180       -3.74       -3.67    1.2    285ms
 11   -16.73133667494   +   -5.50       -3.49    3.0    795ms
 12   -16.73134011070       -5.46       -3.98    1.3    236ms
 13   -16.73133816273   +   -5.71       -3.63    2.2    297ms
 14   -16.73134019530       -5.69       -4.67    2.0    251ms
 15   -16.73134019507   +   -9.63       -4.73    2.1    283ms
 16   -16.73134018565   +   -8.03       -4.66    1.3    230ms
 17   -16.73134020027       -7.83       -5.39    1.1    216ms
 18   -16.73134020030      -10.57       -5.63    2.1    271ms
 19   -16.73134020043       -9.86       -6.32    2.0    281ms
scfres.energies
Energy breakdown (in Ha):
    Kinetic             5.8593969 
    AtomicLocal         -105.6100104
    AtomicNonlocal      2.3494808 
    Ewald               35.5044300
    PspCorrection       0.2016043 
    Hartree             49.5614251
    Xc                  -4.5976635
    Entropy             -0.0000035

    total               -16.731340200435