modified for loops in simple pairwise potential to reduce cache misses