A simple
but approximate algorithm is described for computing second
virial coefficients based on equilibrated molecular configurations
that may be generated during any Monte Carlo or molecular dynamics
simulation. The algorithm uses simple quadrature based on sampling
every binary pair in the configuration and moving their center–center
distances from zero to infinity. Comparisons are made in the literature
results using more sophisticated sampling and integration for n-alkanes of ethane through n-dodecane.
Accuracy is within the error bars determined by block averaging, and
temperature effects can be inferred using a single configurational
temperature, including perturbative virial coefficients. Predictably,
the accuracy is best at the configurational temperature and when the
configurational density is lowest. More notably, good accuracy is
achieved from configurations at intermediate densities, and the trend
at high density conveys valuable insight about conformational changes.
The algorithm is simple enough to assign as a homework problem in
an introductory molecular modeling course and reinforces the elementary
knowledge of pairwise potentials among multisite molecules, numerical
integration, and conformational averaging. The result is also quite
valuable on its own merits, especially considering thermodynamic integration
to compute phase equilibria. Additionally, the incidental data derived
from the computation can provide simple but meaningful insights into
the nature of multisite interactions, as demonstrated by relating
the Mayer averaged potential to an effective Mie potential. Altogether,
the argument is made that the computation of the second virial coefficient
should be considered to be a routine metric of any molecular simulation,
such as the radial distribution function, pressure, or energy.