Phase Transitions at the Nanoscale in Functional Materials