Reaction coordinate optimization in python