This section provides an overview of the input and output formats supported by DFTK, usually via integration with a third-party library.
AtomsIO is a Julia package which supports reading / writing atomistic structures from / to a large range of file formats. Supported formats include Crystallographic Information Framework (CIF), XYZ and extxyz files, ASE / Gromacs / LAMMPS / Amber trajectory files or input files of various other codes (e.g. Quantum Espresso, VASP, ABINIT, CASTEP, …). The full list of formatis is available in the AtomsIO documentation.
As an example we start the calculation of a simple antiferromagnetic iron crystal using a Quantum-Espresso input file, Fe_afm.pwi. For more details about calculations on magnetic systems using collinear spin, see Collinear spin and magnetic systems.
First we parse the Quantum Espresso input file using AtomsIO,
which reads the lattice, atomic positions and initial magnetisation
from the input file and returns it as an
AtomsBase AbstractSystem
,
the JuliaMolSim community standard for representing atomic systems.
using AtomsIO
system = load_system("Fe_afm.pwi")
FlexibleSystem(Fe₂, periodic = TTT): bounding_box : [ 2.86814 0 0; 0 2.86814 0; 0 0 2.86814]u"Å" Atom(Fe, [ 0, 0, 0]u"Å") Atom(Fe, [ 1.43407, 1.43407, 0]u"Å")
Next we attach pseudopotential information, since currently the parser is not yet capable to read this information from the file.
using DFTK
system = attach_psp(system, Fe="hgh/pbe/fe-q16.hgh")
FlexibleSystem(Fe₂, periodic = TTT): bounding_box : [ 2.86814 0 0; 0 2.86814 0; 0 0 2.86814]u"Å" Atom(Fe, [ 0, 0, 0]u"Å") Atom(Fe, [ 1.43407, 1.43407, 0]u"Å")
Finally we make use of DFTK's AtomsBase integration to run the calculation.
model = model_LDA(system; temperature=0.01)
basis = PlaneWaveBasis(model; Ecut=10, kgrid=(2, 2, 2))
ρ0 = guess_density(basis, system)
scfres = self_consistent_field(basis, tol=1e-3, ρ=ρ0, mixing=KerkerMixing());
n Energy log10(ΔE) log10(Δρ) Magnet Diag Δtime --- --------------- --------- --------- ------ ---- ------ 1 -223.7489879781 0.22 -6.320 5.2 2 -224.1789288080 -0.37 -0.23 -3.272 2.3 250ms 3 -224.2163500490 -1.43 -1.07 -1.804 2.8 314ms 4 -224.2191795108 -2.55 -1.35 -1.346 1.0 199ms 5 -224.2204936479 -2.88 -1.64 -0.917 1.0 285ms 6 -224.2210312965 -3.27 -1.86 -0.655 1.0 201ms 7 -224.2212858421 -3.59 -2.10 -0.382 1.2 203ms 8 -224.2214124597 -3.90 -2.60 -0.062 1.8 215ms 9 -224.2214201471 -5.11 -3.28 -0.022 2.4 240ms
For visualizing the density or the Kohn-Sham orbitals DFTK supports storing the result of an SCF calculations in the form of VTK files. These can afterwards be visualized using tools such as paraview. Using this feature requires the WriteVTK.jl Julia package.
using WriteVTK
save_scfres("iron_afm.vts", scfres; save_ψ=true);
This will save the iron calculation above into the file iron_afm.vts
,
using save_ψ=true
to also include the KS orbitals.
using JLD2
save_scfres("iron_afm.jld2", scfres);
Since such JLD2 can also be read by DFTK to start or continue a calculation, these can also be used for checkpointing or for transferring results to a different computer. See Saving SCF results on disk and SCF checkpoints for details.
(Cleanup files generated by this notebook.)
rm("iron_afm.vts")
rm("iron_afm.jld2")