Statistical mechanics connects microstates to macrostates through probability distributions. Its microcanonical ensemble, canonical ensemble and grand canonical ensemble specify different constraints on exchanges with the surroundings. An ensemble average describes repeated preparations under those constraints; it need not be the value in every individual preparation.
This makes the subject useful whenever tracking every microscopic detail would obscure the question being asked. To predict a heat capacity, we need how the expected value of energy changes with temperature, rather than a record of every unit's state. The partition function packages that calculation into one reusable object.
In his 1902 book, J. Willard Gibbs systematically developed the canonical ensemble. His preface contrasts following one system through time with studying a collection of systems with different microscopic conditions. Chapter IV defines the canonical ensemble through an exponential function of energy and establishes its normalization. This supplied a general strategy for predicting collective measurements by averaging over possible microscopic conditions, with the partition function organizing the calculation. [ref] [ref]
Boundaries or inclusions change the available thermal or quantum fluctuations and thereby the free energy. Their force follows from under specified control conditions. Electromagnetic dispersion, depletion and critical fluctuations are distinct realizations, with signs and ranges set by their physical modes and boundary conditions.
Confining a near-critical fluctuating order parameter changes its free energy. Its range is governed by the growing correlation length, and its sign depends on the boundary preferences. This is a thermal collective effect, distinct from the zero-temperature ideal-conductor electromagnetic formula.
Two parallel ideal conducting plates at zero temperature have separation-dependent electromagnetic energy per area and pressure . The negative sign denotes attraction in this geometry. Finite temperature, material response and boundary geometry change the ideal result; an absolute divergent vacuum energy is not the measured quantity.
For a massless real scalar in one spatial dimension, applying to both the Dirichlet mode sum and the unbounded-line integral gives the same leading bulk energy . Their finite difference is in units , producing the attractive force . This scalar boundary force is distinct from the retarded atom-surface Casimir-Polder interaction.
classical statistical mechanics assigns probability distributions to classical states. For a Hamiltonian particle system the canonical weight is on phase space. The weak-exchange, high-temperature limit of a quantum gas supplies the measure per particle and the indistinguishable-particle factor .
quantum statistical mechanics describes equilibrium and fluctuations with density matrices and traces over a quantum Hilbert space. The canonical equilibrium state is , while particle exchange introduces in the grand canonical ensemble. Noncommutativity and particle exchange distinguish it from a classical phase-space distribution.

Articles by others on the same topic (2)

Statistical mechanics is a branch of theoretical physics that connects the microscopic properties of individual atoms and molecules to the macroscopic properties of materials and systems. It provides a framework for understanding thermodynamics in terms of the behavior of large numbers of particles, allowing for predictions about bulk properties based on the statistical behavior of microscopic states.