Exercises with Octave: Particle in 2D box
clear
x=0:0.01:1;
y=0:0.01:1;
#setting mesh along X, Y
[X,Y]=meshgrid(x,y);
#defining the wavefunction PIB-1d solution
function p=psi_pib(n,L,x); p=sqrt(2.0)* sin((n*pi/L)*x) ; end
#plotting nx=2,ny=2 wavefunction
nx=2;
ny=2;
Lx=1;
Ly=1;
#constructing psi_[nx,ny] (x,y)
psi=psi_pib(nx,Lx,X).* psi_pib(ny,Ly,Y) ;
#plot the function
surf(X,Y,psi)
#Make contour graphs
figure
contour(X,Y,psi,20)