Energy density of a quantum mechanical ensemble

How do we determine the energy density of a given system? I have seen that the density operator

$$\rho~=~\frac{\exp(-\beta \hat{H})}{\text{tr}(\exp(-\beta \hat{H}))}.$$

What does this mean exactly and how does it relate to the pure and unpolarized states of a system? For example, given a system of relativistic spin-1/2 particles, the completely unpolarized beam density is $\sigma~=~\frac{1}{2} \left| \uparrow\right>\left<\uparrow \right|+\frac{1}{2} \left| \downarrow\right>\left<\downarrow \right|$ or

$$\sigma~=~\left( \begin{array}{cc} \frac{1}{2} & 0 \\ 0 & \frac{1}{2} \end{array} \right)$$

Are the diagonal elements the probabilities that within the ensemble a particular particle will be found to be in that spin state? If so, how does this affect the energy density of the system? I am not entirely sure what the Hamiltonian would be in this case. But I think that spin-up and spin-down are eigenstates with eigenvalues $\lambda_{\pm}=\pm \frac{\hbar}{2}$, so as a guess, since we are talking about spin-projections, that the energy eigenvalues are going to be proportional to $\lambda_{\pm}$

$$\displaystyle \rho~=~\frac{1}{\text{e}^{-\frac{\beta\hbar}{2}} + \text{e}^{\frac{\beta\hbar}{2}}} \left( \begin{array}{cc} \text{e}^{\frac{\beta\hbar}{2}} & 0 \\ 0 & \text{e}^{-\frac{\beta\hbar}{2}} \end{array} \right)$$

where $\beta$ is the inverse of temperature given by $\beta=\frac{1}{kT}$, however I am not sure what the constant of proportionality will be since I am assuming that the Hamiltonian will be proportional to $\sigma_z$ and not equal to it.

Would it be possible to see an example or have an explanation of what is happening? I am referring to Sakurai's Modern Quantum Mechanics and Quantum Mechanics by Bransden and Joachain.

Yeah, the example $\sigma=\frac{1}{2} \left | \uparrow \right \rangle \langle \uparrow|+\frac{1}{2} \left | \downarrow \right \rangle \langle \downarrow|$ you give describes a completely unpolarized ensemble for single spin-$1/2$ system, and the coefficients $1/2$ definitely represent the probabilities for the particle be in either up or down spin state.Now I will explain the meaning of the density operator $\rho =exp(-\beta H)/Z—(1)$ where $Z\equiv tr(exp(-\beta H))$ and its application to the single spin-$1/2$ system including its connections to the pure and unpolarized states.

Generally speaking, eqn(1) is the density operator for an equilibrium system $H$, its physical meaning becomes more clear if we rewrite it as $\rho =\frac{exp(-\beta E_1)}{Z}\left | 1 \right \rangle \langle 1|+\frac{exp(-\beta E_2)}{Z}\left | 2 \right \rangle \langle 2|+...$(you can prove this formula by yourself), where $\left | n \right \rangle$ are normalized energy eigenstates of $H$ with eigenvalues $E_n$. Here the coefficients $\frac{exp(-\beta E_n)}{Z}$ give the probabilities of the system being in state $\left | n \right \rangle$.

Now consider two extreme cases which are physically important:

(1)Low temperature limit$(\beta\rightarrow\infty)$ , $\rho =\frac{1}{D}\left | 1 \right \rangle \langle 1|+\frac{1}{D}\left | 2 \right \rangle \langle 2|+...+\frac{1}{D}\left | D \right \rangle \langle D|$, where $\left | 1 \right \rangle,\left | 2 \right \rangle,...,\left | D \right \rangle$ are the $D$ degenerate groundstates of $H$.

(2) High temperature limit$(\beta\rightarrow0)$, $\rho =\frac{1}{d}\left | 1 \right \rangle \langle 1|+\frac{1}{d}\left | 2 \right \rangle \langle 2|+...+\frac{1}{d}\left | d\right \rangle \langle d|$, where $d$ is the dimension of the system's Hilbert space, $\left | 1 \right \rangle,\left | 2 \right \rangle,...,\left | d \right \rangle$ are the energy eigenstates.

Now apply the above formulas to your example, let $H=\sigma_z$ be the Hamiltonian of the single spin-$1/2$ system. Then its energy eigenstates are just $\left | \uparrow \right \rangle$ and $\left | \downarrow \right \rangle$, its groundstate is simply $\left | \downarrow \right \rangle$(so here $d=2,D=1$). So for low temperature limit , we have $\rho= \left | \downarrow \right \rangle \langle \downarrow|$ (pure state you mentioned); and for high temperature limit, we have $\rho=\frac{1}{2} \left | \uparrow \right \rangle \langle \uparrow|+\frac{1}{2} \left | \downarrow \right \rangle \langle \downarrow|$(completely unpolarized states you mentioned).

Hope my answer is useful for you.