Numerical analysis of brushless permanent magnet motors using Lagrange multiplier