The hamiltonian representing spin-orbit interaction is

${\begin{aligned}&{\hat {H}}_{SO}={\frac {1}{2mc^{2}}}\sum _{i}{\hat {{\vec {S}}_{i}}}{\hat {{\vec {L}}_{i}}}{\frac {1}{r_{i}}}{\frac {\partial {\hat {V}}\left(r_{i}\right)}{\partial r_{i}}}\\&{\hat {V}}\left(r\right)={\frac {-Ze^{2}}{4\pi \epsilon _{0}r}}+{\hat {V}}_{H}\left(r\right)\end{aligned}}$

We can treat ${\hat {H}}_{SO}$ as a perturbation to ${\hat {H}}_{H.F}$.
If we're not dealing with other perturbation of the same order ( which means spin-orbit corrections are the leading ones), we simply have to find a basis which is able to diagonalize ${\hat {H}}_{SO}$ and ${\hat {H}}_{H.F}$ simultaneously. That basis is $\left|n_{i},l_{i},j_{i},m_{j_{i}}\right\rangle$, where ${\hat {{\vec {J}}_{i}}}={\hat {{\vec {L}}_{i}}}+{\hat {{\vec {S}}_{i}}}$ represent the total angular momentum of each electron. We can pass from the previous basis to the new one through Clebsch-Gordan coefficients:

$\left|n_{i},l_{i},j_{i},m_{j_{i}}\right\rangle =\sum _{m_{l_{i}},m_{s_{i}}}\underbrace {\left(\dots \right)} _{\mbox{ Clebsch-Gordan}}\left|n_{i},l_{i},m_{l_{i}},m_{s_{i}}\right\rangle$

The mathematical need for this basis represents the physical fact that when spin-orbit interaction becomes strong (in heavy atoms, $Z\geq 40$), each orbital angular momentum tends to couple with its own spin:${\hat {{\vec {J}}_{i}}}={\hat {{\vec {L}}_{i}}}+{\hat {{\vec {S}}_{i}}}$. The ${\hat {{\vec {J}}_{i}}}$ then combines to give the total ${\hat {\vec {J}}}=\sum _{i}{\hat {{\vec {J}}_{i}}}$ (*jj coupling*)

Individual spin orbitals are now labeled with the new good quantum numbers:

$[n][l]_{[j]}$

The effect of spin-orbit coupling consists in a partial removal of degeneracy according to $j-$value:

$\left\langle {\hat {H}}_{SO}\right\rangle =E^{\left(1\right)}\left(\{n_{i},l_{i}\},j_{i}\right)$

For example

$2p$ level, characterized by

$l=1,s={\frac {1}{2}}$, is split in

$2p_{\frac {1}{2}}2p_{\frac {3}{2}}$.

If we want to fill $2p$ level with electrons we simply have to add an apix $\alpha$ representing the occupation number. After placing all the electrons in the jj levels compute the possible values of the total J: $\left(nl_{j}^{\alpha }n'l_{j'}^{'\alpha '}\dots \right)_{J_{1},J_{2},\dots }$

When we take into account non-spherical corrections on these states $m_{j_{i}}$ is no longer a good quantum number and we need to label states with $\left|\{n_{i},l_{i},j_{i}\},J,M_{J}\right\rangle$. Degeneracy of configurations with same $J$ is removed:

$\left\langle \{n_{i},l_{i},j_{i}\},J,M_{J}\left|{\hat {H}}_{1}\right|\{n_{i},l_{i},j_{i}\},J,M_{J}\right\rangle =E\left(\{n_{i},l_{i},j_{i}\},J\right)$

Each configuration with different value of

$J$ has now different energy. The lowest energy configuration is given by

Hund's third rule ^{[1]}
- $[n][l]_{[j]}$ can have a maximum of $2j+1$ electrons
- If a level $[n][l]$, which can contain $2\left(2l+1\right)$ electrons is split in $[n][l]_{[j_{1}]},[n][l]_{[j_{2}]}$ the equality $2\left(2l+1\right)=\left(2j_{1}+1\right)+\left(2j_{2}+1\right)$ must hold. For example $2p$ level is split in $2p_{\frac {1}{2}}2p_{\frac {3}{2}}$ and we have $2\left(2\cdot 1+1\right)=6=\underbrace {\left(2\cdot {\frac {1}{2}}+1\right)} _{=2}+\underbrace {\left(2\cdot {\frac {3}{2}}+1\right)} _{=4}$

- ↑ For a detailed discussion about how to find atomic terms read JJ scheme