  Kirkwood-Buff (KB) integrals are notoriously difficult to converge from a
canonical simulation because they require estimating the grand-canonical radial
distribution. The same essential difficulty is encountered when attempting to
estimate the direct correlation function of Ornstein-Zernike theory by
inverting the pair correlation functions. We present a new theory that applies
to the entire, finite, simulation volume, so that no cutoff issues arise at
all. The theory gives the direct correlation function for closed systems, while
smoothness of the direct correlation function in reciprocal space allows
calculating canonical KB integrals via a well-posed extrapolation to the
origin. The present analysis method represents an improvement over previous
work because it makes use of the entire simulation volume and its convergence
can be accelerated using known properties of the direct correlation function.
Using known interaction energy functions can make this extrapolation near
perfect accuracy in the low-density case. Because finite size effects are
stronger in the canonical than the grand-canonical ensemble, we state ensemble
correction formulas for the chemical potential and the KB coefficients. The new
theory is illustrated with both analytical and simulation results on the 1D
Ising model and a supercritical Lennard-Jones fluid. For the latter, the
finite-size corrections are shown to be small.
