Data structures

In this section we assume a calculation of silicon LDA model in the setup described in Tutorial.

Model datastructure

The physical model to be solved is defined by the Model datastructure. It contains the unit cell, number of electrons, atoms, type of spin polarization and temperature. Each atom has an atomic type (Element) specifying the number of valence electrons and the potential (or pseudopotential) it creates with respect to the electrons. The Model structure also contains the list of energy terms defining the energy functional to be minimised during the SCF. For the silicon example above, we used an LDA model, which consists of the following terms[2]:

typeof.(model.term_types)
7-element Array{DataType,1}:
 Kinetic
 AtomicLocal
 AtomicNonlocal
 Ewald
 PspCorrection
 Hartree
 Xc

DFTK computes energies for all terms of the model individually, which are available in scfres.energies:

scfres.energies
Energy breakdown:
    Kinetic             3.1521579 
    AtomicLocal         -2.1283885
    AtomicNonlocal      1.5890879 
    Ewald               -8.4004648
    PspCorrection       -0.2948928
    Hartree             0.5469786 
    Xc                  -2.3964718

    total               -7.931993463178

For now the following energy terms are available in DFTK:

  • Kinetic energy
  • Local potential energy, either given by analytic potentials or specified by the type of atoms.
  • Nonlocal potential energy, for norm-conserving pseudopotentials
  • Nuclei energies (Ewald or pseudopotential correction)
  • Hartree energy
  • Exchange-correlation energy
  • Power nonlinearities (useful for Gross-Pitaevskii type models)
  • Magnetic field energy
  • Entropy term

Custom types can be added if needed. For examples see the definition of the above terms in the src/terms directory.

By mixing and matching these terms, the user can create custom models not limited to DFT. Convenience constructors are provided for common cases:

  • model_LDA: LDA model using the Teter parametrisation
  • model_DFT: Assemble a DFT model using any of the LDA or GGA functionals of the libxc library, for example: model_DFT(lattice, atoms, [:gga_x_pbe, :gga_c_pbe]) model_DFT(lattice, atoms, :lda_xc_teter93) where the latter is equivalent to model_LDA. Specifying no functional is the reduced Hartree-Fock model: model_DFT(lattice, atoms, [])
  • model_atomic: A linear model, which contains no electron-electron interaction (neither Hartree nor XC term).

PlaneWaveBasis and plane-wave discretisations

The PlaneWaveBasis datastructure handles the discretization of a given Model in a plane-wave basis. In plane-wave methods the discretization is twofold: Once the $k$-point grid, which determines the sampling inside the Brillouin zone and on top of that a finite plane-wave grid to discretise the lattice-periodic functions. The former aspect is controlled by the kgrid argument of PlaneWaveBasis, the latter is controlled by the cutoff energy parameter Ecut:

PlaneWaveBasis(model, Ecut; kgrid=kgrid)
PlaneWaveBasis (Ecut=15.0, 10 kpoints)

The PlaneWaveBasis by default uses symmetry to reduce the number of k-points explicitly treated. For details see Crystal symmetries.

As mentioned, the periodic parts of Bloch waves are expanded in a set of normalized plane waves $e_G$:

\[\begin{aligned} \psi_{k}(x) &= e^{i k \cdot x} u_{k}(x)\\ &= \sum_{G \in \mathcal R^{*}} c_{G} e^{i k \cdot x} e_{G}(x) \end{aligned}\]

where $\mathcal R^*$ is the set of reciprocal lattice vectors. The $c_{{G}}$ are $\ell^{2}$-normalized. The summation is truncated to a "spherical", $k$-dependent basis set

\[ S_{k} = \left\{G \in \mathcal R^{*} \,\middle|\, \frac 1 2 |k+ G|^{2} \le E_\text{cut}\right\}\]

where $E_\text{cut}$ is the cutoff energy.

Densities involve terms like $|\psi_{k}|^{2} = |u_{k}|^{2}$ and therefore products $e_{-{G}} e_{{G}'}$ for ${G}, {G}'$ in $S_{k}$. To represent these we use a "cubic", $k$-independent basis set large enough to contain the set $\{{G}-G' \,|\, G, G' \in S_{k}\}$. We can obtain the coefficients of densities on the $e_{G}$ basis by a convolution, which can be performed efficiently with FFTs (see G_to_r and r_to_G functions). Potentials are discretized on this same set.

The normalization conventions used in the code is that quantities stored in reciprocal space are coefficients in the $e_{G}$ basis, and quantities stored in real space use real physical values. This means for instance that wavefunctions in the real space grid are normalized as $\frac{|\Omega|}{N} \sum_{r} |\psi(r)|^{2} = 1$ where $N$ is the number of grid points.

For example let us check the normalization of the first eigenfunction at the first $k$-point in reciprocal space:

ψtest = scfres.ψ[1][:, 1]
sum(abs2.(ψtest))
0.9999999999999981

We now perform an IFFT to get ψ in real space. The $k$-point has to be passed because ψ is expressed on the $k$-dependent basis. Again the function is normalised:

ψreal = G_to_r(basis, basis.kpoints[1], ψtest)
sum(abs2.(ψreal)) * model.unit_cell_volume / prod(basis.fft_size)
0.9999999999999983

The list of $k$ points of the basis can be obtained with basis.kpoints.

basis.kpoints
10-element Array{Kpoint{Float64},1}:
 Kpoint{Float64}(Model{Float64}([0.0 5.13 5.13; 5.13 0.0 5.13; 5.13 5.13 0.0], [-0.6123962287699403 0.6123962287699403 0.6123962287699403; 0.6123962287699403 -0.6123962287699403 0.6123962287699403; 0.6123962287699403 0.6123962287699403 -0.6123962287699403], 270.011394, 0.9186657265374463, 3, 8, :none, 1, 0.0, DFTK.Smearing.None(), Pair{Any,Array{StaticArrays.SArray{Tuple{3},Float64,1,3},1}}[ElementPsp(14, :Si, PspHgh(4, 0.44, [-7.33610297, 0.0, 0.0, 0.0], 1, [0.42273813, 0.48427842], [[5.90692831 -1.26189397; -1.26189397 3.25819622], [2.72701346]], "hgh/lda/si-q4", "Si GTH-PADE-q4 GTH-LDA-q4")) => [[0.125, 0.125, 0.125], [-0.125, -0.125, -0.125]]], Any[Kinetic(1), AtomicLocal(), AtomicNonlocal(), Ewald(), PspCorrection(), Hartree(1), Xc([:lda_xc_teter93], 1, nothing)], Tuple{StaticArrays.SArray{Tuple{3,3},Int64,2,9},StaticArrays.SArray{Tuple{3},Float64,1,3}}[([1 0 0; 0 1 0; 0 0 1], [0.0, 0.0, 0.0]), ([1 0 -1; 1 0 0; 1 -1 0], [0.0, 0.5, 0.0]), ([0 1 -1; 1 0 -1; 0 0 -1], [0.0, 0.0, 0.5]), ([0 1 0; 0 1 -1; -1 1 0], [0.5, 0.0, 0.0]), ([-1 0 0; -1 0 1; -1 1 0], [0.5, 0.0, 0.0]), ([0 -1 0; -1 0 0; 0 0 -1], [0.0, 0.0, 0.0]), ([0 -1 1; 0 -1 0; 1 -1 0], [0.0, 0.5, 0.0]), ([-1 0 1; 0 -1 1; 0 0 1], [0.0, 0.0, 0.5]), ([0 1 0; 0 0 1; 1 0 0], [0.0, 0.0, 0.0]), ([-1 1 0; 0 1 0; 0 1 -1], [0.0, 0.5, 0.0])  …  ([-1 0 1; 0 0 1; 0 -1 1], [0.0, 0.5, 0.0]), ([-1 1 0; -1 0 1; -1 0 0], [0.0, 0.0, 0.5]), ([0 0 -1; -1 0 0; 0 -1 0], [0.0, 0.0, 0.0]), ([0 1 -1; 0 0 -1; 1 0 -1], [0.0, 0.5, 0.0]), ([-1 1 0; 0 1 -1; 0 1 0], [0.0, 0.0, 0.5]), ([-1 0 0; -1 1 0; -1 0 1], [0.5, 0.0, 0.0]), ([0 0 1; 0 -1 1; -1 0 1], [0.5, 0.0, 0.0]), ([1 0 0; 0 0 1; 0 1 0], [0.0, 0.0, 0.0]), ([1 -1 0; 1 0 0; 1 0 -1], [0.0, 0.5, 0.0]), ([0 -1 1; 1 -1 0; 0 -1 0], [0.0, 0.0, 0.5])]), 1, [0.125, 0.125, 0.125], [0.07654952859624253, 0.07654952859624253, 0.07654952859624253], [1, 2, 3, 4, 5, 6, 23, 24, 25, 26  …  19657, 19658, 19659, 19660, 19661, 19679, 19680, 19681, 19682, 19683], Dict(18201 => 574,4460 => 408,29 => 13,19013 => 685,1461 => 176,18849 => 627,16713 => 442,17388 => 478,17443 => 494,2300 => 293…), StaticArrays.SArray{Tuple{3},Int64,1,3}[[0, 0, 0], [1, 0, 0], [2, 0, 0], [3, 0, 0], [4, 0, 0], [5, 0, 0], [-5, 0, 0], [-4, 0, 0], [-3, 0, 0], [-2, 0, 0]  …  [0, -1, -1], [1, -1, -1], [2, -1, -1], [3, -1, -1], [4, -1, -1], [-5, -1, -1], [-4, -1, -1], [-3, -1, -1], [-2, -1, -1], [-1, -1, -1]])
 Kpoint{Float64}(Model{Float64}([0.0 5.13 5.13; 5.13 0.0 5.13; 5.13 5.13 0.0], [-0.6123962287699403 0.6123962287699403 0.6123962287699403; 0.6123962287699403 -0.6123962287699403 0.6123962287699403; 0.6123962287699403 0.6123962287699403 -0.6123962287699403], 270.011394, 0.9186657265374463, 3, 8, :none, 1, 0.0, DFTK.Smearing.None(), Pair{Any,Array{StaticArrays.SArray{Tuple{3},Float64,1,3},1}}[ElementPsp(14, :Si, PspHgh(4, 0.44, [-7.33610297, 0.0, 0.0, 0.0], 1, [0.42273813, 0.48427842], [[5.90692831 -1.26189397; -1.26189397 3.25819622], [2.72701346]], "hgh/lda/si-q4", "Si GTH-PADE-q4 GTH-LDA-q4")) => [[0.125, 0.125, 0.125], [-0.125, -0.125, -0.125]]], Any[Kinetic(1), AtomicLocal(), AtomicNonlocal(), Ewald(), PspCorrection(), Hartree(1), Xc([:lda_xc_teter93], 1, nothing)], Tuple{StaticArrays.SArray{Tuple{3,3},Int64,2,9},StaticArrays.SArray{Tuple{3},Float64,1,3}}[([1 0 0; 0 1 0; 0 0 1], [0.0, 0.0, 0.0]), ([1 0 -1; 1 0 0; 1 -1 0], [0.0, 0.5, 0.0]), ([0 1 -1; 1 0 -1; 0 0 -1], [0.0, 0.0, 0.5]), ([0 1 0; 0 1 -1; -1 1 0], [0.5, 0.0, 0.0]), ([-1 0 0; -1 0 1; -1 1 0], [0.5, 0.0, 0.0]), ([0 -1 0; -1 0 0; 0 0 -1], [0.0, 0.0, 0.0]), ([0 -1 1; 0 -1 0; 1 -1 0], [0.0, 0.5, 0.0]), ([-1 0 1; 0 -1 1; 0 0 1], [0.0, 0.0, 0.5]), ([0 1 0; 0 0 1; 1 0 0], [0.0, 0.0, 0.0]), ([-1 1 0; 0 1 0; 0 1 -1], [0.0, 0.5, 0.0])  …  ([-1 0 1; 0 0 1; 0 -1 1], [0.0, 0.5, 0.0]), ([-1 1 0; -1 0 1; -1 0 0], [0.0, 0.0, 0.5]), ([0 0 -1; -1 0 0; 0 -1 0], [0.0, 0.0, 0.0]), ([0 1 -1; 0 0 -1; 1 0 -1], [0.0, 0.5, 0.0]), ([-1 1 0; 0 1 -1; 0 1 0], [0.0, 0.0, 0.5]), ([-1 0 0; -1 1 0; -1 0 1], [0.5, 0.0, 0.0]), ([0 0 1; 0 -1 1; -1 0 1], [0.5, 0.0, 0.0]), ([1 0 0; 0 0 1; 0 1 0], [0.0, 0.0, 0.0]), ([1 -1 0; 1 0 0; 1 0 -1], [0.0, 0.5, 0.0]), ([0 -1 1; 1 -1 0; 0 -1 0], [0.0, 0.0, 0.5])]), 1, [0.375, 0.125, 0.125], [-0.07654952859624253, 0.2296485857887276, 0.2296485857887276], [1, 2, 3, 4, 5, 23, 24, 25, 26, 27  …  19658, 19659, 19660, 19661, 19678, 19679, 19680, 19681, 19682, 19683], Dict(18201 => 575,29 => 12,16062 => 421,19013 => 687,1461 => 178,16713 => 442,17388 => 480,17443 => 496,2300 => 294,17553 => 529…), StaticArrays.SArray{Tuple{3},Int64,1,3}[[0, 0, 0], [1, 0, 0], [2, 0, 0], [3, 0, 0], [4, 0, 0], [-5, 0, 0], [-4, 0, 0], [-3, 0, 0], [-2, 0, 0], [-1, 0, 0]  …  [1, -1, -1], [2, -1, -1], [3, -1, -1], [4, -1, -1], [-6, -1, -1], [-5, -1, -1], [-4, -1, -1], [-3, -1, -1], [-2, -1, -1], [-1, -1, -1]])
 Kpoint{Float64}(Model{Float64}([0.0 5.13 5.13; 5.13 0.0 5.13; 5.13 5.13 0.0], [-0.6123962287699403 0.6123962287699403 0.6123962287699403; 0.6123962287699403 -0.6123962287699403 0.6123962287699403; 0.6123962287699403 0.6123962287699403 -0.6123962287699403], 270.011394, 0.9186657265374463, 3, 8, :none, 1, 0.0, DFTK.Smearing.None(), Pair{Any,Array{StaticArrays.SArray{Tuple{3},Float64,1,3},1}}[ElementPsp(14, :Si, PspHgh(4, 0.44, [-7.33610297, 0.0, 0.0, 0.0], 1, [0.42273813, 0.48427842], [[5.90692831 -1.26189397; -1.26189397 3.25819622], [2.72701346]], "hgh/lda/si-q4", "Si GTH-PADE-q4 GTH-LDA-q4")) => [[0.125, 0.125, 0.125], [-0.125, -0.125, -0.125]]], Any[Kinetic(1), AtomicLocal(), AtomicNonlocal(), Ewald(), PspCorrection(), Hartree(1), Xc([:lda_xc_teter93], 1, nothing)], Tuple{StaticArrays.SArray{Tuple{3,3},Int64,2,9},StaticArrays.SArray{Tuple{3},Float64,1,3}}[([1 0 0; 0 1 0; 0 0 1], [0.0, 0.0, 0.0]), ([1 0 -1; 1 0 0; 1 -1 0], [0.0, 0.5, 0.0]), ([0 1 -1; 1 0 -1; 0 0 -1], [0.0, 0.0, 0.5]), ([0 1 0; 0 1 -1; -1 1 0], [0.5, 0.0, 0.0]), ([-1 0 0; -1 0 1; -1 1 0], [0.5, 0.0, 0.0]), ([0 -1 0; -1 0 0; 0 0 -1], [0.0, 0.0, 0.0]), ([0 -1 1; 0 -1 0; 1 -1 0], [0.0, 0.5, 0.0]), ([-1 0 1; 0 -1 1; 0 0 1], [0.0, 0.0, 0.5]), ([0 1 0; 0 0 1; 1 0 0], [0.0, 0.0, 0.0]), ([-1 1 0; 0 1 0; 0 1 -1], [0.0, 0.5, 0.0])  …  ([-1 0 1; 0 0 1; 0 -1 1], [0.0, 0.5, 0.0]), ([-1 1 0; -1 0 1; -1 0 0], [0.0, 0.0, 0.5]), ([0 0 -1; -1 0 0; 0 -1 0], [0.0, 0.0, 0.0]), ([0 1 -1; 0 0 -1; 1 0 -1], [0.0, 0.5, 0.0]), ([-1 1 0; 0 1 -1; 0 1 0], [0.0, 0.0, 0.5]), ([-1 0 0; -1 1 0; -1 0 1], [0.5, 0.0, 0.0]), ([0 0 1; 0 -1 1; -1 0 1], [0.5, 0.0, 0.0]), ([1 0 0; 0 0 1; 0 1 0], [0.0, 0.0, 0.0]), ([1 -1 0; 1 0 0; 1 0 -1], [0.0, 0.5, 0.0]), ([0 -1 1; 1 -1 0; 0 -1 0], [0.0, 0.0, 0.5])]), 1, [-0.375, 0.125, 0.125], [0.38274764298121267, -0.2296485857887276, -0.2296485857887276], [1, 2, 3, 4, 5, 6, 24, 25, 26, 27  …  19657, 19658, 19659, 19660, 19661, 19679, 19680, 19681, 19682, 19683], Dict(18201 => 580,4460 => 408,17362 => 478,29 => 12,19013 => 693,1461 => 176,18849 => 635,16713 => 445,17388 => 483,17443 => 499…), StaticArrays.SArray{Tuple{3},Int64,1,3}[[0, 0, 0], [1, 0, 0], [2, 0, 0], [3, 0, 0], [4, 0, 0], [5, 0, 0], [-4, 0, 0], [-3, 0, 0], [-2, 0, 0], [-1, 0, 0]  …  [0, -1, -1], [1, -1, -1], [2, -1, -1], [3, -1, -1], [4, -1, -1], [-5, -1, -1], [-4, -1, -1], [-3, -1, -1], [-2, -1, -1], [-1, -1, -1]])
 Kpoint{Float64}(Model{Float64}([0.0 5.13 5.13; 5.13 0.0 5.13; 5.13 5.13 0.0], [-0.6123962287699403 0.6123962287699403 0.6123962287699403; 0.6123962287699403 -0.6123962287699403 0.6123962287699403; 0.6123962287699403 0.6123962287699403 -0.6123962287699403], 270.011394, 0.9186657265374463, 3, 8, :none, 1, 0.0, DFTK.Smearing.None(), Pair{Any,Array{StaticArrays.SArray{Tuple{3},Float64,1,3},1}}[ElementPsp(14, :Si, PspHgh(4, 0.44, [-7.33610297, 0.0, 0.0, 0.0], 1, [0.42273813, 0.48427842], [[5.90692831 -1.26189397; -1.26189397 3.25819622], [2.72701346]], "hgh/lda/si-q4", "Si GTH-PADE-q4 GTH-LDA-q4")) => [[0.125, 0.125, 0.125], [-0.125, -0.125, -0.125]]], Any[Kinetic(1), AtomicLocal(), AtomicNonlocal(), Ewald(), PspCorrection(), Hartree(1), Xc([:lda_xc_teter93], 1, nothing)], Tuple{StaticArrays.SArray{Tuple{3,3},Int64,2,9},StaticArrays.SArray{Tuple{3},Float64,1,3}}[([1 0 0; 0 1 0; 0 0 1], [0.0, 0.0, 0.0]), ([1 0 -1; 1 0 0; 1 -1 0], [0.0, 0.5, 0.0]), ([0 1 -1; 1 0 -1; 0 0 -1], [0.0, 0.0, 0.5]), ([0 1 0; 0 1 -1; -1 1 0], [0.5, 0.0, 0.0]), ([-1 0 0; -1 0 1; -1 1 0], [0.5, 0.0, 0.0]), ([0 -1 0; -1 0 0; 0 0 -1], [0.0, 0.0, 0.0]), ([0 -1 1; 0 -1 0; 1 -1 0], [0.0, 0.5, 0.0]), ([-1 0 1; 0 -1 1; 0 0 1], [0.0, 0.0, 0.5]), ([0 1 0; 0 0 1; 1 0 0], [0.0, 0.0, 0.0]), ([-1 1 0; 0 1 0; 0 1 -1], [0.0, 0.5, 0.0])  …  ([-1 0 1; 0 0 1; 0 -1 1], [0.0, 0.5, 0.0]), ([-1 1 0; -1 0 1; -1 0 0], [0.0, 0.0, 0.5]), ([0 0 -1; -1 0 0; 0 -1 0], [0.0, 0.0, 0.0]), ([0 1 -1; 0 0 -1; 1 0 -1], [0.0, 0.5, 0.0]), ([-1 1 0; 0 1 -1; 0 1 0], [0.0, 0.0, 0.5]), ([-1 0 0; -1 1 0; -1 0 1], [0.5, 0.0, 0.0]), ([0 0 1; 0 -1 1; -1 0 1], [0.5, 0.0, 0.0]), ([1 0 0; 0 0 1; 0 1 0], [0.0, 0.0, 0.0]), ([1 -1 0; 1 0 0; 1 0 -1], [0.0, 0.5, 0.0]), ([0 -1 1; 1 -1 0; 0 -1 0], [0.0, 0.0, 0.5])]), 1, [-0.125, 0.125, 0.125], [0.2296485857887276, -0.07654952859624253, -0.07654952859624253], [1, 2, 3, 4, 5, 6, 24, 25, 26, 27  …  19657, 19658, 19659, 19660, 19661, 19679, 19680, 19681, 19682, 19683], Dict(18201 => 583,4460 => 409,17362 => 479,29 => 12,19013 => 698,1461 => 176,18849 => 639,16713 => 447,17388 => 484,17443 => 501…), StaticArrays.SArray{Tuple{3},Int64,1,3}[[0, 0, 0], [1, 0, 0], [2, 0, 0], [3, 0, 0], [4, 0, 0], [5, 0, 0], [-4, 0, 0], [-3, 0, 0], [-2, 0, 0], [-1, 0, 0]  …  [0, -1, -1], [1, -1, -1], [2, -1, -1], [3, -1, -1], [4, -1, -1], [-5, -1, -1], [-4, -1, -1], [-3, -1, -1], [-2, -1, -1], [-1, -1, -1]])
 Kpoint{Float64}(Model{Float64}([0.0 5.13 5.13; 5.13 0.0 5.13; 5.13 5.13 0.0], [-0.6123962287699403 0.6123962287699403 0.6123962287699403; 0.6123962287699403 -0.6123962287699403 0.6123962287699403; 0.6123962287699403 0.6123962287699403 -0.6123962287699403], 270.011394, 0.9186657265374463, 3, 8, :none, 1, 0.0, DFTK.Smearing.None(), Pair{Any,Array{StaticArrays.SArray{Tuple{3},Float64,1,3},1}}[ElementPsp(14, :Si, PspHgh(4, 0.44, [-7.33610297, 0.0, 0.0, 0.0], 1, [0.42273813, 0.48427842], [[5.90692831 -1.26189397; -1.26189397 3.25819622], [2.72701346]], "hgh/lda/si-q4", "Si GTH-PADE-q4 GTH-LDA-q4")) => [[0.125, 0.125, 0.125], [-0.125, -0.125, -0.125]]], Any[Kinetic(1), AtomicLocal(), AtomicNonlocal(), Ewald(), PspCorrection(), Hartree(1), Xc([:lda_xc_teter93], 1, nothing)], Tuple{StaticArrays.SArray{Tuple{3,3},Int64,2,9},StaticArrays.SArray{Tuple{3},Float64,1,3}}[([1 0 0; 0 1 0; 0 0 1], [0.0, 0.0, 0.0]), ([1 0 -1; 1 0 0; 1 -1 0], [0.0, 0.5, 0.0]), ([0 1 -1; 1 0 -1; 0 0 -1], [0.0, 0.0, 0.5]), ([0 1 0; 0 1 -1; -1 1 0], [0.5, 0.0, 0.0]), ([-1 0 0; -1 0 1; -1 1 0], [0.5, 0.0, 0.0]), ([0 -1 0; -1 0 0; 0 0 -1], [0.0, 0.0, 0.0]), ([0 -1 1; 0 -1 0; 1 -1 0], [0.0, 0.5, 0.0]), ([-1 0 1; 0 -1 1; 0 0 1], [0.0, 0.0, 0.5]), ([0 1 0; 0 0 1; 1 0 0], [0.0, 0.0, 0.0]), ([-1 1 0; 0 1 0; 0 1 -1], [0.0, 0.5, 0.0])  …  ([-1 0 1; 0 0 1; 0 -1 1], [0.0, 0.5, 0.0]), ([-1 1 0; -1 0 1; -1 0 0], [0.0, 0.0, 0.5]), ([0 0 -1; -1 0 0; 0 -1 0], [0.0, 0.0, 0.0]), ([0 1 -1; 0 0 -1; 1 0 -1], [0.0, 0.5, 0.0]), ([-1 1 0; 0 1 -1; 0 1 0], [0.0, 0.0, 0.5]), ([-1 0 0; -1 1 0; -1 0 1], [0.5, 0.0, 0.0]), ([0 0 1; 0 -1 1; -1 0 1], [0.5, 0.0, 0.0]), ([1 0 0; 0 0 1; 0 1 0], [0.0, 0.0, 0.0]), ([1 -1 0; 1 0 0; 1 0 -1], [0.0, 0.5, 0.0]), ([0 -1 1; 1 -1 0; 0 -1 0], [0.0, 0.0, 0.5])]), 1, [0.375, 0.375, 0.125], [0.07654952859624253, 0.07654952859624253, 0.38274764298121267], [1, 2, 3, 4, 5, 23, 24, 25, 26, 27  …  19657, 19658, 19659, 19660, 19661, 19679, 19680, 19681, 19682, 19683], Dict(18201 => 574,4460 => 405,29 => 12,19013 => 685,1461 => 179,18849 => 625,16713 => 445,17388 => 479,17443 => 495,2300 => 291…), StaticArrays.SArray{Tuple{3},Int64,1,3}[[0, 0, 0], [1, 0, 0], [2, 0, 0], [3, 0, 0], [4, 0, 0], [-5, 0, 0], [-4, 0, 0], [-3, 0, 0], [-2, 0, 0], [-1, 0, 0]  …  [0, -1, -1], [1, -1, -1], [2, -1, -1], [3, -1, -1], [4, -1, -1], [-5, -1, -1], [-4, -1, -1], [-3, -1, -1], [-2, -1, -1], [-1, -1, -1]])
 Kpoint{Float64}(Model{Float64}([0.0 5.13 5.13; 5.13 0.0 5.13; 5.13 5.13 0.0], [-0.6123962287699403 0.6123962287699403 0.6123962287699403; 0.6123962287699403 -0.6123962287699403 0.6123962287699403; 0.6123962287699403 0.6123962287699403 -0.6123962287699403], 270.011394, 0.9186657265374463, 3, 8, :none, 1, 0.0, DFTK.Smearing.None(), Pair{Any,Array{StaticArrays.SArray{Tuple{3},Float64,1,3},1}}[ElementPsp(14, :Si, PspHgh(4, 0.44, [-7.33610297, 0.0, 0.0, 0.0], 1, [0.42273813, 0.48427842], [[5.90692831 -1.26189397; -1.26189397 3.25819622], [2.72701346]], "hgh/lda/si-q4", "Si GTH-PADE-q4 GTH-LDA-q4")) => [[0.125, 0.125, 0.125], [-0.125, -0.125, -0.125]]], Any[Kinetic(1), AtomicLocal(), AtomicNonlocal(), Ewald(), PspCorrection(), Hartree(1), Xc([:lda_xc_teter93], 1, nothing)], Tuple{StaticArrays.SArray{Tuple{3,3},Int64,2,9},StaticArrays.SArray{Tuple{3},Float64,1,3}}[([1 0 0; 0 1 0; 0 0 1], [0.0, 0.0, 0.0]), ([1 0 -1; 1 0 0; 1 -1 0], [0.0, 0.5, 0.0]), ([0 1 -1; 1 0 -1; 0 0 -1], [0.0, 0.0, 0.5]), ([0 1 0; 0 1 -1; -1 1 0], [0.5, 0.0, 0.0]), ([-1 0 0; -1 0 1; -1 1 0], [0.5, 0.0, 0.0]), ([0 -1 0; -1 0 0; 0 0 -1], [0.0, 0.0, 0.0]), ([0 -1 1; 0 -1 0; 1 -1 0], [0.0, 0.5, 0.0]), ([-1 0 1; 0 -1 1; 0 0 1], [0.0, 0.0, 0.5]), ([0 1 0; 0 0 1; 1 0 0], [0.0, 0.0, 0.0]), ([-1 1 0; 0 1 0; 0 1 -1], [0.0, 0.5, 0.0])  …  ([-1 0 1; 0 0 1; 0 -1 1], [0.0, 0.5, 0.0]), ([-1 1 0; -1 0 1; -1 0 0], [0.0, 0.0, 0.5]), ([0 0 -1; -1 0 0; 0 -1 0], [0.0, 0.0, 0.0]), ([0 1 -1; 0 0 -1; 1 0 -1], [0.0, 0.5, 0.0]), ([-1 1 0; 0 1 -1; 0 1 0], [0.0, 0.0, 0.5]), ([-1 0 0; -1 1 0; -1 0 1], [0.5, 0.0, 0.0]), ([0 0 1; 0 -1 1; -1 0 1], [0.5, 0.0, 0.0]), ([1 0 0; 0 0 1; 0 1 0], [0.0, 0.0, 0.0]), ([1 -1 0; 1 0 0; 1 0 -1], [0.0, 0.5, 0.0]), ([0 -1 1; 1 -1 0; 0 -1 0], [0.0, 0.0, 0.5])]), 1, [-0.375, 0.375, 0.125], [0.5358467001736977, -0.38274764298121267, -0.07654952859624253], [1, 2, 3, 4, 5, 6, 24, 25, 26, 27  …  19657, 19658, 19659, 19660, 19661, 19679, 19680, 19681, 19682, 19683], Dict(18201 => 575,4460 => 406,17362 => 476,29 => 12,19013 => 686,1461 => 178,18849 => 627,16713 => 445,17388 => 481,17443 => 497…), StaticArrays.SArray{Tuple{3},Int64,1,3}[[0, 0, 0], [1, 0, 0], [2, 0, 0], [3, 0, 0], [4, 0, 0], [5, 0, 0], [-4, 0, 0], [-3, 0, 0], [-2, 0, 0], [-1, 0, 0]  …  [0, -1, -1], [1, -1, -1], [2, -1, -1], [3, -1, -1], [4, -1, -1], [-5, -1, -1], [-4, -1, -1], [-3, -1, -1], [-2, -1, -1], [-1, -1, -1]])
 Kpoint{Float64}(Model{Float64}([0.0 5.13 5.13; 5.13 0.0 5.13; 5.13 5.13 0.0], [-0.6123962287699403 0.6123962287699403 0.6123962287699403; 0.6123962287699403 -0.6123962287699403 0.6123962287699403; 0.6123962287699403 0.6123962287699403 -0.6123962287699403], 270.011394, 0.9186657265374463, 3, 8, :none, 1, 0.0, DFTK.Smearing.None(), Pair{Any,Array{StaticArrays.SArray{Tuple{3},Float64,1,3},1}}[ElementPsp(14, :Si, PspHgh(4, 0.44, [-7.33610297, 0.0, 0.0, 0.0], 1, [0.42273813, 0.48427842], [[5.90692831 -1.26189397; -1.26189397 3.25819622], [2.72701346]], "hgh/lda/si-q4", "Si GTH-PADE-q4 GTH-LDA-q4")) => [[0.125, 0.125, 0.125], [-0.125, -0.125, -0.125]]], Any[Kinetic(1), AtomicLocal(), AtomicNonlocal(), Ewald(), PspCorrection(), Hartree(1), Xc([:lda_xc_teter93], 1, nothing)], Tuple{StaticArrays.SArray{Tuple{3,3},Int64,2,9},StaticArrays.SArray{Tuple{3},Float64,1,3}}[([1 0 0; 0 1 0; 0 0 1], [0.0, 0.0, 0.0]), ([1 0 -1; 1 0 0; 1 -1 0], [0.0, 0.5, 0.0]), ([0 1 -1; 1 0 -1; 0 0 -1], [0.0, 0.0, 0.5]), ([0 1 0; 0 1 -1; -1 1 0], [0.5, 0.0, 0.0]), ([-1 0 0; -1 0 1; -1 1 0], [0.5, 0.0, 0.0]), ([0 -1 0; -1 0 0; 0 0 -1], [0.0, 0.0, 0.0]), ([0 -1 1; 0 -1 0; 1 -1 0], [0.0, 0.5, 0.0]), ([-1 0 1; 0 -1 1; 0 0 1], [0.0, 0.0, 0.5]), ([0 1 0; 0 0 1; 1 0 0], [0.0, 0.0, 0.0]), ([-1 1 0; 0 1 0; 0 1 -1], [0.0, 0.5, 0.0])  …  ([-1 0 1; 0 0 1; 0 -1 1], [0.0, 0.5, 0.0]), ([-1 1 0; -1 0 1; -1 0 0], [0.0, 0.0, 0.5]), ([0 0 -1; -1 0 0; 0 -1 0], [0.0, 0.0, 0.0]), ([0 1 -1; 0 0 -1; 1 0 -1], [0.0, 0.5, 0.0]), ([-1 1 0; 0 1 -1; 0 1 0], [0.0, 0.0, 0.5]), ([-1 0 0; -1 1 0; -1 0 1], [0.5, 0.0, 0.0]), ([0 0 1; 0 -1 1; -1 0 1], [0.5, 0.0, 0.0]), ([1 0 0; 0 0 1; 0 1 0], [0.0, 0.0, 0.0]), ([1 -1 0; 1 0 0; 1 0 -1], [0.0, 0.5, 0.0]), ([0 -1 1; 1 -1 0; 0 -1 0], [0.0, 0.0, 0.5])]), 1, [-0.125, 0.375, 0.125], [0.38274764298121267, -0.2296485857887276, 0.07654952859624253], [1, 2, 3, 4, 5, 6, 24, 25, 26, 27  …  19657, 19658, 19659, 19660, 19661, 19679, 19680, 19681, 19682, 19683], Dict(18201 => 573,4460 => 405,17362 => 471,29 => 12,19013 => 686,1461 => 177,18849 => 626,16713 => 440,17388 => 476,17443 => 493…), StaticArrays.SArray{Tuple{3},Int64,1,3}[[0, 0, 0], [1, 0, 0], [2, 0, 0], [3, 0, 0], [4, 0, 0], [5, 0, 0], [-4, 0, 0], [-3, 0, 0], [-2, 0, 0], [-1, 0, 0]  …  [0, -1, -1], [1, -1, -1], [2, -1, -1], [3, -1, -1], [4, -1, -1], [-5, -1, -1], [-4, -1, -1], [-3, -1, -1], [-2, -1, -1], [-1, -1, -1]])
 Kpoint{Float64}(Model{Float64}([0.0 5.13 5.13; 5.13 0.0 5.13; 5.13 5.13 0.0], [-0.6123962287699403 0.6123962287699403 0.6123962287699403; 0.6123962287699403 -0.6123962287699403 0.6123962287699403; 0.6123962287699403 0.6123962287699403 -0.6123962287699403], 270.011394, 0.9186657265374463, 3, 8, :none, 1, 0.0, DFTK.Smearing.None(), Pair{Any,Array{StaticArrays.SArray{Tuple{3},Float64,1,3},1}}[ElementPsp(14, :Si, PspHgh(4, 0.44, [-7.33610297, 0.0, 0.0, 0.0], 1, [0.42273813, 0.48427842], [[5.90692831 -1.26189397; -1.26189397 3.25819622], [2.72701346]], "hgh/lda/si-q4", "Si GTH-PADE-q4 GTH-LDA-q4")) => [[0.125, 0.125, 0.125], [-0.125, -0.125, -0.125]]], Any[Kinetic(1), AtomicLocal(), AtomicNonlocal(), Ewald(), PspCorrection(), Hartree(1), Xc([:lda_xc_teter93], 1, nothing)], Tuple{StaticArrays.SArray{Tuple{3,3},Int64,2,9},StaticArrays.SArray{Tuple{3},Float64,1,3}}[([1 0 0; 0 1 0; 0 0 1], [0.0, 0.0, 0.0]), ([1 0 -1; 1 0 0; 1 -1 0], [0.0, 0.5, 0.0]), ([0 1 -1; 1 0 -1; 0 0 -1], [0.0, 0.0, 0.5]), ([0 1 0; 0 1 -1; -1 1 0], [0.5, 0.0, 0.0]), ([-1 0 0; -1 0 1; -1 1 0], [0.5, 0.0, 0.0]), ([0 -1 0; -1 0 0; 0 0 -1], [0.0, 0.0, 0.0]), ([0 -1 1; 0 -1 0; 1 -1 0], [0.0, 0.5, 0.0]), ([-1 0 1; 0 -1 1; 0 0 1], [0.0, 0.0, 0.5]), ([0 1 0; 0 0 1; 1 0 0], [0.0, 0.0, 0.0]), ([-1 1 0; 0 1 0; 0 1 -1], [0.0, 0.5, 0.0])  …  ([-1 0 1; 0 0 1; 0 -1 1], [0.0, 0.5, 0.0]), ([-1 1 0; -1 0 1; -1 0 0], [0.0, 0.0, 0.5]), ([0 0 -1; -1 0 0; 0 -1 0], [0.0, 0.0, 0.0]), ([0 1 -1; 0 0 -1; 1 0 -1], [0.0, 0.5, 0.0]), ([-1 1 0; 0 1 -1; 0 1 0], [0.0, 0.0, 0.5]), ([-1 0 0; -1 1 0; -1 0 1], [0.5, 0.0, 0.0]), ([0 0 1; 0 -1 1; -1 0 1], [0.5, 0.0, 0.0]), ([1 0 0; 0 0 1; 0 1 0], [0.0, 0.0, 0.0]), ([1 -1 0; 1 0 0; 1 0 -1], [0.0, 0.5, 0.0]), ([0 -1 1; 1 -1 0; 0 -1 0], [0.0, 0.0, 0.5])]), 1, [-0.375, -0.375, 0.125], [0.07654952859624253, 0.07654952859624253, -0.5358467001736977], [1, 2, 3, 4, 5, 6, 24, 25, 26, 27  …  19657, 19658, 19659, 19660, 19661, 19679, 19680, 19681, 19682, 19683], Dict(18201 => 570,4460 => 404,29 => 12,16062 => 423,19013 => 682,1461 => 179,18849 => 624,2351 => 305,16713 => 444,17388 => 479…), StaticArrays.SArray{Tuple{3},Int64,1,3}[[0, 0, 0], [1, 0, 0], [2, 0, 0], [3, 0, 0], [4, 0, 0], [5, 0, 0], [-4, 0, 0], [-3, 0, 0], [-2, 0, 0], [-1, 0, 0]  …  [0, -1, -1], [1, -1, -1], [2, -1, -1], [3, -1, -1], [4, -1, -1], [-5, -1, -1], [-4, -1, -1], [-3, -1, -1], [-2, -1, -1], [-1, -1, -1]])
 Kpoint{Float64}(Model{Float64}([0.0 5.13 5.13; 5.13 0.0 5.13; 5.13 5.13 0.0], [-0.6123962287699403 0.6123962287699403 0.6123962287699403; 0.6123962287699403 -0.6123962287699403 0.6123962287699403; 0.6123962287699403 0.6123962287699403 -0.6123962287699403], 270.011394, 0.9186657265374463, 3, 8, :none, 1, 0.0, DFTK.Smearing.None(), Pair{Any,Array{StaticArrays.SArray{Tuple{3},Float64,1,3},1}}[ElementPsp(14, :Si, PspHgh(4, 0.44, [-7.33610297, 0.0, 0.0, 0.0], 1, [0.42273813, 0.48427842], [[5.90692831 -1.26189397; -1.26189397 3.25819622], [2.72701346]], "hgh/lda/si-q4", "Si GTH-PADE-q4 GTH-LDA-q4")) => [[0.125, 0.125, 0.125], [-0.125, -0.125, -0.125]]], Any[Kinetic(1), AtomicLocal(), AtomicNonlocal(), Ewald(), PspCorrection(), Hartree(1), Xc([:lda_xc_teter93], 1, nothing)], Tuple{StaticArrays.SArray{Tuple{3,3},Int64,2,9},StaticArrays.SArray{Tuple{3},Float64,1,3}}[([1 0 0; 0 1 0; 0 0 1], [0.0, 0.0, 0.0]), ([1 0 -1; 1 0 0; 1 -1 0], [0.0, 0.5, 0.0]), ([0 1 -1; 1 0 -1; 0 0 -1], [0.0, 0.0, 0.5]), ([0 1 0; 0 1 -1; -1 1 0], [0.5, 0.0, 0.0]), ([-1 0 0; -1 0 1; -1 1 0], [0.5, 0.0, 0.0]), ([0 -1 0; -1 0 0; 0 0 -1], [0.0, 0.0, 0.0]), ([0 -1 1; 0 -1 0; 1 -1 0], [0.0, 0.5, 0.0]), ([-1 0 1; 0 -1 1; 0 0 1], [0.0, 0.0, 0.5]), ([0 1 0; 0 0 1; 1 0 0], [0.0, 0.0, 0.0]), ([-1 1 0; 0 1 0; 0 1 -1], [0.0, 0.5, 0.0])  …  ([-1 0 1; 0 0 1; 0 -1 1], [0.0, 0.5, 0.0]), ([-1 1 0; -1 0 1; -1 0 0], [0.0, 0.0, 0.5]), ([0 0 -1; -1 0 0; 0 -1 0], [0.0, 0.0, 0.0]), ([0 1 -1; 0 0 -1; 1 0 -1], [0.0, 0.5, 0.0]), ([-1 1 0; 0 1 -1; 0 1 0], [0.0, 0.0, 0.5]), ([-1 0 0; -1 1 0; -1 0 1], [0.5, 0.0, 0.0]), ([0 0 1; 0 -1 1; -1 0 1], [0.5, 0.0, 0.0]), ([1 0 0; 0 0 1; 0 1 0], [0.0, 0.0, 0.0]), ([1 -1 0; 1 0 0; 1 0 -1], [0.0, 0.5, 0.0]), ([0 -1 1; 1 -1 0; 0 -1 0], [0.0, 0.0, 0.5])]), 1, [0.375, 0.375, 0.375], [0.2296485857887276, 0.2296485857887276, 0.2296485857887276], [1, 2, 3, 4, 5, 6, 23, 24, 25, 26  …  19657, 19658, 19659, 19660, 19661, 19679, 19680, 19681, 19682, 19683], Dict(18201 => 582,17362 => 476,29 => 13,16062 => 412,19013 => 699,1461 => 183,18849 => 639,16713 => 440,17388 => 482,17443 => 499…), StaticArrays.SArray{Tuple{3},Int64,1,3}[[0, 0, 0], [1, 0, 0], [2, 0, 0], [3, 0, 0], [4, 0, 0], [5, 0, 0], [-5, 0, 0], [-4, 0, 0], [-3, 0, 0], [-2, 0, 0]  …  [0, -1, -1], [1, -1, -1], [2, -1, -1], [3, -1, -1], [4, -1, -1], [-5, -1, -1], [-4, -1, -1], [-3, -1, -1], [-2, -1, -1], [-1, -1, -1]])
 Kpoint{Float64}(Model{Float64}([0.0 5.13 5.13; 5.13 0.0 5.13; 5.13 5.13 0.0], [-0.6123962287699403 0.6123962287699403 0.6123962287699403; 0.6123962287699403 -0.6123962287699403 0.6123962287699403; 0.6123962287699403 0.6123962287699403 -0.6123962287699403], 270.011394, 0.9186657265374463, 3, 8, :none, 1, 0.0, DFTK.Smearing.None(), Pair{Any,Array{StaticArrays.SArray{Tuple{3},Float64,1,3},1}}[ElementPsp(14, :Si, PspHgh(4, 0.44, [-7.33610297, 0.0, 0.0, 0.0], 1, [0.42273813, 0.48427842], [[5.90692831 -1.26189397; -1.26189397 3.25819622], [2.72701346]], "hgh/lda/si-q4", "Si GTH-PADE-q4 GTH-LDA-q4")) => [[0.125, 0.125, 0.125], [-0.125, -0.125, -0.125]]], Any[Kinetic(1), AtomicLocal(), AtomicNonlocal(), Ewald(), PspCorrection(), Hartree(1), Xc([:lda_xc_teter93], 1, nothing)], Tuple{StaticArrays.SArray{Tuple{3,3},Int64,2,9},StaticArrays.SArray{Tuple{3},Float64,1,3}}[([1 0 0; 0 1 0; 0 0 1], [0.0, 0.0, 0.0]), ([1 0 -1; 1 0 0; 1 -1 0], [0.0, 0.5, 0.0]), ([0 1 -1; 1 0 -1; 0 0 -1], [0.0, 0.0, 0.5]), ([0 1 0; 0 1 -1; -1 1 0], [0.5, 0.0, 0.0]), ([-1 0 0; -1 0 1; -1 1 0], [0.5, 0.0, 0.0]), ([0 -1 0; -1 0 0; 0 0 -1], [0.0, 0.0, 0.0]), ([0 -1 1; 0 -1 0; 1 -1 0], [0.0, 0.5, 0.0]), ([-1 0 1; 0 -1 1; 0 0 1], [0.0, 0.0, 0.5]), ([0 1 0; 0 0 1; 1 0 0], [0.0, 0.0, 0.0]), ([-1 1 0; 0 1 0; 0 1 -1], [0.0, 0.5, 0.0])  …  ([-1 0 1; 0 0 1; 0 -1 1], [0.0, 0.5, 0.0]), ([-1 1 0; -1 0 1; -1 0 0], [0.0, 0.0, 0.5]), ([0 0 -1; -1 0 0; 0 -1 0], [0.0, 0.0, 0.0]), ([0 1 -1; 0 0 -1; 1 0 -1], [0.0, 0.5, 0.0]), ([-1 1 0; 0 1 -1; 0 1 0], [0.0, 0.0, 0.5]), ([-1 0 0; -1 1 0; -1 0 1], [0.5, 0.0, 0.0]), ([0 0 1; 0 -1 1; -1 0 1], [0.5, 0.0, 0.0]), ([1 0 0; 0 0 1; 0 1 0], [0.0, 0.0, 0.0]), ([1 -1 0; 1 0 0; 1 0 -1], [0.0, 0.5, 0.0]), ([0 -1 1; 1 -1 0; 0 -1 0], [0.0, 0.0, 0.5])]), 1, [-0.375, 0.375, 0.375], [0.6889457573661828, -0.2296485857887276, -0.2296485857887276], [1, 2, 3, 4, 5, 6, 24, 25, 26, 27  …  19658, 19659, 19660, 19661, 19662, 19679, 19680, 19681, 19682, 19683], Dict(18201 => 565,17362 => 463,29 => 12,19013 => 680,1461 => 175,18849 => 621,16713 => 429,17388 => 468,17443 => 484,16011 => 399…), StaticArrays.SArray{Tuple{3},Int64,1,3}[[0, 0, 0], [1, 0, 0], [2, 0, 0], [3, 0, 0], [4, 0, 0], [5, 0, 0], [-4, 0, 0], [-3, 0, 0], [-2, 0, 0], [-1, 0, 0]  …  [1, -1, -1], [2, -1, -1], [3, -1, -1], [4, -1, -1], [5, -1, -1], [-5, -1, -1], [-4, -1, -1], [-3, -1, -1], [-2, -1, -1], [-1, -1, -1]])

The $G$ vectors of the "spherical", $k$-dependent grid can be obtained with G_vectors:

[length(G_vectors(kpoint)) for kpoint in basis.kpoints]
10-element Array{Int64,1}:
 743
 748
 753
 757
 751
 748
 747
 747
 763
 744
ik = 1
G_vectors(basis.kpoints[ik])[1:4]
4-element Array{StaticArrays.SArray{Tuple{3},Int64,1,3},1}:
 [0, 0, 0]
 [1, 0, 0]
 [2, 0, 0]
 [3, 0, 0]

The list of $G$ vectors (Fourier modes) of the "cubic", $k$-independent basis set can be obtained similarly with G_vectors(basis).

length(G_vectors(basis)), prod(basis.fft_size)
(19683, 19683)
collect(G_vectors(basis))[1:4]
4-element Array{StaticArrays.SArray{Tuple{3},Int64,1,3},1}:
 [0, 0, 0]
 [1, 0, 0]
 [2, 0, 0]
 [3, 0, 0]

Analogously the list of $r$ vectors (real-space grid) can be obtained with r_vectors(basis):

length(r_vectors(basis))
19683
collect(r_vectors(basis))[1:4]
4-element Array{StaticArrays.SArray{Tuple{3},Float64,1,3},1}:
 [0.0, 0.0, 0.0]
 [0.037037037037037035, 0.0, 0.0]
 [0.07407407407407407, 0.0, 0.0]
 [0.1111111111111111, 0.0, 0.0]

Accessing Bloch waves and densities

Wavefunctions are stored in an array scfres.ψ as ψ[ik][iG, iband] where ik is the index of the kpoint (in basis.kpoints), iG is the index of the plane wave (in G_vectors(basis.kpoints[ik])) and iband is the index of the band. Densities are usually stored in a special type, RealFourierArray, from which the representation in real and reciprocal space can be accessed using ρ.real and ρ.fourier respectively.

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.ρ.real[:, 1, 1], label="", xlabel="x", ylabel="ρ", marker=2)
G_energies = [sum(abs2.(model.recip_lattice * G)) ./ 2 for G in G_vectors(basis)][:]
scatter(G_energies, abs.(scfres.ρ.fourier[:]);
        yscale=:log10, ylims=(1e-12, 1), label="", xlabel="Energy", ylabel="|ρ|^2")