A method to simulate a semi-infinite continuum system in the grand canonical ensemble is proposed. It uses a Monte Carlo method to evaluate the largest eignvalue of the Kramers–Wannier matrix. For a two-dimensional system of parallel hard squares the pressure and the density computed from the proposed grand-canonical-ensemble method show satisfactory agreement with the corresponding canonical-ensemble calculations at densities below 72% of the close-packed density. An approximate method for high-density calculations is proposed.