Algorithms for real-time time-dependent density functional theory and calculation of phase diagrams for two-dimensional phase-change materials