t=1;coupj=1;L = 4;d = 3;N_hole=2:2:-2;tic%for nume = 1:length(N_hole)
Nh = 2;%N_hole(nume)
N_UP=(L-Nh)/2;N_DN = (L-Nh)/2;%***************** Basis generation %************************************
%**************** Hamiltonian parameter ********************************
%pbc=1; % pbc=1 ==> PBC, pbc=0 RBC
%sz=0; %Subblock of sz for the computations
Sz0_space=factorial(L)/(factorial(N_UP)*factorial(N_DN)*factorial(Nh))%***************************************************************************
%Whole basis computation
basis_spin=zeros(d^L,L);for i1=1:1:L ba=0; for i2=1:1:d^L basis_spin(i2,i1)=ba; if mod(i2,d^(L-i1))==0 ba=mod(ba+1,d); end endend% Chagrge conservation and magnetization conservation
% first we count the number of 1's and 2's in each basis states from
% basis_spin. Then we set condition that if number of 1's = N_UP and number
% of 2's=N_DN then we store those basis from d^L basis states.
szbasis_Ne = zeros(Sz0_space,L);basis_Ne=zeros(Sz0_space,L);val=1;for i2=1:d^L Loca1 = basis_spin(i2,:)==1; Loca2 = basis_spin(i2,:)==2; if (sum(Loca1~=0,2)~=0 && sum(Loca2~=0,2)~=0 && sum(Loca1~=0,2)==N_UP && sum(Loca2~=0,2)==N_DN) basis_Ne(val,:)=basis_spin(i2,:); order_sz(1,val)=i2-1; %order_sz_1(1,val) = bi2de(basis_Ne(val,:), 3,'left-msb');
val=val+1; endenddimension = size(basis_Ne);dimension = dimension(1);dn_v1 =cell(L,1);%***********************************************
for i1 = 1:L cont1=1; if i1==L n=1; m=L; else n=i1; m=i1+1; end n m % Loop over the basis elements
for i2=1:dimension if basis_Ne(i2,m)==2 && basis_Ne(i2,n)==0 %basis_Ne(i2,:)
%order_sz(i2)
basis_Ne(i2,n)=2; basis_Ne(i2,m)=0; %basis_Ne(i2,:) aux_dn = bi2de(basis_Ne(i2,:), 3,'left-msb'); %aux_dn=order_sz(i2)+(-1)^P*value %Output vector in the whole basis
out_dn=find(order_sz==aux_dn); %Output vector position in the subblock
%We construct the matrix and the complex conjugate
dn_v1{i1}(cont1)=out_dn; dn_vc1{i1}(cont1)=i2; dn_w1{i1}(cont1)=i2; dn_wc1{i1}(cont1)=out_dn; cont1=cont1+1; end endend
The code does not run for all i2 for i1=L. Could any one help me to figure it out?
Best Answer