Function for calculating kinetic energy
Adds calculatePotentialEnergy for uppg4