The field of statistical thermodynamics starts with the definition of the system in an ensemble. An ensemble is a collection of systems that are identical in certain respects, but have fluctuations in certain variables. There are four common ensembles:
Microcanonical = number of states can vary
Canonical = internal energy can vary
Isobaric-Isothermal = enthalpy can vary
Grand Canonical = number of particles can vary
The central role of the system partition function is based on the hypothesis that we can treat matter as a collection of systems (an ensemble). In the canonical ensembles all of the systems have the same N, V and T, but the internal energy, E or U, can vary. The statistical fluctuations in the energy account can explain the heat capacity and entropy of the system. The canonical ensemble is most useful for the derivation of internal energy and Helmholtz free energy. However, we can also derive and expression for the pressure and therefore the work term can be included. In this way, we can also derive expressions for the enthalpy and Gibbs free energy. The starting point for all of these derivations is the system partition function in the ensemble where N, V and T are fixed in each system. We consider first how this is defined.
The system partition function appears in each thermodynamic quantity. The system partition function is composed of molecular partition functions, Q = qN/N! (for indistinguishable particles). Since the partition function can be interpreted as the average number of occupied levels at a given temperature we can intuitively understand that it would be related to energy and entropy. The general derivation shows that U = kT2(d ln Q/dT) and A = kT ln Q. Since A = U - TS, we can also see that S = (U - U0)/T + k ln Q. We next consider how these expressions are derived from energy considerations of the statistical method for calculating properties.