Hi na-taya,
Humans are diurnal creatures, hard wired to be awake during the day, and asleep at night. This daily cycling is circadian rhythm. At dusk, and with cooling temperatures, our biological clocks signal our endocrine system to secrete sleep-inducing hormones into our systems, such as melatonin. Sleep then cycles in ultradian fashion: stages 1,2,3, and REM (rapid eye movement), every 90-120 minutes until waking, usually 6-8 hours or more in adults. With dawn, the increasing light and rising temperatures signal the endocrine changes to promote waking.
In sleep, the brain engages a complex process of maintenance. During non-REM sleep, hormones are released, which promote physical healing and repair of damaged tissues, and promote growth of new tissue where needed. In REM, the dream stage, the brain processes, organizes, and stores information, making sense of the vast amount of "data" we receive both consciously and unconsciously during wake.
This all gets screwed up by stress. The stress of pain is a big interrupter of the sleep-wake cycle. Another is emotional stress. Of course there are many other interrupters, including environmental adversity, for instance too much light, heat, noise, etc. in the sleeping room. There are numerous sleep disorders which totally ruin sleep.
Sleep hygiene is one thing you can control. Make sure that your sleep environment is comfortably cool and dark, and free of intrusive stimuli such as a radio or TV on in the room, an illuminated clock at the bedside, a cell phone, a pet (or pets) or a restless bed partner in bed with you. Aromatherapy can be ok, as long as the scent is not strong. Music therapy can be ok too, as long as it is quiet and soothing. White noise generators are ok, and may be helpful in masking intrusive outside noises. As much as possible, make your bed time consistent every night. This sets your biological clock, and attunes your circadian rhythm to enter the sleep cycle at the appropriate time.
The conscious process of getting to sleep tends to be ritualistic, and may be highly ritualistic. Rituals provide cues to the subconscious that it is time to sleep. Brushing teeth, reading a book, listening to calming music, having a small cup of non-caffeinated tea (no alcohol nitecap), saying prayers or meditating (counting sheep or counting blessings), fluffing (or subtly scenting) the pillow, etc. etc. all can engage the unconscious (autonomic nervous system) processes which initiate sleep.
If our circadian rhythm is sufficiently disrupted, it can be very difficult to reestablish it, as in jet lag. This is a circadian rhythm disorder, and while our tendency is to be diurnal, resetting our clocks to their normal sleep-wake pattern once the brain has been thrown off its pace, and can result in it having a hard time getting it back.
Chronic sleep deprivation, it is well known, has significant negative effects on our cognitive and emotional function (i.e. anxiety and depression), and is commonly used as a torture method.
If pain is the issue, medical pain control may be required. Consult your physician for an appropriate prescription. Few people can sleep through pain, unless they are so exhausted that the virtually pass out.
If the stress is psychological, the question has to be asked: Is the sleep being inhibited by the anxiety/depression? Or, is the anxiety/depression the result of insufficient sleep? A psychiatrist worth his/her salt will evaluate an individual who presents with depression for a sleep disorder before prescribing drugs. If anxiety and/or PTSD is the issue, a comprehensive program of integrated therapies may be needed before normal sleep can be obtained.
When sleep-aid medication is appropriate for its calming effect, the minimum dose is the best practice. Taking the prescribed medication at the specific time each night, and engaging the normal bedtime ritual(s), should do two things: 1, establish the circadian sleep initiation cycle, and 2, insure that sleep will occur. An effective medication should facilitate 4-6 hours of sleep. If you wake before you are fully rested, and can't get back to sleep again within 20 minutes or so, get up. Don't lie abed awake and frustrated. Turn on the lights, get up and find a way to engage your mind. If you get drowsy later, take a snooze if you think you can sleep another 2 hours or so. If not, stay up until the next evening's bed time, and repeat. You may find that four hours plus a two hour nap may be the best combination initially. This should morph into 6+/- hours of continuous sleep, once you have retrained your brain.
Don't be dismayed at only four hours of sleep. This will likely represent two good non-REM periods, and two good REM periods, and while not satisfying, particularly if you have been sleep deprived for a long time, this is very beneficial, and vastly better than no sleep. Stay with your prescribed program. You may find that you can reduce the med dosage.
Hope this helps...
"Sleep, that knits the ravelled sleeve of care." Wm Shakespeare