!--------------! module system !--------------! implicit none integer :: nn integer :: nrep integer, allocatable :: repr(:) integer, allocatable :: peri(:) integer, allocatable :: mtrf(:) real(8), allocatable :: mat(:,:) real(8), allocatable :: vec(:,:) real(8), allocatable :: enr(:) real(8), allocatable :: spn(:) real(8), allocatable :: ffun(:,:,:) real(8), allocatable :: gfun(:,:) end module system !-----------------! !==================! program hchain_mkp !==================! use system; implicit none integer :: i,k,p,nu,rm,p1,p2 open(10,file='read.in',status='old') read(10,*)nn,rm close(10) allocate(repr(rm)) allocate(peri(rm)) allocate(mtrf(rm)) do nu=0,nn/2 do k=0,nn/2 if (k==0.or.k==nn/2) then p1=-1; p2=+1 else p1=+1; p2=+1 endif call fgfunctions(k) do p=p1,p2,2 call makebasis(nu,k,p) if (nrep/=0) then allocate(mat(nrep,nrep)) allocate(vec(nrep,nrep)) allocate(enr(nrep)) allocate(spn(nrep)) call hamiltonian(p) call diagonalize(nrep,mat,vec,enr) call spinsquared(nu,p) call transform(nrep,mat,vec,spn) spn(:)=0.5d0*abs(sqrt(1.d0+4.d0*spn(:))-1.d0) deallocate(mat) deallocate(vec) deallocate(enr) deallocate(spn) endif call writedata(nu,k,p) enddo enddo enddo deallocate(repr) deallocate(peri) deallocate(mtrf) deallocate(ffun) deallocate(gfun) end program hchain_mkp !======================! !----------------------------! subroutine writedata(nu,k,p) !----------------------------! use system; implicit none integer :: i,k,p,nu open(10,file='eig.dat',position='append') write(10,'(a,i2,a,i2,a,i2,a,i4)')'nu =',nu,', k = ',k,', p = ',p,', nst =',nrep do i=1,nrep write(10,'(i5,2f18.10)')i-1,enr(i),spn(i) enddo close(10) open(10,file='low.dat',position='append') if (nrep/=0) write(10,30)nu,k,p,enr(1),spn(1),nrep 30 format(3i5,2f16.10,i10) close(10) end subroutine writedata !------------------------! !-------------------------! subroutine hamiltonian(p) !-------------------------! use system; implicit none integer :: i,j,a,b,p,r,l,q,ia,ib,sa,sb,na,nb real(8) :: matelement,ez mat(:,:)=0.d0 do ia=1,nrep sa=repr(ia) if (ia>1.and.sa==repr(ia-1)) then cycle elseif (ia=0) then if (ib>1.and.repr(ib)==repr(ib-1)) then ib=ib-1 nb=2 elseif (ib1.and.sa==repr(ia-1)) then cycle elseif (ia=0) then if (ib>1.and.repr(ib)==repr(ib-1)) then ib=ib-1 nb=2 elseif (ib1.d-8)) pass=.false. endif if (pass) then nrep=nrep+1 repr(nrep)=a peri(nrep)=s*ra mtrf(nrep)=tp endif pass=.true. enddo endif enddo end subroutine makebasis !------------------------! !-------------------------------------------! subroutine checkstate(a0,nu,k,p,ra,tp,pass) !-------------------------------------------! use system; implicit none integer :: i,t,k,p,nu,n1,ra,tp,a0,at logical :: pass pass=.false. n1=0 do i=0,nn-1 if (btest(a0,i)) n1=n1+1 enddo if (n1/=nu) return ra=nn at=a0 do t=1,nn-1 if (btest(at,0)) then at=at/2 at=ibset(at,nn-1) else at=at/2 endif if (atrepr(a)) then amin=a+1 else return endif if (amin>amax) then a=-1 return endif enddo end subroutine findstate !-------------------------! !-------------------------! subroutine fgfunctions(k) !-------------------------! use system; implicit none real(8), parameter :: pi=3.14159265358979d0 integer :: i,k real(8) :: kk kk=dfloat(2*k)*pi/dfloat(nn) if (.not.allocated(ffun)) then allocate(ffun(-1:1,-1:1,-nn:nn)) allocate(gfun(-1:1,-nn:nn)) endif do i=-nn,nn ffun(-1,-1,i)=+cos(kk*i) ffun(+1,+1,i)=+cos(kk*i) ffun(+1,-1,i)=+sin(kk*i) ffun(-1,+1,i)=-sin(kk*i) gfun(-1,i)=1.d0-cos(kk*i) gfun(+1,i)=1.d0+cos(kk*i) enddo end subroutine fgfunctions !--------------------------! !-------------------------------------! subroutine diagonalize(n,mat,vec,eig) !-------------------------------------! implicit none integer :: n,info real(8) :: mat(n,n),vec(n,n),eig(n),work(n*(3+n/2)) vec=mat call dsyev('V','U',n,vec,n,eig,work,n*(3+n/2),info) end subroutine diagonalize !--------------------------! !-----------------------------------! subroutine transform(n,mat,vec,dia) !-----------------------------------! implicit none integer :: i,n real(8) :: mat(n,n),vec(n,n),dia(n) mat=matmul(mat,vec) mat=matmul(transpose(vec),mat) do i=1,n dia(i)=mat(i,i) enddo end subroutine transform !------------------------!