  The virial theorem relates averages of kinetic energy and forces in confined
systems. It is widely used to relate stresses in molecular simulation as
measured at a boundary and in the interior of a system. In periodic systems,
the theorem must be modified in order to produce useful results. We formulate
the theorem so that it is valid for both confined and for periodic systems. We
cross-check our formulation in a study of a small system using both Monte Carlo
and molecular dynamics simulations.
