Lattice Dynamics in Temperature-driven and Photo-induced Phase Transitions