Theory of lattice dynamics in the harmonic approximation