板凳
zqt27 [专家分:0] 发布于 2012-03-16 16:44:00
alsoran谢谢,错误提示显示 incrementally linked image--pc correlation disabled,据说是读写错误,但是我在矩阵小于100x100时没有任何问题。你帮忙看看,程序中 N*M<100的话计算结果都是正确的,程序如下:
PROGRAM NEGF
USE IMSL
IMPLICIT NONE
REAL(8), PARAMETER :: U=0.D0, T=3.D0, ITA=1.D-5 ! ITA-Infinitesimal value, U-grid energy value, T-Hopping energy value
REAL(8) :: E
INTEGER :: I, J,J2
INTEGER, PARAMETER :: N=3, M=16 ! N=Grid points in X direction, M=Grid points in Y direaction.
COMPLEX(8) :: G1N(M,M)
REAL(8) :: H(M,M)=0.D0, HLR(M,M)=0.D0,HRL(M,M)=0.D0,UN(M,M)=0.0D0,UN2(N*M,N*M)=0.0D0
COMPLEX(8) :: GSLR(M,M), GSLA(M,M),GSRR(M,M),GSRA(M,M)
COMPLEX(8) :: SEGMALA(M,M), SEGMALR(M,M),SEGMARA(M,M), SEGMARR(M,M)
COMPLEX(8) :: GAMA11(M,M), GAMANN(M,M)
COMPLEX(8) :: GT(M,M),GT2(N*M,N*M)
COMPLEX(8) :: TRACE,IM,TRACE2
REAL(8) :: HD(N*M,N*M)
COMPLEX(8) :: GDR(N*M,N*M)=0.0D0,GAMAT11(N*M,N*M)=0.0D0,GAMATNN(N*M,N*M)=0.0D0
COMPLEX(8) :: SEGMARTR(N*M,N*M)=0.0D0,SEGMALTR(N*M,N*M)=0.0D0
REAL(8)::X,Y,X2,Y2
IM=DCMPLX(0., 1)
OPEN (10, FILE = 'D:\GRAPHENE NANORIBBON.TXT')
LOOP1: DO E=-10., 10., 0.01
CALL MATRIX(U, T, M, UN,H,HLR,HRL)
CALL F1(M,E*UN-H+IM*UN*ITA,HLR,GSRR)
!CALL F1(M,E*UN-H-IM*UN*ITA,HLR,GSRA)
GSRA=DCONJG(.t.GSRR)
CALL F1(M,E*UN-H+IM*UN*ITA,HRL,GSLR)
!CALL F1(M,E*UN-H-IM*UN*ITA,HRL,GSLA)
GSLA=DCONJG(.t.GSLR)
SEGMARR= matmul(matmul(.t.HLR,GSRR),HLR)
SEGMARA= matmul(matmul(.t.HLR,GSRA),HLR)
SEGMALR= matmul(matmul(.t.HRL,GSLR),HRL)
SEGMALA= matmul(matmul(.t.HRL,GSLA),HRL)
GAMA11=IM*(SEGMALR-SEGMALA)
GAMANN=IM*(SEGMARR-SEGMARA)
LOOP2:DO I=1,N
HD((I-1)*M+1:(I-1)*M+M,(I-1)*M+1:(I-1)*M+M)=H
UN2((I-1)*M+1:(I-1)*M+M,(I-1)*M+1:(I-1)*M+M)=UN
IF(I<N)THEN
HD((I-1)*M+1:(I-1)*M+M,I*M+1:I*M+M)=HLR
HD(I*M+1:I*M+M,(I-1)*M+1:(I-1)*M+M)=HRL
END IF
END DO LOOP2
GAMAT11(1:M,1:M)=GAMA11
GAMATNN((N-1)*M+1:(N-1)*M+M,(N-1)*M+1:(N-1)*M+M)=GAMANN
SEGMARTR(1:M,1:M)=SEGMARR
SEGMALTR((N-1)*M+1:(N-1)*M+M,(N-1)*M+1:(N-1)*M+M)=SEGMALR
GDR=.i.(E*UN2-HD+IM*ITA*UN2-SEGMARTR-SEGMALTR)
GT2=matmul(MATMUL(MATMUL(gamat11, GDR), gamatnn), DCONJG(.t.GDR))
TRACE2=0.0D0
LOOP4: DO J2=1, M*N
TRACE2=TRACE2+GT2(J2,J2)
END DO LOOP4
x2=trace2
y2=DIMAG(trace2)
WRITE(*, *) E, x2, y2
WRITE(10, *) E, x2, y2
CALL F2(N,M,HLR, E*UN-H+IM*UN*ITA, SEGMALR, SEGMARR, G1N)
gt=matmul(MATMUL(MATMUL(gama11, G1n), gamann), DCONJG(.t.G1N))
TRACE=0.
LOOP3: DO J=1, M
TRACE=TRACE+GT(J,J)
END DO LOOP3
x=trace
y=DIMAG(trace)
! WRITE(*, *) E, x, y
! WRITE(10, *) E, x, y
END DO LOOP1
END PROGRAM NEGF
SUBROUTINE F1(M, AL, TL, GS)
USE IMSL
IMPLICIT NONE
INTEGER :: IC
INTEGER, INTENT(IN) :: M
COMPLEX(8), INTENT(OUT):: GS(M,M)
COMPLEX(8), INTENT(IN) :: AL(M,M)
REAL(8), INTENT(IN) :: TL(M,M)
COMPLEX(8) ::GS1(M,M), GS0(M,M)
REAL(8), PARAMETER :: ETA=1.D-5
! initial value for surface green function
GS1=.I.AL
IC=0
DO
GS0=.i.(AL- matmul(matmul(.t.TL,GS1),TL))
GS1=GS0*0.5+GS1*0.5
IC=IC+1
IF(IC.GT.2000) EXIT
END DO
GS=GS0
END SUBROUTINE F1
SUBROUTINE F2(N,M,TL, ALR, SEGMALR, SEGMARR ,G1N)
USE IMSL
IMPLICIT NONE
INTEGER :: I
INTEGER, INTENT(IN) :: N,M
COMPLEX(8), INTENT(IN) :: ALR(M,M), SEGMALR(M,M), SEGMARR(M,M)
REAL(8), INTENT(IN) :: TL(M,M)
COMPLEX(8), INTENT(OUT) :: G1N(M,M)
COMPLEX(8) :: G1NM(M,M), G11(M,M), G12(M,M),G22(M,M),G13(M,M),G33(M,M)
complex(8):: matrix1(m,m), matrix2(m,m), matrix3(m,m), matrix4(m,m), matrix5(m,m)
G11=.i.(ALR-SEGMALR)
matrix1=ALR-MATMUL(MATMUL((.t.TL), G11), TL)
CALL DLINCG(M, MATRIX1,M, g22, M)
g12=MATMUL(MATMUL(g11, tl), g22)
DO I=1, N-3
MATRIX2=ALR-MATMUL(MATMUL((.t.TL), G22), TL)
CALL DLINCG(M, MATRIX2,M, g33, M)
G13=MATMUL(MATMUL(G12, TL), g33)
G12=G13
G22=G33
END DO
MATRIX4=ALR-SEGMARR-MATMUL(MATMUL((.t.TL), G33), TL)
CALL DLINCG(M, MATRIX4,M, MATRIX5, M)
G1N=MATMUL(MATMUL(G13, TL), MATRIX5)
END SUBROUTINE F2
SUBROUTINE MATRIX(U, T, N, UN,H,HLR,HRL)
USE IMSL
IMPLICIT NONE
INTEGER, INTENT(IN) :: N
REAL(8), INTENT(OUT) :: UN(N,N),H(N,N), HLR(N,N), HRL(N,N)
REAL(8), INTENT(IN) :: U,T
INTEGER:: J,I,MP,MI
!******给出单位矩阵Un*******
UN=0.0D0
H=0.0D0
HLR=0.0D0
HRL=0.0D0
!******给出单位元胞Hamiltonian矩阵H*******
LOOP1: do J=1,N-1
UN(J,J)=1.
UN(N,N)=1.
H(J,J)=U
H(N,N)=U
H(1,N)=-t
H(N,1)=-t
H(J,J+1)=-t
H(J+1,J)=-t
!******给出元胞间互作用矩阵Hlr******ZIGZAG graphene元胞***
mp=N/4
LOOP2:do I=1,mp
Hlr((I-1)*4+1,(I-1)*4+2)=-t
Hlr((I-1)*4+4,(I-1)*4+3)=-t
END DO LOOP2
MI=MOD(N/2,2)
IF(MI.EQ.1)THEN
HLR(N-1,N)=-T
ENDIF
END DO LOOP1
HRL=.t.HLR
END SUBROUTINE MATRIX
SUBROUTINE MATRIX2(U, T, N, UN,H,HLR,HRL)
USE IMSL
IMPLICIT NONE
INTEGER, INTENT(IN) :: N
REAL(8), INTENT(OUT) :: UN(N,N),H(N,N), HLR(N,N), HRL(N,N)
REAL(8), INTENT(IN) :: U,T
INTEGER:: J,I,MP,MI
!******给出单位矩阵Un*******
UN=0.0D0
H=0.0D0
HLR=0.0D0
HRL=0.0D0
!******给出单位元胞Hamiltonian矩阵H*******
LOOP1: do J=1,N-1
UN(J,J)=1.
UN(N,N)=1.
H(J,J)=U+4.*T
H(N,N)=U+4.*T
H(J,J+1)=-t
H(J+1,J)=-t
!******给出元胞间互作用矩阵Hlr******ZIGZAG graphene元胞***
Hlr(J,J)=t
HLR(N,N)=T
END DO LOOP1
HRL=.t.HLR
END SUBROUTINE MATRIX2