calculation of consumed energy