how to initialize function values in Fourier space

조회 수: 4 (최근 30일)
haohao gu
haohao gu 2022년 5월 26일
답변: haohao gu 2022년 5월 30일
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

채택된 답변

haohao gu
haohao gu 2022년 5월 30일
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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Discrete Fourier and Cosine Transforms에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by