Help with using IFFT to calculate radial distribution function g(r) ! PLEASE help

Hi all, I am trying to use ifft function to evaluate the radial distribution function g(r), r is distance (nm), by using the structure factor s(q) , which is function of wave vector q (1/nm) :
I did this by using normal integration (quad) but it takes long time to calculate it. So I believe I can use ifft to do this since the function s(q) is a discrete function.
I do not know what input I have to use in ifft() ? do I have to put q*s(q) ? what about sin (q r) ? Is it just : image (ifft()) ? Do I have to take in my account Nyquist frequency in my data ?
I am sorry there are too many questions but I am REALLY confused ):
Any help will be appreciated!
Thanks a lot .

2 Comments

hi, did you try other functions /methods for intergating : "trapz" as example ?
I think FFT/iFFT would be a good choice if the equation has convolution then in frequency domain it becomes simple produc .
Thanks Youssef for your comment. No I did not try that. what do you mean by "I think FFT/iFFT would be a good choice if the equation has convolution....'' ..what does convolution mean? sorry I am not good in fft/ifft at all!

Sign in to comment.

Answers (1)

can you try "trapz" as example ?
r=(0:0.1:2)*1e-9; % distance in NM
rho=5e-3; % charge density maybe .
K=1./(2*pi^2*r*rho); % factor
q_max=1;
N=length(r);
q=linspace(0,q_max,N); % wave factor .
sq=2*q; % example of the structure factor
f=q.*sq.*sin(q.*r); % the function
F=trapz(q,f);
F=F*K;
g=1+F;
figure, plot(r,g), title(' RADIAL FUNCTION'), grid on
xlabel(' Distance (m)'), ylabel(' magnitude');
In the program, we choose the radius so start from the origin, so the plot G(r) makes sens as we move forward, the distribution function decreases .
waiting for others users to clarify the use of FFT/IFFT....

1 Comment

it does not work ): ..I do not get what I suppose to get ..I am trying to calculate g(r) for water ..I got good result by using quad : if true
% for i=1:length(r)
fun1 = 1./(2*pi^2*r(i)*Water_num_den); % outside integration
fun2 = @(x) interp1(xVal, S_factor', x, 'linear').*x.*sin(x*r(i)); % inside integration
g(i)=1+(fun1*(quad(fun2,0,xMax)));% calculate in terms of x with a lower bound 0 and upper bound xMax
%
% end
end
I use interpolation because as I told you that it is discrete points not continuos. waiting for others users ):

Sign in to comment.

Tags

Asked:

on 24 Mar 2013

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!