Electromechanical theory of microelectromechanical devices