This page provides a small example problem, which is not exactly electronic structure theory, but that structurally resembles the challenges we will face in density-functional theory (DFT). The tasks are deliberately formulated in a very open fashion to give you the flexibility to tackle them in a form you feel comfortable with.
A large part of the exercise is to implement a discretisation and solution procedure for the problem discussed below. Please keep an eye on writing your code in a readable and understandable fashion as I will not manage to spend a lot of time looking at it. Ideally the code should be unit tested and work beyond the scenario we are considering here, but for the sake of this exercise this is optional as you likely won't have enough time for this.
Both your code as well as your reasoning during the exercise will be discussed in the interview. Don't worry if you don't manage to complete the full exercise. The idea is that you spend a couple of hours on this, such that we have a basis for discussion and I get an idea how you approach such a problem.
It is completely natural when getting into a new topic to get stuck somewhere. I very much encourage you to send me an email with questions if this is the case.
In this example we will deal with the numerical modelling of the (time-independent) Gross-Pitaevskii equation (GPE). The GPE is simpler than DFT, but since it still displays interesting behaviour, which makes it a favourite model of applied mathematicians, that study electronic structure problems. Of note the GPE itself has physical significance as well: it is a mean-field model for bosonic systems.
In one dimension the GPE reads in atomic units:
where is the effective one-particle bosonic wave function, provides the strength of the boson-boson coupling. The application of the external potential is point-wise (in real space), i.e.
Of note is an eigenvector-dependent operator. Overall the GPE is thus a non-linear eigenvalue problem, where we seek the lowest eigenvalue and associated eigenfunction .
In this example we will consider external potentials of the form
i.e. the sum of two inverted Gaussians plus a confining parabola. Due to the confinement decays exponentially as .
Consider the setting , , , , , and find the corresponding and (lowest eigenpair of ) numerically. You can use any discretisation method and programming language of your choice. Ensure that your method converges to at least digits.
The remainder of this task description is basically some hints that help you to achieve this in one particularly simple way. You don't have to follow any of this and in fact there are plenty of better methods out there, which you are welcome to follow if you want.
Tip on the algorithm: Since this is a non-linear eigenvalue problem you will need another iterative procedure around the actual diagonalisation to find the eigenfunction . Since the phase of the eigenvectors is ill-defined, it is usually more convenient to iterate on the bosonic density instead of the eigenfunction . One approach we will consider here is the self-consistent field (SCF) procedure, which is a fixed-point method.
It can be implemented as follows:
Assume that at the -th iteration we have a good guess density . For just take the zero vector.
From this we can build a corresponding and diagonalise it to find its lowest eigenfunction, which we call . From we obtain .
Typically a good next iterate is , i.e. we perform damped fixed-point iterations. For GPE usually a very small is needed (e.g. between and ).
Convergence is achieved if and or respectively if the subsequent first eigenvalues and do not differ significantly any more. The desired eigenpair is then . Usually on the order of iterations in the outer loop are required.
Tip on the implementation: If you are unsure how to set up and discretise the problem, you can take a look at the DFTK code developed in our group. It uses plane waves and periodic boundary conditions, see this introduction in the documentation. As a result of this you will put the GPE problem above into a large box with artificial periodic boundary conditions, see this example for details. Don't forget to converge wrt. the box size. Custom potentials (like the two Gaussians) are discussed in this example. Once you have constructed a PlaneWaveBasis
object, you can easily obtain a representation of the discretised Hamiltonian at given bosonic density ρ
by constructing a Hamiltonian
object, e.g.
# Make sure to use kgrid=(1,1,1) when setting up the PlaneWaveBasis
basis = PlaneWaveBasis( #= ... more arguments ... =#, kgrid=(1,1,1) )
ρ = zeros(basis.fft_size..., 1)
H = Hamiltonian(basis; ρ=ρ).blocks[1] # [1] Select 1st (and only) k-Point
The resulting Hamiltonian object H
can be directly passed to an eigensolver as it supports e.g. the *
operator to perform a matrix-vector product. E.g. here we use an LOBPCG built into DFTK to find the smallest 3 eigenpairs starting from a random guess:
X = randn(ComplexF64, size(H, 2), 3) # ramdom guess
prec = PreconditionerTPA(H.basis, H.kpoint) # Setup preconditioner
# Solve and get eigenpairs back
(; λ, X) = lobpcg_hyper(H, X; prec, tol=1e-6, maxiter=300)
It is generally a good idea to use the eigenvectors X
from a previous SCF step as an initial guess to save on the number of required iterations of the diagonalisation procedure.
Note that DFTK has a self_consistent_field
function to do a (more sophisticated) SCF. You can use it for testing, but I would still ask you to code up your own SCF as part of this exercise.
Once your numerical SCF scheme from the previous section is up and running, play with the model's parameters, in particular and the Gaussian parameters , , and . For each parameter choice first run the SCF to obtain the solution and then investigate the total potential , the density as well as the five lowest eigenvalues of the GPE operator . How do the eigenvalues depend on your parameter choices?
For and find values for the Gaussian parameters such that the gaps between the first three eigenvalues have a ratio of . In other words if we denote the lowest eigenvalues of by , then we desire
Tip: One solution can be obtained by restricting , and .