Molecular and lattice dynamical study on modulated structures in quartz