Calculating velocity correlation function

  • Thread starter svartak
  • Start date
  • #1
5
0
Hi,

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
 

Answers and Replies

Related Threads on Calculating velocity correlation function

  • Last Post
Replies
1
Views
3K
  • Last Post
Replies
0
Views
2K
Replies
0
Views
1K
  • Last Post
Replies
3
Views
4K
  • Last Post
Replies
11
Views
13K
  • Last Post
Replies
3
Views
17K
  • Last Post
Replies
1
Views
6K
  • Last Post
Replies
1
Views
3K
Replies
4
Views
8K
  • Last Post
Replies
6
Views
2K
Top