This is a no-brainer.
The XXI is almost immune to depth charges and it can conduct 100% submerged attacks due to its stunning underwater speed. It can attack with all 6 tubes at once. It can attack without periscope from 50m depth.
The IXD2 is slow underwater, slow to dive, does not always have a snorkel and can not attack convoys above 6knts without running the diesel motors.
Are you using the deck gun in 1945? That's crazy!