7
$\begingroup$

I am trying to understand the computational expense of calculating only the energy, versus the gradient/Hessian of the DFT energy with respect to nuclear coordinates. How do these scale with the size of the system $N$ in the $O(N^p) $ notation?

I have tried to find this in Frank Jensen's Intro to Computational Chemistry, and in papers, but I could not find any reference where these are provided. (I am currently working on a project where I have to compare the timings of these three things on the same systems - and I need to know what is the theoretical scaling).

$\endgroup$
4
  • $\begingroup$ I gave +1 but the cost of calculating DFT energies is easy to find on Google, it's not clear what you mean by N (for example whether it's the number of electrons, number of atoms, number of basis functions, or a combination of two of these), and it's not clear whether you want automatic, analytic, or numerical derivatives, and most importantly, we ask that everyone ask one question per post, so ideally the question would be focused on gradients or Hessians but not both. $\endgroup$ Commented Jul 10 at 13:18
  • $\begingroup$ @NikeDattani-NoFreeTime I didn't explicitly write analytic because that's what most QM packages default to - so I thought it would be obvious. I edited the questions to clarify what my actual question was. I don't see the point of rolling back. I come to the forum to get answers to my questions and if there is a miscommunication somewhere I try to clarify the question. $\endgroup$
    – S R Maiti
    Commented Jul 11 at 14:40
  • $\begingroup$ @NikeDattani-NoFreeTime Now you are not letting me edit the question, because you wrote an answer that does not actually answer my question. I am honestly shocked to see this kind of heavy-handed behaviour. It is certainly not encouraging me to engage in this community more. $\endgroup$
    – S R Maiti
    Commented Jul 11 at 14:44
  • $\begingroup$ I'm treating this case in exactly the same way as every other case in which someone edits a question after it has been answered. It might be hard to see the value of such a policy when your own question and desires go against it, but it's a policy widely supported (and you'll see not just me, but others also rolling back questions when they see edits made after an answer was written). I'm not removing the part in my answer about numerical derivatives, and neither should the question be changed to make that part irrelevant. The part about basis sets and atoms completely changes the question. $\endgroup$ Commented Jul 11 at 16:10

1 Answer 1

5
$\begingroup$

Energies

An excellent answer to this question was provided here, and arose immediately with this Google search.

Numerical gradients

Derivatives of energies with respect to a nuclear coordinate can be calculated numerically by calculating two energies, then calculating the difference between them and dividing the result by the difference in the nuclear coordinate values. This means that the cost of doing a derivative calculation, is only two times the cost of doing an energy calculation, and therefore does not change the power $p$ in the $O(N^p)$ notation, in which $N$ is basically the number of electrons (see the first link that I provided for more details about what $N$ is). This procedure will be repeated many times if you have a lot of nuclear coordinates and want the gradient, and if you want to try different "finite difference" sizes and seek convergence with respect to that parameter, but this does not affect the $O(N^p)$ cost based on the way that you asked the question, with basically the number of electrons being the "size of the system". If you want the $O(N^p M^q)$ cost, in which $N$ is basically the number of electrons and $M$ is the number of nuclear coordinates, then it's a different question, which we can also answer if you post that question next.

Numerical Hessians

If you use one of the formulas for "second order" derivatives found here, then the cost becomes "three times" the original cost, rather than "two times" the original cost, so everything that I said about the power not changing for gradients, is also true for Hessians.

Analytic and automatic derivatives

If you want analytic derivatives, it might cost a bit more than just "two times" or "three times" the original cost, but the advantages over the above-described numerical derivatives, would be that you don't have to do the above procedure for each nuclear coordinate change, and you don't have to repeat the calculation for different "finite difference" step sizes in order to get numerical convergence. The power is unlikely to change though, and certainly the power wouldn't change if you were to use automatic derivatives.

Conclusion

If you plot the cost of the energy, gradient, and Hessian calculations with respect to the cube of the number of electrons, you will theoretically get three straight lines with different slopes, which indicates that the $O(N^p)$ cost is the same for these three types of calculations, but the pre-factors that are hidden under the $O()$ are different. Practically (not theoretically), you would have to take into account the details that were explained in the first link that I provided.

$\endgroup$
14
  • $\begingroup$ For analytic gradients, I agree, but for analytic Hessians the scaling (without using low order scaling tricks) is $O(N^pM)$, because one has to solve a CPHF equation with $O(M)$ right hand side (RHS) vectors. Solving the CPHF equation for a constant number of RHS vectors scales the same as SCF itself, but it also scales linearly with the number of RHS vectors. With complicated tricks it is possible to get rid of the $M$ factor (see doi.org/10.1063/1.4908131), but this usually requires $p$ to be first reduced to 1 or 2 from the original value of 3, which is already complicated. $\endgroup$
    – wzkchem5
    Commented Jul 7 at 12:32
  • $\begingroup$ @wzkchem5 what is M? In my answer it was the number of nuclear coordinates, in which case the scaling with respect to N is still the same whether you are calculating energies, gradients or Hessians. $\endgroup$ Commented Jul 7 at 17:43
  • $\begingroup$ In my answer the definition of $M$ is the same as in your post. Now I understand you may mean the power of $N$, not the total power of $M$ and $N$. I was in the mindset of the quantum chemistry community, where (when the basis set size per atom is held fixed) it is assumed that $M$ scales linearly with $N$ and one tends to talk about their total power. $\endgroup$
    – wzkchem5
    Commented Jul 7 at 18:18
  • $\begingroup$ @wzkchem5 I don't think it's fair to say that the whole quantum chemistry community assumes that M scales linearly with N, because so much work is on dinuclear, trinuclear, and other small polynuclear molecules. I think the biggest molecule in the GW100 dataset has 16 nuclei, and the enormous GMTKN30 dataset which is composed of many smaller and widely used datasets, also doesn't have very big molecules. Even if M=500, if we assume that they are all carbon, then we have N=3000 electrons (linear scaling but with a prefactor of 6). I'm curious to see any reference that combines M and N! $\endgroup$ Commented Jul 8 at 0:46
  • $\begingroup$ I have to agree with wzchem5, I want to know the total power including the pre-factor of N (considering the same basis set but different number of atoms). Maybe the question was not clear - I will edit it. $\endgroup$
    – S R Maiti
    Commented Jul 9 at 14:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .