LCOV - code coverage report
Current view: top level - wannier - wann_dipole_electronic.f (source / functions) Hit Total Coverage
Test: combined.info Lines: 0 48 0.0 %
Date: 2019-09-08 04:53:50 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_dipole_electronic
       8             :       use m_juDFT
       9             :       contains
      10           0 :       subroutine wann_dipole_electronic(
      11           0 :      >               natd,pos,omtil,
      12             :      >               jspins,l_absolute,num_wann,
      13             :      <               electronic_moment)
      14             : c*********************************************
      15             : c     Calculate the dipole moment due to 
      16             : c     Wannier-electrons.
      17             : c
      18             : c     This subroutine can operate in two modes:
      19             : c
      20             : c     i)  l_absolute=.true.  => Simply evaluate
      21             : c         the center of mass moment of all 
      22             : c         Wannier functions.
      23             : c 
      24             : c     ii) l_absolute=.false. => Sum up the dipoles
      25             : c         that arise from the displacements of the
      26             : c         Wannier functions' centers from their 
      27             : c         host atoms. 
      28             : c
      29             : c     Frank Freimuth
      30             : c*********************************************
      31             :       use m_wann_readcenters
      32             :       implicit none
      33             :       integer, intent(in)  :: natd
      34             :       real,    intent(in)  :: pos(3,natd)
      35             :       real,    intent(in)  :: omtil
      36             :       integer, intent(in)  :: jspins
      37             :       logical, intent(in)  :: l_absolute
      38             :       integer, intent(in)  :: num_wann(2)
      39             :       real,    intent(out) :: electronic_moment(3,2)
      40             : 
      41             :       real                 :: electronic_polarization(3,2)
      42             :       real,parameter       :: elemchargmu=1.60217646e-13
      43             :       real,parameter       :: bohrtocm=0.529177e-8
      44             :       integer              :: jspin,j
      45             :       logical              :: l_file
      46             :       character(len=2)     :: spin12(0:2)
      47             :       character(len=6)     :: filename
      48             :       integer              :: num_wann_dum
      49           0 :       integer, allocatable :: waind(:)
      50             :       integer              :: nwf,k
      51           0 :       real, allocatable    :: wann_centers(:,:)
      52             : 
      53             :       data spin12/'  ', '.1', '.2'/
      54             : 
      55           0 :       write(666,*)"*****************************"
      56           0 :       write(666,*)" Electronic terms            "
      57           0 :       write(666,*)"*****************************"
      58           0 :       write(*,*)  "*****************************"
      59           0 :       write(*,*)  " Electronic terms            "
      60           0 :       write(*,*)  "*****************************"
      61             : 
      62           0 :       electronic_moment=0.0
      63             :       
      64           0 :       do jspin=1,jspins
      65           0 :         if(.not.l_absolute)then 
      66             : c--------reading the proj.1 / proj.2 / proj file
      67           0 :          do j=jspin,0,-1
      68           0 :           inquire(file=trim('proj'//spin12(j)),exist=l_file)
      69           0 :           if(l_file)then
      70           0 :              filename='proj'//spin12(j)
      71           0 :              exit
      72             :           endif
      73             :          enddo
      74             :          
      75           0 :          if(l_file)then
      76           0 :           open (203,file=trim(filename),status='old')
      77           0 :           rewind (203)
      78             :          else
      79             :             CALL juDFT_error("no proj/proj.1/proj.2",calledby
      80           0 :      +           ="wann_dipole_electronic")
      81             :          endif  
      82           0 :          read(203,*)num_wann_dum
      83           0 :          if(num_wann_dum/=num_wann(jspin))  CALL juDFT_error
      84           0 :      +        ("num_wann_dum",calledby ="wann_dipole_electronic")
      85           0 :          allocate( waind(num_wann(jspin)) )
      86           0 :          do nwf=1,num_wann(jspin)
      87           0 :           read(203,*)waind(nwf)
      88           0 :           read(203,*)
      89             :          enddo
      90           0 :          close(203)
      91             :         endif 
      92           0 :         print*,"number of wannier functions= ",num_wann(jspin)
      93           0 :         write(6,*)"number of wannier functions",num_wann(jspin)
      94           0 :         allocate( wann_centers(3,num_wann(jspin)) )
      95             :         call wann_readcenters(
      96             :      >         num_wann(jspin),jspin,
      97           0 :      <         wann_centers(:,:))
      98           0 :         if(l_absolute)then
      99           0 :          do k=1,num_wann(jspin)  
     100             :            electronic_moment(:,jspin)=
     101           0 :      &     electronic_moment(:,jspin)-wann_centers(:,k)
     102             :          enddo  
     103             :         else
     104           0 :          do k=1,num_wann(jspin)
     105             :            electronic_moment(:,jspin)=
     106             :      &     electronic_moment(:,jspin)+
     107             :      +        pos(:,waind(k))-
     108           0 :      -        wann_centers(:,k)
     109             :          enddo
     110           0 :          deallocate(waind)
     111             :         endif 
     112           0 :         deallocate(wann_centers)
     113           0 :         write(*,  fmt=555)jspin,electronic_moment(:,jspin)
     114           0 :         write(666,fmt=555)jspin,electronic_moment(:,jspin)
     115           0 :         if(.not.l_absolute)then
     116             :            electronic_polarization=
     117           0 :      &            electronic_moment/omtil*elemchargmu/((bohrtocm)**2)
     118           0 :            write(*,  fmt=777)jspin,electronic_polarization(:,jspin)
     119           0 :            write(666,fmt=777)jspin,electronic_polarization(:,jspin)
     120             :         endif
     121             :       enddo  
     122             :  555  format("spin ",i1.1," electronic moment = (",3f12.6,") a.u.")
     123             :  777  format("spin ",i1.1,
     124             :      &          " electronic polarization = (",3f12.6,") uC/cm**2")
     125           0 :       end subroutine wann_dipole_electronic
     126             :       end module m_wann_dipole_electronic

Generated by: LCOV version 1.13