Thermal analysis of electrical machines