Design of electrical machines