I've been aksing myself, when I try to variationally minimize a Hartree-Fock energy by using the Roothan equations, what I do is to set a Fock-Matrix, then transform it, then diagonalize it so I can read the energy from the diagonal elements and then I test for convergence. But why is usually the density matrix compared to the previous run and not just the sum of the diagonal elements? I know in the end they both have to be evaluated but just for testing for any changes, pretty much any parameter, which changes with the Fock-Matrix and has some relationship with the energy could be used as a criteria for convergence. Or where do I see something wrong here?
When doing the SCF calculation taking the RMSD of the density matrix compared to taking the RMSD of the diagonal of the density matrix takes about the same with respect to the total calculation time. The comparrison of the density matrices is not the time consuming step in the SCF calcultion. When you take the RMSD of the total density matrix you also "keep an eye" on the off diagonal elements, this is a more rigid test for convergence.
In your implementation, you may do whatever you wish. I have (successfully) used the change in total energy to detect convergence in my very first Hartree-Fock SCF.
In more involved projects, the root mean square deviation (RMSD, compared to the previous iteration) or other measures that take the whole density matrix into account are often used because these quantities are easily accessible or even necessary for the convergence speedup procedures that are in place, such as extrapolating the density matrix, direct inversion of iterative space (DIIS) and its variants etc.