필터 지우기
필터 지우기

Calculating the laplacian of a complex field

조회 수: 1 (최근 30일)
Nick Keepfer
Nick Keepfer 2020년 8월 31일
편집: Nick Keepfer 2020년 8월 31일
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개)

카테고리

Help CenterFile Exchange에서 Fortran with MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by