Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

0001 //Solution of square well and triangular well potential

0002 clc;
0003 clear;
0004 clf();
0005 x=(-1:0.01:1);
0006 n=length(x)-1;
0007 //KINETIC ENERGY MATRIX
0008 for i=1:1:n
0009 KE(i,i)=-2
0010 KE(i,i+1)=1
0011 KE(i+1,i)=1
0012 end
0013 KE(n+1,n+1)=-2
0014
0015 //POTENTIAL ENERGY MATRIX for square well
0016 for i=1:1:n+1
0017 V1(i,i)=0
0018 end
0019
0020 //POTENTIAL ENERGY MATRIX FOR triangular well
0021 Vo=10
0022 for i=1:1:n+1
0023 V2(i,i)=Vo*abs(x(i))
0024 end
0025
0026 // formation of hamiltonian matrix for square well
0027 H1=-KE+V1
0028 [u1,v1]=spec(H1)
0029
0030 // formation of hamiltonian matrix for triangular
well
0031 H2=-KE+V2
0032 [u2,v2]=spec(H2)
0033 h=1
0034 disp(v2(h,h))
0035 p(1)=1; p(2)=2; p(3)=8; p(4)=12
0036 for k=1:1:4
0037 subplot(4,2,2*k-1)
0038 plot(x,u1(:,p(k)),"r",'linewidth',2)
0039 //plot(x,diag(V1))
0040 title("SQUARE WELL POTENTIAL")
0041
0042 subplot(4,2,2*k)
0043 plot(x,u2(:,p(k)),"r",'linewidth',2)
0044 //plot(x,diag(V2)/100)
0045 title("TRIANGULAR WELL POTENTIAL")
0046 end

You might also like