You are on page 1of 2

% se_fdm.

m
% Solutions to [1D]time independent Schrodinger Equation
% Finite Difference Method
% Enter E - shooting method
% Ian Cooper
% School of Physics, University if Sydney
% email: ian.cooper@sydney.edu.au

tic
close all
clear all
clc

% INPUTS ==========================================
%Ev = input('Enter the energy E in eV ');
Ev = -373.797396; % -373.84 -296.63 -173.5 -21;
Uv = -400; % depth of potential well [eV]
L = 1e-10; % depth of potential well [m]
N = 1000; % number of x values

% CONSTANTS =======================================
hbar = 1.055e-34; % J.s
e = 1.602e-19; % C
me = 9.109e-31; % kg

% SETUP CALCULATIONS ==============================


% x coodinates
x_min = -2*L;
x_max = -x_min;
x = linspace(x_min,x_max,N);
dx = x(2)-x(1);

U0 = e * Uv; % potential well depth [J]


E = e* Ev; % total energy [J]
U = zeros(1,N);

psi = zeros(1,N); % initial conditions


psi(2) = 1;

% FDM =============================================
for n = 2:N-1
if abs(x(n)) < L/2, U(n) = U0; end;
SEconst = (2*me/hbar^2).*(E - U(n)).* dx^2;
psi(n+1) = (2 - SEconst) * psi(n) - psi(n-1);
end

% normalize wavefunction
A = simpson1d(psi.*psi,x_min,x_max);
psi = psi ./sqrt(A);

% GRAPHICS ========================================
figure(1)
plot(x,U/e,'r','lineWidth',3)
xlabel('position x

figure(2)
set(gcf,'color',[1 1 1]);
plot(x,psi,'lineWidth',3)
hold on
plot([x_min x_max],[0 0],'k');
plot([x_min/2 x_min/2],[-1.2*max(psi) max(psi)],'r','lineWidth',2);
plot([x_max/2 x_max/2],[-1.2*max(psi) max(psi)],'r','lineWidth',2);
plot([x_min x_min/2],[max(psi) max(psi)],'r','lineWidth',2);
plot([x_max/2 x_max],[max(psi) max(psi)],'r','lineWidth',2);
plot([x_min/2 x_max/2],[-1.2*max(psi) -1.2*max(psi)],'r','lineWidth',2);

axis off
toc

You might also like