Confusion of spin-orbit coupling in Hydrogen atom

I'm learning the fine structure of hydrogen and feel a little confused about the spin-orbit coupling term in the hamiltonian. The corrected hamiltonian is:

$$H = \frac{\vec{P}^2}{2m}+ V(R)-\frac{\vec{P}^4}{8m^3 c^2} + \frac{1}{2m^2c^2}\frac{1}{R}\frac{dV(R)}{dR}\vec{L}\cdot\vec{S}$$

Where the last term is spin-orbit coupling.

Both in Griffiths and Cohen-Tannoudji's textbook, they say SOC is due to "In the electron frame, the proton is circling around it. This orbiting positive charge sets up a magnetic field $$\vec{B}$$ which exerts a torque on the spinning electron." Thus should add $$H_{SOC} = -\vec{\mu_e}\cdot\vec{B}$$ in the hamiltonian.

So this $$H_{SOC}$$ is derived in the electron frame, where electron can feel magnetic field of proton. But the kinetic energy terms in the original hamiltonian are definitely not in the electron frame, because in the electron frame we should have $$p_e = 0$$ and $$\frac{\vec{P_e}^2}{2m} = 0$$.

Why we can just combine the hamiltonian from two different frames together and say it is the correct hamiltonian？In different frames we should have different energy(i.e. different hamiltonian), isn't it?

It is necessary to ensure that all the terms in the Hamiltonian correspond to the same coordinate system, but you will need to examine all reference frames to make sure that your Hamiltonian incorporates effects that are not obvious/easy to calculate in the reference frame you choose. Spin orbit coupling can be evaluated by working only in the frame of the proton, but that is considerably more difficult.

The conversion of $$\vec{\mu}\times\mathbf{B}$$ to the form in the combined Hamiltonian incorporates the requirement that we work in a single inertial (at least to a good approximation) coordinate system. The discussion of the case where the nucleus is rotating around the electron is used simply to motivate the argument for the form of $$\mathbf{B}$$. In the two different pictures (i.e. the stationary electron case and the stationary proton case), the velocity of the moving charged particle and the electric field are the same upto a minus sign in the expression for the magnetic field $$\mathbf{B}=-\frac{\mathbf{v}\times\mathbf{E}}{c^2}.$$ Thus, the magnetic field experienced by the electron in the moving electron model is the same as the magnetic field experienced by the electron in the moving proton model (that phrasing should make the argument seem obvious).

In other words, since the magnetic field is a frame-dependent quantity, when we write $$\mathbf{B} = \frac{2\mu_B}{\hbar m_e e c^2}\frac{1}{r}\frac{\partial U(r)}{\partial r} \mathbf{L},$$ (where coordinates refer to the proton's rest frame) we are not talking about a static magnetic field in the rest frame of the proton (since that doesn't exist), but the magnetic field experienced by the electron, expressed in coordinates corresponding to the proton's rest frame.

I believe that spin-orbit coupling is very badly discussed in text books, for precisely the reason that you describe. The spin-orbit Hamiltonian you quote is the sum of two terms, an electron-field interaction, and a Thomas term which is not elecromagnetic in origin at all, which happens to be -1/2 as big, so that the resultant is 1/2 of the electromagnetic term.

In the electron rest frame it has a magnetic dipole moment, but, as you correctly point out, we are working in the atom centre of mass frame. In this frame it also has a magnetic moment, but in Hydrogen there is no magnetic field (neglecting hyperfine effects), so that's not relevant. However there is also an electric dipole, given by $$\mathbf{v}\times\mu/c^2$$. This has the usual $$-\mathbf{d}\cdot\mathbf{E}$$ interaction with an electric field $$\mathbf{E}$$.

The Thomas term is an extra energy for an accelerating spin $$\mathbf{s}$$ of $$\mathbf{a}\times\mathbf{v}\cdot\mathbf{s}/2c^2$$. If you put the acceleration $$\mathbf{a}$$ equal to $$-e\mathbf{E}/m$$, and the magnetic moment equal to $$-ge\mathbf{s}/2m$$, then you find the sum simply replaces $$g$$ by $$g-1$$, Since $$g$$ is approximately 2 this looks like a factor of half, and textbooks give the impression it somehow is a factor of a half deriving from the Lorentz transformation between the two frames, which it is not.

In nuclei, where the dominant acceleration of nucleons is not electromagnetic in origin, the two terms are very different in size, with the Thomas term dominant. This is why the spin-orbit interaction in nuclei is 'inverted'.