how to initialize function values in Fourier space

4 views (last 30 days)
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

Accepted Answer

haohao gu
haohao gu on 30 May 2022
to ensure the periodic boundary, weight function or other functions may used in later convolution as response singnal should be initiated from 4 directions instead of 2.
2d weight function in fourier space can be calculated as shown in fweight.m

More Answers (0)

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!