Calculation of heat generated by battery discharge