Calculation of the residual capacity