Calculating the laplacian of a complex field
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
I'm trying to solve a Nonlinear-Schrodinger equation that contains a laplacian term
.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/354113/image.png)
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 Kommentare
Antworten (0)
Siehe auch
Kategorien
Mehr zu Fortran with MATLAB finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!