Verlet buffer calculation slow due to O(N^2) operations
For systems with many different atom types the Verlet buffer calculation code can become very slow, up to many minutes, see https://gromacs.bioexcel.eu/t/the-issue-of-slow-tpr-generation-speed-and-slow-running-simulation-speed-of-15-million-atoms-system/7357
There are two issues: One is finding all the different atom types. This is an O(#atoms_in_molecule_types * #verlet_atom_types) operation. This can be changed to O(#atoms_in_molecule_types) by using std::unordered_map. The drift calculation itself is O(#verlet_atom_types^2). Here the number of types can be reduced for cases with many types by storing properties, in particular the charges, with limited precision.