24 lines
683 B
Mathematica
24 lines
683 B
Mathematica
|
function [VParams] = find_nk_fit(VParams)
|
||
|
|
||
|
Lz = 20;
|
||
|
Nz = 4000;
|
||
|
normfac = Lz/Nz;
|
||
|
|
||
|
z = linspace(-0.5*Lz,0.5*Lz-Lz/Nz,Nz);
|
||
|
dz = abs(z(2)-z(1));
|
||
|
Kmax = pi*Nz/Lz;
|
||
|
kz = linspace(-Kmax,Kmax,Nz+1);
|
||
|
kz = kz(1:end-1);
|
||
|
|
||
|
psiz = exp(-0.5*(abs(z)/VParams.ell).^VParams.nu);% VParams.nu
|
||
|
normz = sum(abs(psiz).^2)*dz;
|
||
|
psiz = psiz / sqrt(normz);
|
||
|
|
||
|
psik = fftn(psiz)*normfac/(sqrt(2*pi)); % fftshifted
|
||
|
nk = abs(psik).^2;
|
||
|
nk_forfit = ifftshift(nk);
|
||
|
|
||
|
f = fit(kz',nk_forfit','gauss1'); % f(x) = a1*exp(-((x-b1)/c1)^2)
|
||
|
|
||
|
VParams.ell_eff = 1/f.c1;
|
||
|
end
|