Method of calculating energy losses in distribution networks