The 'Automation' script which you can start and which will move your sub at flank speed and doing a serie of random zig-zags does a really good job, the gun crew is constantly firing and not too much disturbed by the sub's movements. If you are reasonably close, the crew will hit fairly often, and you are not limited to only let the script do the job, you can pause it, making hard turns and resume the script
But I don't know how well it works with rough sea (if it works at all), I have to test it in a special single mission.