Numerical calculation of a.c. losses