- #1

- 5

- 0

I have been trying to write a code to calculate velocity correlation function so that I can obtain a frequency spectrum for my system on taking a fourier transform. For testing my code I generated a sine wave data and calculated vcf and took dft. I got correct frequency value but the peak splits into two (the value should be 1.6 but I get two peaks 1.58 and 1.62) and there are several small peaks in the spectrum.

I am pasting the vcf calculation part below. Could someone please help me find a flaw in my logic?

Thanks a lot!

vcf = 0

do m = 2, Nmax, dnsample !loop thorugh all time origins

vm=v(m)

denom=(Nmax-m)/dnsample

norm=1/denom

do n = 2, Nmax-m, dnsample !loop over velocity at time t points

vdot = vm * v(m+n)

vmag = v(m+n) * v(m+n)

vcf = vcf + (vdot/vmag)

end do

time = m*0.5*1d-13

vcf = vcf*norm

write(4,*) time, vcf

end do