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 meshUse 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);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.58718673017 -0.58 5.1 10.7s
2 -16.72515219176 -0.86 -1.01 1.0 5.02s
3 -16.73051440540 -2.27 -1.57 2.1 365ms
4 -16.73121154197 -3.16 -2.15 1.0 229ms
5 -16.73132340362 -3.95 -2.58 1.8 842ms
6 -16.73133152090 -5.09 -2.83 2.0 272ms
7 -16.73059076936 + -3.13 -2.37 2.2 278ms
8 -16.73132498045 -3.13 -2.97 2.2 256ms
9 -16.73130202877 + -4.64 -2.99 2.0 271ms
10 -16.73132091693 -4.72 -3.14 1.8 235ms
11 -16.73133521581 -4.84 -3.41 1.2 212ms
12 -16.73133786457 -5.58 -3.56 1.0 210ms
13 -16.73133920957 -5.87 -3.75 1.0 209ms
14 -16.73134019096 -6.01 -4.52 1.3 220ms
15 -16.73134014723 + -7.36 -4.41 2.0 281ms
16 -16.73134015313 -8.23 -4.43 1.0 210ms
17 -16.73134017546 -7.65 -4.56 1.0 787ms
18 -16.73134017022 + -8.28 -4.52 1.0 203ms
19 -16.73134019499 -7.61 -4.76 1.3 209ms
20 -16.73134019834 -8.47 -4.89 1.0 215ms
21 -16.73134019906 -9.14 -5.02 1.0 209ms
22 -16.73134019999 -9.03 -5.27 1.0 208ms
23 -16.73134020042 -9.37 -5.86 1.6 218ms
24 -16.73134020033 + -10.08 -5.78 2.0 241ms
25 -16.73134020044 -9.99 -6.33 1.1 209ms
scfres.energiesEnergy breakdown (in Ha):
Kinetic 5.8593977
AtomicLocal -105.6100216
AtomicNonlocal 2.3494812
Ewald 35.5044300
PspCorrection 0.2016043
Hartree 49.5614356
Xc -4.5976639
Entropy -0.0000035
total -16.731340200436