I have found that one of the best places for me to do my writing and generally get work done is in the library. There are a variety of reasons for this. For one, I am taken from the distractions of my main computer at home, which I have associated in my mind with listening to music, endlessly surfing the internet, watching all sorts of videos on YouTube and gaming.
Knowing this of myself, I have dedicated my laptop to work. Now, whenever I turn it on, I actually do get work done. Perhaps it is my association with my devices that gets me into a particularly frame of mind, which brings me to believe that:
Thoughts lead to actions, actions to habits and habits back to thoughts.
As I carry out certain habits, the inherent thoughts behind them are repeated from when the habit first formed. It is my belief that this reinforces the habit and vice versa until it becomes so simple for me to just fall back on what I am already familiar with.
Now, when I turn my main computer on, I automatically open my web browser before anything else. After that, depending on the mood, I may put on some music or play a video or movie. It is done so fluently that I hardly even need to think about it. It has come to a point where, if the icon for the web browser has somehow moved, as it has done before, I click the exact same spot, accidentally opening a different program.
Instead of forcing a change in habit, I simply turn on my laptop, which I have habitually taught myself to use for work. Without the distractions of easily accessible distractions, I get much more done.
Another reason for using the library is that it allows me access to a vast cache of information in a format that I enjoy in an environment where I am comfortable but not so comfortable that I may decide to just take a nap and waste the day away.
I also read somewhere that having shoes on helps keep the brain active. I have no idea why this is but, perhaps, it is the association our brains have made since our childhood that we wear shoes when we are out studying/working and not when we are comfortably lounging at home.
So my advice on this:
1) Dedicate a space purely for work and another for recreation.
2) Dedicate a device for work if possible. Otherwise, create a user profile in your computer that only has access to the basic things you need to get work done.
3) Find a time when you are most productive. For me, I am a night person and am usually more productive in the evenings than in the mornings and afternoons.
4) Be just comfortable, not so much that you doze off.
5) Stay hydrated. Lack of water can make you sleepy.