using DFTK using Plots using Unitful using UnitfulAtomic using PseudoPotentialData # 1. Define lattice and atomic positions a = 5.431u"angstrom" # Silicon lattice constant lattice = a / 2 * [[0 1 1.]; # Silicon lattice vectors [1 0 1.]; # specified column by column [1 1 0.]]; pd_lda_family = PseudoFamily("dojo.nc.sr.lda.v0_4_1.standard.upf") Si = ElementPsp(:Si, pd_lda_family) # Specify type and positions of atoms atoms = [Si, Si] positions = [ones(3)/8, -ones(3)/8] # 2. Select model and basis model = model_DFT(lattice, atoms, positions; functionals=LDA()) kgrid = [4, 4, 4] # k-point grid (Regular Monkhorst-Pack grid) Ecut = 7 # kinetic energy cutoff # Ecut = 190.5u"eV" # Could also use eV or other energy-compatible units basis = PlaneWaveBasis(model; Ecut, kgrid) # Note the implicit passing of keyword arguments here: # this is equivalent to PlaneWaveBasis(model; Ecut=Ecut, kgrid=kgrid) # 3. Run the SCF procedure to obtain the ground state scfres = self_consistent_field(basis, tol=1e-5); scfres.energies stack(scfres.eigenvalues) stack(scfres.occupation) rvecs = collect(r_vectors(basis))[:, 1, 1] # slice along the x axis x = [r[1] for r in rvecs] # only keep the x coordinate plot(x, scfres.ρ[1, :, 1, 1], label="", xlabel="x", ylabel="ρ", marker=2) compute_forces_cart(scfres) plot_bandstructure(scfres; kline_density=10) bands = compute_bands(scfres, MonkhorstPack(6, 6, 6)) plot_dos(bands; temperature=1e-3, smearing=Smearing.FermiDirac()) plot_dos(scfres; temperature=1e-3, smearing=Smearing.FermiDirac())