I am following a propaedeutic course in quantum mechanics, and we did some basics of statistical mechanics deriving the Boltzmann equation for energy:
$$n_i=\frac{N}{Z}g_i e^\frac{-E_i}{kT}$$
where $n_i$ is the number of particles with $E_i$, $Z$ is the partition function, and $g_i$ is the multiplicity.
From that equation, we derived that the average energy is:
$$\bar E=kT^2\frac{d}{dT}(\log Z)$$
Some lessons later, we are now doing Rayleigh-Jeans model for the black body, and we said that the electrons on the walls of the black body are modelled as 1-dimensional harmonic oscillators, so, for the equipartition theorem, the average kinetic energy is $\frac{1}{1}kT$, the average potential energy is $\frac{1}{1}kT$, and the total energy is $kT$.
After that, our professor told us this can be derived also from statistical mechanic, because
$$p(E)=\frac{e^\frac{-E_i}{kT}}{kT}$$
where kT is the normalization factor, and, by definition of average:
$$\bar E=\int_{0}^\infty Ep(E)dE=kT$$
But now I am confused: where did the factor $\frac{N}{Z}g_i$ go? And therefore, where did the factor $\frac{d}{dT}(\log Z)$ go when calculating $\langle E\rangle$?
Energy Statistical Mechanics – Deriving the Relationship: ?E? = kT Where k is the Boltzmann Constant
energystatistical mechanics
Best Answer
Probably, part of the explanation passed unnoticed, or it was missing. The formula $$ p(E)=\frac{e^{-\frac{E}{kT}}}{kT} \tag{1} $$ has not the same validity as the general probability of finding the system in a state of energy $E$ in a canonical ensemble, which can be obtained from your formula for $n_i$ dividing by $N$.
However, once one has justified the use of the partition function for a set of non-interacting one-dimensional harmonic oscillators$^*$, formula ($1$) is the correct energy distribution for the $1D$ harmonic oscillator, the energy density of states is a constant (it does not depend on $E$). Therefore, if $g_i=constant$, the probability is proportional to $e^{-\frac{E}{kT}}$, and the normalization factor of the density distribution in energy is $\frac{1}{kT}$. If we evaluate the partition function of a classical harmonic oscillator in $1D$, we find $$ Z=\frac{kT}{\hbar \omega}, \tag{2} $$ differing from the previous normalization by an energy factor $\hbar \omega$, necessary for dimensional reasons (the probability density of states in the phase space is dimensionless, while the probability density of energy has the dimension of inverse energy). In any case, a partition function depending linearly on $T$ is all we need to get the average energy equal to $kT$.
Summarizing, equation $(1)$ is valid only for the $1D$ classical harmonic oscillator. However, the final result $\left< E \right>= kT$, is a special case of the equipartition theorem, stating that the equilibrium average of each quadratic degree of freedom in the Hamiltonian is equal to $\frac{kT}{2}$.
$^*$ I'm afraid I disagree with the justification for using a set of harmonic oscillators the way you reported (electrons on the walls of the black body are modeled as 1-dimensional harmonic oscillators). The main reasons are the following: