Hi,(adsbygoogle = window.adsbygoogle || []).push({});

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

**Physics Forums | Science Articles, Homework Help, Discussion**

Dismiss Notice

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Calculating velocity correlation function

Can you offer guidance or do you also need help?

Draft saved
Draft deleted

**Physics Forums | Science Articles, Homework Help, Discussion**