- #1
JohanL
- 158
- 0
I start with calculating psi(x,0). Then i use fft(psi(x,0)) to get the Fourier coefficients. and with fftshift i get the terms with negative index in the beginning. Then i multiply with the timedependent factor and use ifftshift and ifft to get the wavefunction psi(x,t).
Here is the code:
N=4096;
L=30;
k0=5.0;
x=linspace(-L,L,N);
t=linspace(0,5,N);
psi0=f.*exp(im.*k0.*x); % where f is a function that gives the initial condition
c=fft(psi0);
cs=fftshift(c);
n=-N/2:(N/2-1);
fftPSI=cs.*exp(im.*pi^2.*n.^2.*t);
fftPSIs=ifftshift(fftPSI);
PSI=ifft(fftPSIs);
But then when i plot i only get nonsense.
Can somebody please help me with this?
Here is the code:
N=4096;
L=30;
k0=5.0;
x=linspace(-L,L,N);
t=linspace(0,5,N);
psi0=f.*exp(im.*k0.*x); % where f is a function that gives the initial condition
c=fft(psi0);
cs=fftshift(c);
n=-N/2:(N/2-1);
fftPSI=cs.*exp(im.*pi^2.*n.^2.*t);
fftPSIs=ifftshift(fftPSI);
PSI=ifft(fftPSIs);
But then when i plot i only get nonsense.
Can somebody please help me with this?