~nickpapior/siesta/tddft-work

« back to all changes in this revision

Viewing changes to Src/diag2g.F

  • Committer: Rafi Ullah
  • Date: 2017-08-30 14:09:10 UTC
  • mfrom: (611.1.19 trunk)
  • Revision ID: rraffiu@gmail.com-20170830140910-bhu0osuh4d59wn8e
Merged with trunk-630

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
      subroutine diag2g( nuo, no, maxnh, maxnd, maxo,
9
9
     .                   numh, listhptr, listh, numd, listdptr,
10
10
     .                   listd, H, S, getD, qtot, temp, e1, e2,
11
 
     .                   eo, qo, Dnew, Enew, ef, Entropy, psi, 
 
11
     .                   eo, qo, Dnew, Enew, ef, Entropy, 
 
12
     .                   Haux, Saux, psi, caux, 
12
13
     .                   nuotot, occtol, iscf, neigwanted)
13
14
 
14
15
!
30
31
C eigenvector, for given Hamiltonian and Overlap matrices.
31
32
C This version is for non-collinear spin at gamma point.
32
33
C Writen by J.Soler, May and August 1998.
 
34
C Reduced memory requirements, Nick, Aug. 2017
33
35
C **************************** INPUT **********************************
34
36
C integer nuo                 : Number of basis orbitals on local node
35
37
C integer no                  : Number of basis orbitals
69
71
C real*8 ef                   : Fermi energy
70
72
C real*8 Entropy              : Electronic entropy
71
73
C *************************** AUXILIARY *******************************
72
 
C real*8 Haux(2,2,nuotot,2,nuo): Auxiliary space for the hamiltonian matrix
73
 
C real*8 Saux(2,2,nuotot,2,nuo): Auxiliary space for the overlap matrix
74
 
C real*8 psi(2,2,nuotot,2*no) : Auxiliary space for the eigenvectors
75
 
C real*8 aux(5,2*nuotot)      : Extra auxiliary space
 
74
C complex*16 Haux(2,nuotot,2,nuo): Auxiliary space for the hamiltonian matrix
 
75
C complex*16 Saux(2,nuotot,2,nuo): Auxiliary space for the overlap matrix
 
76
C complex*16 psi(2,nuotot,2*nuo) : Auxiliary space for the eigenvectors
 
77
C complex*16 caux(2,nuotot)      : Extra auxiliary space
76
78
C *************************** UNITS ***********************************
77
79
C xij and kpoint must be in reciprocal coordinates of each other.
78
80
C temp and H must be in the same energy units.
95
97
      real(dp) Entropy, eo(maxo*2), H(maxnh,4), qo(maxo*2)
96
98
      real(dp) qtot, S(maxnh), temp, occtol
97
99
      
 
100
      complex(dp), dimension(2,nuotot,2*nuo) :: psi
 
101
      complex(dp), dimension(2,nuotot,2,nuo) :: Haux, Saux
 
102
      complex(dp), dimension(2,nuotot) :: caux
98
103
      logical               getD
99
104
      
100
105
!     Internal variables .............................................
101
 
      real(dp)                       psi(2,2,nuotot,2*nuo)
102
 
      complex(dp),dimension(:,:,:,:), allocatable :: Haux, Saux
103
 
      complex(dp),dimension(:,:),     allocatable :: caux
104
 
      
 
106
 
105
107
      integer           BNode, BTest, ie, ierror, iie, iio
106
108
      integer           ind, io, j, jo, nd, iuo, juo
107
109
      real(dp)          ee, pipj, qe, t
116
118
!***********************************************************************
117
119
!     B E G I N
118
120
!***********************************************************************
119
 
!     define the arrays
120
 
      allocate(Haux(2,nuotot,2,nuo))
121
 
      call memory('A','Z',2*nuotot*2*nuo,'diag2g')
122
 
      allocate(Saux(2,nuotot,2,nuo))
123
 
      call memory('A','Z',2*nuotot*2*nuo,'diag2g')
124
 
      allocate(caux(2,nuotot))
125
 
      call memory('A','Z',2*nuotot,'diag2g')
126
121
 
127
122
!***********************************************************************
128
123
! BUILD HAMILTONIAN
179
174
      
180
175
!     Solve the eigenvalue problem
181
176
      call cdiag(Haux,Saux,2*nuotot,2*nuo,2*nuotot,eo,psi,
182
 
     .                       2*neigwanted,iscf,ierror, 2*BlockSize)
 
177
     .           2*neigwanted,iscf,ierror, 2*BlockSize)
183
178
      
184
179
!     Check error flag and take appropriate action
185
180
      if (ierror.gt.0) then
201
196
          enddo
202
197
        enddo
203
198
        call cdiag(Haux,Saux,2*nuotot,2*nuo,2*nuotot,eo,psi,
204
 
     .                         2*neigwanted,iscf,ierror, 2*BlockSize)
 
199
     .             2*neigwanted,iscf,ierror, 2*BlockSize)
205
200
      endif
206
201
      
207
202
!     Check if we are done
259
254
        if (abs(qe).gt.occtol) then
260
255
          if (Node.eq.BNode) then
261
256
            do j = 1,nuotot
262
 
              caux(1,j)=dcmplx( psi(1,1,j,iie), psi(2,1,j,iie)) ! c_{i,up}
263
 
              caux(2,j)=dcmplx( psi(1,2,j,iie), psi(2,2,j,iie)) ! c_{i,dn}
 
257
              caux(1,j)= psi(1,j,iie) ! c_{i,up}
 
258
              caux(2,j)= psi(2,j,iie) ! c_{i,dn}
264
259
            enddo
265
260
          endif
266
261
#ifdef MPI
326
321
 
327
322
 1001 continue
328
323
      
329
 
!     deallocate the arrays
330
 
      call memory('D','Z',2*nuotot*2*nuo,'diag2g')
331
 
      deallocate(Haux)
332
 
      call memory('D','Z',2*nuotot*2*nuo,'diag2g')
333
 
      deallocate(Saux)
334
 
      call memory('D','Z',2*nuotot,'diag2g')
335
 
      deallocate(caux)
336
324
#ifdef DEBUG
337
325
      call write_debug( '    POS diag2k' )
338
326
#endif