# Partition Functions

Consider two canonical systems, 1 and 2, with particle numbers $$N_1$$ and $$N_2$$, volumes $$V_1$$ and $$V_2$$ and at temperature $$T$$. The systems are in chemical contact, meaning that they can exchange particles. Furthermore, we assume that $$N_2 \gg N_1$$ and $$V_2 \gg V_1$$ so that system 2 is a particle reservoir. The total particle number and volume are

$V = V_1 + V_2$

$N = N_1 + N_2$

The total Hamiltonian $$H (x, N )$$ is

$H(x,N) = H_1(x_1,N_1) + H_2(x_2,N_2)$

If the systems could not exchange particles, then the canonical partition function for the whole system would be

$Q(N,V,T) = \dfrac {1}{N! h^{3N}}\int dx \, e^{-\beta (H_1(x_1,N_1)+ H_2(x_2,N_2))}$

$= \dfrac {N_1! N_2!}{N!}Q_1(N_1,V_1,T)Q_2(N_2,V_2,T)$

where

$Q_1(N_1,V_1,T) = \dfrac{1}{N_1! h^{3N_1}}\int dx \, e^{-\beta H_1(x_1,N_1)}$

$Q_2(N_2,V_2,T) = \dfrac{1}{N_2! h^{3N_2}}\int dx \, e^{-\beta H_2(x_2,N_2)}$

However, $$N_1$$ and $$N_2$$ are not fixed, therefore, in order to sum over all microstates, we need to sum over all values that $$N_1$$ can take on subject to the constraint $$N = N_1 + N_2$$. Thus, we can write the canonical partition function for the whole system as

$Q(N,V,T) = \sum_{N_1=0}^N f(N_1,N) \frac {N_1! N_2!}{N!} Q_1(N_1,V_1,T) Q_2(N_2,V_2,T)$

where $$f (N_1, N_2 )$$ is a function that weights each value of $$N_1$$ for a given $$N$$. Thus,

$$f (0, N )$$ is the number of configurations with 0 particles in $$V_1$$ and $$N$$ particles in $$V_2$$.

$$f (1, N)$$ is the number of configurations with 1 particles in $$V_1$$ and $$N - 1$$ particles in $$V_2$$.

etc.

Determining the values of $$f (N_1, N )$$ amounts to a problem of counting the number of ways we can put $$N$$ identical objects into 2 baskets. Thus,

$f (0, N ) = 1$

$f (1, N) = N = \frac {N!}{1! (N - 1)! }$

$f(2,N)=\frac {N(N-1)}{2} = \frac {N!}{2!(N-2)!}$

etc. or generally,

$f(N_1,N) = \frac {N!}{N_1! (N-N_1)!} = \frac {N!}{N_1! N_2!}$

which is clearly a classical degeneracy factor. If we were doing a purely classical treatment of the grand canonical ensemble, then this factor would appear in the sum for $$Q (N, V, T )$$, however, we always include the ad hoc quantum correction $$\frac {1}{N !}$$ in the expression for the canonical partition function, and we see that these quantum factors will exactly cancel the classical degeneracy factor, leading to the following expression:
$Q(N,V,T) = \sum_{N_1=0}^N Q_1(N_1,V_1,T)Q_2(N_2,V_2,T)$

which expresses the fact that, in reality, the various configurations are not distinguishable from each other, and so each one should count with equal weighting. Now, the distribution function $$\rho(x)$$ is given by

$\rho(x,N) = \frac{\frac{1}{N!h^{3N}}e^{-\beta H(x,N)}}{Q(N,V,T)}$

which is chosen so that

$\int dx \rho(x,N) = 1$

However, recognizing that $$N_2 \approx N$$, we can obtain the distribution for $$\rho _1 (x_1, N_1)$$ immediately, by integrating over the phase space of system 2:

$\rho_1(x_1,N_1) = \frac{1}{Q(N,V,T)} \frac{1}{N_1! h^{3N_1}}e^{-\beta H_1 (x_1, N_1)} \frac{1}{N_2! h^{3N_2}}\int dx_2 e^{-\beta H_2(x_2,N_2)}$

where the $$\frac{1}{N_1! h^{3N_1}}$$ prefactor has been introduced so that

$\sum_{N_1=0}^N \int dx_1 \rho(x_1,N_1) = 1$

and amounts to the usual ad hoc quantum correction factor that must be multiplied by the distribution function for each ensemble to account for the identical nature of the particles. Thus, we see that the distribution function becomes

$\rho_1(x_1,N_1) = \frac {Q_2(N_2,V_2,T)}{Q(N,V,T)} \frac{1}{N_1! h^{3N_1}}e^{-\beta H_1(x_1,N_1)}$

Recall that the Hemlholtz free energy is given by

$A = -\frac {1}{\beta}\ln Q$

Thus,

 $$Q(N,V,T)$$ $$e^{-\beta A(N,V,T)}$$ $$Q_2(N_2,V_2,T)$$ $$e^{-\beta A(N_2,V_2,T)} =e^{-\beta A(N-N_1,V-V_1,T)}$$

or

$\frac {Q_2(N_2,V_2,T)}{Q(N,V,T)} = e^{-\beta (A(N-N_1,V-V_1,T) -A(N,V,T))}$

But since $$N \gg N_1$$ and $$V \gg V_1$$, we may expand:
 $$A(N-N_1,V-V_1,T)$$ $$A(N,V,T) - \frac{\partial A}{\partial N}N_1- \frac{\partial A}{\partial V}V_1 + \cdots$$ $$A(N,V,T) - \mu N_1 + PV_1 + \cdots$$

Therefore the distribution function becomes

 $$\rho_1(x_1,N_1)$$ $$\frac{1}{N_1! h^{3N_1}}e^{\beta \mu N_1}e^{-\beta PV_1}e^{-\beta H_1(x_1,N_1)}$$ $$\frac{1}{N_1! h^{3N_1}} \frac{1}{e^{\beta PV_1}}e^{\beta \mu N_1}e^{-\beta H_1(x_1,N_1)}$$

Dropping the 1'' subscript, we have

$\rho(x,N) =\frac{1}{e^{\beta PV}}\left[\frac{1}{N! h^{3N}}e^{\beta \mu N}e^{-\beta H(x,N)}\right]$

We require that $$\rho (x, N)$$ be normalized:
 $$\sum_{N=0}^{\infty}\int dx\rho(x,N)$$  $$\frac{1}{e^{\beta PV}}\left[\sum_{N=0}^{\infty} \frac{1}{N! h^{3N}}e^{\beta \mu N}\int dxe^{-\beta H(x,N)}\right]$$  Now, we define the grand canonical partition function

${\cal Z}(\mu,V,T) = \sum_{N=0}^{\infty} \frac{1}{N! h^{3N}}e^{\beta \mu N}\int dxe^{-\beta H(x,N)}$

Then, the normalization condition clearly requires that

${\cal Z}(\mu,V,T) = e^{\beta PV}$

$\ln {\cal Z}(\mu,V,T) = \frac{PV}{kT}$

Therefore $$PV$$ is the free energy of the grand canonical ensemble, and the entropy $$S (\mu , V, T )$$ is given by

$S(\mu,V,T) = \left(\frac{\partial (PV)}{\partial T}\right)_{\mu, V} = k \ln {\cal Z} (\mu, V, T) - k \beta \left ( \frac {\partial}{\partial \beta } \ln {\cal Z}(\mu,V,T)\right)_{\mu,V}$

We now introduce the fugacity $$\zeta$$ defined to be

$\zeta = e^{\beta \mu}$

Then, the grand canonical partition function can be written as

${\cal Z}(\zeta,V,T) = \sum_{N=0}^{\infty} \frac{1}{N! h^{3N}} \zeta ^N \int dx e^{-\beta H(x,N)} =\sum_{N=0}^{\infty} \zeta^N Q(N,V,T)$

which allows us to view the grand canonical partition function as a function of the thermodynamic variables $$\zeta , V$$ and $$T$$.

$\frac{\partial}{\partial \mu} = \frac{\partial \zeta}{\partial \zeta}= \beta \zeta\frac{\partial}{\partial \zeta}$

Thus,

$\langle N \rangle = \zeta \frac{\partial}{\partial \zeta}\ln {\cal Z}(\zeta,V,T)$

## Energy

$E = \langle H(x,N)\rangle = \dfrac{1}{\cal {Z}}\sum_{N=0}^{\infty} \dfrac{\zeta^N}{N! h^{3N}}\int dxH(x,N)e^{-\beta H(x,N)}$

$= -\left(\frac{\partial\ln {\cal Z}(\zeta,V,T)}{\partial \beta}\right)_{\zeta,V}$

Average particle number

$\langle N \rangle = kT\left(\frac{\partial \ln {\cal Z}(\mu,V,T)}{\partial \mu}\right)_{V,T}$

This can also be expressed using the fugacity by noting that