add_Vnonlocal.F90 6.81 KB
Newer Older
1 2 3 4 5 6
!--------------------------------------------------------------------------------
! Copyright (c) 2016 Peter Grünberg Institut, Forschungszentrum Jülich, Germany
! This file is part of FLEUR and available as free software under the conditions
! of the MIT license as expressed in the LICENSE file in more detail.
!--------------------------------------------------------------------------------

Daniel Wortmann's avatar
Daniel Wortmann committed
7
MODULE m_add_vnonlocal
8
   USE m_judft
Daniel Wortmann's avatar
Daniel Wortmann committed
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
! c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c
!     This module is the driver routine for the calculation of the Hartree    c
!     Fock exchange term by using the mixed basis set.                        c
!                                                                             c
!     hsfock                                                                  c
!         |                                                                   c
!         |- symm.F:                                                          c
!         |  calculates the irreducible representation                        c
!         |                                                                   c
!         |- wavefproducts.F:                 s      s*                       c
!         |  computes the repsentation of phi    phi       in the mixed basis c
!         |                                  n,k    n',k+q                    c
!         |                                                                   c
!         |- exchange.F:                                                      c
!         |  calculates valence-valence part of the exchange matrix (mat_ex), c
!         |                                                                   c
!         |- exchange_core.F                                                  c
!         |  calculate valence-core contribution                              c
!                                                                             c
!     variables:                                                              c
!         kpts%nkptf   :=   number of kpoints                                      c
!         kpts%nkpt   :=   number of irreducible kpoints                          c
!         nbands  :=   number of bands for which the exchange matrix (mat_ex) c
!                      in the space of the wavefunctions is calculated        c
!         te_hfex :=   hf exchange contribution to the total energy           c
!         mnobd   :=   maximum number of occupied bands                       c
!         parent  :=   parent(ikpt) points to the symmetry equivalent point   c
!                      under the little group of kpoint nk                    c
!         symop   :=   symop(ikpt) points to the symmetry operation, which    c
!                      maps parent(ikpt) on ikpt                              c
!                                                                             c
!                                                                             c
!                                               M.Betzinger (09/07)           c
! c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c
43
   CONTAINS
Daniel Wortmann's avatar
Daniel Wortmann committed
44

45
   SUBROUTINE add_vnonlocal(nk,lapw,atoms,hybrid,dimension,kpts,jsp,results,xcpot,noco,hmat)
Daniel Wortmann's avatar
Daniel Wortmann committed
46

47 48
      USE m_symm_hf,            ONLY: symm_hf
      USE m_util,               ONLY: intgrf,intgrf_init
Daniel Wortmann's avatar
Daniel Wortmann committed
49 50 51 52
      USE m_exchange_valence_hf
      USE m_exchange_core
      USE m_symmetrizeh
      USE m_wrapper
53
      USE m_hsefunctional,      ONLY: exchange_vccvHSE,exchange_ccccHSE
Daniel Wortmann's avatar
Daniel Wortmann committed
54 55 56
      USE m_types
      USE m_io_hybrid

57
      IMPLICIT NONE
Daniel Wortmann's avatar
Daniel Wortmann committed
58

59 60 61 62 63
      TYPE(t_results),       INTENT(INOUT) :: results
      CLASS(t_xcpot),        INTENT(IN)    :: xcpot
      TYPE(t_dimension),     INTENT(IN)    :: dimension
      TYPE(t_hybrid),        INTENT(INOUT) :: hybrid
      TYPE(t_kpts),          INTENT(IN)    :: kpts
64 65 66
      TYPE(t_lapw),          INTENT(IN)    :: lapw
      TYPE(t_atoms),         INTENT(IN)    :: atoms
      TYPE(t_noco),          INTENT(IN)    :: noco
67 68 69 70
      TYPE(t_mat),           INTENT(INOUT) :: hmat
   
      INTEGER,               INTENT(IN)    :: jsp 
      INTEGER,               INTENT(IN)    :: nk
Daniel Wortmann's avatar
Daniel Wortmann committed
71

72
      ! local scalars
73
      INTEGER                 :: n,nn,iband,nbasfcn
74
      REAL                    :: a_ex
Daniel Wortmann's avatar
Daniel Wortmann committed
75
      TYPE(t_mat)             :: olap,tmp,v_x,z
76 77
      COMPLEX                 :: exch(dimension%neigd,dimension%neigd)

Daniel Wortmann's avatar
Daniel Wortmann committed
78
      ! initialize weighting factor for HF exchange part
79
      a_ex=xcpot%get_exchange_weight()      
80 81 82

      nbasfcn = MERGE(lapw%nv(1)+lapw%nv(2)+2*atoms%nlotot,lapw%nv(1)+atoms%nlotot,noco%l_noco)
      CALL v_x%init(hmat%l_real,nbasfcn,nbasfcn)
Daniel Wortmann's avatar
Daniel Wortmann committed
83

84
      CALL read_v_x(v_x,kpts%nkpt*(jsp-1)+nk)
85
      ! add non-local x-potential to the hamiltonian hmat
86 87
      DO n = 1, v_x%matsize1
         DO nn = 1, n           
88
            IF (hmat%l_real) THEN
89
               hmat%data_r(nn,n) = hmat%data_r(nn,n) - a_ex*v_x%data_r(nn,n)
90
            ELSE
91
               hmat%data_c(nn,n) = hmat%data_c(nn,n) - a_ex*v_x%data_c(nn,n)
92 93 94 95 96 97
            ENDIF
         END DO
      END DO
      ! calculate HF energy
      IF(hybrid%l_calhf) THEN
         WRITE(6,'(A)') new_line('n')//new_line('n')//' ###     '// '        diagonal HF exchange elements (eV)              ###'
Daniel Wortmann's avatar
Daniel Wortmann committed
98
          
99 100
         WRITE(6,'(A)') new_line('n') // '         k-point      '// 'band          tail           pole       total(valence+core)'
      END IF
Daniel Wortmann's avatar
Daniel Wortmann committed
101

102
      ! read in lower triangle part of overlap matrix from direct acces file olap
103
      CALL olap%init(hmat%l_real,nbasfcn,nbasfcn)
104
      CALL read_olap(olap,kpts%nkpt*(jsp-1)+nk)
105
      IF (.NOT.olap%l_real) olap%data_c=conjg(olap%data_c)
106 107 108

      CALL z%init(olap%l_real,nbasfcn,dimension%neigd)

109
      CALL read_z(z,kpts%nkpt*(jsp-1)+nk)
Daniel Wortmann's avatar
Daniel Wortmann committed
110
       
111 112 113 114 115 116 117
      ! calculate exchange contribution of current k-point nk to total energy (te_hfex)
      ! in the case of a spin-unpolarized calculation the factor 2 is added in eigen.F90 
      IF (.NOT.v_x%l_real) v_x%data_c=conjg(v_x%data_c) 
      exch = 0
      z%matsize1=MIN(z%matsize1,v_x%matsize2)

      CALL v_x%multiply(z,tmp)
Daniel Wortmann's avatar
Daniel Wortmann committed
118

119 120 121 122
      DO iband = 1, hybrid%nbands(nk)
         IF (z%l_real) THEN
            exch(iband,iband) = dot_product(z%data_r(:z%matsize1,iband),tmp%data_r(:,iband))
         ELSE
123
            exch(iband,iband) = dot_product(z%data_c(:z%matsize1,iband),tmp%data_c(:,iband))
124 125 126 127 128 129 130 131 132 133 134
         END IF
         IF(iband.LE.hybrid%nobd(nk)) THEN
            results%te_hfex%valence = results%te_hfex%valence -a_ex*results%w_iks(iband,nk,jsp)*exch(iband,iband)
         END IF
         IF(hybrid%l_calhf) THEN
            WRITE(6, '(      ''  ('',F5.3,'','',F5.3,'','',F5.3,'')'',I4,4X,3F15.5)')&
                    kpts%bkf(:,nk),iband, (REAL(exch(iband,iband))-hybrid%div_vv(iband,nk,jsp))*(-27.211608),&
                    hybrid%div_vv(iband,nk,jsp)*(-27.211608),REAL(exch(iband,iband))*(-27.211608)
         END IF
      END DO
   END SUBROUTINE add_vnonlocal
Daniel Wortmann's avatar
Daniel Wortmann committed
135

136
END MODULE m_add_vnonlocal