# Statistical Mechanics – First Law of Thermodynamics

In the previous post, we found an expression for a closed system’s Gibbs entropy $S_G$ in terms of its energy $U$, the partition function $Z$, and the enigmatic variable $\beta$:

$S_G=\beta U+\ln Z$

This expression for $S_G$ is not wholly enlightening, since only the variable that is easily interpretable is $U$. Instead we’ll look at its differential, an infinitesimal change in its value:

$dS_G=d(\beta U+\ln Z)$

Using the product rule on the first term gives

$dS_G=\beta dU+Ud\beta+d\ln Z$

and using the chain rule on the second term gives

$dS_G=\beta dU+Ud\beta+\frac{1}{Z}dZ$

Let’s look at the second term in more detail:

$\displaystyle \frac{1}{Z}dZ=\frac{1}{Z}d\sum_\alpha e^{-\beta E_\alpha}$

The differential sign can be taken inside the sum, since the differential of a sum is the sum of the differentials:

$\displaystyle \frac{1}{Z}dZ=\frac{1}{Z}\sum_\alpha de^{-\beta E_\alpha}$

Using the chain rule gives

$\displaystyle \frac{1}{Z}dZ=\frac{1}{Z}\sum_\alpha e^{-\beta E_\alpha}d(-\beta E_\alpha)$

We use the product rule again, and separate out the terms:

$\displaystyle \frac{1}{Z}dZ=-d\beta\frac{1}{Z}\sum_\alpha E_\alpha e^{-\beta E_\alpha}-\beta\frac{1}{Z}\sum_\alpha dE_\alpha e^{-\beta E_\alpha}$

This expression looks unpleasant, but can be simplified when we recall that

$\displaystyle \frac{1}{Z}e^{-\beta E_\alpha}=p_\alpha$

where $p_\alpha$ is the probability that the system is in the state $\alpha$. So

$\displaystyle \frac{1}{Z}dZ=-d\beta\sum_\alpha p_\alpha E_\alpha-\beta\sum_\alpha p_\alpha dE_\alpha$

Now we implement the meaning of the set of probabilities $\{p_\alpha\}$.

The first sum is recognisable as the energy $U$ of the system, since it represents the statistical mean of the system’s energy.

The second sum is a subtler. It represents the mean change of the system’s microstate energies. The cause of this change cannot be identified yet, because we don’t know the form of the set of energy levels $\{E_\alpha\}$ – we know the system has energy, but we don’t know by what virtue. For now, we will just call this mean change $\langle dE\rangle$:

$\displaystyle \frac{1}{Z}dZ = -Ud\beta-\beta\langle dE\rangle$

Now we’ve simplified this term, we can substitute it back into the expression for $dS_G$:

$dS_G=Ud\beta+\beta dU-Ud\beta-\beta\langle dE\rangle$

$dS_G=\beta dU-\beta\langle dE\rangle$

We rearrange:

$\displaystyle dU = \frac{1}{\beta}dS_G+\langle dE\rangle$

Hmm. What does this mean?

It means the system’s energy $U$ can be changed in two ways.

The first way to change $U$ is to change the Gibbs entropy $S_G$. Remember the Gibbs entropy is a function of the set of occupation probabilities $\{p_\alpha\}$. So to change $S_G$ is to change $\{p_\alpha\}$. The set $\{p_\alpha\}$ quantifies the probability that the system occupies any one of the set of microstates $\{\alpha\}$ with associated energies $\{E_\alpha\}$. So to change $S_G$ is to change the probability distribution of state energies.

You could imagine displaying the canonical ensemble on an array of screens, and twisting a dial controlling $S_G$. As you did so, the distribution of microstates would change – screens would flicker as they updated, with some states (energies) becoming more probable and others less so. For example, it might be possible to twiddle the Gibbs entropy such that higher energy levels have a greater probability of being occupied. The system will be, on average, more energetic. Conversely, you might be able to change $S_G$ such that lower energy levels are more probable. The system calms, and becomes less energetic.

This action we will call the transferral of heat.

The second way to change $U$ is to bring about a non-zero $\langle dE\rangle$ – that is, to grab the system by the lapels and physically manipulate it such that the energy levels available to it are changed. This action could be something as simple as lifting it up through Earth’s gravitational field. Suppose the energy levels before are

$E_0 = 0\ J$

$E_1 = 10\ J$

$E_2 = \text{banana}\ J$

$...$

If the system is raised a distance $y$, the new energy levels will be

$E_0'=mgy\ J$

$E_1'=10 + mgy\ J$

$E_2'=\text{banana}+mgy\ J$

$...$

So the mean change in the system’s energy levels is $\langle dE\rangle=mgy$, so the change in energy $U$ of the system is also $mgy$, as we might expect.

This action we will call the performance of work.

The expression

$\displaystyle dU=\frac{1}{\beta}dS_G+\langle dE\rangle$

is called the first law of thermodynamics, and is more usually written

$dU=dQ+dW$

where $dQ$ is the heat supplied to the system and $dW$ is the work done on the system. It is an expression of the conservation of energy in the context of thermodynamics, and introduces the concept of heat as a physical, measurable quantity, on a par with mechanical work.

This differential form allows us to interpret what happens when two systems are brought into loose thermal contact, finally allowing us to give meaning to $\beta$. In the next post, we establish how to calculate the Gibbs entropy of a composite system.