  We introduce a quantum Monte Carlo method at finite temperature for
interacting fermionic models in the canonical ensemble, where the conservation
of the particle number is enforced. Although general thermodynamic arguments
ensure the equivalence of the canonical and the grand-canonical ensembles in
the thermodynamic limit, their approach to the infinite-volume limit is
distinctively different. Observables computed in the canonical ensemble
generically display a finite-size correction proportional to the inverse
volume, whereas in the grand-canonical ensemble the approach is exponential in
the ratio of the linear size over the correlation length. We verify these
predictions by quantum Monte Carlo simulations of the Hubbard model in one and
two dimensions in the grand-canonical and the canonical ensemble. We prove an
exact formula for the finite-size part of the free energy density, energy
density and other observables in the canonical ensemble and relate this
correction to a susceptibility computed in the corresponding grand-canonical
ensemble. This result is confirmed by an exact computation of the
one-dimensional classical Ising model in the canonical ensemble, which for
classical models corresponds to the so-called fixed-magnetization ensemble. Our
method is useful for simulating finite systems which are not coupled to a
particle bath, such as in nuclear or cold atom physics.
