LCOV - code coverage report
Current view: top level - wannier - wann_torque.F (source / functions) Hit Total Coverage
Test: FLEUR test coverage Lines: 0 81 0.0 %
Date: 2024-04-28 04:28:00 Functions: 0 1 0.0 %

          Line data    Source code
       1             :       module m_wann_torque
       2             :             use m_judft
       3             :       private
       4             :       public :: wann_torque
       5             :       contains
       6           0 :       subroutine wann_torque(
       7             :      >               amat,
       8           0 :      >               ntype,lmaxd,lmax,nat,
       9           0 :      >               neq,noccbd,lmd,natd,llod,nlod, 
      10           0 :      >               nlo,llo,
      11           0 :      >               acof,bcof,ccof,
      12           0 :      >               us,dus,duds,uds,
      13           0 :      >               ulos,dulos,
      14           0 :      >               rmt,pos,atomlist_num,atomlist, 
      15             :      >               l_soc,nbnd,
      16           0 :      &               torque)
      17             : c******************************************************
      18             : c     Calculate matrix elements of the surface 
      19             : c     current operator.
      20             : c     Frank Freimuth
      21             : c******************************************************
      22             : c      use m_dwigner
      23             :       use m_constants, only:pimach
      24             : c      use m_gaunt,only:gaunt1
      25             : c      use m_wann_surfcurr_anglsum2
      26             : c      use m_wann_gfactor
      27             : 
      28             :       implicit none
      29             :       real,    intent(in) :: amat(:,:) !amat(3,3)
      30             : 
      31             :       integer, intent(in) :: ntype
      32             :       integer, intent(in) :: lmaxd
      33             :       integer, intent(in) :: lmax(:) !lmax(ntype)
      34             :       integer, intent(in) :: nat
      35             : 
      36             :       integer, intent(in) :: neq(:) !neq(ntype)
      37             :       integer, intent(in) :: noccbd
      38             :       integer, intent(in) :: lmd,natd,llod,nlod
      39             : 
      40             :       integer, intent(in) :: nlo(:) !nlo(ntype)
      41             :       integer, intent(in) :: llo(:,:) !llo(nlod,ntype)
      42             : 
      43             :       complex, intent(in) :: acof(:,0:,:,:) !acof(noccbd,0:lmd,natd,jspins=2)
      44             :       complex, intent(in) :: bcof(:,0:,:,:) !bcof(noccbd,0:lmd,natd,jspins=2)
      45             :       complex, intent(in) :: ccof(-llod:,:,:,:,:) !ccof(-llod:llod,noccbd,nlod,natd,2)
      46             : 
      47             :       real,    intent(in) :: us(0:,:,:)    !us  (0:lmaxd,ntype,jspins=2)
      48             :       real,    intent(in) :: dus(0:,:,:)   !dus (0:lmaxd,ntype,jspins=2)
      49             :       real,    intent(in) :: duds(0:,:,:)  !duds(0:lmaxd,ntype,jspins=2)
      50             :       real,    intent(in) :: uds(0:,:,:)   !uds (0:lmaxd,ntype,jspins=2)
      51             : 
      52             :       real,    intent(in) :: ulos(:,:,:)   !ulos(nlod,ntype,jspins=2)
      53             :       real,    intent(in) :: dulos(:,:,:)  !dulos(nlod,ntype,jspins=2)
      54             : 
      55             :       real,    intent(in) :: rmt(:) !rmt(ntype)
      56             :       real,    intent(in) :: pos(:,:)!pos(3,nat)
      57             :       integer, intent(in) :: atomlist_num
      58             :       integer, intent(in) :: atomlist(:)
      59             : 
      60             :       logical, intent(in) :: l_soc
      61             :       integer, intent(in) :: nbnd
      62             : 
      63             :       complex, intent(out) :: torque(:,:,:,:) !noccbd,noccbd,3,atomlist_num
      64             : 
      65             :       integer             :: at,n,itype,nt,minat,maxat
      66             :       integer             :: m,l,lm,j,i,jspin
      67           0 :       complex,allocatable :: surfcof(:,:,:,:)
      68           0 :       complex,allocatable :: surfder(:,:,:,:)
      69           0 :       complex,allocatable :: currmat(:,:,:,:)
      70             :       real                :: bmat(3,3)
      71             :       integer             :: tlp1,ilo,iat,jj
      72             :       integer(kind=8)     :: varint
      73             :       real                :: sqrtpi
      74             :       integer             :: lp,lpp,lppp,lmp,lmin,lmaxx
      75             :       integer             :: spin1,spin2,mp,mppp,lmppp,mpp,lmpp
      76             :       complex,parameter   :: ci=(0.0,1.0)
      77             :       integer             :: dir,list_ind
      78             :       logical             :: l_inthelist
      79             : 
      80             : 
      81           0 :       call timestart("wann_torque")
      82           0 :       allocate ( surfcof(noccbd,0:lmd,nat,2) )
      83           0 :       allocate ( surfder(noccbd,0:lmd,nat,2) )  
      84             : 
      85           0 :       surfcof=0.0
      86           0 :       surfder=0.0
      87           0 :       do jspin=1,2
      88           0 :        nt=0
      89           0 :        DO itype=1,ntype
      90           0 :         minat=nt+1
      91           0 :         maxat=nt+neq(itype)
      92           0 :         do at=minat,maxat  
      93           0 :          do l=0,lmax(itype)  
      94           0 :           do m=-l,l  
      95           0 :            lm=l*(l+1)+m
      96           0 :            do j=1,noccbd
      97             :             surfcof(j,lm,at,jspin)=
      98             :      &        ( acof(j,lm,at,jspin)* us(l,itype,jspin)
      99             :      &                    +
     100             :      &          bcof(j,lm,at,jspin)* uds(l,itype,jspin) )*
     101           0 :      &              rmt(itype)*ci**l
     102             : 
     103             :             surfder(j,lm,at,jspin)=
     104             :      &        ( acof(j,lm,at,jspin)*dus(l,itype,jspin)
     105             :      &                    +
     106             :      &          bcof(j,lm,at,jspin)*duds(l,itype,jspin) )*
     107           0 :      &              rmt(itype)*ci**l
     108             : 
     109             :            enddo !j
     110             :           enddo !m 
     111             :          enddo !l 
     112           0 :          do ilo=1,nlo(itype)
     113           0 :           l=llo(ilo,itype)
     114           0 :           do m=-l,l
     115           0 :            lm=l*(l+1)+m
     116           0 :            do j=1,noccbd
     117             : c              if(.false.)then
     118             :             surfcof(j,lm,at,jspin)=surfcof(j,lm,at,jspin)+
     119             :      &        ( ccof(m,j,ilo,at,jspin)* ulos(ilo,itype,jspin) )*
     120           0 :      &              rmt(itype)*ci**l
     121             : 
     122             :             surfder(j,lm,at,jspin)=surfder(j,lm,at,jspin)+
     123             :      &        ( ccof(m,j,ilo,at,jspin)*dulos(ilo,itype,jspin) )*
     124           0 :      &              rmt(itype)*ci**l             
     125             : c            endif
     126             :            enddo !j
     127             :           enddo !m   
     128             :          enddo !ilo
     129             :         enddo !at
     130           0 :         nt=nt+neq(itype)
     131             :        enddo !itype
     132             :       enddo !jspin
     133             : 
     134           0 :       allocate( currmat(noccbd,noccbd,2,2) )
     135           0 :       at=0
     136           0 :       do itype=1,ntype
     137           0 :        do iat=1,neq(itype)
     138           0 :         at=at+1
     139           0 :         l_inthelist=.false.
     140           0 :         do list_ind=1,atomlist_num
     141           0 :           if(atomlist(list_ind).eq.at)then
     142             :              l_inthelist=.true.
     143             :              exit
     144             :           endif
     145             :         enddo !list_ind
     146           0 :         if(.not.l_inthelist)cycle
     147           0 :         currmat=cmplx(0.0,0.0)
     148           0 :         do spin2=1,2
     149           0 :          do spin1=1,2
     150           0 :           do l=0,lmax(itype)
     151           0 :            do m=-l,l
     152           0 :             lm=l*(l+1)+m
     153           0 :             do j=1,noccbd
     154           0 :              do jj=1,noccbd  
     155             :               currmat(jj,j,spin1,spin2)=
     156             :      &           currmat(jj,j,spin1,spin2)+
     157             :      &             conjg(surfcof(jj,lm,at,spin1))*
     158           0 :      &             surfder(j,lm,at,spin2)
     159             :              enddo !jj
     160             :             enddo !j
     161             :            enddo !m
     162             :           enddo !l
     163             :          enddo !spin1
     164             :         enddo !spin2
     165             : 
     166             : c-------x-component
     167             : c-------Pauli-x:
     168             : c-------( 0  1 )
     169             : c-------( 1  0 )
     170           0 :         if(l_soc)then
     171           0 :          do j=1,noccbd
     172           0 :           do jj=1,noccbd
     173             :            torque(1,jj,j,list_ind)=
     174             :      &            currmat(jj,j,2,1)+
     175           0 :      &            currmat(jj,j,1,2)
     176             :           enddo
     177             :          enddo
     178             :         else
     179           0 :          do j=1,noccbd
     180           0 :           do jj=1,noccbd
     181             :            torque(1,jj+nbnd,j,list_ind)=
     182           0 :      &            currmat(jj,j,2,1)
     183             :            torque(1,jj,j+nbnd,list_ind)=
     184           0 :      &            currmat(jj,j,1,2)
     185             :           enddo
     186             :          enddo
     187             :         endif
     188             : 
     189             : c-------y-component
     190             : c-------Pauli-y:
     191             : c-------( 0 -i )
     192             : c-------( i  0 )
     193           0 :         if(l_soc)then
     194           0 :          do j=1,noccbd
     195           0 :           do jj=1,noccbd
     196             :            torque(2,jj,j,list_ind)=
     197             :      &              ci*currmat(jj,j,2,1)-
     198           0 :      &              ci*currmat(jj,j,1,2)
     199             :           enddo
     200             :          enddo
     201             :         else
     202           0 :          do j=1,noccbd
     203           0 :           do jj=1,noccbd
     204             :            torque(2,jj+nbnd,j,list_ind)=
     205           0 :      &              ci*currmat(jj,j,2,1)
     206             :            torque(2,jj,j+nbnd,list_ind)=
     207           0 :      &             -ci*currmat(jj,j,1,2)
     208             : 
     209             :           enddo
     210             :          enddo
     211             :         endif
     212             : 
     213             : c-------z-component
     214             : c-------Pauli-z:
     215             : c-------( 1  0 )
     216             : c-------( 0 -1 )
     217           0 :         if(l_soc)then
     218           0 :          do j=1,noccbd
     219           0 :           do jj=1,noccbd
     220             :            torque(3,jj,j,list_ind)=
     221             :      &              currmat(jj,j,1,1)-
     222           0 :      &              currmat(jj,j,2,2)
     223             :           enddo
     224             :          enddo
     225             :         else
     226           0 :          do j=1,noccbd
     227           0 :           do jj=1,noccbd
     228             :            torque(3,jj,j,list_ind)=
     229           0 :      &              currmat(jj,j,1,1)
     230             : 
     231             :            torque(3,jj+nbnd,j+nbnd,list_ind)=
     232           0 :      &             -currmat(jj,j,2,2)
     233             :           enddo
     234             :          enddo
     235             :         endif
     236             :        enddo !iat
     237             :       enddo !itype
     238             : 
     239             : c      write(*,*)torque
     240             : 
     241             : c      stop 'ok till here'
     242           0 :       call timestop("wann_torque")
     243           0 :       end subroutine wann_torque
     244             :       
     245             :       end module m_wann_torque

Generated by: LCOV version 1.14