The power spectral density describes the distribution of a time series (in your case the velocity autocorrelation function) over its different frequencies.
what you need to do is calculate the mass-weighted velocity autocorrelation function (averaged over all atoms) and do a Fourier transformation to get from the time domain to the frequency domain. I have attached a part of one of my posters where I had the equations for that sort of calculations: tau is your time-correlation window (from 0 to whatever your trajectory alows), t are instantaneous timesteps in your trajectory. i is the index and N_beta the total number of atoms of a species (H, N, or O for example), and alpha the Cartesian component. You can calculate correlation functions for each subset of atomic species, that's why it looks a bit complicated, but in the end you can just sum up all to have one total velocity autocorrelation function which includes all information of your system's vibrations. The brackets denote averages over all the taus, i.e., your error is getting worse towards larger taus (e.g. if tau is equal to your runtime you get only 1 Z(tau), if tau equals 1/100 of your runtime you get an average of 100 Z(tau). Usually you would calculate all possible taus, but cut off any correlation function beyond (~) half your trajectory and neglect them for the spectra calculation (that's why you need many long trajectories to get good statistics and resolution in your spectrum).
Once you have done the Fourier transformation take the sum of your squared real and imaginary part and you'll have the power spectrum (vibrational density of states in case of the velocity autocorrelation function). Same goes for the dipole moment, but it's less work to calculate because you only have one total dipole moment per frame (instead of 3n atomic velocity components).
what I forgot to mention, in case of the dipole moment autocorrelation I subtracted the total average dipole moment from every instantaneous one to compensate any centers-of-mass drifts during the simulation run...
What is difference between Power spectrum density spectrum and vibrational density of states. I find some researchers recommend mass weighted velocity autocorrelation funtion while some recommend velocity auto-correlation without mass-weight. Do you have any comments about this argue and references about this in detail? Thanks.