When I'm failing to feel motivated or keep focused, I generally stop myself and instead ask myself why that might be: have I been getting enough sleep/exercise/socialization/etc? And I generally find my problem lies there, and then I can try to correct for it in the future (get to bed earlier, eat healthier, exercise more, etc).
If I'm still not feeling it after making corrections, then it's time to ask myself if what I'm doing is something that I really want to be doing? It's always disappointing when the answer is that it's not something I really want to be doing (sunk-cost), _but_ I've found walking away is better than continuing to beat myself up over a lack of motivation.
It's like the dash readout in hybrid cars showing you when you're burning more gas-- there are times when certain maneuvers call for maxxing it out, but mostly you want to stay in the 'eco' zone. Otherwise you're not only wasting fuel, but prematurely aging your engine.
From a macro perspective though I've gradually come to the view that the average amount of work a man can get done if he's really trying is more or less the same. You might see someone else able to work non stop but that might be because he's doing mindless repetitive tasks. For things requiring more brainpower it's impossible to run 100%. You also get to a point where physical quirks might be the limiting factor. I've had a few times times where I've forced myself to push on with something, pulling all nigjters and what not, and suffered physical and mental burnout consequently which averages out the "productive" period before. Consequently I've taken on a more zen approach to pushing myself, try my best but don't overdo it cause sometimes it might backfire.