\documentclass[11pt]{article}

\topmargin=0.0in
\oddsidemargin=0.0in
\evensidemargin=0.0in
\textwidth=6.5in
\textheight=9.0in
\setlength{\parindent}{0cm}
\setlength{\parskip}{1em}
\usepackage{latexsym}

\begin{document}
\title{Physics 213 Final Review Notes}
\author{Anne C. Hanna\\ ahanna@uiuc.edu}
\date{\today}
\maketitle
\tableofcontents
\pagebreak
\section{Disclaimers and usage notes}
These final notes are intended to be used in conjunction with my midterm review notes, since the final \emph{will} be cumulative.  They are not necessarily complete, correct, or even useful.  And even if they were, they shouldn't be your only review materials.  Look through the text and the lecture notes, and try some practice exams too, please!

Also, I would advise not becoming too dependent on the equation sheet during your studying.  It has valuable information on it, but it provides this information without context.  For example, it gives several different equations for the entropy of a system, but it does not tell which equations are valid under which circumstances.  I have seen people unthinkingly use the ideal gas entropy equation for things which are not ideal gases because they blindly copied the equation sheet instead of sitting back and saying, ``Okay, what's the physics here?  Is this an ideal gas?  Is it a binning problem?  A spin statistics problem?  How many microstates does it have?''  It is \emph{much} better to have a solid understanding of the concepts and the derivations which stand behind the equations, because then you can easily handle unfamiliar problems, or derive the correct equation for your purposes on the fly.

Okay, rant over.

\section{Entropy}
\subsection{Fundamentals for an isolated system}
As our thermodynamic systems get larger and larger, counting microstates may become unwieldy.  There's a certain point where your calculator just can't represent the numbers anymore because they're too darn huge.  So in order to mitigate this problem somewhat we define the entropy:
\begin{equation}\sigma = \ln\Omega\end{equation}
$\sigma$ has no units.  Just as a macrostate with a higher number of microstates associated with it will have a higher probability, a state with higher entropy will also have a higher probability.  We also sometimes use the so-called conventional entropy, which is just $S = k_B\sigma = k_B\ln\Omega$.  $S$ has units of Joules per Kelvin.

Entropy is fundamentally related to the input heat into a system by the fact that if we add a very small amount of heat energy $\delta Q$ to a system which is at a temperature $T$, then its entropy will increase by a small amount:
\begin{equation}\delta S = \frac{\delta Q}{T}\end{equation}
If the system's volume is held constant, so that it can do no work on its surroundings, then the input heat $\delta Q$ will be equal to the change in the internal energy of the system, $\delta U$, so we can write, $\delta S = \delta U/T$, or as $\delta U$ becomes extremely small:
\begin{equation}\left(\frac{dS}{dU}\right)_V = \frac{1}{T}\end{equation}

The relations of internal energy and heat input to entropy underlie everything we do with entropy.  One important result that comes from these fundamental relations is the fact that, since a temperature increase in a system implies an increase in its internal energy, this will also imply an entropy increase.  So, all other things being equal, a higher-temperature system has greater entropy than a lower-temperature one.

\subsection{Most probable state and equilibrium state}
As we start talking about entropy, we also start to move from being concerned with the probabilty of finding the system in a particular state to figuring out what the most probable state is.  In most macroscopic systems, the most probable state (and possibly a few nearby, practically indistinguishable states) is so much more probable than all the other possible states that we will almost never see a system which is already in its most probable state evolve towards a less probable state without some external influence.

Every system we see which is \emph{not} in its most probable state will seek the most probable state, and every system which is in its most probable state will stay there as long as it remains undisturbed.  So we call this most probable state ``equilibrium''.  It's what happens when we take a disturbed system and let it alone to seek its preferred configuration.  In general, the preferred configuration is one in which energy, particles, volume, and all the other system parameters are distributed as evenly as possible amongst the system components.

So, for example, two objects at different temperatures will seek an equilibrium where their combined energy is distributed equally amongst all the particles in both objects.  (This matches the equipartion principle, which states that in equilibrium, each quadratic degree of freedom will have the same amount of energy, $k_BT/2$.)  Gas which is initially confined in one corner of a room and then released will seek to distribute itself evenly throughout the room.

A moving macroscopic harmonic oscillator has a certain excess of energy in the center-of-mass kinetic energy of its particles and/or in its stored potential energy in the particles of its spring, so it will seek to redistribute this energy equally amongst all the different kinetic, vibrational, rotational, {\it etc.} degrees of freedom of the spring particles and of the oscillator's surroundings.  This is why the spring's oscillations slowly decay and stop --- it is attempting to approach its equilibrium state.  As we will show later, the probability of a harmonic oscillator in contact with a large reservoir having a particular energy is distributed according to the Boltzmann distribution, for which the lowest-energy state ($E=0$ in this case) is the most probable state.

\subsection{Entropy for a classical ideal gas}
\subsubsection{Microstate counting and entropy changes}
The ideal gas is one of our most important model systems, and any reasonable-sized volume of ideal gas is going to contain many particles which can occupy many different postions and have many different possible systems.  This makes it a good case for the application of entropy instead of simple microstate counting.  We can approximate the number of possible microstates for an ideal gas in the following way:

First, let's suppose we have a gas of $N$ particles occupying a region of volume $V$, which is divided up into $V/\delta V$ tiny cells of volume $\delta V$, each of which can be occupied by one particle.  We make the cells so tiny that there are many more particles than cells.  Since gas molecules are indistinguishable, there are $(V/\delta V)^N/N!$ possible ways to drop these molecules into the cells.

Also, the gas has a total energy $U$ distributed amongst the $2\alpha N$ quadratic degrees of freedom.  We can treat every two degrees of freedom as a harmonic oscillator (see the harmonic oscillator discussion), with energy quanta of size $\delta U$.  Then we have $U/\delta U$ energy quanta distributed amongst $\alpha N$ oscillators, and again we can assume that the energy quanta are small enough so that we have many many quanta per oscillator ($U/\delta U \gg \alpha N$).  The quanta will act like $q = U/\delta U$ indistinguishable particles which occupy $\alpha N$ unlimited-occupancy sites, so there are $(q+\alpha N - 1)!/q!/(\alpha N)! \approx q^{\alpha N-1}/(\alpha N-1)!$ ways to distribute them.  (The Stirling approximation is used to derive the simplified result.)  If we have a lot of oscillators we may further approximate $N-1$ as $N$.

So, given all this stuff, the total number of possible microstates for an ideal gas under these conditions will be:
\begin{equation}\Omega \approx \frac{(V/\delta V)^N}{N!}\cdot\frac{(U/\delta U)^{\alpha N}}{(\alpha N)!} = C(N)\,V^NU^{\alpha N}\end{equation}
where $C(N)$ is an ugly and irrelevant constant which depends on $\delta U$, $\delta V$, $\alpha$, and $N$.  For a given ideal gas, all of these parameters are usually constant, but since we don't know what $\delta U$ and $\delta V$ are, this formula is still unmanageable for probability computations.  Computing the ideal gas entropy makes things somewhat better:
\begin{equation}
S = k_B\ln\Omega = k_B\left(N\ln V + \alpha N\ln U + \ln C(N)\right)
\end{equation}
because now $C(N)$ is relegated to an additive term.  If we want to know how the entropy of an ideal gas changes between two initial and final states then this term will drop out:
\begin{eqnarray*}
\Delta S = S_f-S_i &=& k_B\left(N\ln\left(\frac{V_f}{V_i}\right) + \alpha N\ln\left(\frac{U_f}{U_i}\right)\right) = Nk_B\ln\left(\frac{V_f}{V_i}\right) + \alpha N k_B\ln\left(\frac{\alpha Nk_BT_f}{\alpha Nk_BT_i}\right)\\
 &=& Nk_B\ln\left(\frac{V_f}{V_i}\right) + C_V\ln\left(\frac{T_f}{T_i}\right)
\end{eqnarray*}
where $C_V$ is the heat capacity of the ideal gas at constant volume.

\subsubsection{Absolute entropy for a monatomic ideal gas}
If we actually want to know $S$ and not just $\Delta S$ then we need to have some information about the quantum mechanics of the situation.  First we'll need to know how tightly we can possibly pack the molecules so that we can actually find out $\delta V$, and second we'll need to know the size of the energy quanta for the system, so that we have $\delta U$.  Both of these issues are beyond the scope of this course, but suffice it to say that it turns out that we can write the absolute entropy of a \emph{monatomic} gas entirely in terms of computable parameters:
\begin{equation}S = Nk_B\left(\ln\left(\frac{n_Q}{n}\right) +\frac{5}{2}\right)\end{equation}
This is the Sackur-Tetrode formula.  $N$ is the number of molecules of gas and $k_B$ is Boltzmann's constant.  The $n$ and $n_Q$ parameters require some further explanation.  For this problem (and pretty much from this point onwards in the course) $n$ will no longer represent the number of moles of gas.  Instead it will represent the number density of gas molecules, which is just the number of molecules per unit volume, $n = N/V$.  (On the equation sheet this distinction between number of moles and number density is represented by italicizing {\it n} for the number of moles and romanizing n for the number density.)

\subsubsection{Quantum number density}
The quantum number density is a measure of how tightly you can pack the particles of the gas.  It's a sort of theoretical maximum particles per unit volume \emph{for that type of gas at that particular temperature}.  It is defined as:
\begin{equation}
n_Q = \left(\frac{mk_BT}{2\pi\hbar^2}\right)^{3/2} = \left(10^{30}\,\mathrm{m}^{-3}\right)\left(\frac{m}{m_p}\,\frac{T}{300\,\mathrm{K}}\right)^{3/2}
\end{equation}
The parameter $m$ is the mass of a single particle of the gas and $m_p$ is the mass of a single proton.  So, for example, if the gas consisted of oxygen molecules, each of which has a mass equal to 32 proton masses (since their so-called ``molecular weight''\footnote{Molecular weight is one of the most inaccurate terms in the history of everything ever, since it's not a weight, and it's usually not given as a mass per molecule, but as a mass per mole.  ``Molar mass'' would be a better term to describe this quantity, which is the mass in grams of a single mole of particles of the type in question} is 32), then the ratio $m/m_p$ would be equal to 32.  For a gas of electrons, $m_e = m_p/1836$, so $m/m_p = m_e/m_p = 1/1836$.

Note that the quantum number density depends both on the mass of molecules and on their temperature, so you will need to recompute it if either of these parameters changes.

\subsubsection{Quantum pressure}
We can use the ideal gas equation to rewrite the ideal gas entropy in terms of the pressure, which may be a more convenient form depending on the given parameters.  Since $pV = Nk_BT$, we have $p = Nk_BT/V = nk_BT$.  If we define the gas's quantum pressure to be:
\begin{equation}
p_Q = n_Qk_BT = \left(4.04\cdot10^4\,\mathrm{atm}\right)\left(\frac{m}{m_p}\right)^{3/2}\left(\frac{T}{300K}\right)^{5/2}
\end{equation}
then we can rewrite its absolute entropy as:
\begin{equation}
S = Nk_B\left(\ln\left(\frac{p_Q}{p}\right) + \frac{5}{2}\right)
\end{equation}

\section{The Boltzmann factor}
\subsection{Microstate counting for non-isolated systems}
All the state counting and probability computation that we have done so far has been for small, isolated systems about which we can easily understand all of the details and count the microstates.  But now we'd like to understand what happens if we take our well-understood small system and put it in contact with a large poorly-understood system.  The way these problems are usually set up is that the large system has some unknown enormous but constant amount of energy $U$, some of which can be transferred to the small system (which initially has zero energy), and we are trying to find the probability that the small system will be found to have an energy $E$.

As before, this probability is simply going to be the ratio of the number of microstates of the small + large system when the small system has energy $E$ (call this $\Omega(E)$) to the total number of possible microstates for the small + large system (call this $\Omega_{\mathrm{tot}}$).  The energy-$E$ microstate count will simply be the product of the small-system and large-system microstate counts for that small-system energy.  So:
\begin{equation}
P(E) = \frac{\Omega(E)}{\Omega_{\mathrm{tot}}} = \frac{\Omega_{\mathrm{small}}(E)\,\Omega_{\mathrm{large}}(U-E)}{\Omega_{\mathrm{tot}}}
\end{equation}

Since the small-system is well-understood, we can count up its microstates pretty simply, using whatever the appropriate formula is for the system type.  The large system, however, is poorly-understood.  All we know for sure is that it will satisfy the basic entropy relation $(dS_{\mathrm{large}}/dU)_{V_{\mathrm{large}}} = 1/T_{\mathrm{large}}$.  Since the large system is \emph{very} large compared to the small system, we can assume that whatever amount of energy it gives up to the small system does not significantly affect its temperature or volume, so we can write $\Delta S_{\mathrm{large}}/\Delta U = 1/T_{\mathrm{large}}$ for any energy loss by the large system.  So the microstate count for the large system is:
\begin{equation}
\Omega_{\mathrm{large}}(U-E) = e^\sigma = e^{S/k_B} = e^{(S(U)+\Delta S_{\mathrm{large}})/k_B)} = e^{(S(U)-E/T_{\mathrm{large}})/k_B} = e^{S(U)/k_B}e^{-E/k_BT_{\mathrm{large}}}
\end{equation}

Typically we have no good way of determining the entropy of the large system at energy $U$ ($S(U)$).  So we just treat $K = e^{S(U)/k_BT_{\mathrm{large}}}$ as a normalization constant, which will turn out to not matter for anything we do.  Noting that the total number of microstates possible for the system is just:
\begin{equation}
\Omega_{\mathrm{tot}} = \sum_E \Omega_{\mathrm{small}}(E)\Omega_{\mathrm{large}}(U-E) = \sum_E \Omega_{\mathrm{small}}(E)\cdot Ke^{-E/k_BT_{\mathrm{large}}} = K\sum_E \Omega_{\mathrm{small}}(E)\,e^{-E/k_BT_{\mathrm{large}}}
\end{equation}
we then see that the probability of finding the small system with energy $E$ is:
\begin{equation}
P(E) = \frac{\Omega_{\mathrm{small}}(E)\Omega_{\mathrm{large}}(U-E)}{\Omega_{\mathrm{tot}}} = \frac{\Omega_{\mathrm{small}}(E)\cdot Ke^{-E/k_BT_{\mathrm{large}}}}{K\sum_{E^\prime} \Omega_{\mathrm{small}}(E^\prime)\,e^{-E^\prime/k_BT_{\mathrm{large}}}} = \frac{\Omega_{\mathrm{small}}(E)\,e^{-E/k_BT_{\mathrm{large}}}}{\sum_{E^\prime} \Omega_{\mathrm{small}}(E^\prime)\,e^{-E^\prime/k_BT_{\mathrm{large}}}}
\end{equation}

The denominator of this probability relation is just a constant, so we can treat it as a normalization factor which is determined by the requirement that $\sum_EP(E) = 1$.  Then the probability becomes:

\begin{equation}
P(E) = C\,\Omega_{\mathrm{small}}(E)\,e^{-E/k_BT_{\mathrm{large}}}
\end{equation}

The factor $e^{-E/k_BT_{\mathrm{large}}}$ is called the \emph{Boltzmann factor} and if $\Omega_{\mathrm{small}}(E) = 1$ the probability distribution is called the Boltzmann distribution.  The Boltzmann distribution applies \emph{only} to a small system which has only one possible microstate at each energy and which is in contact with a large reservoir at temperature $T$.  For such a system the most probable state is \emph{always} the lowest energy state.  For systems where $\Omega_{\mathrm{small}}(E)$ is a function of $E$, the Boltzmann distribution no longer applies and the most probable energy will be different.

\subsection{Probability and probability density}
If our small system has only a discrete set of energies ({\it eg.} it can only have energies 0, $\varepsilon$, $2\varepsilon$, $3\varepsilon$, ...) then the above probability stuff works fine.  However, if the system has a continuous range of energies ({\it eg.} it can have \emph{any} energy at all from zero to infinity), then we need to modify a couple things.

First of all, instead of having a finite probability of having any one exact value of energy it will have zero probability of having that exact energy, but it will have a finite \emph{probability density} at that point.  We can then use the probability density to find the probability of having an energy in some small range $\Delta E$ around an energy $E$ by finding the area under that region of the probability density graph.  So for a continuous energy spectrum and a small $\Delta E$, we have:
\begin{equation}
P\{E,\ E+\Delta E\} \approx P(E)\,\Delta E
\end{equation}

In addition, when we normalize the probability density, the normalization equation goes from being $\sum_EP(E) = 1$ to:
\begin{equation}
\int_{E_{\mathrm{min}}}^{E_{\mathrm{max}}} P(E)\,dE = 1
\end{equation}

For a continuous probability distribution, we can find the ``most probable'' energy for the small system by finding the one with the highest associated probability density, which, for a distribution with a single peak, will be the energy which satisfies $dP(E)/dE = 0$.

\subsection{Average energy}
In addition to the most probable energy for the small system, it is sometimes useful to know its average energy.  Note that these are two very distinct concepts, and the two energies will usually be different.  The average energy is usually represented as $\left<E\right>$.  For a discrete probability distribution it is:
\begin{equation}\left<E\right> = \sum_EE\,P(E)\end{equation}
For a continuous probability distribution it is:
\begin{equation}\left<E\right> = \int_{E_{\mathrm{min}}}^{E_{\mathrm{max}}}E\,P(E)\,dE\end{equation}

\subsection{Spins in a magnetic field}
The simplest case where we may apply the Boltzmann factor is the case of a single magnetic spin in a magnetic field and in contact with a reservoir at temperature $T$.  The spin may either point in the same direction as the magnetic field or in the opposite direction.  In either case, its energy is
\begin{equation}U = -\vec{\mu}\cdot\vec{B}\end{equation}
where $\vec{\mu}$ is its magnetic moment of the single spin.  So if the spin points along the magnetic field its energy is $U_\parallel = -\mu B$.  If it points opposite the magnetic field its energy is $U_{-\parallel} = +\mu B$.  So the associated probabilities for these two states are:
\begin{eqnarray*}
P_\parallel &=& C\,e^{-(-\mu B)/k_BT} = C\,e^{\mu B/k_BT}\\
P_{-\parallel} &=& C\,e^{-(+\mu B)/k_BT} = C\,e^{-\mu B/k_BT}
\end{eqnarray*}
Probability normalization requires that $P_\parallel + P_{-\parallel} = 1$, so the normalization constant $C$ is:
\begin{equation}C = \frac{1}{e^{\mu B/k_BT} + e^{-\mu B/k_BT}}\end{equation}

So if we have a system of $N$ spins in a magnetic field $\vec{B}$ in contact with a reservoir at temperature $T$, then the average number of spins pointing in each direction will be:
\begin{eqnarray*}
N_\parallel &=& N\frac{e^{\mu B/k_BT}}{e^{\mu B/k_BT} + e^{-\mu B/k_BT}}\\
N_{-\parallel} &=& N\frac{e^{-\mu B/k_BT}}{e^{\mu B/k_BT} + e^{-\mu B/k_BT}}
\end{eqnarray*}

The ``net'' number of spins pointing parallel to $\vec{B}$ will be:
\begin{equation}
m = N_\parallel - N_{-\parallel} = N\frac{e^{\mu B/k_BT} - e^{-\mu B/k_BT}}{e^{\mu B/k_BT} + e^{-\mu B/k_BT}} = N\tanh\left(\frac{\mu B}{k_BT}\right)
\end{equation}
And so the total magnetic moment of the entire spin system will be:
\begin{equation}
\mathcal{M} = N\mu\left(\frac{\mu B}{k_BT}\right)
\end{equation}

Note that if the external magnetic field is zero, then there will be on average the same number of spins pointing up as down and we can go back to plain vanilla spin statistics.

\subsection{Heat capacity}
Once we have the average energy of the small system we can compute things like the heat capacity.  As mentioned with ideal gases, the heat capacity is the amount of energy it takes to raise the system's temperature by one Kelvin.  In the context of the small system in contact with a thermal reservoir, what this means is that if we increase the reservoir temperature by one Kelvin, the average energy of the small system will go up by an amount equal to its heat capacity.  So the heat capacity for this kind of system is defined as:
\begin{equation} C = \frac{d\left<E\right>}{dT}\end{equation}
Note that, since the probability of the small system having any particular energy depends on the reservoir's temperature through the Boltzmann factor, the average energy will be a function of the temperature, and so the heat capacity will generally be non-zero.

For most systems, as the temperature increases from absolute zero, so does the heat capacity, because increased thermal randomness at higher temperatures makes more and more possible modes readily accessible to the system.  At absolute zero, there are no accessible modes and so the heat capacity is zero.  Despite the overall variability of heat capacity, in the everyday range of temperatures (one hundred to a few hundred Kelvins), most systems we are interested in will have approximately constant heat capacities.

\subsection{Classical {\it vs.} quantum}
This temperature variance of the behavior of the heat capacity touches on an important point, which is that, depending on what the system's temperature is, there are certain approximations which are more and less valid.

In particular, at everyday temperatures, it is often possible to treat a discrete quantum mechanical system as having a continuous energy distribution (because the separation between its different possible energies is so much smaller than its average energy).  (This is called the classical approximation.)  But if the temperature of the system is low (there are not very many energy quanta), then it will be necessary to use the exact discrete probability distribution in order to get accurate results. 

Also, you have learned that the average energy of a system is always equal to $k_BT/2$ times the number of quadratic degrees of freedom it has.  However, this actually a classical approximation which is only valid in the everyday world.  If you drop the temperature of the system to down around absolute zero, quantum mechanical effects will start to come into play which will greatly decrease the accuracy of this approximation, in which case you can no longer set $\left<E\right> = \alpha k_BT/2$.  Instead you will have to compute the average energy using the exact discrete probability distribution and the averaging formulas described above.

In addition, if you raise the temperature to be much higher than everyday temperatures, additional degrees of freedom may become accessible, which will increase $\alpha$ in the equipartition formula and possibly cause other unusual effects.

\subsection{The one-dimensional quantum harmonic oscillator}
If we take a linear harmonic oscillator (energy $E=mv^2/2+kx^2/2$) and treat it as a quantum mechanical system, it turns out that the oscillator can only have certain discrete values of energy which are multiples of some very small energy quantum $\varepsilon$.  Specifically its energy can be 0, $\varepsilon$, $2\varepsilon$, $3\varepsilon$, and so forth, on up to infinity.

There are two different possible situations to consider for the harmonic oscillator.  The first case is an isolated system of $N$ oscillators which share $q$ energy quanta amongst themselves.  Since each oscillator can take an unlimited number of energy quanta, and energy quanta are in principle indistinguishable from each other, we can count the number of possible microstates of such a system using the unlimited occupancy/indistinguishable objects formula:
\begin{equation}\Omega(N,q) = {q+N-1 \choose q} = {q+N-1 \choose N-1} = \frac{(q+N-1)!}{q!(N-1)!}\end{equation}

Another possible situation is a single oscillator in contact with a large reservoir at temperature $T$.  In this case, there is exactly one microstate for the harmonic oscillator at each possible energy $n\varepsilon$, so the probability of finding the oscillator with energy $n\varepsilon$ is:
\begin{equation}P_n = Ce^{-n\varepsilon/k_BT}\end{equation}
where $n$ is an integer from zero to infinity.  The normalization formula $\sum_{n=0}^{\infty}P_n = 1$ gives the normalization constant $C = 1/\mathcal{Z}$ where:
\begin{eqnarray*}
\mathcal{Z} &=& \sum_{n=0}^{\infty}e^{-n\varepsilon/k_BT} = \sum_{n=0}^{\infty}\left(e^{-\varepsilon/k_BT}\right)^n = 1 + e^{-\varepsilon/k_BT} + \left(e^{-\varepsilon/k_BT}\right)^2 + \left(e^{-\varepsilon/k_BT}\right)^3 + ...\\
  &=& 1 + e^{-\varepsilon/k_BT}\left(1 + e^{-\varepsilon/k_BT} + \left(e^{-\varepsilon/k_BT}\right)^2 + \left(e^{-\varepsilon/k_BT}\right)^3 + ...\right) = 1 + e^{-\varepsilon/k_BT}\mathcal{Z}
  \end{eqnarray*}
We can solve this equation for $\mathcal{Z}$ to get:
\begin{eqnarray*}
\mathcal{Z} &=& \frac{1}{1-e^{-\varepsilon/k_BT}}\\
 \Longrightarrow\ C &=& 1 - e^{-\varepsilon/k_BT}\\
 \Longrightarrow\ P_n &=& e^{-n\varepsilon/k_BT}\left(1 - e^{-\varepsilon/k_BT}\right)\end{eqnarray*}
which is the exact probability of finding this single harmonic oscillator with energy $n\varepsilon$.  You can use then this formula and some similar math tricks to also find the exact average energy of a one-dimensional quantum harmonic oscillator:
\begin{equation}
\left<E\right> = \varepsilon\frac{e^{-\varepsilon/k_BT}}{1-e^{-\varepsilon/k_BT}}
\end{equation}
If you have a system of $N$ harmonic oscillators at a temperature $T$, it is usual to treat each harmonic oscillator as being individually in contact with the reservoir at temperature $T$, so that for $N$ oscillators the average total energy is:
\begin{equation}
\left<E_N\right> = N\varepsilon\frac{e^{-\varepsilon/k_BT}}{1-e^{-\varepsilon/k_BT}}
\end{equation}

The ``Einstein model'' of a crystalline solid treats each atom in the solid as if it has three independent harmonic oscillator motions, one in each of the three spatial dimensions.  So a solid with $N$ atoms can be treated as if it were composed of $3N$ independent harmonic oscillators. 

\subsection{The classical approximation to the quantum harmonic oscillator}
The above description of quantum harmonic oscillators is an exact formulation.  However, if we have many oscillators and many quanta per oscillator, ({\it ie.} a large system at a high temperature), then we can apply the classical approximation to this system.  First of all we can approximate the discrete energy spectrum as a continuous spectrum (since the spacing between energy levels will be very small compared to the average energy).  So we'll have a pure Boltzmann probability density:
\begin{equation}P(E) = C\,e^{-E/k_BT}\end{equation}
Applying the normalization integral $\int P(E)\,dE = 1$ gives a normalization constant of $C = 1/k_BT$, so that:
\begin{equation}P(E) = \frac{1}{k_BT}\,e^{-E/k_BT}\end{equation}
and the average energy will be
\begin{equation}\left<E\right> = k_BT\end{equation}
which matches the equipartition result (since there are two quadratic degrees of freedom, spring potential energy and kinetic energy).  This is good --- the classical approximation of a quantum mechanical system should match the expected answer we get from equipartition.

\subsection{The Maxwell-Boltzmann distribution}
Another interesting \emph{classical} system for which we can use the Boltzmann factor is kinetic energy distribution for particles in an ideal gas.  Unlike the harmonic oscillator, a single ideal gas particle with a kinetic energy $E$ actually has several different possible microstates associated with it, since $E=mv^2/2$ corresponds to only one particle speed, but each possible direction of travel at that speed corresponds to a different microstate for the particle which corresponds to that energy.  Carefully working through the physics results in $\Omega(E) \propto E^{1/2}$, so that the probability density is:
\begin{equation}P(E) = CE^{1/2}\,e^{-E/k_BT}\end{equation}
Since the kinetic energy of the particles can in principle vary from zero all the way up to infinity in this classical approximation, doing the normalization integral gives $C = 2/\sqrt{\pi} \cdot (k_BT)^{-3/2}$.  So the probability density and average energy are:
\begin{eqnarray*}
P(E) &=& \frac{2}{\sqrt{\pi}} \left(k_BT\right)^{-3/2}\,E^{1/2}\,e^{-E/k_BT}\\
\left<E\right> &=& \frac{3}{2}k_BT
\end{eqnarray*}
As usual, since this is a classical model, the average energy is equal to the equipotential result.

Another value of interest for this model is the most probable energy (which is \emph{not} the same as the average energy).  As aforementioned, the most probable energy will be the one for which the distribution peaks, that is the one for which $dP/dE = 0$.  For this probability density:
\begin{eqnarray*}
\left.\frac{dP(E)}{dE}\right|_{E=E_{\mathrm{max}}} &=& 0 = \frac{2}{\sqrt{\pi}} \left(k_BT\right)^{-3/2}\,e^{-E_{\mathrm{max}}/k_BT}\,\left(\frac{1}{2E_{\mathrm{max}}^{1/2}} - \frac{E_{\mathrm{max}}^{1/2}}{k_BT}\right)\\
E_{\mathrm{max}} &=& \frac{1}{2}k_BT
\end{eqnarray*}
So the most probable energy in this case is smaller than the average energy.

\subsection{Photons and blackbodies}
A final sample case for the Boltzmann distribution is an ``ideal gas'' of photons.  It turns out that a single photon with energy $E$ can be treated as three coupled harmonic oscillators sharing a total energy $E$.  If you work through the physics, it turns out that the probability density is
\begin{equation}P(E) = \frac{1}{2}(k_BT)^{3/2}\,E^2e^{-E/k_BT}\end{equation}

A hot object which is a perfect radiator will emit photons in accordance with this probability density at the temperature of the object.  If the object has surface area $A$, then the amount of energy it emits per second is:
\begin{equation}
H = A\cdot J = A\cdot \sigma_BT^4
\end{equation}
where $H$ is measured in units of Watts = J/s, and $J$ is measured in units of W/m${}^2$.  The constant $\sigma_B$ is the Stefan-Boltzmann constant and is equal to:
\begin{equation}
\sigma_B = 5.670\cdot10^{-8}\mathrm{\ W/m^2-K^4}
\end{equation}

The wavelength of light which corresponds to the peak of the energy distribution satisfies:
\begin{equation}\lambda_{\mathrm{max}} T = 0.029\mathrm{\ m-K}\end{equation}
and the most probable photon energy is thus $E_{\mathrm{max}} = hc/\lambda_{\mathrm{max}}$ where $h = 6.636\cdot 10^{-34}\mathrm{\ J-s}$ is Planck's constant.

\section{Free energy}
\subsection{Entropy for non-isolated systems}
As with the microstate counting, if we have a small system (for which we can easily measure the parameters) which is in thermal (energy-exchange) contact with a much larger system (which cannot be easily measured), it would be nice to be able to express the change in entropy of the small+large system in terms only of parameters of the small system (plus possibly the temperature of the large system).  The change in the total entropy of the joint system will be:
\begin{equation}\Delta S_{\mathrm{tot}} = \Delta S_{\mathrm{small}} + \Delta S_{\mathrm{large}}\end{equation}
Since the small system is in thermal contact \emph{only} with the large system, the energy change of the small system will be equal and opposite that of the large system: $\Delta U_{\mathrm{large}} = -\Delta U_{\mathrm{small}}$.  Then we can use the fundamental entropy relation $(dS/dU)_V = 1/T$ and the fact that the large system is so large that its temperature and volume will remain constant to find that:
\begin{equation}\Delta S_{\mathrm{large}} = \frac{\Delta U_{\mathrm{large}}}{T_{\mathrm{large}}} =  \frac{-\Delta U_{\mathrm{small}}}{T_{\mathrm{large}}}\end{equation}
and thus the total entropy change of the joint system will be:
\begin{equation}\Delta S_{\mathrm{tot}} = \Delta S_{\mathrm{small}} - \frac{\Delta U_{\mathrm{small}}}{T_{\mathrm{large}}}\end{equation}

If the system is moving towards equilibrium (the temperature of the small object is approaching that of the large reservoir) then the total system entropy will increase.  (It will turn out that we can use this approach to equilibrium to extract a certain amount of work from the system.)  However, we can also cause the total entropy of the system to decrease by doing work on it to drive it out of equilibrium.  For example, if the small system and reservoir were initially at the same temperature, we could use a refrigerator to transfer some heat energy from the small system to the large reservoir, thus causing the small system to cool off despite having initially been in equilibrium with the reservoir.

\subsection{Free energy and work}
Using the above information, we can define a quantity called the free energy:
\begin{equation}\Delta F_{\mathrm{tot}} = -T_{\mathrm{large}}\Delta S_{\mathrm{tot}} = \Delta U_{\mathrm{small}} - T_{\mathrm{large}} \Delta S_{\mathrm{small}}\end{equation}
or in absolute terms:
\begin{equation}F_{\mathrm{tot}} = -T_{\mathrm{large}}S_{\mathrm{tot}} = U_{\mathrm{small}} - T_{\mathrm{large}}S_{\mathrm{small}}\end{equation}
(Specifically, this is the Helmholtz free energy --- there is also a Gibbs free energy $G$ that we don't use in this course.)  Since the equilibrium (most probable) state is found by maximizing entropy, we can equivalently minimize free energy.  A system approaching equilibrium will see an entropy increase and a free energy decrease; a system being forced away from equilibrium will see an entropy decrease and a free energy increase.

It is very important to notice that the relevant temperature in the free energy computation is the temperature of the large system with which the small system is exchanging energy, regardless of whether that's the hotter temperature or the colder temperature or anything like that.  Also, the internal energy and entropy used are those of the small system.

You can consider the free energy of a system as the amount of energy that system has available with which it can perform work.  If we have a system which is not in equilibrium, it will have a positive free energy, and with an ideal engine we can harness all of the free energy released by its evolution towards equilibrium to perform work:
\begin{equation}W_{\mathrm{by}} \le -\Delta F_{\mathrm{tot}}\end{equation}
(Note that since the temperature of the small system is changing during this evolution, you cannot simply use the initial Carnot efficiency and the change in internal energy of the small system to compute the maximum possible work, since the changing temperature means the Carnot efficiency is \emph{also} changing.)

Conversely, if a system starts in equilibrium, it cannot perform any work.  But I can do work on it to drive it out of equilibrium.  In the ideal case, the maximum amount by which I can raise the system's free energy is the amount of work I have done on it:
\begin{equation}\Delta F_{\mathrm{tot}} \le -W_{\mathrm{by}} = W_{\mathrm{on}}\end{equation}
So, in the best case, I can do work on the system and store every bit of work I've done on the system for later extraction.  I can't ever get more work out of the system than I've put in (no perpetual motion!).

\subsubsection{One large and one small reservoir}
\paragraph{Heat engines}
As an example, suppose we have a brick with a constant heat capacity $C$ which is initially at a cold temperature $T_c$ in a room at a hotter temperature $T_h$.  If we allow the brick to warm up to room temperature, its internal energy will change by
\begin{equation}
\Delta U_{\mathrm{brick}} = \int_{T_c}^{T_h} \frac{dU_{\mathrm{brick}}}{dT_{\mathrm{brick}}}dT_{\mathrm{brick}} = \int_{T_c}^{T_h} C\,dT_{\mathrm{brick}} = C(T_h-T_c)
\end{equation}
Its entropy will satisfy $(dS/dU)_V = 1/T$ and so its entropy change will be:
\begin{equation}
\Delta S_{\mathrm{brick}} = \int_{T_c}^{T_h} \frac{dU_{\mathrm{brick}}}{T_{\mathrm{brick}}} = \int_{T_c}^{T_h} \frac{C}{T_{\mathrm{brick}}}dT_{\mathrm{brick}} = C\ln\left(\frac{T_h}{T_c}\right)
\end{equation}
Since the brick is heating up, both its entropy and its energy change will be positive.  Its free energy change will be:
\begin{equation}
\Delta F_{\mathrm{tot}} = -W_{\mathrm{by}} = \Delta U_{\mathrm{brick}} - T_{\mathrm{room}}\Delta S_{\mathrm{brick}} = C\left(T_h-T_c-T_h\ln\left(\frac{T_h}{T_c}\right)\right)
\end{equation}
which, if you compute it for any arbitrary choice of $T_h>T_c$, will be negative.  This is good, since the brick is approaching equilibrium --- its free energy should be decreasing and we should be able to harness that free energy decrease to do work.

Conversely, if we start with a hot brick in a cold room, we will have:
\begin{eqnarray*}
\Delta U_{\mathrm{brick}} &=& C(T_c-T_h)\\
\Delta S_{\mathrm{brick}} &=& C\ln\left(\frac{T_c}{T_h}\right)\\
\Delta F_{\mathrm{tot}} &=& -W_{\mathrm{by}} = C\left(T_c-T_h-T_c\ln\left(\frac{T_c}{T_h}\right)\right)
\end{eqnarray*}
In this case, the internal energy and entropy of the brick will both decrease.  But the free energy change will still be negative, and the work the system is capable of doing will be positive, since again the system is approaching equilibrium.

\paragraph{Refrigerators and Heat Pumps}
The other thing we can do with this brick-room system is start with the system in an equilibrium state and do work on the system to drive it away from this equilibrium state.  If we start with both brick and room at $T_h$ and hook them up to a refrigerator which transfers energy from the brick to the room until the brick has reached a final temperature $T_c$, then the energy and entropy change of the brick will be the same as when we allowed it to cool down in a cool room:
\begin{eqnarray*}
\Delta U_{\mathrm{brick}} &=& C(T_c-T_h)\\
\Delta S_{\mathrm{brick}} &=& C\ln\left(\frac{T_c}{T_h}\right)
\end{eqnarray*}
But the free energy change will still depend on the temperature of the room, since this is the large system with which the brick is exchanging energy, so:
\begin{equation}
\Delta F_{\mathrm{tot}} = W_{\mathrm{on}} = \Delta U_{\mathrm{brick}} - T_{\mathrm{room}}\Delta S_{\mathrm{brick}} =  C\left(T_c-T_h-T_h\ln\left(\frac{T_c}{T_h}\right)\right)
\end{equation}
In this case it will turn out (if you plug in any pair of $T_c<T_h$) that the free energy change is always positive.  This system has been driven out of equilibrium by the work we did on it.

Similarly, we may start with brick and room both at $T_c$ and run a heat pump between them in order to warm the brick up to a temperature $T_h$ by transferring energy from the brick to the room.  In this case:
\begin{eqnarray*}
\Delta U_{\mathrm{brick}} &=& C(T_h-T_c)\\
\Delta S_{\mathrm{brick}} &=& C\ln\left(\frac{T_h}{T_c}\right)\\
\Delta F_{\mathrm{tot}} &=& W_{\mathrm{on}} = \Delta U_{\mathrm{brick}} - T_{\mathrm{room}}\Delta S_{\mathrm{brick}} =  C\left(T_h-T_c-T_c\ln\left(\frac{T_h}{T_c}\right)\right)
\end{eqnarray*}
So the energy and entropy change match the approach to equilibrium case, but again the free energy change is positive because we had to do work on it to get it into the final state.

\subsubsection{The leaky heat engine}
This problem was presented in class as a free energy problem, but really it's much simpler than that.  The proposed situation is that we have a heat engine which consists of two large reservoirs at temperatures $T_c$ and $T_h$.  This heat engine is ideal (Carnot) in every way, except that it has a leak, so that if I put an amount of energy $Q_h^{\mathrm{tot}}$ into the hot reservoir, a fraction $f$ of this heat leaks directly from the hot reservoir to the cold reservoir, so that the magnitude of the leak is $Q_{\mathrm{leak}} = fQ_h^{\mathrm{tot}}$.

This leaves an amount of energy $Q_h = (1-f)Q_h^{\mathrm{tot}}$ of heat energy in the hot reservoir available for use in generating work.  Since aside from the leak the engine is perfectly ideal, we can just use the Carnot efficiency and the available heat energy to determine how much work the engine performs:
\begin{equation}
W_{\mathrm{by}} = \varepsilon_{\mathrm{Carnot}}Q_h = \left(1-\frac{T_c}{T_h}\right)\left(1-f\right)Q_h^{\mathrm{tot}}
\end{equation}

The total entropy change of the engine will be equal to the sum of the entropy changes of both reservoirs, $\Delta S_{\mathrm{tot}} = \Delta S_h + \Delta S_c$, and we can use the constancy of the reservoir temperatures and volumes and the fundamental entropy relation $(dS/dU)_V = 1/T$ to get:
\begin{eqnarray*}
\Delta S_h &=& \frac{\Delta U_h}{T_h} = \frac{-Q_h^{\mathrm{tot}}}{T_h}\\
\Delta S_c &=& \frac{\Delta U_c}{T_c} = \frac{Q_c}{T_c} = \frac{Q_h^{\mathrm{tot}} - W_{\mathrm{by}}}{T_c} = \frac{Q_h^{\mathrm{tot}}}{T_c}\left(1 - \left(1-\frac{T_c}{T_h}\right)\left(1-f\right)\right)\\
\Delta S_{\mathrm{tot}} &=& \Delta S_h + \Delta S_c = fQ_h^{\mathrm{tot}}\left(\frac{1}{T_c} - \frac{1}{T_h}\right) = Q_{\mathrm{leak}}\left(\frac{1}{T_c} - \frac{1}{T_h}\right)
\end{eqnarray*}
The exact details of this result are not important.  The main point is to compute the entropy change of each reservoir in terms of its energy loss or gain, and then add these two entropy changes to get the resultant change in total entropy.  Note that the cold reservoir gains entropy and the hot reservoir loses entropy, but the total system still gains entropy, as it should.

\section{Phase transitions}
Phase transitions occur when a material changes from one distinct state of matter to another.  Common examples include melting/freezing (solid $\leftrightarrow$ liquid), evaporation/condensation (liquid $\leftrightarrow$ gas), and sublimation/deposition (solid $\leftrightarrow$ gas).

As an example, if we start with liquid water at 20$^\circ$C and begin heat it up to 100$^\circ$C, the water will have some heat capacity $C$ which is equal to the amount of energy required to raise its temperature by 1 K.  If the heat capacity does not depend on temperature, then heating the water from 20$^\circ$C to 100$^\circ$C will require a thermal energy input of $Q_{\mathrm{heating}} = C\,\Delta T = C\cdot(80^\circ\mathrm{C})$.

Once the water's temperature reaches 100$^\circ$C, the water begins to boil, and until all the water has vaporized its temperature will remain at 100$^\circ$C.  So the evaporation phase transition takes place at constant temperature.  All of the input energy at this point is going to either promoting liquid molecules to the gas phase (increasing the internal energy of the gas, although not its temperature) or to doing the work associated with the volume increase that occurs when liquid becomes gas.  The total amount of energy required to completely convert liquid water at 100$^\circ$C to water vapor at 100$^\circ$C is called the enthalpy change $\Delta H$ of the water:
\begin{equation}
\Delta H = \Delta U_{\mathrm{int}} + W_{\mathrm{by}}
\end{equation}
where $W_{\mathrm{by}}$ is the work done by the water during its expansion.  We can also define the latent heat of the vaporization process $L_{\mathrm{vap}}$ as the enthalpy change during vaporization of some specified amount of water.  For example, the latent heat of vaporization per mole would be:
\begin{equation}
L_{\mathrm{vap}}^{\mathrm{molar}} = \frac{\Delta H}{n_{\mathrm{moles}}}
\end{equation}
where $n_{\mathrm{moles}}$ is the number of moles of water.  The latent heat of vaporization per kilogram would be:
\begin{equation}
L_{\mathrm{vap}}^{\mathrm{mass}} = \frac{\Delta H}{M}
\end{equation}
where $M$ is the mass of the entire amount of water.

In these problems, there is a very important distinction between the input energy and the change in the internal energy of the substance in question, since some of the input energy may go into, for example, work done by a vaporizing liquid as it expands into its gaseous state.  The latent heat is defined in terms of the \emph{total} input energy, not in terms of the change in internal energy.

\section{Chemical potential}
\subsection{Fundamentals}
Chemical potential is an abstraction of free energy which allows us to more simply understand the equilibrium state of systems containing several different kinds of particles which can undergo chemical-like reactions.  For example, I might take a pure gas of $N_{\mathrm{H_2}}^{\mathrm{tot}}$ hydrogen molecules and mix it with a pure gas of $N_{\mathrm{O_2}}^{\mathrm{tot}}$ oxygen molecules.  Some of the hydrogen and oxygen molecules will combine to form water molecules, and I would like to know at equilibrium how many molecules of each type I will have.  The chemical reaction relating these three types of molecules is:
\begin{equation}
\mathrm{2H_2 + O_2 \longleftrightarrow 2H_2O}
\end{equation}
so every time I create a water molecule I lose one hydrogen molecule and half of an oxygen molecule.

The equilibrium state is a state of minimum \emph{total} free energy ($F_{\mathrm{tot}} = F_{\mathrm{H_2}} + F_{\mathrm{O_2}} + F_{\mathrm{H_2O}}$), and so I want to minimize this total free energy with respect to some relevant parameter, like the number of water molecules I have created by mixing the gases together.  So at equilibrium:
\begin{eqnarray*}
\frac{dF_{\mathrm{tot}}}{dN_{\mathrm{H_2O}}} = 0 &=& \frac{dF_{\mathrm{H_2}}}{dN_{\mathrm{H_2O}}} + \frac{dF_{\mathrm{O_2}}}{dN_{\mathrm{H_2O}}} + \frac{dF_{\mathrm{H_2O}}}{dN_{\mathrm{H_2O}}}\\
 &=& \left(\frac{dN_{\mathrm{H_2}}}{dN_{\mathrm{H_2O}}}\right)\frac{dF_{\mathrm{H_2}}}{dN_{\mathrm{H_2}}} + \left(\frac{dN_{\mathrm{O_2}}}{dN_{\mathrm{H_2O}}}\right)\frac{dF_{\mathrm{O_2}}}{dN_{\mathrm{O_2}}} + \frac{dF_{\mathrm{H_2O}}}{dN_{\mathrm{H_2O}}}\\
  &=& -\frac{dF_{\mathrm{H_2}}}{dN_{\mathrm{H_2}}} - \frac{1}{2}\,\frac{dF_{\mathrm{O_2}}}{dN_{\mathrm{O_2}}} + \frac{dF_{\mathrm{H_2O}}}{dN_{\mathrm{H_2O}}}
\end{eqnarray*}
where the last equality comes from the fact that when I create one water molecule ($dN_{\mathrm{H_2O}} = 1$), I lose one hydrogen molecule ($dN_{\mathrm{H_2}} = -1$) and one-half of an oxygen molecule ($dN_{\mathrm{O_2}} = -1/2$).

I can then define a \emph{chemical potential} $\mu_i$ for each of these particle types:
\begin{eqnarray*}
\mu_{\mathrm{H_2}} &=& \frac{dF_{\mathrm{H_2}}}{dN_{\mathrm{H_2}}}\\
\mu_{\mathrm{O_2}} &=& \frac{dF_{\mathrm{O_2}}}{dN_{\mathrm{O_2}}}\\
\mu_{\mathrm{H_2O}} &=& \frac{dF_{\mathrm{H_2O}}}{dN_{\mathrm{H_2O}}}
\end{eqnarray*}
and the above free energy equation becomes:
\begin{equation}
\frac{dF_{\mathrm{tot}}}{dN_{\mathrm{H_2O}}} = 0 = -\mu_{\mathrm{H_2}} - \frac{1}{2}\mu_{\mathrm{O_2}} + \mu_{\mathrm{H_2)}}
\end{equation}
A little rearrangement causes this chemical potential relation to suspiciously resemble the chemical reaction:
\begin{eqnarray*}
2\mu_{\mathrm{H_2}} + \mu_{\mathrm{O_2}} &=& 2\mu_{\mathrm{H_2O}}\\
\mathrm{2H_2 + O_2} &\longleftrightarrow& \mathrm{2H_2O}
\end{eqnarray*}

And this suspicious result turns out to actually be generally true.  So we've now reduced the problem to the following steps:
\begin{enumerate}
\item Find a chemical reaction representation of the system.
\item Replace the chemical species with their associated chemical potentials, and replace the reaction arrow with an equals sign.
\item Find the chemical potentials of the species and plug them into the chemical potential equation.
\item Solve this equation to find a relationship amongst the numbers (or number densities) of all the different types of particles.
\end{enumerate}

In outline, it really is that simple, although specific details may be tricky.

\subsection{Monatomic ideal gases}
The internal energy of a monatomic ideal gas is $U = (3/2)Nk_BT + N\Delta$, where $\Delta$ is the potential energy of one of the gas molecules, and its entropy is given by the Sackur-Tetrode formula $S = Nk_B\left(\ln(n_Q/(N/V) + 5/2\right)$.  So its free energy is:
\begin{equation}
F = U - TS = \left(\frac{3}{2}Nk_BT+N\Delta\right) - Nk_BT\left(\ln\left(\frac{n_QV}{N}\right)+\frac{5}{2}\right) = Nk_BT\left(\ln\left(\frac{N}{n_QV}\right) - 1\right) + N\Delta
\end{equation}
and its chemical potential is:
\begin{equation}
\mu = \frac{dF}{dN} = k_BT\left(\ln\left(\frac{N}{n_QV}\right) - 1\right) + Nk_BT\cdot\frac{1}{N} + \Delta = k_BT\ln\left(\frac{n}{n_Q}\right) + \Delta
\end{equation}
Note that the value of $\Delta$ is going to depend on where we have defined the zero of potential energy to be.  If the particle is bound, for example, in a gravitational potential well, $\Delta$ may be negative.

\subsection{The atmosphere}
One example which can be solved with chemical potential is the number of particles at various heights in the atmosphere.  To simplify this problem, we assume the atmosphere is at a constant temperature, and we assume that a particular particle can only be at two possible heights --- it can be at sea level (zero height) or it can be at a height $h$ above the ground.  We also assume a finite number of particles, so that if I gain a particle at height $h$ I have lost a particle at sea level, and {\it vice versa}.  In this case the chemical reaction is simply:
\begin{eqnarray*}
\mathrm{particle\ at\ height\ 0} &\longleftrightarrow& \mathrm{particle\ at\ height\ }h\\
\mu_0 &=& \mu_h
\end{eqnarray*}
Treating both particle types as ideal gases and noting that the particles at sea level have potential energy $\Delta_0 = 0$ while the particles at height $h$ have potential energy $\Delta_h = mgh$ (where $m$ is the mass of a single particle) gives:
\begin{eqnarray*}
\mu_0 &=& k_BT\ln\left(\frac{n_0}{n_{Q_0}}\right) + 0\\
\mu_h &=& k_BT\ln\left(\frac{n_h}{n_{Q_h}}\right) + mgh
\end{eqnarray*}
Since both particle types have the same mass and temperature, their quantum densities will be identical, $n_{Q_0} = n_{Q_h} = n_Q$.  Plugging the chemical potentials into the equilibrium relation and using $p = nk_BT$ gives:
\begin{equation}
\frac{n_h}{n_0} = \frac{p_h}{p_0} = e^{-mgh/k_BT}
\end{equation}
so we can see that the atmospheric pressure of a particular type of gas decreases exponentially as we go higher and higher from the surface of the earth, at a rate depending on the mass of molecules of that gas.

\subsection{Semiconductors}
\subsubsection{Pure crystals}
Recall that electrons in atoms are arranged in shells of increasing energy.  Each shell can only contain a fixed number of atoms (two for the lowest-energy, innermost shell; eight for the next; eighteen for the one after that; and so forth).  Generally, the electrons will fill the lowest unoccupied energy level before beginning to occupy higher-energy shells.  Most neutral atoms (except noble gases) have unoccupied spots in their outermost, or ``valence'' shell, and they seek to bond with other atoms in such a way that the shared valence electrons will exactly fill all of the slots in the valence shell without any empty slots or excess electrons.

When a large number of atoms join together to form a crystal the energy levels associated with their valence shells join together to form a big near-continuous smear of possible energies, called the valence band.  Electrons in this band are shared amongst all the different atoms, and in principle if there were open spaces in the band they could move freely from one atom to the next and conduct electricity.  But in a perfect, pure crystal at absolute zero, all the valence energy levels are exactly filled, preventing the electrons from migrating.

If we raise the temperature a little bit, some electrons will gain enough energy to jump up to a higher energy band which is (at 0 K) completely unoccupied.  In this ``conduction'' band, the electrons will be able to move about relatively freely.  At the same time, the empty spaces in the valence band left behind by electrons jumping to the conduction band will allow a certain amount of movement by the valence band electrons.  These empty spaces are called ``holes'' and can be treated as if they were effectively positive electrons (positrons or anti-electrons) which migrate around in the valence band just like electrons migrate in the conduction band.  In a pure crystal there will be exactly as many electrons as holes, so their number densities will be equal ($n_e = n_h$).

To solve this as a chemical potential problem, we treat the electrons and holes as ideal gas particles with the same mass $m_e$.  A particle in the conduction band will have an electrical potential energy which is $\Delta$ higher than that of a particle in the valence band, so we may write:
\begin{eqnarray*}
\mu_e &=& k_BT\ln\left(\frac{n_e}{n_Q}\right) + \Delta\\
\mu_h &=& k_BT\ln\left(\frac{n_h}{n_Q}\right)
\end{eqnarray*}
or alternately:
\begin{eqnarray*}
\mu_e &=& k_BT\ln\left(\frac{n_e}{n_Q}\right)\\
\mu_h &=& k_BT\ln\left(\frac{n_h}{n_Q}\right) - \Delta
\end{eqnarray*}
or even:
\begin{eqnarray*}
\mu_e &=& k_BT\ln\left(\frac{n_e}{n_Q}\right) + \frac{1}{2}\Delta\\
\mu_h &=& k_BT\ln\left(\frac{n_h}{n_Q}\right) - \frac{1}{2}\Delta
\end{eqnarray*}
Note that, again, the quantum densities for the electrons and holes are the same only because they have the same mass.  Then we just need a chemical reaction equation, and since electrons and holes can annihilate each other one-for-one, we have:
\begin{eqnarray*}
e + h &\longleftrightarrow& 0\\
\mu_e + \mu_h &=& 0
\end{eqnarray*}
If we plug in the chemical potentials and rearrange the equation a bit, we get:
\begin{equation}
n_en_h = n_Q^2\,e^{-\Delta/k_BT}
\end{equation}
and using the fact that for a pure crystal $n_e = n_h$ gives:
\begin{equation}
n_i\equiv n_e = n_h = n_Q\,e^{-\Delta/2k_BT}
\end{equation}
(Be aware of that factor of $1/2$ in the exponent!)  The density of electrons or holes in a pure crystal is also referred to as the intrinsic carrier density for that material.

\subsubsection{Impure (doped) crystals}
If we add a small fraction of atoms of a different type to the crystal, these impurities will disrupt the perfectly filled valence bands of the pure crystal.  The impurities may create a certain number of extra conduction-band electrons with no corresponding valence-band holes (n-doping) or they may create extra holes with no corresponding electrons (p-doping).  In this case we can no longer assume $n_e = n_h$.  However, the relation
\begin{equation}
n_en_h = n_Q^2\,e^{-\Delta/k_BT} = n_i^2
\end{equation}
still holds.  The doping is usually small enough that $\Delta$ and $n_Q$ will be unaffected, and so the intrinsic carrier density $n_i$ will also remain the same.  But the doping may have increased $n_e$ by several orders of magnitude over its pure-crystal value, and in this case:
\begin{equation}
n_h = \frac{n_i^2}{n_e}
\end{equation}
will decrease by several orders of magnitude.  Alternately, $n_h$ may have been dramatically increased and $n_e$ dramatically decreased.  Either way, both electron and hole concentrations will be affected.  Usually you will be given the new value of one and asked to solve for the new value of the other.

\subsection{Atoms adsorbed onto the surface of a solid}
As a final example of chemical potential stuff, suppose we have $N$ atoms stuck to the surface of a solid which has a temperature $T$.  Each atom can either occupy one of $M_1$ sites in which it will have a binding energy $\Delta_1$ or one of $M_2$ sites in which it will have a binding energy $\Delta_2$ where there are many more sites of either type than atoms.  We would like to know the equilibrium number of atoms bound to each type of site.  Be aware that the term ``binding energy'' means the amount of energy which is required to \emph{remove} an atom from that site.  So when the atom is bound to a site of type $i$ it has a potential energy $-\Delta_i$.

In this case the number of microstates for which $N_1$ atoms are bound to sites of type one will be
\begin{equation}\Omega_1 \approx \frac{M_1^{N_1}}{N_1!}\end{equation}
(dilute approximation, indistinguishable particles) and similarly for the $N_2$ atoms bound to sites of type 2.  So the entropy of the type-$i$ particles will be
\begin{equation}S_i = k_B\ln\Omega_i \approx N_ik_B\left(\ln\left(\frac{M_i}{N_i}\right) + 1\right)\end{equation}
and their free energy will be
\begin{equation}F_i = -N_i\Delta_i - N_ik_BT\left(\ln\left(\frac{M_i}{N_i}\right) + 1\right)\end{equation}
which gives chemical potentials of:
\begin{equation}\mu_i = -\Delta_i - k_BT\ln\left(\frac{M_i}{N_i}\right)\end{equation}
The equilibrium chemical potential relation is similar to that for gas particles in the atmosphere:
\begin{eqnarray*}
1 &\longleftrightarrow& 2\\
\mu_1 &=& \mu_2
\end{eqnarray*}
and plugging in the chemical potentials and rearranging gives:
\begin{equation}
\frac{N_1}{N_2} = \frac{M_1}{M_2}e^{-(\Delta_1-\Delta_2)/k_BT}
\end{equation}
for the ratio of the number of particles on type-1 sites to the number of particles on type-2 sites.

\section{Laws of Thermodynamics}
The first law of thermodynamics is simply a statement of energy conservation.  It says that in a thermodynamical problem, the only ways you can change the internal energy of an object are by adding heat energy to it (thermal contact with another object), or by allowing it to do work ({\it eg.} letting an ideal gas expand).  In this case the change in the internal energy of the object will be:
\begin{equation}\Delta U_{\mathrm{int}} = Q_{\mathrm{in}} - W_{\mathrm{by}}\end{equation}
Of course if the object has work done on it instead of doing work, then $W_{\mathrm{by}}$ may be replaced by $-W_{\mathrm{on}}$.

The second law of thermodynamics states that the total entropy of an isolated system may never decrease.  At best, entropy can remain constant, for a perfectly reversible process, but in general entropy is going up all the time.  It \emph{may} be true that the entropy of a particular part of the system decreases during a particular process, but other parts of the system will then see a corresponding entropy increase which is at least equal to if not greater than that entropy loss.  The whole universe is (probably) an isolated system.  The earth is \emph{not} an isolated system, since the sun is dumping energy on us all the time, in the form of a continuous influx of photons.  So:
\begin{equation}\Delta S_{\mathrm{isolated}} \ge 0\end{equation}

And the third and final law of thermodynamics, which has little impact on this course, is that the total entropy of any system at absolute zero (0 K) is zero.  So, there is only one possible microstate for a system at absolute zero:
\begin{equation}S(T = 0\,\mathrm{K}) = 0\end{equation}
\end{document}
