  Critical properties of a liquid film between two planar walls are
investigated in the canonical ensemble, within which the total number of
particles, rather than their chemical potential, is kept constant. The effect
of this constraint is analyzed within mean field theory (MFT) based on a
Ginzburg-Landau free energy functional as well as via Monte Carlo simulations
of the 3D Ising model with fixed total magnetization. Within MFT and for finite
adsorption strengths at the walls, the thermodynamic properties of the film in
the canonical ensemble can be mapped exactly onto a grand canonical ensemble in
which the corresponding chemical potential plays the role of the Lagrange
multiplier associated with the constraint. However, due to a non-integrable
divergence of the mean field order parameter profile near a wall, the limit of
infinitely strong adsorption turns out to be not well-defined within MFT,
because it would necessarily violate the constraint. The critical Casimir force
(CCF) acting on the two planar walls of the film is generally found to behave
differently in the canonical and grand canonical ensembles. For instance, the
canonical CCF in the presence of equal preferential adsorption at the two walls
is found to have the opposite sign and a slower decay behavior as a function of
the film thickness compared to its grand canonical counterpart. We derive the
stress tensor in the canonical ensemble and find that it has the same
expression as in the grand canonical case, but with the chemical potential
playing the role of the Lagrange multiplier associated with the constraint. The
different behavior of the CCF in the two ensembles is rationalized within MFT
by showing that, for a prescribed value of the thermodynamic control parameter
of the film, i.e., density or chemical potential, the film pressures are
identical in the two ensembles, while the corresponding bulk pressures are not.
