  Halide perovskites have emerged as a promising class of materials for
photovoltaic applications. A challenge in these applications is how to prevent
the crystal structure from degradation to photovoltaically inactive phases,
which requires an understanding of the free energy landscape of these
materials. Here, we uncover the free energy landscape of two prototypical
halide perovskites, CsPbBr$_3$ and MAPbI$_3$ via atomic scale simulations using
umbrella sampling and machine-learned potentials. For CsPbBr$_3$ we find very
small free energy differences and barriers close to the transition temperatures
for both the tetragonal-to-cubic and the orthorhombic-to-tetragonal transition.
For MAPbI$_3$, however, the situation is more intricate. In particular the
orthorhombic-to-tetragonal transition exhibits a large free energy barrier and
there are several competing tetragonal phases. Using large-scale molecular
dynamics simulations we explore the character of these transition and observe
latent heat and a discrete change in structural parameters for the
tetragonal-to-cubic phase transition in both CsPbBr$_3$ and MAPbI$_3$
indicating first-order transitions. We find that in MAPbI$_3$ the orthorhombic
phase has an extended metastability range and furthermore identify a second
metastable tetragonal phase. Finally, we compile a phase diagram for MAPbI$_3$
that includes potential metastable phases.
