Problem: Here is what i want to do. I need to construct an Hamiltonian matrix of dimension 2 by 2, then diagonalise it and find the eigenvalues for set of input values. I can do the problem for input values on a line, but i want a 3D plot and hence want to use a meshgrid.
The following working code plots for values on a line.
clear allclca0 = 1.42; alpha0=1;%-------------------------------------Define k range----------------------------------
kx = -2*pi/(3*a0):2*pi/(3*49.5*a0):2*pi/(3*a0);ky = -2*pi/(3*a0):2*pi/(3*49.5*a0):2*pi/(3*a0);a= 3*a0/2; b= sqrt(3)*a0/2;N=2;% % % % Hamiltonian generation
H=zeros(N,N);for c = 1:100 hk(c)=exp(1i*ky(c)*a0)+exp(1i*(a*kx(c)- b*ky(c)))+exp(-1i*(a*kx(c)+ b*ky(c)));%h(k) for kx, ky ne 0.
%*****Hamiltoninan generation starts here**************
for i=1:N for j=1:N if (j-i)==1 H(i,j)= -alpha0*hk(c); elseif (j-i)==-1 H(i,j)= -alpha0*conj(hk(c)); end end end E(:,c) = eig(H); %Eigenvalues
endplot(kx,E);
Now for the above eigenvalues, i can't use surf to 3D plot and hence i tried the following code to generate eigenvalues in a meshgrid.
This code has an error.
a0 = 1.42; alpha0=1;%-------------------------------------Define k range----------------------------------kx = -2*pi/(3*a0):2*pi/(3*49.5*a0):2*pi/(3*a0);ky = -2*pi/(3*a0):2*pi/(3*49.5*a0):2*pi/(3*a0);[x,y]=meshgrid(kx,ky);a= 3*a0/2; b= sqrt(3)*a0/2;N=2;H=zeros(N,N);for l=1:100 for m=1:100 hk(l,m)=exp(1i*y(l,m)*a0)+exp(1i*(a*x(l,m)- b*y(l,m)))+exp(-1i*(a*x(l,m)+ b*y(l,m)));%h(k) for kx, ky ne 0. %*****Hamiltoninan**************
for i=1:N for j=1:N if (j-i)==1 H(i,j)= -alpha0*hk(l,m); elseif (j-i)==-1 H(i,j)= -alpha0*conj(hk(l,m)); end end end E(l,m) = eig(H); %Here is the problem because it can't store two values in one grid
H=zeros(N,N); end end figure meshgrid(kx,ky,100); surf(kx,ky,E);
So the core of the problem is that, i want to solve the Hamiltonian matrix for the values scattered in a mesh and obtain the eigenvalues and plot those to obtain a 3D plot.
Any help or suggestion will be helpful.
Thank you.
Best Answer