The simulation of unsteady cavitating flows with external perturbations