How do I open port 51413 for Transmission?

It could very well be your ISP blocking it. Try a different port, and see if you can find any info on the web about your ISP restricting incoming traffic or BitTorrent traffic.

When troubleshooting ufw, you should just disable it temporarily to ensure it's not the problem.