function [Phim,Xim,X,Y,E,area]=DB(L1s,L1l,...
L2s,L2l,Nx,Ny,G,Vm,Ve,Ax,Ay,enumber,ecenter,norm_func)
% The function computes the eigenstates and eigenvalues of a Dirac billiard (DB)
% with abitrary shape and of arbitrary potentials.
%
% For details about the
% method, please consult [email protected]. A acedminc paper is to be
% potentially published later with reference here.
% We appreciate your reference to this article if it is used for
% for academic purpose!
%%%% Input:
%
% Ls1,L1l,L2s,L2l - define a rectangular space [Ls1,L1l]*[L2s,L2l] that
% encompasses the billiard.
% Nx and Ny - the number of discretization in x and y direction, such
% that the finite difference unit is h1=[L1l-L2s]/Nx, h2=[L2l-L2s]/Ny;
% G - cell-list fucntion handle. G=[G1,G2,G3,...], where G1 is the
% outer-boundary function handle such that G1(x,y)==1 contains all the
% points inside. This also applies to G2,G3 ..., which are function handles
% for the inner-boundaries.
% Vm - scalar function handle @(x,y), the mass potential
% Ve - scalar fcuntion hanlde @(x,y), the electric potential
% Ax - scalar function handle @(x,y), the x direction vector potential
% Ay - scalar function handle @(x,y), the y direction vector potential
% enumber, ecenter - number of eigenvalues (enumber) around the center (ecenter)
% norm_func - user defined linear and homogenous boundary condition
% cell-list function handle @(x,y)
% norm_func=[norm_func_1,norm_func_2,....] with a length same as G with the corresponding meaning
% for example, norm_func_1(x,y) gives the ratio between chi and phi
% component at the outer-boundary
%%%% Output:
%
% Phim,Chim - matrices of phi and chi component of the eigenvector
% X, Y - matrices of the discrete points
% E - eigenvalues
% area - actual area that the discretized billiard takes place
%%%% Example:
% An AB billiard
% clear
% R1=0.3;Rd1=0.65;Rd2=0.85;R2=1;V=5;alpha=0.5;
% L1=2.1;L2=2.1;N=200;
% L1s=-L1/2;L1l=L1/2;L2s=-L2/2;L2l=L2/2;
% Nx=N;Ny=N;
% number=10;center=0;L1=2.1;L2=2.1;
% PhiB=alpha*2*pi;NL=@(x,y) x.*0;
% Ax=@(x,y) PhiB/(2*pi)*(-(y)./((y).^2+(x).^2));
% Ay=@(x,y) PhiB/(2*pi)*((x)./((y).^2+(x).^2));
% Ve=@(x,y) V*(x.^2+y.^2>=Rd1^2).*(x.^2+y.^2<=Rd2^2);Vm=@(x,y) x.*0;
% G1=@(x,y) x.^2+y.^2<=R2^2;
% G2=@(x,y) x.^2+y.^2<=R1^2;
% G={G1,G2};
% circlefun=@(x,y) 1i*(x+1i*y)./sqrt((x).^2+(y).^2);
% norm_func={@(x,y) circlefun(x,y),@(x,y) -1*circlefun(x,y)};
% tic;
% [Phim,Xim,X,Y,E,area]=DB(-L1/2,L1/2,-L2/2,L2/2,Nx,Ny,G,Vm,Ve,...
% Ax,Ay,number,center,norm_func);
% toc;
% pcolor(X,Y,(real(Phim(:,:,1))))
% shading interp
% title(['Re(Phi), E=',num2str(real(E(1)))])
h1=(L1l-L1s)/Nx;h2=(L2l-L2s)/Ny;
sigma_x=[0,1;1,0];sigma_y=[0,-1i;1i,0];sigma_z=[1,0;0,-1];
x = linspace(L1s, L1l, Nx+1);y = linspace(L2s,L2l, Ny+1);[X, Y] = meshgrid(x, y);
area=zeros(numel(G),1);
n_Bt=zeros(numel(G),1);
% Find the boundary points given by G
for t=1:numel(G)
if t==1
binary_image = G{t}(X, Y) ==1;
[yt,xt]=find(binary_image==1);
B = bwboundaries(binary_image,4);
boundary_points = [B{1}(1:end-1,:)];
boundary_x = boundary_points(:,2);boundary_y = boundary_points(:,1);
area(t)=polyarea(boundary_points(:,2),boundary_points(:,1))*h1*h1;
n_Bt(t)=numel(boundary_x);
else
binary_image = G{t}(X, Y) ==1;
[ytn,xtn]=find(binary_image==1);
B = bwboundaries(binary_image,4);
boundary_pointsn = [B{1}(1:end-1,:)];
boundary_xn = boundary_pointsn(:,2);boundary_yn = boundary_pointsn(:,1);
XYtot=[setdiff([xt,yt],[xtn,ytn],'rows');[boundary_xn,boundary_yn]];
xt=XYtot(:,1);yt=XYtot(:,2);
boundary_x=[boundary_x;boundary_xn];
boundary_y=[boundary_y;boundary_yn];n_Bt(t)=numel(boundary_xn);
area(t)=polyarea(boundary_pointsn(:,2),boundary_pointsn(:,1))*h1*h1;
end
end
% Construct the discretized Hamiltonians
n_tot=numel(xt);
n_B=sum(n_Bt);
tab=zeros(n_tot,2);
tab(1:n_B,:)=[boundary_x,boundary_y];
tab(n_B+1:end,:)=setdiff([xt,yt],[boundary_x,boundary_y],"rows");
tabinv = sparse(tab(:,1),tab(:,2),1:n_tot);
xright_up=xt+0.5;yright_up=yt+0.5;
xleft_up=xt-0.5;yleft_up=yt+0.5;
xright_down=xt+0.5;yright_down=yt-0.5;
xleft_down=xt-0.5;yleft_down=yt-0.5;
XYnew=intersect(intersect(intersect([xright_up,yright_up],[xright_down,yright_down],"rows")...
,[xleft_up,yleft_up],'rows'),[xleft_down,yleft_down],'rows');
n_Dirac=size(XYnew,1);
xm=XYnew(1:end,1)-0.5;xp=XYnew(1:end,1)+0.5;ym=XYnew(1:end,2)-0.5;yp=XYnew(1:end,2)+0.5;
C=sparse([1:n_Dirac,1:n_Dirac,1:n_Dirac,1:n_Dirac],[tabinv(sub2ind(size(tabinv), xm,ym ));...
tabinv(sub2ind(size(tabinv), xm,yp ));...
tabinv(sub2ind(size(tabinv), xp,yp ));...
tabinv(sub2ind(size(tabinv), xp,ym ))],1,n_Dirac,n_tot);
Dx=sparse([1:n_Dirac,1:n_Dirac,1:n_Dirac,1:n_Dirac],[tabinv(sub2ind(size(tabinv), xm,ym ));...
tabinv(sub2ind(size(tabinv), xm,yp ));...
tabinv(sub2ind(size(tabinv), xp,yp ));...
tabinv(sub2ind(size(tabinv), xp,ym ))],kron(ones(n_Dirac,1),...
[-1,-1,1,1]),n_Dirac,n_tot);
Dy=sparse([1:n_Dirac,1:n_Dirac,1:n_Dirac,1:n_Dirac],[tabinv(sub2ind(size(tabinv), xm,ym ));...
tabinv(sub2ind(size(tabinv), xm,yp ));...
tabinv(sub2ind(size(tabinv), xp,yp ));...
tabinv(sub2ind(size(tabinv), xp,ym ))],kron(ones(n_Dirac,1),...
[-1,1,1,-1]),n_Dirac,n_tot);
V=C.*transpose(Vm(x(xm)+h1/2,y(ym)+h2/2));
Vel=C.*transpose(Ve(x(xm)+h1/2,y(ym)+h2/2));
Axx=C.*transpose(Ax(x(xm)+h1/2,y(ym)+h2/2));
Ayy=C.*transpose(Ay(x(xm)+h1/2,y(ym)+h2/2));
loss1=setdiff(1:2*n_tot,(1:n_B)*2-1);
loss2=setdiff(loss1,(1:n_B)*2);
% This permutation is just to make the boudary condition could be written
% easier, not nessasary.
pert=[loss2,(1:n_B)*2,(1:n_B)*2-1];
P=sparse(1:2*n_tot,pert(1:2*n_tot),1,2*n_tot,2*n_tot);
Hprime=((-2i/h1)*kron(Dx,sigma_x)+(-2i/h2)*kron(Dy,sigma_y)+kron(V,sigma_z)...
+kron(Vel,eye(2))-kron(Axx,sigma_x)-kron(Ayy,sigma_y))*transpose(P);
Cprime=kron(C,eye(2))*transpose(P);
Pi=2*n_tot-(2*n_Dirac)-n_B;
if Pi==2
Bprime=spalloc(n_B+2,2*n_tot,n_B+2);
zeroprime=spalloc(n_B+2,2*n_tot,0);
else
Bprime=spalloc(n_B,2*n_tot,n_B);
zeroprime=spalloc(n_B,2*n_tot,0);
end
% Apply boundary conditions
for i=1:numel(G)
if i==1
for m=1:n_Bt(1)
%[m+2*(n_tot-n_B),2*(n_tot-n_B)+m+n_B]
xx=x(tab(m,1));
yy=y(tab(m,2));
buff=norm_func{i}(xx,yy);
Bprime(m,m+2*(n_tot-n_B))=1;
Bprime(m,2*(n_tot-n_B)+m+n_B)=-buff;
end
else
for m=sum(n_Bt(1:i-1))+1:sum(n_Bt(1:i))
xx=x(tab(m,1));
yy=y(tab(m,2));
buff=norm_func{i}(xx,yy);
Bprime(m,m+2*(n_tot-n_B))=1;
Bprime(m,2*(n_tot-n_B)+m+n_B)=-buff;
end
end
end
% Extra constraint for Pi=2
if Pi==2 %
psedomode1=zeros(1,2*n_tot);
psedomode2=zeros(1,2*n_tot);
for k=1:n_tot
psedomode1(2*k)=(-1)^(tab(k,1)+tab(k,2));
psedomode2(2*k-1)=(-1)^(tab(k,1)+tab(k,2));
end
buff1=Bprime(1,:);
buff2=Bprime(2,:);
Bprime(1,:)=psedomode1*transpose(P);
Bprime(2,:)=psedomode2*transpose(P);
Bprime(n_B+1,:)=buff1;
Bprime(n_B+2,:)=buff2;
end
hh1=[Hprime;Bprime];
hh2=[Cprime;zeroprime];
% Different hamiltonian dependent Pi
if numel(G)<3
[V,E]=eigs(hh1,hh2,enumber,ecenter);
else
[V,E]=eigs(hh2'*hh1,hh2'*hh2,enumber,ecenter);
end
E=diag(E);V=transpose(P)*V;
Phi=V(1:2:end,:);Xi=V(2:2:end,:);
[~,sq2]=sort(real(E),'ascend');
Phi=Phi(:,sq2);Xi=Xi(:,sq2);E=E(sq2);
% Convert one-dimensional vector back to two dimensional
[Phim,Xim]=tomatrix(Phi,Xi,tabinv,Nx,Ny);
function [P,X]=tomatrix(Phi,Xi,tabinv,Nx,Ny)
P=zeros(Nx+1,Ny+1,size(Phi,2));
X=zeros(Nx+1,Ny+1,size(Phi,2));
for tt=1:size(Phi,2)
for ll=1:size(tabinv,1)
for j=1:size(tabinv,2)
if tabinv(ll,j)~=0
P(j,ll,tt)=Phi(tabinv(ll,j),tt);
X(j,ll,tt)=Xi(tabinv(ll,j),tt);
end
end
end
end
end
end

timer_017
- 粉丝: 561
最新资源
- 网络工程师学习笔记共享共章.doc
- 中国物流供需与中国物流网络.doc
- 基于单片机的电子钟设计.doc
- 基于FPGA的SPI接口设计-徐慧军.doc
- 计算机教师总结.docx
- 微软学科培训-学员手册2014.6.doc
- 基于单片机的步进电机控制系统汇编及C语言程序各一个样本.doc
- 小学生网络安全黑板报.docx
- 数字图像处理入门.ppt
- 计算机专业实习调研报告.doc
- 网络舆情工作总结范文合集.doc
- 计算机网络基础考试试题4(最终).doc
- 软件需求说明书.doc
- 信息化发展战略选择课件.pptx
- 微机原理与接口技术吉海彦主编机械工业出版社课后习题答案.doc
- 网络优化暑期社会实践心得体会.docx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈


