Modeling and simulation of electric machines, converters and systems