Modeling and simulation of electromechanical systems