Electromagnetic modeling and control of switched reluctance motor using finite elements