Reducing vortex density in superconductors using the ratchet effect