# Are there any full worked examples of DFT calculations?

I just started learning DFT and now I am totally confused.

Assuming I want to use B3LYP: \begin{align} v_s\left(\textbf{r}\right) &= v_\text{ext}\left(\textbf{r}\right) + \int d^3r\frac{n\left( \textbf{r}\right) }{\left|\textbf{r} - \textbf{r}^\prime\right|} + v_{\text{XC}}\left[ n \right]\left(\textbf{r}\right)\\ v_{\text{XC}}\left( r \right) &= \frac{\delta E_\text{XC}}{\delta n \left(\textbf{r}\right) }\\ \end{align}

I know that we use B3LYP for approximation of $v_{\text{XC}}$ - but I have no idea about how - and then we use some basis sets to run an SCF calculation to minimize the energy. I downloaded a bunch of articles and bought some books and read them, but all of them give very detailed discussion about all the basics (e.g. what a functional is, or Kohn and Sham theorem, etc.), but no one talks about how to use them.

I am looking for a reading material or video that explains all the calculation, step by step, for example, some material that shows all the calculations for a CO molecule, from the beginning to the end of the SCF calculation.

• So, I repeat it one more time: you are not even supposed to understand how DFT calculations are done step by step. There are scientists who basically spent all their scientific carrier to understand it. And they share their knowledge with everyone else not only by means of scientific papers, but also in a form of ready to use programs. Thus, for everyone else, the question is how to properly and efficiently use a program, and not how it works under the hood. – Wildcat Jul 26 '14 at 7:37
• Do not get me wrong. You can (and even should) understand what is going in under the hood, at least at some basic level: you need to know what this whole business about SCF is, how DFT works in principle, what are the main differences between functionals and basis sets. But understanding how DFT calculations are done step by step is far away from these fundamentals, and it will require a lot of time. – Wildcat Jul 26 '14 at 7:42
• Here is a related question chemistry.stackexchange.com/questions/8140/…. Pay attention to the last sentence in @Aesin answer, which basically says that "you should really make sure you have a scientific justification for doing this". – Wildcat Jul 26 '14 at 12:24
• When you are talking about light absorption, then you are basically talking about excited states calculations. Not a good job for DFT in the first place. So you will have to switch to the time dependent Schrödinger equation. There are some handy codes available, like TDDFT and CIS and the most powerful and time consuming CASPT2. It is still a very active field of research and only applying some of these methods might sometimes need a lot of time. (I have studied computational chemistry now for more than five years and my comprehension of CASPT2 is quite limited.) – Martin - マーチン Jul 28 '14 at 4:00
• I'm erring on the side of what @Wildcat said. Unless you're someone who does well jumping into the thick of things and working your way out, I'd suggest beginning with the fundamentals and work your way toward the center. This means building a solid foundation on QM theory, the Hartree-Fock approximation and the SCF procedure. Once you've mastered this, then moving onto the Kohn-Sham SCF equations would be the next logical step. (See: journals.aps.org/archive/abstract/10.1103/PhysRev.140.A1133) Also, most everything you need to know about SCF is in Szabo & Ostlund. – LordStryker Jul 28 '14 at 12:32

The XC potential for DFT actually consists of two terms: $V_x$ and $V_c$. Depending on which XC functional you choose, the exchange part is either computed exactly (using Hartree-Fock) or using fitted parameters or in a combination of both. In the case of B3LYP the exchange is 20% Hartree + 8% Slater + 72% Becke88. The correlation functional consists of three (3) different terms (LYP) in a different form. If you take a different functional, say M06-2X, it has different functional type (54% Hartree exchange, 200+ parameters!).

Coming to the next part: You use a basis set only to compute the kinetic energy and exchange terms in the system. Let me walk you through a HF routine first:

The Hamiltonian consists of four terms(nuclear kinetic energy is zero because of Born-Oppenheimer Approximation) : $T_{elec} + V_{nn} + V_{en} + V_{ee}$. The nuclear-nuclear potential energy is constant (because they are 'clamped'). The first and third terms are fairly trivial, and are computed with relative ease. The electron-electron potential term consists of Pauli's exchange term, and the coulomb repulsion term. They are the computationally expensive part of the HF calculation, and the eigenvalues (energies) are solved self-consistently.

So, when you obtain the HF energy of a system, it is obtained variationally with respect to all the energy components in an interacting system of electrons and nuclei. Coming to DFT:

The first term you mentioned $V_{ext}$ is the external potential, which is usually the nuclear potential for an unperturbed system. The second term is equivalent to Coulomb repulsion. The third term is evaluated using the XC potential of your choice(every DFT method differs only at this part). You evaluate the energies for each and every orbital using the effective potential $V_s$ which you mentioned. Note: You evaluate energies for every orbital separately.

This is because of the KS theorem that equates the density created by non-interacting particles to be the same as that of interacting particles. So, we solve Kohn-Sham equation instead of Schrodinger equation, under a constraint that the sum of square of all the orbitals gives the density:

$$\rho(\mathbf r)=\sum_i^N |\phi_{i}(\mathbf r)|^2$$

This means that the energy computed using DFT is minimum with respect to a non-interacting system of electrons. This is the biggest assumption of DFT, which is quite valid too. As a result, DFT provides a good account of correlation energy at a very minimal computational expense (HF accounts for ZERO correlation)!!!

I took a computational chemistry course, where DFT was a small part, so I am not able to explain more in detail. I used Prof. Kieron Burke's ABC of DFT book, which he has uploaded online in his site for free use. It is a good source to start. There is also a video lecture of Prof. David Sherrill on Youtube: https://www.youtube.com/watch?v=5orzn-XA29M .

I missed the last question: For any molecule:

1. Compute the kinetic energy (using the KE functional)
2. Compute the external potential ($V_{ext}$)
3. Compute the Coulomb repulsion using an initial guess density ($n(r)$)
4. Compute the XC potential from the XC functional
5. Use Kohn Sham equations to find out orbital energies (under the constraint that the density ($n(r)$) is equal to the density of interacting particles (electrons). In this case, the density must be equal to the total number of electrons.
6. Using the newly obtained density, recompute the effective potential ($V_s$)
7. Perform until self-consistency is achieved. Then total energy is the sum of occupied orbital energies times the occupancy number.

Hope this helps!

• (HF accounts for ZERO correlation) This is wrong. HF accounts for Exchange Correlation, exactly. It therefore accounts for almost all correlation energy. This is also a reason why it is used in Hybrid functionals. But otherwise, this is probably as close as you can get for this kind of question. (I am out of votes, but I will come back and give you the thumbs up. Please change the statement I referred to, though.) [It would also be nice if you could add the link to Burkes webpage.] – Martin - マーチン Jul 30 '14 at 5:33
• @user3786990 The equation you give is sloppy at best even if it is touted by nearly everyone. Martin is correct that HF accounts for exchange correlation (between electrons of parallel spin). This business that HF accounts for ZERO correlation is completely false but CONVENIENT to say. – LordStryker Jul 30 '14 at 21:04
• @LordStryker : I agree with your statement. I should have said ZERO correlation between electrons of opposite spin. But for all practical purposes, we worry about the correlation that is not accounted for, and we call this correlation energy as the correlation energy, as we try to reach the exact limit, isn't it? I should also point that Martin said "HF accounts for Exchange Correlation, exactly", and hence I gave my comment. Thanks for pointing my mistake. My bad. – user3786990 Jul 30 '14 at 23:02
• There is a confusion here due to the crap nomenclature: correlation energy is per definition the energy difference between the HF limit and non-relativistic Schrodinger solution. This is how it was defined by Lowdin! Therefore per definition HF contains zero of it. On the other hand, DFT theory loves to talk about exchange-correlation which is exchange AND correlation. In hybrid functionals, we use the exchange from HF. – Greg Aug 11 '14 at 12:14
• @Greg This is untrue. Löwdin referred to correlation effects as for all electrons independent of spin. He continued "The exchange energy will therefore take care of a rather large part of the original correlation energy, referring to particles with parallel spins." journals.aps.org/pr/pdf/10.1103/PhysRev.97.1509 However, the IUPAC rules in your favour with a rather sloppy definition of the correlation energy. – Martin - マーチン Aug 25 '14 at 7:25

To actually perform calculations technically speaking you don't really need all this stuff. You need them to able to read papers, design scientifically sound research, understand what the input parameters mean and discuss your results, but not for the manual part of the labor. There are several + 1 commercial and free software are available which does these things for you as those are mentioned in the very useful comments. If you find an unscratched itch to add some energy term that is not in the software and you don't know how, it is kind of a sure sign you don't know what you are doing. It may sound harsh, but the truth is that you need to understand much more about the calculations before you can just add terms here and there, and at that level you will be able to use the developer version of those programs anyway.

It is a funny side effect of education: generally QChem is taught by people who develop code, who talk all day about HF theory and numerical details, but mostly used by students who does not need to develop code, but use already existing programs. You come out from the lecture, learnt all those equations, you think you need to use somewhere, but the cold truth is that you have to open a window an click-click here and there or open a textfile and put some cryptic switches. At manual level, QChem calculations are much more about know-how and experience than writing equations.

• This doesn't really answer the question, unfortunately. – jonsca Jul 29 '14 at 8:15
• Could you add a bit more to it regarding the actual problem the OP is facing? – jonsca Jul 29 '14 at 8:16
• Speaking of QChem, the OP should browse the QChem manual which is packed full of incredibly helpful theoretical background on nearly every method the program implements. Find it here: hogwarts.usc.edu/~krylov/manual.pdf Density functional theory starts on page 75. – LordStryker Jul 29 '14 at 14:14
• OK, I reiterate it: the OPs question seems to based on a misunderstanding. This misunderstanding is that an actual calculation is a very involved process where someone actually have to touch those equations. It is not. For calculations like optimizing CO, he shouldn't read more papers or textbooks, he need to read the manual or a tutorial of the qchem software of his choice. E.g. if he choose to use Gaussian, "Exploring Chemistry with Electronic Structure Methods" is a good tutorial which will tell him to write "#p B3LYP/6-311G opt" or similar to a file and done. – Greg Jul 29 '14 at 15:14

It sounds like you are a lot like me and have to do the work of solving every part of a problem before you feel like you understand it. Actually putting numbers in the equations instead of just looking at them.

Unfortunately, I have not found any fully worked examples on Quantum Chemical DFT. However, I would highly recommend the book by Szabo and Ostlund "Modern Quantum Chemistry: Introduction to Advanced Electronic Structure Theory". They go through full calculations using self consistent Hartree Fock theory. They not only provide the equations, but get this, they actually put numbers in the matrices so you can figure out if you are doing the linear algebra and integrals correctly!!! If you really want to understand QC calculations this is a great book to have. I built a QC engine for two hydrogen atoms using this book. If you would like my notes I would be more than happy to share them with you, or anyone else for that matter.

Once you have Hartree Fock and the self consistent field approach down, I do not believe there is a huge leap to DFT. Though I have to admit I have not yet built a DFT engine.