Reference frame theory and its application for modeling of electric machines