There are two methods that I know of; quantitative or qualitative. The former involves all sort of MTF charts and physics, while the latter means just shooting a bunch of images at different apertures and focal lengths (if it's a zoom) until that 'something special' shows up. I couldn't tell you how the first one works and I'll bet you've been working on the second. That's my personal method. And a whole bunch of fun to boot... I look for sharpness (200% blowups in PS), contrast, and color rendition to make my decision. YMMV.
For my Nikkor 180mm f/2.8 prime, that happens to be f/4.0. The 85mm f/1.4 has the biggest sweet spot I've ever seen from f/2.0 to f/8. At least to my eyes
