I often studied 14-16 hour days for a solid year when doing my final exams in Oxford University. These are the things that kept me sane, happy, and motivated. You can do this. You already have the ability within you because you are asking this question. With these tips you will be unstoppable.
Exercise - Every day get your blood flowing. It's cliché for a reason: healthy body, healthy mind. 20 minutes a day is good enough. Go for a walk in the morning whilst listening to something that motivates you (but unrelated to work). When I studied in Oxford, I routinely pulled 14 hour days (often 16 hour days) for a year straight. I lifted weights at the end of every day.
Sunlight and fresh air - Don't get cabin fever. Supplement with vitamin D but also make sure you breathe in fresh air and see the sun regularly.
Diet - A diet rich in good fats will keep your mind lubricated. Try coconut oil (a teaspoon every day to begin with, then up the dose). Also try MCT-oil. Eat fish, nuts, fruits, vegetables. Limit refined sugars/grains/dairy. Have a dessert but have it at nighttime because the carbohydrates will help you sleep well. Bananas are great to eat before bed because they contain tryptophan which will boost the serotonin in your brain (the chemical that makes you happy and motivated). Eat light during the day. If you can fast in the morning, that will be great for concentration. Digestion slows you down.
Coffee + Tea - Get yourself a really good quality coffee and some great green tea. I recommend matcha, genmaicha, and gyokuro for green tea (you can't go wrong with the Japanese stuff). Have a cup of coffee and a cup of green tea beside you whilst you study and sip them. The coffee has caffeine, which keeps you alert, and the green tea has l-theanine, which keeps you relaxed and happy. This combination is fantastic. The green tea stops you from getting coffee jitters. David's Tea has a wonderful selection:
The Matcha Shop | DAVIDsTEA
Pomodoro Technique - Work in bursts. Set a timer for 25 minutes and do nothing but concentrate on work. Then have a 5 minute break where you do whatever you want. Watch something funny on YouTube, walk around, play with your dog. Here's a time I used: Tomato Timer. You can sustain long bouts of work by doing this. This will also make sure that you absorb most of what you study. Seriously, after 25 minutes of studying, your brain needs a break or you're going to be ineffective.
Olympic Athlete Mindset - Tell yourself that you're training for the academic gold. Keep yourself fit, healthy, happy, and focused. Make this your purpose. There's nothing depressing about living your purpose. You can do this! This is your mission.
Smart Drugs - Adaptogens like ashwaghanda, rhodiola rosea, and bacopa are all excellent at improving your memory, motivation, and stamina.
Meditation/Stretching/Yoga/Pranayama - Learn to quiet the mind. Read The Power of Now by Eckhart Tolle and listen to his guided meditations on YouTube. Go for walks and just focus on your breathing, don't indulge your thoughts, and notice things around you. You will be sitting down for long periods of time so make sure you have a good stretching/yoga routine. I followed this 30 day challenge whilst I studied in my final year in Oxford:
Relax Every Day - This is important. You have to switch off your mind at the end of the day for your own sanity. Relaxation time is important because that is the time where your mind consolidates all the information you fed it during the day. Protect 'You Time' and give yourself at least 2 hours to relax. Go see friends, talk with your family, watch a movie, read a book, take a hot bath (or contrast shower). Do whatever you need to do to feel normal again. Doing social stuff is a great idea because you don't want to spend too much time in your head.
Keep a To-Do List and Diary - Every Sunday, write out what you will do over the week. And every day before bed, write out and review what you will do the next day. Then tick off everything as you do it. This will give you a little burst of motivation and happiness because you will feel a sense of achievement every day. Write on paper. There is something therapeutic about getting away from a computer screen and organising your thoughts.
Good luck to you! You can do it! Focus on the present, look after yourself, do everything you can, and you will be fine!