how to initialize function values in Fourier space
Afficher commentaires plus anciens
I'm trying to learn classical density functional theory and learning to numerical implementation FMT functional which invovled convolutions of weight functions and density.
Some weight functions have the following forms: (R is constant,0.5.)
w2(r) = 2*R*(R^2-r^2)^-0.5*heaviside(R-r)
I am not quite sure about how to calculate the weight function values in Fourier space to avoid singularities in real space. My codes are here, thanks for your precious help.
clear
syms r y2(r)
R = 0.5;
y2(r) = 2*R/sqrt(R^2-r^2)*heaviside(R-r);
fy2 = fourier(y2);
dx = 0.05;dy = 0.05;
N = 500; M = 500;
fw2 = zeros(500,500);
Norm = 1/(N*M);
for i = 1:N
for j = 1:M
if i <= N/2
kx = 2*pi*i/(N*dx);
else
kx = -2*pi*(N-i)/(N*dx);
end
if j <= M/2
ky = 2*pi*j/(M*dy);
else
ky = -2*pi*(M-j)/(M*dy);
end
k_abs = sqrt(kx^2+ky^2);
if k_abs == 0
fw2(i,j) = Norm*4*pi*R^2;
else
fw2(i,j) = fy2(k_abs);
end
end
end
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Discrete Fourier and Cosine Transforms dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!