Add energy and derivatives computation.
comparap and comedge compute the energy, and dr, dvi, dvj compute
the derivatives. testd tests all the derivatives.