Partition function (statistical mechanics)
From Academic Kids

In statistical mechanics, the partition function Z is an important quantity that encodes the statistical properties of a system in thermodynamic equilibrium. It is a function of temperature and other parameters, such as the volume enclosing a gas. Most of the thermodynamic variables of the system, such as the total energy, free energy, entropy, and pressure, can be expressed in terms of the partition function or its derivatives.
There are actually several different types of partition function, each corresponding to different types of statistical ensemble (or, equivalently, different types of free energy.) The canonical partition function applies to a canonical ensemble, in which the system is allowed to exchange heat with the environment at fixed temperature, volume, and number of particles. The grand canonical partition function applies to a grand canonical ensemble, in which the system can exchange both heat and particles with the environment, at fixed temperature, volume, and chemical potential. Other types of partition functions can be defined for different circumstances.
Contents 
Canonical partition function
Definition
Suppose we have a thermodynamically large system that is in constant thermal contact with the environment, which has temperature T, with both the volume of the system and the number of constituent particles fixed. This kind of system is called a canonical ensemble. Let us label the exact states (microstates) that the system can occupy by j (j = 1, 2, 3, ...), and denote the total energy of the system when it is in microstate j as E_{j}. Generally, these microstates can be regarded as discrete quantum states of the system.
The canonical partition function is
 <math> Z = \sum_{j} e^{ \beta E_j}<math>
where the "inverse temperature" β is conventionally defined as
 <math>\beta \equiv \frac{1}{k_BT}<math>
with k_{B} denoting Boltzmann's constant.
In classical statistical mechanics, it is not really correct to express the partition function as a sum of discrete terms, as we have done. In classical mechanics, the position and momentum variables of a particle can vary continuously, so the set of microstates is actually uncountable. In this case, some form of coarse graining procedure must be carried out, which essentially amounts to treating two mechanical states as the same microstate if the differences in their position and momentum variables are "not too large". The partition function then takes the form of an integral. For instance, the partition function of a gas of N classical particles is
 <math>Z=\frac{1}{N!h^{3N}} \int \, \exp[\beta H(p_1 \cdots p_N, x_1
\cdots x_N)] \; d^3p_1 \cdots d^3p_N \, d^3x_1 \cdots d^3x_N <math>
where h is some infinitesimal quantity with units of action (usually taken to be Planck's constant, in order to be consistent with quantum mechanics), and H is the classical Hamiltonian. The reason for the N! factor is discussed below. For simplicity, we will use the discrete form of the partition function in this article, but our results will apply equally well to the continuous form.
In quantum mechanics, the partition function can be more formally written as a trace over the state space (which is independent of the choice of basis):
 <math>Z=\operatorname{tr} ( e^{\beta H} )<math>
where H is the quantum Hamiltonian operator. Note that the exponential of an operator is defined using the usual power series.
Meaning and significance
It may not be obvious why the partition function, as we have defined it above, is an important quantity. Firstly, let us consider what goes into it. The partition function is a function of, firstly, the temperature T; and, secondly, the microstate energies E_{1}, E_{2}, E_{3}, etc. The microstate energies are determined by other thermodynamic variables, such as the number of particles and the volume, as well as microscopic quantities like the mass of the constituent particles. This dependence on microscopic variables is the central point of statistical mechanics. With a model of the microscopic constituents of a system, one can calculate the microstate energies, and thus the partition function, which will then allow us to calculate all the other thermodynamic properties of the system.
The partition function can be related to thermodynamic properties because it has a very important statistical meaning. The probability P_{j} that the system occupies microstate j is
 <math>P_j = \frac{1}{Z} e^{ \beta E_j} <math>
This is the wellknown Boltzmann factor. (For a detailed derivation of this result, see Derivation of the partition function.) The partition function thus plays the role of a normalizing constant (note that it does not depend on j), ensuring that the probabilities add up to one:
 <math>\sum_j P_j = \frac{1}{Z} \sum_j e^{ \beta E_j} = \frac{1}{Z} Z
= 1 <math>
This is the reason for calling Z the "partition function": it encodes how the probabilities are partitioned among the different microstates, based on their individual energies. The letter Z stands for the German word Zustandsumme, "sum over states".
Calculating the thermodynamic total energy
In order to demonstrate the usefulness of the partition function, let us calculate the thermodynamic value of the total energy. This is simply the expected value, or ensemble average for the energy, which is the sum of the microstate energies weighted by their probabilities:
 <math>\langle E \rangle = \sum_j E_j P_j = \frac{1}{Z} \sum_j E_j
e^{ \beta E_j} =  \frac{1}{Z} \frac{\partial}{\partial \beta} Z(\beta, E_1, E_2, \cdots) =  \frac{\partial \ln Z}{\partial \beta} <math>
or, equivalently,
 <math>\langle E\rangle = k_B T^2 \frac{\partial \ln Z}{\partial T}
<math>
Incidentally, one should note that if the microstate energies depend on a parameter λ in the manner
 <math>E_j = E_j^{(0)} + \lambda A_j \qquad \mbox{for all}\; j <math>
then the expected value of A is
 <math>\langle A\rangle = \sum_j A_j P_j = \frac{1}{\beta}
\frac{\partial}{\partial\lambda} \ln Z(\beta,\lambda)<math>
This provides us with a trick for calculating the expected values of many microscopic quantities. We add the quantity artificially to the microstate energies (or, in the language of quantum mechanics, to the Hamiltonian), calculate the new partition function and expected value, and then set λ to zero in the final expression. This is analogous to the source field method used in the path integral formulation of quantum field theory.
Relation to thermodynamic variables
In this section, we will state the relationships between the partition function and the various thermodynamic parameters of the system. These results can be derived using the method of the previous section and the various thermodynamic relations.
As we have already seen, the thermodynamic energy is
 <math>\langle E \rangle =  \frac{\partial \ln Z}{\partial \beta}
<math>
The variance in the energy (or "energy fluctuation") is
 <math>\langle \delta E^2 \rangle \equiv \langle (E  \langle
E\rangle)^2 \rangle = \frac{\partial^2 \ln Z}{\partial \beta^2} <math>
The heat capacity is
 <math>C_v = \frac{\partial \langle E\rangle}{\partial T} = \frac{1}{k_B T^2} \langle \delta E^2 \rangle <math>
The entropy is
 <math>S= k_B (\ln Z + \beta \langle E\rangle) <math>
The above expression allows us to identify the Helmholtz free energy F (defined as F = E  TS, where E is the total energy and S is the entropy) as
 <math>F =  k_B T \ln Z<math>
Partition functions of subsystems
Suppose a system is subdivided into N subsystems with negligible interaction energy. If the partition functions of the subsystems are ζ_{1}, ζ_{2}, ... ζ_{N}, then the partition function of the entire system is the product of the individual partition functions:
 <math>Z =\prod_{j=1}^{N} \zeta_j<math>
If the subsystems have the same physical properties, then their partition functions are equal, ζ_{1} = ζ_{2} = ... = ζ, in which case
 <math>Z = \zeta^N<math>
However, there is a wellknown exception to this rule. If the subsystems are actually identical particles, in the quantum mechanical sense that they are impossible to distinguish even in principle, the total partition function must be divided by a N! (N factorial):
 <math>Z = \frac{\zeta^N}{N!}<math>
This is to ensure that we do not "overcount" the number of microstates. While this may seem like a strange requirement, it is actually necessary to preserve the existence of a thermodynamic limit for such systems. This is known as the Gibbs paradox.
Grand canonical partition function
Definition
In a manner similar to the definition of the canonical partition function for the canonical ensemble, we can define a grand canonical partition function for a grand canonical ensemble, a system that can exchange both heat and particles with the environment, which has a constant temperature T, volume V, and chemical potential μ. The grand canonical partition function, although conceptually more involved, simplifies the calculation of the physics of quantum systems. The grand canonical partition function <math>\mathcal{Z}<math> for an ideal quantum gas is written:
 <math>
\mathcal{Z} = \sum_{N=0}^\infty\,\sum_{\{n_i\}}\,\prod_i e^{\beta n_i(\epsilon_i\mu)} <math>
where N is the total number of particles in the volume V, and index i runs over every microstate of the system, with n_{i } being the number of particles in state i and ε_{i } being the energy of state i. {n_{i}} is the set of all possible occupation numbers for each of the microstates such that Σ_{i}n_{i}=N. For example, consider the N=3 term in the above sum. One possible set of occupation numbers would be {n_{i}}=0,1,0,2,0... and the contribution of this set of occupation numbers to the N=3 term would be
 <math>
\prod_i e^{\beta n_i(\epsilon_i\mu)}=e^{\beta(\epsilon_1\mu)}\,e^{2\beta(\epsilon_3\mu)}
<math>
For bosons, the occupation numbers can take any integer values as long as their sum is equal to N. For fermions, the Pauli exclusion principle requires that the occupation numbers only be 0 or 1, again adding up to N.
Specific expressions
The above expression for the grand partition function can be shown to be mathematically equivalent to:
 <math>
\mathcal{Z} = \prod_i \mathcal{Z}_i <math>
(Note: the above product is sometimes taken over all states with equal energy, rather than over each state, in which case the individual partition functions must be raised to a power g_{i} where g_{i} is the number of such states. g_{i} is also referred to as the "degeneracy" of states.)
For a system composed of bosons:
 <math>
\mathcal{Z}_i = \sum_{n_i=0}^\infty e^{\beta n_i(\epsilon_i\mu)} = \frac{1}{1e^{\beta (\epsilon_i\mu)}} <math>
and for a system composed of fermions:
 <math>
\mathcal{Z}_i = \sum_{n_i=0}^1 e^{\beta n_i(\epsilon_i\mu)} = \left(1+e^{\beta (\epsilon_i\mu)}\right) <math>
For the case of a MaxwellBoltzmann gas, we must use "correct Boltzmann counting" and divide the Boltzmann factor <math>e^{\beta (\epsilon_i\mu)}<math> by n_{i}!.
 <math>
\mathcal{Z}_i = \sum_{n_i=0}^\infty \frac{e^{\beta n_i(\epsilon_i\mu)}}{n_i!} = \exp \left( e^{\beta (\epsilon_i\mu)}\right) <math>
Relation to thermodynamic variables
Just as with the canonical partition function, the grand canonical partition function can be used to calculate thermodynamic and statistical variables of the system. As with the canonical ensemble, the thermodynamic quantities are not fixed, but have a statistical distribution about a mean or expected value.
 Defining α=βμ, the most probable occupation numbers are:
 <math>
 <math>
 <math>
 <math>
 Total number of particles
 <math>
 Variance in total number of particles
 <math>
 Internal energy
 <math>
 Variance in internal energy
 <math>
 Pressure
 <math>
 Mechanical equation of state
 <math>
Discussion
Before specific results can be obtained from the grand canonical partition function, the energy levels of the system under consideration need to be specified. For example, the particle in a box model or particle in a harmonic oscillator well provide a particular set of energy levels and are a convenient way to discuss the properties of a quantum fluid. (See the gas in a box and gas in a harmonic trap articles for a description of quantum fluids.) These results may be used to construct the grand partition function to describe an ideal Bose gas or Fermi gas, and can be used as well to describe a classical ideal gas.
References
 Huang, Kerson, "Statistical Mechanics", John Wiley \& Sons, New York, 1967.
 A. Isihara, "Statistical Physics", Academic Press, New York, 1971.
 Kelly, James J, (Lecture notes) (http://www.physics.umd.edu/courses/Phys603/kelly/Notes/IdealQuantumGases.pdf)
 L. D. Landau and E. M. Lifshitz, "Statistical Physics, 3rd Edition Part 1", ButterworthHeinemann, Oxford, 1996.