PhD studies can be very different. Wet-lab students who do experiments can spend 12 hours a day in a lab cutting mice. But that’s somewhat mechanical work where you repeat the protocol. PhD students are also less experienced and spend a lot of time making mistakes and learning. When I got my fist full-time developer job I spent day and night working as well. After 5-7 years, I was something like the author because I could do non-trivial tasks quickly. It felt like the code was writing itself in the back of my mind while I was drinking coffee or browsing HN.
When I was building the physical apparatus itself and plumbing it up, I was working 70 hour weeks because it was more or less mindless physical labor.
When I was writing software to operate the experiment or analyze data, I settled into more of a few hours a day of deep work pattern. Part of that might be the nature of science; after I implemented an idea, it might be hours before the experiment fully responded to my changes or the computers finished crunching numbers. And I needed that feedback to inform what I'd do next.
Writing my dissertation was somewhere in the middle. The actual writing required focus, but a lot of it was tracking down references or making figures, which required some thought but not too deep. That's probably the closest I came to a 40 hour week.
Based on other replies, it sounds like other people have experienced similar relationships of the nature of the work to their capacity to do it.
5 - 10 hours of deep work per week required to get a Phd from Imperial. That's impressive.