Update the energy calculation