Sloop v. Xebec

It’s been many years since I read Master and Commander, but I distinctly remember the battle between Lucky Jack Aubrey, newly made Commander of a sloop (was it called Sophie yet?) and an Ottoman xebec far larger and more capable. I need to read those books again!
But I never knew upon whom this story was based, and today, pretty much randomly, I stumbled across the Wiki entry for Thomas Cochrane, clearly one of the inspirations for Aubrey.,_10th_Earl_of_Dundonald