What to do when a professor gives an undeserved D to a PhD Student?
I would advise her to discuss this with her advisor. Do not push the "unethical behavior" idea. Instead, focus on two points:


She does not understand the reasons for the D.
She is concerned about the consequences for her funding etc.


All the better if the advisor is close to the professor who gave the D. It makes the advisor a better potential advocate. No professor likes to have a PhD student fail - it makes them look bad.