Test volume method
An alternative to the virial pressure route to calculating the pressure, there is a method which consists on evaluating the change in internal energy, produced by a small change in the volume of the system .
This should be tough of as a "blow-up" (or "in") of the whole system, with a small (same for y and ), exactly in the way as the virial pressure expression may be derived - not as leaving the particles in their places and changing the simulation cell (a procedure which does not make sense in general).
It can be shown that
where is the Boltzmann constant and is the temperature. The method is clearly inspired by the Widom test-particle method to obtain the chemical potential.
It has been argued that this method can be more useful than virial pressure since it avoids the calculation of forces (which are not needed in a Monte Carlo simulation). Moreover, there are interaction potentials that are discontinuous - in this case, the forces are not well defined, and one should consider the limit of "almost-discontinuous" potentials instead, which can be cumbersome. However, it is not clear how to "blow up" a system containing molecules held by rigid constraints.