- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
PROGRAM DOS2
IMPLICIT NONE
INTEGER :: omega=1 ,k ,w ,Nc=1000 ,Ne=1000 ,M ,L
INTEGER, PARAMETER :: N=2
REAL :: eta=0.0015 ,ek ,kx ,t0=0.25 ,a0=1.0 ,DENSITY ,dE=0.001 ,eA ,eB ,X ,REALENERGY
DOUBLE PRECISION :: pi=4*ATAN(1.0)
COMPLEX , PARAMETER :: i=(0.0,1)
COMPLEX :: ENERGY ,C
COMPLEX :: ek1 ,ek2
COMPLEX,DIMENSION(N,N) :: MATRIX
COMPLEX,DIMENSION(N,N) :: INVERSE_MATRIX
COMPLEX :: GREEN
COMPLEX :: GREENFUNC
OPEN(2,FILE='DENSITY.txt')
OPEN(1,FILE='REALENERGY.txt')
DO w=-Ne,Ne
ENERGY=w*dE+i*eta
X=REAL(ENERGY)
REALENERGY =X/t0
WRITE(1,*) REALENERGY
GREENFUNC=(0,0)
DO k=-Nc,+Nc
kx=(pi*k)/(1000*a0)
ek1=t0*(1+EXP((-2)*i*kx*a0))
ek2=t0*(1+EXP(2*i*kx*a0))
eA=0.5*t0
eB=(- 0.5)*t0
DO M=1,N
DO L=1,N
MATRIX(M,N)=RESHAPE((/ (ENERGY-eB),ek2,ek1,(ENERGY-eA) /),(/ M,L /))
C=1.0/(((((X-eA)+i*eta)*((X-eB)+i*eta))/t0)-(ek1*ek2))
INVERSE_MATRIX(M,L)=C*(MATRIX(M,L))
GREEN=INVERSE_MATRIX(1,1)+INVERSE_MATRIX(2,2)
GREENFUNC=GREENFUNC+GREEN
END DO
END DO
END DO
GREENFUNC=GREENFUNC/(2*Nc+1)
DENSITY=DBLE(GREENFUNC*i) / (pi*omega)
WRITE(2,*) DENSITY
END DO
CLOSE(1)
CLOSE(2)
END PROGRAM DOS2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
matrix = reshape( [a,b,c,d],[2,2] )
you are assigning the whole matrix in that command "[" is the same as the older "(/" BTW
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
>>MATRIX(M,N)=RESHAPE((/ (ENERGY-eB),ek2,ek1,(ENERGY-eA) /),(/ M,L /))
MATRIX(M,N) is a scalar (a single cell in array MATRIX), the result of the RESHAPE is an array.
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for your help. How can I assign those values to matrix elements? Is there a solution other than using the RESHAPE command?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
matrix = reshape( [a,b,c,d],[2,2] )
you are assigning the whole matrix in that command "[" is the same as the older "(/" BTW
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page