using DFTK a = 5.42352 # Bohr lattice = a / 2 * [[-1 1 1]; [ 1 -1 1]; [ 1 1 -1]] atoms = [ElementPsp(:Fe, psp=load_psp("hgh/lda/Fe-q8.hgh"))] positions = [zeros(3)] kgrid = [3, 3, 3] # k-point grid (Regular Monkhorst-Pack grid) Ecut = 15 # kinetic energy cutoff in Hartree model_nospin = model_LDA(lattice, atoms, positions, temperature=0.01) basis_nospin = PlaneWaveBasis(model_nospin; kgrid, Ecut) scfres_nospin = self_consistent_field(basis_nospin; tol=1e-6, mixing=KerkerDosMixing()); scfres_nospin.energies magnetic_moments = [4]; model = model_LDA(lattice, atoms, positions; magnetic_moments, temperature=0.01) basis = PlaneWaveBasis(model; Ecut, kgrid) ρ0 = guess_density(basis, magnetic_moments) scfres = self_consistent_field(basis, tol=1e-6; ρ=ρ0, mixing=KerkerDosMixing()); scfres.energies println("No magnetization: ", scfres_nospin.energies.total) println("Magnetic case: ", scfres.energies.total) println("Difference: ", scfres.energies.total - scfres_nospin.energies.total); iup = 1 idown = iup + length(scfres.basis.kpoints) ÷ 2 @show scfres.occupation[iup][1:7] @show scfres.occupation[idown][1:7]; @show scfres.eigenvalues[iup][1:7] @show scfres.eigenvalues[idown][1:7]; using Plots plot_dos(scfres) using Unitful using UnitfulAtomic plot_bandstructure(scfres; kline_density=6)