Analytical modeling of a permanent-magnet synchronous machine in a flywheel