Many modern electric train locomotives have the option of regenerative braking. Most of these locos have HVAC power transmission. I'm wondering, when they brake in regenerative mode do they actually generate DC (I'm not sure whether modern electric locos prefer DC motors or AC motors or is the choice still open), then invert it to the right AC frequency, then match the frequency / phase on the fly precisely to the grid & then transmit power back? Sounds like a lot of work especially if you factor in the large power loads involved e.g. a typical electric locomotive can easily exceed 8000 hP though I'm not sure how large the max regenerative braking load can be. Anyone know?