In the second chapter of Understanding Molecular Simulation, Frenkel and Smit derive an equation for the partition function and the thermal average of the generic observable A, stating that these equations "are the starting point of virtually all classical simulations of many-body systems".

I understand the theoretical significance of the partition function, and I can see how, in theory, by knowing the partition function one would know the energy of the system, and if I'm not mistaken, also all the other thermodynamic quantities one could be interested in.

What leaves me confused is the practical use of the partition function in the computational chemist's work. I have some experience with running simulations with programs such as LAMMPS and GROMACS, and yet have never had a real first-hand encounter with the partition function. Is it used by the programs to compute the thermodynamic quantities they output? If so, would it be possible to provide a general description of how this is done?

  • 3
    $\begingroup$ The partition function is impractical to compute, so the reason you never encounter it in simulation is because you can't work with it; the fact that the partition function is also the normalization constant for probabilities means that simulations have to work around this inconvenience instead. This is what motivates the use of Monte Carlo methods in simulation: you never have to work with absolute probabilities (hard to compute because of the partition function), but only their ratios (the partition function cancels out). $\endgroup$ Sep 21, 2021 at 19:14

2 Answers 2


The actual partition function is unimaginably formidable. For just $N$ point particles in a 3D box, it's already got $3N$ dimensions. If the box is length $L$, GROMACS would probably divide the box into a machine-precision grid and calculate the energy from $\sim L \times 10^{10}$ values in each dimension. The partition function would incorporate all of that information, the energy at each of those $L \times 10^{30N}$ points; even for two particles in a one unit box, that's already $10^{60}$.

When you speak of "the partition function" you're talking about the entire thermodynamic state of the system and all of its possible permutations. If we truly knew that function, we would be omniscient and could calculate anything about the system! Since we can't really calculate at the level of the entire partition function, we use simulations (MC and MD, etc.) to sample regions of interest (usually low-energy areas).

To a computational chemist, the partition function is most practical for its mathematical basis. It's the way to get from statistical mechanics (a bunch of particles moving around in a box) to actual thermodynamic properties (Helmholtz energy, pressure, etc.).

As a practical example, imagine you want to calculate the surface tension for some fluid interacting according to some potential function. Using LAMMPS or GROMACS, you can set up your vapor-liquid interface in the simulation box. Then by simply changing (perturbing) the simulation box shape and measuring the energy change, you can calculate the surface tension. The whole derivation of this method starts with the configuration integral of the partition function and then, via mathematical manipulation, eventually leads to the quantity we want to calculate and variables we can actually measure.

Test-area method - Gloor and Jackson, J. Chem. Phys. 123, 134703 (2005)

Free energy perturbation - Zwanzig, J. Chem. Phys. 22, 1420 (1954)

  • $\begingroup$ But to your last point: is it used in practice in a quite direct way? if so, how? $\endgroup$ Sep 19, 2021 at 16:50
  • $\begingroup$ @simulation_engine I have edited and hopefully addressed this now! $\endgroup$ Sep 19, 2021 at 19:43
  • $\begingroup$ thanks for the edit, it did address my question more fully. it would be great if you could provide a couple additional examples that have to do with some other properties besides the surface tension. in any case i'll mark your answer as the accepted answer. $\endgroup$ Sep 20, 2021 at 7:03

Partition function, by definition can be written, \begin{align} Q&=\frac{1}{N!h^{3N}}\int_{-\infty}^{\infty}d\textbf{P}\int d\textbf{R} e^{-\beta U(\textbf{P},\textbf{R})}. \end{align} In most cases, the integral over $\textbf{P}$ can be calculated analytically, leaving only $\textbf{R}$ contribution left inside the integral. It is easy to see that direct integration of the Boltzmann factor($e^{-\beta U(\textbf{R})}$), is impractical; you need to sample all possible configurations. Roughly speaking, the partition function in statistical mechanics is like wave function in quantum mechanics. If you know analytically form of the functions, you know everything about the system, but the function itself does not have clear meanings. Of course, knowing the analytical form of the functions is out of reach except for few simplest examples. That brings us to your question of what practical use the partition function has.

My answer to that would be "free energy".

Free energy not only directs in which direction a system will evolve over time but also relative probabilities of different states of the system when it reached equilibrium. For example, under fixed number of particles, volume, and temperature, system's partition function, called canonical partition function is related to Helmholtz free energy, $A$, \begin{align} A&=-\frac{1}{\beta} \ln Q. \end{align} I am not going to prove the equation above, but maybe you can look it up somewhere online. What I want to show is how such relation connects free energy differences between states to relative probabilities between the states when the system has reached equilibrium. First of all, the range of integral over $\textbf{R}$ in $Q$ is considered along the volume of the system but can be limited to the states of interest. For instance, consider two states, $a$ and $b$, where all particles are limited in $R_a$ or $R_b$ for each state, where both of them are subspaces of $R$. The free energy of state $a(b)$ can be written, \begin{align} \label{eq:twopartitionfuctions} A_{a(b)}&=-\frac{1}{\beta} \ln Q_{a(b)}\\ \text{where, }Q_{a(b)} &=\frac{1}{N!h^{3N}}\int_{-\infty}^{\infty}d\textbf{P}\int _{a(b)}d\textbf{R} e^{-\beta U(\textbf{P},\textbf{R})}. \end{align} The range of integral for position vector $\textbf{R}$, is limited to each state $a$ or $b$. The difference between the two free energies can be written, \begin{align} \label{eq:twopartitionfuctions1} \Delta A&=A_{b}-A_{a}\\ \label{eq:twopartitionfuctions2} &=-\frac{1}{\beta} \ln \frac{Q_{b}}{Q_{a}}\\ \label{eq:twopartitionfuctions3} &=-\frac{1}{\beta} \ln \frac{\frac{Q_{b}}{Q}}{\frac{Q_{a}}{Q}}. \end{align} The denominator inside the logarithm, $\frac{Q_{b}}{Q}$ can be expanded, \begin{align} \label{eq:twopartitionfuctions4} \frac{Q_{b}}{Q}&=\int _{b}d\textbf{R} \frac{e^{-\beta V(\textbf{R})}}{\int d\textbf{R} e^{-\beta V(\textbf{R})}}\\ \label{eq:twopartitionfuctions5} &=\int _{b}d\textbf{R} P(\textbf{R} )\\ \label{eq:twopartitionfuctions6} &=P_b, \end{align} where $P(\textbf{R})$ is Boltzmann probability, and $P_b$ is probability of system to be at state $b$ in equilibrium. Using the result, the free energy difference between state $A$ and $B$, $\Delta A$ is related to there relative probabilities in equilibrium, \begin{align} \label{eq:twopartitionfuctions7} \Delta A&=-\frac{1}{\beta} \ln \frac{P_{b}}{P_{a}}. \end{align}

In summary, partition function is related to free energy and free energy is related to equilibrium probability. Knowing the probability is critical on understanding a physical or chemical phenomenon like in the example of drug binding. When designing a drug, we want the drug to favor the target site most, but not other sites in the target protein and sites in other proteins. The probability of the drug binding to many possible binding sites will tell if the drug is a good candidate or not. That is just one example of why free energy calculations are important topics in the field of computational chemistry.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.