Making it work!
Hello everyone! I’m back (albeit quite late) to tell you a bit more about the project the I and @ioanniss have been working on. In my previous post, I gave a rough outline of the project, and what our task was, now I will go in a bit more detail.
Within the project we are tasked with modifying an implementation of the Hartree-Fock algorithm, written by Noga and Šimunek . In the simplest words, the Hartree-Fock algorithm give us an approximation of the ground state wave function, and energy of a molecule. The implementation by Noga and Šimunek  provides a new way of obtaining the solution, by removing the step of diagonalizing the Fock matrix. This has the affect of speeding up the calculation since, for linearly scaling methods and/or parallelization, the diagonalization is an unwanted step . Thus the diagonalization is replaced by a matrix-matrix multiplication. One of the matricies involved in this multiplication is the electron density matrix, which for larger systems can be classified as a sparse matrix. Therefore, a natural step in further speeding up the algorithm, would be replacing the matrix-matrix multiplication, with a sparse matrix-dense matrix multiplication.
The first step in solving this problem was getting acquainted with Fortran, which I haven’t used before. This was followed by a prolonged search of an implementation of the sparse matrix-dense matrix multiplication in Fortran. After a few weeks of unsuccessfully trying different implementations of the Sparse BLAS library, we stumbled upon a StackOverflow post which contained a working copy of Sparse BLAS for Fortran. The Sparse BLAS library contained the multiplication algorithm we were searching for. Replacing the matrix multiplication was quite an easy step. We had to replace this
with, (side a few matrix allocations, the spare matrix creation and a few matrix transpositions) a function that looks like this:
Very exciting, right? This step was pretty straight forward. We had a lot more difficulties understanding the intricacies of the code that preforms the calculations. We had a hard time understanding the myriad of parameters and functions involved at each step. Eventually we managed to arrive at a working code, that contained the mutliplication function from the Sparse BLAS library. We used a methane molecule to see is the code is even working, and after that we started looking at other molecules. We use 5 different alkenes: C6H14, C12H26, C18H38, C24H50, C30H62, C36H74 and a molecule called methotrexate (C20H22N8O5), which is shown in Fig 1.
Fig 1. Methotrexate (C20H22N8O5).
In my next post I will tell you how we used these molecules to test the performance of the new code, and how we compared it to the original code. I also plan to have a retrospective look at what was like taking part in Summer of HPC and what was like working in a team in a “home office” setup. Good luck to everyone for the final presentation!
 Jozef Noga, Ján Šimunek, J. Chem. Theory Comput. 2010, 6, 9, 2706–2713