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 Center および File ExchangeDiscrete 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