LCOV - code coverage report
Current view: top level - wannier - wann_dipole2.f (source / functions) Hit Total Coverage
Test: combined.info Lines: 0 67 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             : c********************************************************
       8             : c     Calculate the electric polarization.
       9             : c     Frank Freimuth, October 2006
      10             : c********************************************************
      11             :       module m_wann_dipole2
      12             :       use m_juDFT
      13             :       contains
      14           0 :       subroutine wann_dipole2(
      15           0 :      >               jspins,pos,omtil,natd,
      16             :      >               l_nocosoc)
      17             :       use m_wann_readcenters
      18             :       implicit none
      19             :       integer,intent(in) :: jspins
      20             :       real,intent(in)    :: omtil
      21             :       integer,intent(in) :: natd
      22             :       real,intent(in)    :: pos(3,natd)
      23             :       logical,intent(in) :: l_nocosoc
      24             : 
      25             :       integer            :: jspin,jspins2
      26             :       logical            :: l_file
      27           0 :       integer,allocatable:: ind(:)
      28             :       integer            :: nwf,nwfs
      29           0 :       real,allocatable   :: distance(:,:)
      30           0 :       real               :: moment(3,jspins)
      31             :       real               :: moment2(3)
      32             :       real               :: elemchargmu,bohrtocm
      33             :       integer            :: shifted,ishift,ind1,ind2
      34           0 :       real,allocatable   :: centers(:,:)
      35           0 :       real,allocatable   :: spreads(:)
      36             : 
      37           0 :       open(204,file='dipole_out')
      38           0 :       write(204,*)"*****************************************"
      39           0 :       write(204,*)"Calculation of the electric polarization."
      40           0 :       write(204,*)"*****************************************"
      41           0 :       elemchargmu=1.60217646e-13
      42           0 :       bohrtocm=0.529177e-8
      43             : 
      44           0 :       jspins2=jspins
      45           0 :       if(l_nocosoc)jspins2=1
      46           0 :       do jspin=1,jspins2
      47           0 :          inquire(file='proj',exist=l_file)
      48           0 :          IF(.NOT.l_file) CALL juDFT_error("proj not found",calledby
      49           0 :      +        ="wann_dipole2")
      50           0 :          open(203,file='proj',form='formatted')
      51           0 :          read(203,*)nwfs
      52           0 :          print*,"nwfs=",nwfs
      53           0 :          allocate(ind(nwfs))
      54           0 :          allocate(distance(3,nwfs))
      55           0 :          allocate(centers(3,nwfs))
      56           0 :          allocate(spreads(nwfs))
      57           0 :          do nwf=1,nwfs
      58           0 :           read(203,*)ind(nwf)
      59           0 :           read(203,*)
      60             :          enddo
      61           0 :          close(203)
      62           0 :          write(204,*)"spin=",jspin
      63           0 :          call wann_readcenters(nwfs,jspin,centers,spreads)
      64           0 :          write(204,*)"*****centers:******"
      65           0 :          do nwf=1,nwfs
      66           0 :            write(204,fmt=1000)nwf,centers(:,nwf),spreads(nwf)
      67             :          enddo
      68           0 :          moment(:,jspin)=0.0
      69           0 :          do nwf=1,nwfs
      70           0 :             distance(:,nwf)=pos(:,ind(nwf))-centers(:,nwf)
      71           0 :             moment(:,jspin)=moment(:,jspin)+distance(:,nwf)
      72             :          enddo
      73           0 :          if((jspins.eq.1).and..not.l_nocosoc) 
      74           0 :      &                    moment(:,jspin)=moment(:,jspin)*2
      75           0 :          moment(:,jspin)=moment(:,jspin)/omtil
      76           0 :          moment(:,jspin)=moment(:,jspin)*elemchargmu/((bohrtocm)**2)
      77           0 :          write(204,*)"polarization due to shift of wannierorbitals"
      78           0 :          write(204,*)moment(:,jspin),"uC/cm2"
      79           0 :          deallocate(ind,distance,centers,spreads)
      80             :       enddo!jspin
      81             : 1000  format(2x,'WF centre and spread', 
      82             :      &       i5,2x,'(',f10.6,',',f10.6,',',f10.6,' )',f15.8)
      83           0 :       inquire(file='dipole',exist=l_file)
      84           0 :       if(.not.l_file)then
      85           0 :             write(204,*)"no file dipole found"
      86             :       else
      87           0 :          moment2(:)=0.0
      88           0 :          open(224,file='dipole',form='formatted')
      89           0 :          read(224,*)shifted
      90           0 :          do ishift=1,shifted
      91           0 :                read(224,*)ind1,ind2 !electron taken from 1 and moved to 2
      92           0 :                moment2(:)=moment2(:)+pos(:,ind1)-pos(:,ind2)
      93             :          enddo
      94           0 :          close(224)
      95           0 :          moment2(:)=moment2(:)/omtil
      96           0 :          moment2(:)=moment2(:)*elemchargmu/(bohrtocm)**2
      97             :          write(204,*)"polarization due to electrons 
      98           0 :      &              being catched by other atoms"
      99           0 :          write(204,*)moment2(:),"uC/cm2"
     100             : 
     101             :       endif
     102           0 :       write(204,*)"total moment:"
     103           0 :       if(jspins2.eq.2)moment(:,1)=moment(:,1)+moment(:,2)
     104           0 :       if(l_file)then
     105           0 :          moment(:,1)=moment(:,1)+moment2(:)
     106             :       endif
     107           0 :       write(204,*)moment(:,1),"uC/cm2"
     108           0 :       close(204)
     109           0 :       end subroutine wann_dipole2
     110             :       end module m_wann_dipole2

Generated by: LCOV version 1.13