General Analytical Modeling for Magnet Demagnetization in Surface Mounted Permanent Magnet Machines