  Thermodynamic theory is developed for the ferroelectric phase transition of
an ultrathin film in equilibrium with a chemical environment that supplies
ionic species to compensate its surface. Equations of state and free energy
expressions are developed based on Landau-Ginzburg-Devonshire theory, using
electrochemical equilibria to provide ionic compensation boundary conditions.
Calculations are presented for a monodomain PbTiO$_3$ (001) film coherently
strained to SrTiO$_3$ with its exposed surface and its electronically
conducting bottom electrode in equilibrium with a controlled oxygen partial
pressure. The stability and metastability boundaries of phases of different
polarization are determined as a function of temperature, oxygen partial
pressure, and film thickness. Phase diagrams showing polarization and internal
electric field are presented. At temperatures below a thickness-dependent Curie
point, high or low oxygen partial pressure stabilizes positive or negative
polarization, respectively. Results are compared to the standard cases of
electronic compensation controlled by either an applied voltage or charge
across two electrodes. Ionic surface compensation through chemical equilibrium
with an environment introduces new features into the phase diagram. In
ultrathin films, a stable non-polar phase can occur between the positive and
negative polar phases when varying the external chemical potential at fixed
temperature, under conditions where charged surface species are not present in
sufficient concentration to stabilize a polar phase.
