A rapid method for determining rate constants by molecular dynamics