minor optimisation of dip-dip energy

This is a slightly optimized version. Did I mess it up?