# Calculating first and second derivatives of a molecular Hamiltonian?

I'm interested in computing first and second derivatives of molecular Hamiltonians with respect to nuclear coordinates. I've been using Psi4 and PySCF to perform Hartree-Fock calculations, and I was wondering if there is any way to use these packages (or similar Python packages) to compute first and second derivatives analytically, by solving the coupled-perturbed Hartree-Fock equations?

• +1 and welcome to our new community! Thank you for contributing your question here and we hope to see much more of you in the future! Jun 15, 2021 at 19:23
• Thank you @NikeDattani! Jun 15, 2021 at 19:24

## 1 Answer

The derivatives of a molecular Hamiltonian with respect to nuclear coordinates can be performed analytically (as you correctly pointed out), and therefore does not need PySCF or Psi4, which are programs for doing numerical calculations for things that cannot be done analytically. This is how it's done:

\begin{align} H &= -\sum_{i}\frac{1}{2}\nabla_{i}^{2}-\sum_{i,A}\frac{Z_{A}}{\left|r_{i}-R_{A}\right|}+\sum_{A>B}\frac{Z_{A}Z_{B}}{\left|R_{A}-R_{B}\right|}+\sum_{i>j}\frac{1}{r_{ij}},\tag{1}\\ \frac{\partial H}{\partial R} &= \sum_{i,A}\frac{Z_{A}}{\left|r_{i}-R_{A}\right|^{2}}-\sum_{A>B}\frac{Z_{A}Z_{B}}{R^{2}}. \tag{2} \end{align}

More interesting is how to calculate derivatives of the energy or wavefunction. It can be done for the energy via the misappropriately named Hellmann-Feynman theorem, but often electronic structure programs prefer to do it in other ways. A lot of detail can be written about derivatives in electronic structure programs (for example, about linear response theory), depending on what your specific final goal is, so while the answer to "how to analytically calculate derivatives of a molecular Hamiltonian" has been given in Eq. 2 above, you might consider asking a new question with more details about the specific end goal in your project.

• Thank you for the reply! I probably should have been more precise: I am actually interested in computing the derivative of the Hamiltonian obtained from Hartree-Fock. I'm currently updating the question to provide more details. Jun 15, 2021 at 19:46
• @JackCeroni I think a new question would be more appropriate for that! You can provide a link to this one in the new question! Jun 15, 2021 at 19:47
• Ok, sounds good. Thanks! Jun 15, 2021 at 19:48