LCOV - code coverage report
Current view: top level - wannier - wann_socmat_rs.f (source / functions) Hit Total Coverage
Test: FLEUR test coverage Lines: 0 104 0.0 %
Date: 2024-04-26 04:44:34 Functions: 0 1 0.0 %

          Line data    Source code
       1             : !--------------------------------------------------------------------------------
       2             : ! Copyright (c) 2016 Peter Grünberg Institut, Forschungszentrum Jülich, Germany
       3             : ! This file is part of FLEUR and available as free software under the conditions
       4             : ! of the MIT license as expressed in the LICENSE file in more detail.
       5             : !--------------------------------------------------------------------------------
       6             : 
       7             :       module m_wann_socmat_rs
       8             :       use m_juDFT
       9             :       contains 
      10           0 :       subroutine wann_socmat_rs(
      11           0 :      >          rvecnum,rvec,kpoints,
      12             :      >          jspins_in,nkpts,l_bzsym,film,
      13             :      >          l_soc,band_min,band_max,neigd,
      14             :      >          l_socmmn0,wan90version)
      15             : c*************************************************
      16             : c     Calculate the matrix elements of SOC perturbation 
      17             : c     in real space from the
      18             : c     files WF1.chk (and WF1_um.dat) (produced
      19             : c     by wannier90) and WF1.hsomtx.
      20             : c     FF, April 2010
      21             : c*************************************************
      22             :       use m_constants
      23             :       use m_wann_read_umatrix
      24             : 
      25             :       implicit none
      26             :       integer, intent(in) :: rvecnum
      27             :       integer, intent(in) :: rvec(:,:)
      28             :       real,    intent(in) :: kpoints(:,:)
      29             : 
      30             :       integer, intent(in) :: jspins_in
      31             :       integer, intent(in) :: nkpts
      32             :       logical,intent (in) :: l_bzsym,l_soc
      33             :       logical,intent(in)  :: film
      34             :       integer,intent(in)  :: band_min(2),band_max(2),neigd
      35             :       logical, intent(in) :: l_socmmn0
      36             :       integer, intent(in) :: wan90version
      37             : 
      38             : 
      39             :       integer             :: ikpt,jspins
      40             :       integer             :: kpts
      41             :       logical             :: l_file
      42             : c      real                :: kpoints(3,nkpts)
      43             :       integer             :: num_wann,num_kpts,num_nnmax,jspin
      44             :       integer             :: kspin,kkspin
      45             :       integer             :: wann_shift,num_wann2
      46             :       integer             :: i,j,k,m,info,r1,r2,r3,dummy1
      47             :       integer             :: dummy2,dummy3,dummy4,dummy5
      48             :       integer             :: hopmin,hopmax,counter,m1,m2
      49             :       integer             :: num_bands2
      50             :       integer,allocatable :: iwork(:)
      51             :       real,allocatable    :: energy(:,:),ei(:)
      52             :       real,allocatable    :: eigw(:,:),rwork(:)
      53             :       complex,allocatable :: work(:),vec(:,:)
      54           0 :       complex,allocatable :: u_matrix(:,:,:,:)
      55           0 :       complex,allocatable :: hwann(:,:,:,:,:)
      56           0 :       complex,allocatable :: hreal(:,:,:,:,:)
      57           0 :       complex,allocatable :: hsomtx(:,:,:,:,:)
      58           0 :       complex,allocatable :: hsomtx2(:,:,:,:,:)
      59             :       complex             :: fac,eulav,eulav1
      60             :       real                :: tmp_omi,rdotk,tpi,minenerg,maxenerg
      61             :       real, allocatable   :: minieni(:),maxieni(:)
      62             :       character           :: jobz,uplo
      63             :       integer             :: kpt,band,lee,lwork,lrwork,liwork,n,lda
      64             :       complex             :: value(4)
      65             :       logical             :: um_format
      66             :       logical             :: repro_eig
      67             :       logical             :: l_chk,l_proj
      68             :       logical             :: have_disentangled
      69           0 :       integer,allocatable :: ndimwin(:,:)
      70           0 :       logical,allocatable :: lwindow(:,:,:)
      71             :       integer             :: chk_unit,nkp,ntmp,ierr
      72             :       character(len=33)   :: header
      73             :       character(len=20)   :: checkpoint
      74             :       real                :: tmp_latt(3,3), tmp_kpt_latt(3,nkpts)
      75             :       real                :: omega_invariant
      76           0 :       complex,allocatable :: u_matrix_opt(:,:,:,:)
      77             :       integer             :: num_bands
      78             :       logical             :: l_umdat
      79             :       real,allocatable    :: eigval2(:,:)
      80             :       real,allocatable    :: eigval_opt(:,:)
      81             :       real                :: scale,a,b
      82             :       character(len=2)    :: spinspin12(0:2)
      83             :       character(len=3)    :: spin12(2)
      84             :       character(len=6)    :: filename
      85             :       integer             :: jp,mp,kk,ii,jj,rvecind
      86             :       complex,parameter   :: ci=(0.0,1.0)
      87             : 
      88             :       data spinspin12/'  ','.1' , '.2'/
      89             :       data spin12/'WF1','WF2'/
      90             : 
      91           0 :       call timestart("wann_socmat_rs")
      92             : 
      93           0 :       tpi=2*pimach()
      94             : 
      95           0 :       jspins=jspins_in
      96           0 :       if(l_soc)jspins=1
      97             : 
      98           0 :       write(oUnit,*)"nkpts=",nkpts
      99             : 
     100             : c*****************************************************
     101             : c     get num_bands and num_wann from the proj file
     102             : c*****************************************************
     103           0 :       do j=1,0,-1
     104           0 :           inquire(file=trim('proj'//spinspin12(j)),exist=l_file)
     105           0 :           if(l_file)then
     106           0 :             filename='proj'//spinspin12(j)
     107           0 :             exit
     108             :           endif
     109             :       enddo
     110           0 :       if(l_file)then
     111           0 :           open (203,file=trim(filename),status='old')
     112           0 :           rewind (203)
     113             :       else
     114             :          CALL juDFT_error("no proj/proj.1/proj.2",calledby
     115           0 :      +        ="wann_socmat_rs")
     116             :       endif
     117           0 :       read (203,*) num_wann,num_bands
     118           0 :       close (203)
     119           0 :       write(oUnit,*)'According to proj there are ',num_bands,' bands'
     120           0 :       write(oUnit,*)"and ",num_wann," wannier functions."
     121             : 
     122             : c****************************************************************
     123             : c        read in chk
     124             : c****************************************************************
     125           0 :       num_kpts=nkpts
     126           0 :       allocate( u_matrix_opt(num_bands,num_wann,nkpts,2) )
     127           0 :       allocate( u_matrix(num_wann,num_wann,nkpts,2) )
     128           0 :       allocate( lwindow(num_bands,nkpts,2) )
     129           0 :       allocate( ndimwin(nkpts,2) )
     130             : 
     131           0 :       do jspin=1,jspins  !spin loop
     132             :          call wann_read_umatrix2(
     133             :      >       nkpts,num_wann,num_bands,
     134             :      >       um_format,jspin,wan90version,
     135             :      <       have_disentangled,
     136             :      <       lwindow(:,:,jspin),
     137             :      <       ndimwin(:,jspin),
     138             :      <       u_matrix_opt(:,:,:,jspin),
     139           0 :      <       u_matrix(:,:,:,jspin))
     140           0 :          num_bands2=num_bands
     141             :       enddo !jspin   
     142           0 :       if(jspins.eq.1)then
     143           0 :          lwindow(:,:,2)        = lwindow(:,:,1)
     144           0 :          ndimwin(:,2)          = ndimwin(:,1)
     145           0 :          u_matrix_opt(:,:,:,2) = u_matrix_opt(:,:,:,1)
     146           0 :          u_matrix(:,:,:,2)     = u_matrix(:,:,:,1)
     147             :       endif
     148             : 
     149             : c****************************************************
     150             : c        Read the file "WF1.hsomtx".
     151             : c**************************************************** 
     152           0 :       allocate( hsomtx(2,2,num_bands2,num_bands2,nkpts) )
     153           0 :       open(304,file='WF1.hsomtx',form='formatted')
     154           0 :       read(304,*) !title
     155           0 :       read(304,*) !specification of array dimensions
     156           0 :       do nkp=1,num_kpts
     157           0 :        do i=1,num_bands2
     158           0 :         do j=1,num_bands2
     159           0 :          do ii=1,2
     160           0 :           do jj=1,2
     161           0 :             read(304,*)dummy1,dummy2,dummy3,dummy4,dummy5,a,b
     162           0 :             hsomtx(jj,ii,j,i,nkp)=cmplx(a,-b)
     163             :           enddo !jj
     164             :          enddo !ii 
     165             :         enddo !j
     166             :        enddo !i
     167             :       enddo !nkp
     168           0 :       close(304)
     169             : 
     170             : c****************************************************************
     171             : c        Calculate matrix elements of SOC in the basis of
     172             : c        rotated Bloch functions.
     173             : c****************************************************************
     174           0 :       allocate( hsomtx2(2,2,num_wann,num_wann,nkpts) )
     175             :       write(oUnit,*)"calculate matrix elements of SOC operator
     176           0 :      &between wannier orbitals"
     177             : 
     178           0 :       if(have_disentangled) then       
     179           0 :        hsomtx2=0.0  
     180           0 :        do nkp=1,num_kpts
     181           0 :         do j=1,num_wann
     182           0 :          do jp=1,num_wann  
     183           0 :           do ii=1,2
     184           0 :            do jj=1,2
     185           0 :             do m=1,ndimwin(nkp,ii)
     186           0 :              do mp=1,ndimwin(nkp,jj)  
     187             :               hsomtx2(jj,ii,jp,j,nkp)=hsomtx2(jj,ii,jp,j,nkp)+ 
     188             :      &            conjg(u_matrix_opt(mp,jp,nkp,jj))*
     189             :      &                  hsomtx(jj,ii,mp,m,nkp)*
     190           0 :      &                  u_matrix_opt(m,j,nkp,ii)
     191             :              enddo !mp   
     192             :             enddo !m
     193             :            enddo !jj  
     194             :           enddo !ii
     195             :          enddo !jp 
     196             :         enddo !j
     197             :        enddo !nkp
     198             :       else
     199           0 :        hsomtx2 = hsomtx
     200             :       end if !have_disentangled
     201             : 
     202           0 :       allocate(hwann(2,2,num_wann,num_wann,num_kpts))
     203           0 :       hwann(:,:,:,:,:)=cmplx(0.0,0.0)
     204             :       wann_shift=0
     205           0 :       do k=1,num_kpts
     206           0 :        do m=1,num_wann
     207           0 :         do mp=1,num_wann
     208           0 :          do ii=1,2
     209           0 :           do jj=1,2
     210           0 :            do i=1,num_wann
     211           0 :             do j=1,num_wann
     212             :              hwann(jj,ii,mp,m,k)=hwann(jj,ii,mp,m,k)+
     213             :      *        conjg(u_matrix(j,mp,k,jj))*
     214             :      *                hsomtx2(jj,ii,j,i,k)*
     215           0 :      *              u_matrix(i,m,k,ii)
     216             :             enddo !j
     217             :            enddo !i     
     218             :           enddo !jj 
     219             :          enddo !ii
     220             :         enddo !mp
     221             :        enddo !m
     222             :       enddo !k
     223             : 
     224             : c************************************************************
     225             : c        Calculate matrix elements in real space.
     226             : c***********************************************************      
     227           0 :       write(oUnit,*)"calculate SOC-mat in rs"
     228             : 
     229           0 :       allocate(hreal(2,2,num_wann,num_wann,rvecnum))
     230           0 :       hreal=cmplx(0.0,0.0)
     231           0 :       do rvecind=1,rvecnum
     232           0 :        do k=1,nkpts  
     233             :         rdotk=tpi*(  kpoints(1,k)*rvec(1,rvecind)+
     234             :      +                  kpoints(2,k)*rvec(2,rvecind)+
     235           0 :      +                  kpoints(3,k)*rvec(3,rvecind)  )
     236           0 :         fac=cmplx(cos(rdotk),-sin(rdotk))
     237           0 :         do m2=1,num_wann
     238           0 :          do m1=1,num_wann
     239           0 :           do ii=1,2
     240           0 :            do jj=1,2
     241             :             hreal(jj,ii,m1,m2,rvecind)=hreal(jj,ii,m1,m2,rvecind)+
     242           0 :      &            fac*hwann(jj,ii,m1,m2,k)
     243             :            enddo 
     244             :           enddo 
     245             :          enddo 
     246             :         enddo 
     247             :        enddo !k
     248             :       enddo !rvecind
     249           0 :       hreal=hreal/cmplx(real(nkpts),0.0)
     250             : 
     251           0 :       open(321,file='rssocmat.1',form='formatted')
     252             : 
     253           0 :       do rvecind=1,rvecnum
     254           0 :          r3=rvec(3,rvecind)
     255           0 :          r2=rvec(2,rvecind)
     256           0 :          r1=rvec(1,rvecind)
     257           0 :          do i=1,num_wann
     258           0 :            do j=1,num_wann
     259           0 :             do ii=1,2
     260           0 :              do jj=1,2  
     261             :               write(321,'(i3,1x,i3,1x,i3,1x,i3,1x,i3,1x,
     262             :      &                      i3,1x,i3,1x,f20.8,1x,f20.8)')
     263           0 :      &                r1,r2,r3,i,j,jj,ii,hreal(jj,ii,i,j,rvecind) 
     264             :              enddo
     265             :             enddo !kk  
     266             :            enddo !j
     267             :          enddo !i
     268             :       enddo !rvecind    
     269             : 
     270           0 :       close(321)
     271             : 
     272           0 :       deallocate(lwindow,u_matrix_opt,ndimwin)
     273           0 :       deallocate(u_matrix,hwann,hreal)
     274             : 
     275           0 :       call timestop("wann_socmat_rs")
     276           0 :       end subroutine wann_socmat_rs
     277             :       end module m_wann_socmat_rs

Generated by: LCOV version 1.14