  A fluid in a pore can form diverse heterogeneous structures. We combine a
capillary description with the cubic-plus-association equation of state to
study the thermodynamic stability of droplets, bubbles and films of water at
358 K in a cylindrically symmetric pore. The equilibrium structure depends
strongly on the size of the pore and whether the pore is closed or connected to
a particle reservoir. A new methodology is presented to analyze the
thermodynamic stability of films, where the integral that describes the total
energy of the system is approximated by a quadrature rule. We show that, for
large pores, the thermodynamic stability limit of adsorbed droplets and bubbles
in both open and closed pores is governed by their mechanical stability, which
is closely linked to the pore shape. This is also the case for a film in a
closed pore. In open pores, the film is chemically unstable except for very low
film-phase contact angles and for a limited range in external pressure. This
result emphasizes the need to invoke a complete thermodynamic stability
analysis, and not restrict the discussion to mechanical stability. A common
feature for most of the heterogeneous structures examined is the appearance of
regions where the structure is metastable with respect to a pore filled with a
homogeneous fluid. In the closed pores, these regions grow considerably in size
when the pores become smaller. [...] Complete phase diagrams are presented that
compare all the investigated structures. In open pores at equilibrium, the most
stable structure is either the homogeneous phase or adsorbed droplets and
bubbles, depending on the type of phase in the external reservoir. Smaller
pores allow for droplets and bubbles to adsorb for a larger span in pressure.
In closed pores, most of the investigated configurations can occur depending on
the total density, the contact angle and the pore shape. [...]
