Molecular dynamics with constraints