Cogeneration of mechanical energy