Previously we didn't consider the effect the way spin interacts with the magnetic field
Here we will use a classical analogy to add a ad-hoc term
๐ผ Case: Consider the magnetic moment of a spinning charge $\vec \mu$ with a magnetic field $H=-\vec \mu \cdot \vec B$
๐งฝ Assume: spin magnetic momentum
$$ \hat{\vec \mu} = -g_e \frac{e}{2m} \hat{\vec S}=-\frac{e}{m} \hat {\vec S} $$
where we take the electron $g$-factor to be $g_e=2$
From there we get the following Hamiltonian operator
$$ \hat H_\text{magnetic}= \frac{e}{m} \vec B \cdot \hat{\vec S} = \mu_B \vec B \cdot \vec \sigma $$
For a homogeneous magnetic field oriented along the $z$-direction we have
$$ \hat H_\text{magnetic} = \frac{2}{\hbar} \mu_B B \hat S_z=\mu_B B \sigma_z= \begin{bmatrix} \mu_B B & 0 \\ 0 & - \mu_B B \end{bmatrix} $$
Where we chose the gauge $\vec A= (0, Bx,0)$
We can use our Previous Hamiltonian and add the new term which gives
$$ \hat H= \frac{1}{2m} \left [ \hat p_x^2 + q^2 B^2 \left ( x-\frac{\hbar k_y}{qB}\right )^2+\hbar ^2 k^2_z\right ]+\frac{2}{\hbar} \mu_B B \hat S_z $$
We have $[\hat H,\hat S_z]=0$ thus they share an eigenstate $\chi$ which we write as
$$ \hat S_z\chi = \pm \frac{\hbar}{2} \chi $$
Now since $[\hat H,\hat S_z]=0$ our previous analysis still holds and we just get an extra term
$$ E_{n,k_y}=\hbar \omega_c \left ( n+ \frac 12 \right )+\frac{\hbar ^2 k^2_z}{2m} \pm \mu_B B \qquad \forall n \in \N $$
๐ผ Case: We introduce spinors to describe spatial and spin degree of freedom of a spin-$\frac 12$ particle
Consider the eigenstate of $\hat S_z$ defined by
$$ \hat S_z \chi = \frac{\hbar}{2} \begin{bmatrix} 1 & 0 \\ 0 & -1 \end{bmatrix}\chi = \epsilon \chi $$
<aside> ๐ฌ
Eigenspinorโs: We define both the spin up $\chi^+_z$ and down $\chi^-_z$ for a spin-$\frac 12$ particle
$$ \chi_z^+ = \begin{pmatrix} 1 \\ 0 \end{pmatrix} \qquad \chi_z^- = \begin{pmatrix} 0 \\ 1 \end{pmatrix} $$
with energy $\epsilon = \hbar /2$ and $\epsilon =-\hbar/2$ respectively
We can also look at the $\hat S_x$ and $\hat S_y$ which give
$$ \begin{aligned} \chi^+_x &=\frac{1}{\sqrt{2}} \begin{pmatrix} 1 \\ 1 \end{pmatrix} \quad & \quad \chi^-_x &=\frac{1}{\sqrt{2}} \begin{pmatrix} 1 \\ -1 \end{pmatrix} \\ \chi^+_y &=\frac{1}{\sqrt{2}} \begin{pmatrix} 1 \\ i \end{pmatrix} \quad & \quad \chi^-_y &=\frac{1}{\sqrt{2}} \begin{pmatrix} 1 \\ -i \end{pmatrix} \end{aligned} $$
</aside>
For an arbitrary state we write the wavefunction in a two-component spinor form as
$$ \psi(\vec r,t)=\begin{pmatrix} \psi_2(\vec r,t) \\ \psi_2(\vec r,t) \end{pmatrix}\qquad \ket{\psi}=\ket{\psi_1} \otimes \ket{\chi^+_z} + \ket{\psi_2}\otimes \ket{\chi^-_z} $$
Such that we have
$$ \braket{\vec r |\psi}=\psi_1 (\vec r,t)\ket{\chi^+ _z}+ \psi_2(\vec r,t)\ket{\chi^-_z} $$
๐๏ธ Note: if the spin decouples from the spatial motion we can ignore the spin degree of freedom
๐ Example: we can write our Hamiltonian as follows
$$ \hat H = \begin{bmatrix} \hat{\vec p}^2 /2m & 0 \\ 0 & \hat p^2 /2m \end{bmatrix}=\frac{\hat{\vec p}^2}{2m}I_2 $$
where $I_2$ is the two dimensional identity matrix
Now we can rewrite this as
$$ \hat H=\frac{\hat{\vec p}^2}{2m}I_2=\frac{\hat{\vec p}^2 I_2+i\vec\sigma \cdot ( \hat{\vec p} \times \hat{\vec p})}{2m}I_2=\frac{(\vec \sigma \cdot \hat{\vec p})^2}{2m}I_2 $$
We now perform a minimal-coupling substitution (i.e. replace $\hat {\vec p}\to \hat {\vec p}-q\vec A$)
$$ \hat H =\frac{(\vec \sigma \cdot ( \hat {\vec p}-q\vec A))^2}{2m }=\frac{(\hat{\vec p}-q\vec A)^2}{2m}I_2+\frac{i}{2m}\vec \sigma \cdot [(\hat{\vec p}-q\vec A)\times(\hat{\vec p}-q\vec A) ] $$
We can look at the cross section with itself giving
$$ \begin{aligned} [(\hat{\vec p }-q\vec A )\times (\hat{\vec p }-q\vec A )]\psi & =-q[\hat{\vec p} \times ( \vec A\psi) + \vec A \times (\hat{\vec p}\psi)] \\ &=i\hbar q [\vec \nabla \times (\vec A \psi) +\vec A \times \vec \nabla \psi)] \\ &=i\hbar q [\psi \vec \nabla \times \vec A +\vec \nabla \psi \times \vec A + \vec A\times (\vec \nabla \psi)] \\ &=i\hbar q [\psi\vec \nabla \times \vec A-\vec A \times ( \vec \nabla \psi )+\vec A \times (\vec \nabla \psi)]\\ &=i\hbar q\psi \vec B
\end{aligned} $$
for an arbitrary scalar $\psi$ we can thus sub this in to get
$$ \boxed{\hat H =\frac{(\hat{\vec p}-q\vec A(\hat{\vec r},t))^2}{2m}I_2-\frac{\hbar q}{2m}\vec \sigma \cdot \vec B(\hat{\vec r},t)} $$
๐ Example: we can write it for an electron which has $q=-e$ to give
$$ \hat H =\frac{(\hat{\vec p}+e\vec A(\hat{\vec r},t))^2}{2m}I_2-\mu_B\vec \sigma \cdot \vec B(\hat{\vec r},t) $$
๐๏ธ Note: the right hand side is still a matrix due to $\vec \sigma$ being a vector of $2\times 2$ matrices