dharam44
Please clarify the concept
"coffee was drunk by her in order to stay awake." is incorrect sentence.
When we have a modifier like "in order to stay awake," we have an adverbial modifier that modifies the action described.
So what is the action? Was drunk.
OK, who or what engaged in that action?
The coffee.
So, your example sentence conveys the following illogical meaning.
Coffee was drunk in order to stay awake.
Did the coffee want to stay awake? No.
Adding "by her" doesn't solve the problem. Adding "by her" just gives you a reason to make the mistake of thinking that the sentence makes sense.