Calculating the laplacian of a complex field
2 views (last 30 days)
Show older comments
I'm trying to solve a Nonlinear-Schrodinger equation that contains a laplacian term.
I know that you can use the
del2(psi,x,y)
command. But I wish to do this in Fourier space, and without using any inbuilt functions as I am porting the code over to fortran.
So far, I have the code
%% Setup of grid and Fourier grid/operators
xmax = 15;
xmin = -15;
ymax = 15;
ymin = -15;
nx = 1024;
ny = 1024;
dx = (xmax-xmin)/nx;
dy = (ymax-ymin)/nx;
x = [xmin+dx:dx:xmax];
y = [ymin+dy:dy:ymax];
kx = 2*pi/(xmax-xmin)*[0:nx/2 -nx/2+1:-1];
ky = 2*pi/(ymax-ymin)*[0:ny/2 -ny/2+1:-1];
Tx = - kx .* kx;
Ty = - ky .* ky;
%% Load wavefunction
load('psi.mat')
psi = psiR + 1i.*psiI;
%% Move to fourier space
kpsi = fftn(psi);
%% Calculate laplacian using both methods
delsqLaplacian = 4*del2(u_og,x,y); % using del2
fourierLaplacian = ifftn((Tx + Ty').*kpsi)*(4*pi*pi/((xmax-xmin)*(ymax-ymin))); % Using Fourier derivatives
Unfortunately, these two variables do not return the same result. Can someone let me know how I should be doing this?
0 Comments
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!