Ab initio study of Raman and optical spectra of crystalline materials and their temperature dependence